aboutsummaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp8
-rw-r--r--src/vehicles/Boat.cpp20
-rw-r--r--src/vehicles/Boat.h1
-rw-r--r--src/vehicles/HandlingMgr.cpp20
-rw-r--r--src/vehicles/Transmission.cpp2
-rw-r--r--src/vehicles/Transmission.h2
-rw-r--r--src/vehicles/Vehicle.cpp6
7 files changed, 45 insertions, 14 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 79d3f6af..753b853d 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -216,12 +216,15 @@ CAutomobile::SetModelIndex(uint32 id)
CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f);
CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f);
+#pragma optimize("", off) // that's what R* did
+
void
CAutomobile::ProcessControl(void)
{
int i;
float wheelRot;
CColModel *colModel;
+ float brake = 0.0f;
if(bUsingSpecialColModel)
colModel = &CWorld::Players[CWorld::PlayerInFocus].m_ColModel;
@@ -537,7 +540,6 @@ CAutomobile::ProcessControl(void)
break;
}
- float brake;
if(skipPhysics){
bHasContacted = false;
bIsInSafePosition = false;
@@ -723,7 +725,7 @@ CAutomobile::ProcessControl(void)
traction *= 4.0f;
if(FindPlayerVehicle() && FindPlayerVehicle() == this){
- if(CPad::GetPad(0)->WeaponJustDown()){
+ if(CPad::GetPad(0)->CarGunJustDown()){
if(m_bombType == CARBOMB_TIMED){
m_bombType = CARBOMB_TIMEDACTIVE;
m_nBombTimer = 7000;
@@ -1214,6 +1216,8 @@ CAutomobile::ProcessControl(void)
}
}
+#pragma optimize("", on)
+
void
CAutomobile::Teleport(CVector pos)
{
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index aba48bad..f2f80569 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -1,5 +1,6 @@
#include "common.h"
+#include "main.h"
#include "General.h"
#include "Timecycle.h"
#include "HandlingMgr.h"
@@ -719,6 +720,15 @@ CBoat::Render()
((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->SetVehicleColour(m_currentColour1, m_currentColour2);
if (!CVehicle::bWheelsOnlyCheat)
CEntity::Render();
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+ RenderWaterOutPolys(); // not separate function in III
+}
+
+void
+CBoat::RenderWaterOutPolys(void)
+{
KeepWaterOutIndices[0] = 0;
KeepWaterOutIndices[1] = 2;
KeepWaterOutIndices[2] = 1;
@@ -758,19 +768,29 @@ CBoat::Render()
KeepWaterOutVertices[2].v = 1.0f;
KeepWaterOutVertices[3].u = 1.0f;
KeepWaterOutVertices[3].v = 1.0f;
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+{
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpWaterRaster);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDZERO);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+}
if (!CVehicle::bWheelsOnlyCheat && RwIm3DTransform(KeepWaterOutVertices, 4, GetMatrix().m_attachment, rwIM3D_VERTEXUV)) {
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, KeepWaterOutIndices, 6);
RwIm3DEnd();
}
+#ifdef NEW_RENDERER
+ if(!gbNewRenderer)
+#endif
+{
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
}
+}
void
CBoat::Teleport(CVector v)
diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h
index 56aff264..157b4852 100644
--- a/src/vehicles/Boat.h
+++ b/src/vehicles/Boat.h
@@ -54,6 +54,7 @@ public:
virtual bool IsComponentPresent(int32 component) { return true; }
virtual void BlowUpCar(CEntity *ent);
+ void RenderWaterOutPolys(void);
void ApplyWaterResistance(void);
void SetupModelNodes();
void PruneWakeTrail(void);
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index 3ac6f057..00aaa682 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -143,7 +143,7 @@ cHandlingDataMgr::LoadHandlingData(void)
case 11: handling->fTractionBias = strtod(word, nil); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = strtod(word, nil); break;
- case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4f; break;
+ case 14: handling->Transmission.fEngineAcceleration = strtod(word, nil) * 0.4; break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = strtod(word, nil); break;
@@ -191,7 +191,7 @@ void
cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
{
// acceleration is in ms^-2, but we need mf^-2 where f is one frame time (50fps)
- float velocity, a, b, specificVolume;
+ float velocity, a, b;
handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f);
handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f);
@@ -202,21 +202,27 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
handling->fInvMass = 1.0f/handling->fMass;
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass;
- // What the hell is going on here?
- specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ?
+ // Don't quite understand this. What seems to be going on is that
+ // we calculate a drag (air resistance) deceleration for a given velocity and
+ // find the intersection between that and the max engine acceleration.
+ // at that point the car cannot accelerate any further and we've found the max velocity.
a = 0.0f;
b = 100.0f;
velocity = handling->Transmission.fMaxVelocity;
while(a < b && velocity > 0.0f){
velocity -= 0.01f;
+ // what's the 1/6?
a = handling->Transmission.fEngineAcceleration/6.0f;
- b = -velocity * (1.0f/(specificVolume * sq(velocity) + 1.0f) - 1.0f);
+ // no density or drag coefficient here...
+ float a_drag = 0.5f*SQR(velocity) * handling->Dimension.x*handling->Dimension.z / handling->fMass;
+ // can't make sense of this... maybe v - v/(drag + 1) ? but that doesn't make so much sense either
+ b = -velocity * (1.0f/(a_drag + 1.0f) - 1.0f);
}
if(handling->nIdentifier == HANDLING_RCBANDIT){
- handling->Transmission.fUnkMaxVelocity = handling->Transmission.fMaxVelocity;
+ handling->Transmission.fMaxCruiseVelocity = handling->Transmission.fMaxVelocity;
}else{
- handling->Transmission.fUnkMaxVelocity = velocity;
+ handling->Transmission.fMaxCruiseVelocity = velocity;
handling->Transmission.fMaxVelocity = velocity * 1.2f;
}
handling->Transmission.fMaxReverseVelocity = -0.2f;
diff --git a/src/vehicles/Transmission.cpp b/src/vehicles/Transmission.cpp
index 5287055d..109847a5 100644
--- a/src/vehicles/Transmission.cpp
+++ b/src/vehicles/Transmission.cpp
@@ -128,7 +128,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
else
fCheat = 1.0f;
float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat;
- float accel = fEngineAcceleration*accelMul * (targetVelocity - fVelocity)/Abs(targetVelocity);
+ float accel = (targetVelocity - fVelocity) * (fEngineAcceleration*accelMul) / Abs(targetVelocity);
if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat))
fAcceleration = gasPedal * accel * CTimer::GetTimeStep();
else
diff --git a/src/vehicles/Transmission.h b/src/vehicles/Transmission.h
index 8eeef1e8..a3d15513 100644
--- a/src/vehicles/Transmission.h
+++ b/src/vehicles/Transmission.h
@@ -18,7 +18,7 @@ public:
uint8 Flags;
float fEngineAcceleration;
float fMaxVelocity;
- float fUnkMaxVelocity;
+ float fMaxCruiseVelocity;
float fMaxReverseVelocity;
float fCurVelocity;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index ba9348f0..465d9a9e 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -531,9 +531,9 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
if(!bBraking){
if(m_fGasPedal < 0.01f){
if(GetModelIndex() == MI_RCBANDIT)
- brake = 0.2f * mod_HandlingManager.fWheelFriction / m_fMass;
+ brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->fMass;
else
- brake = mod_HandlingManager.fWheelFriction / m_fMass;
+ brake = mod_HandlingManager.fWheelFriction / pHandling->fMass;
#ifdef FIX_BUGS
brake *= CTimer::GetTimeStepFix();
#endif
@@ -659,7 +659,7 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage
if (m_randomSeed < DAMAGE_FLEE_IN_CAR_PROBABILITY_VALUE) {
CCarCtrl::SwitchVehicleToRealPhysics(this);
AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
- AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fUnkMaxVelocity;
+ AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * pHandling->Transmission.fMaxCruiseVelocity;
SetStatus(STATUS_PHYSICS);
}
}