mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-23 17:49:16 +01:00
more CBike and fixes
This commit is contained in:
parent
07c6752cf7
commit
3e36428568
@ -30,7 +30,7 @@ enum eEntityStatus : uint8
|
||||
STATUS_PLANE,
|
||||
STATUS_PLAYER_REMOTE,
|
||||
STATUS_PLAYER_DISABLED,
|
||||
STATUS_12, // TODO: what is this? used in CPhysical::ApplyAirResistance
|
||||
STATUS_GHOST
|
||||
};
|
||||
|
||||
class CEntity : public CPlaceable
|
||||
|
@ -458,6 +458,7 @@ CPhysical::ApplyFrictionTurnForce(float jx, float jy, float jz, float px, float
|
||||
m_vecTurnFriction += turnimpulse*(1.0f/m_fTurnMass);
|
||||
}
|
||||
|
||||
bool debugSprings;
|
||||
bool
|
||||
CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &point, float springRatio, float bias)
|
||||
{
|
||||
@ -467,6 +468,10 @@ CPhysical::ApplySpringCollision(float springConst, CVector &springDir, CVector &
|
||||
float impulse = -GRAVITY*m_fMass*step * springConst * compression * bias*2.0f;
|
||||
ApplyMoveForce(springDir*impulse);
|
||||
ApplyTurnForce(springDir*impulse, point);
|
||||
if(debugSprings){
|
||||
printf("spring : %.3f %.3f %.3f\n", springDir.x*impulse, springDir.y*impulse, springDir.z*impulse);
|
||||
printf("speed: %.3f %.3f %.3f\n", m_vecMoveSpeed.x, m_vecMoveSpeed.y, m_vecMoveSpeed.z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -484,6 +489,11 @@ CPhysical::ApplySpringCollisionAlt(float springConst, CVector &springDir, CVecto
|
||||
impulse *= 0.75f;
|
||||
ApplyMoveForce(forceDir*impulse);
|
||||
ApplyTurnForce(forceDir*impulse, point);
|
||||
if(debugSprings){
|
||||
printf("spring alt: %.3f %.3f %.3f %.3f\n", forceDir.x*impulse, forceDir.y*impulse, forceDir.z*impulse, springRatio);
|
||||
printf("speed: %.3f %.3f %.3f\n", m_vecMoveSpeed.x, m_vecMoveSpeed.y, m_vecMoveSpeed.z);
|
||||
printf("pos: %.3f %.3f %.3f\n", GetPosition().x, GetPosition().y, GetPosition().z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -531,7 +541,7 @@ void
|
||||
CPhysical::ApplyAirResistance(void)
|
||||
{
|
||||
if(m_fAirResistance > 0.1f){
|
||||
if(GetStatus() != STATUS_12){
|
||||
if(GetStatus() != STATUS_GHOST){
|
||||
float f = Pow(m_fAirResistance, CTimer::GetTimeStep());
|
||||
m_vecMoveSpeed *= f;
|
||||
m_vecTurnSpeed *= f;
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
}
|
||||
|
||||
void Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, float invSin, float t);
|
||||
void Set(RwV3d *axis, float angle);
|
||||
void Get(RwMatrix *matrix);
|
||||
};
|
||||
|
||||
|
@ -170,6 +170,17 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CQuaternion::Set(RwV3d *axis, float angle)
|
||||
{
|
||||
float halfCos = Cos(angle*0.5f);
|
||||
float halfSin = Sin(angle*0.5f);
|
||||
x = axis->x*halfSin;
|
||||
y = axis->y*halfSin;
|
||||
z = axis->z*halfSin;
|
||||
w = halfCos;
|
||||
}
|
||||
|
||||
void
|
||||
CQuaternion::Get(RwMatrix *matrix)
|
||||
{
|
||||
|
@ -255,6 +255,7 @@ void
|
||||
CAutomobile::ProcessControl(void)
|
||||
{
|
||||
int i;
|
||||
float wheelRot;
|
||||
CColModel *colModel;
|
||||
|
||||
if(bUsingSpecialColModel)
|
||||
@ -422,7 +423,7 @@ CAutomobile::ProcessControl(void)
|
||||
float slowdown;
|
||||
CVector parallelSpeed = m_vecMoveSpeed - DotProduct(m_vecMoveSpeed, GetUp())*m_vecMoveSpeed;
|
||||
float fSpeed = parallelSpeed.MagnitudeSqr();
|
||||
if(fSpeed > 0.09f){
|
||||
if(fSpeed > SQR(0.3f)){
|
||||
fSpeed = Sqrt(fSpeed);
|
||||
parallelSpeed *= 0.3f / fSpeed;
|
||||
slowdown = SAND_SLOWDOWN * Max(1.0f - 2.0f*fSpeed, 0.2f);
|
||||
@ -461,11 +462,9 @@ CAutomobile::ProcessControl(void)
|
||||
|
||||
pHandling->Transmission.CalculateGearForSimpleCar(AutoPilot.m_fMaxTrafficSpeed/50.0f, m_nCurrentGear);
|
||||
|
||||
{
|
||||
float wheelRot = ProcessWheelRotation(WHEEL_STATE_NORMAL, GetForward(), m_vecMoveSpeed, 0.35f);
|
||||
wheelRot = ProcessWheelRotation(WHEEL_STATE_NORMAL, GetForward(), m_vecMoveSpeed, 0.35f);
|
||||
for(i = 0; i < 4; i++)
|
||||
m_aWheelRotation[i] += wheelRot;
|
||||
}
|
||||
|
||||
PlayHornIfNecessary();
|
||||
ReduceHornCounter();
|
||||
@ -500,7 +499,7 @@ CAutomobile::ProcessControl(void)
|
||||
break;
|
||||
|
||||
case STATUS_ABANDONED:
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() < 0.01f)
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() < SQR(0.1f))
|
||||
m_fBrakePedal = 0.2f;
|
||||
else
|
||||
m_fBrakePedal = 0.0f;
|
||||
@ -529,7 +528,7 @@ CAutomobile::ProcessControl(void)
|
||||
break;
|
||||
|
||||
case STATUS_PLAYER_DISABLED:
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() < 0.01f ||
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() < SQR(0.1f) ||
|
||||
(pDriver && pDriver->IsPlayer() &&
|
||||
(pDriver->GetPedState() == PED_ARRESTED ||
|
||||
pDriver->GetPedState() == PED_DRAG_FROM_CAR ||
|
||||
@ -770,7 +769,7 @@ CAutomobile::ProcessControl(void)
|
||||
for(i = 0; i < 4; i++){
|
||||
if(m_aSuspensionSpringRatio[i] < 1.0f){
|
||||
float bias = pHandling->fSuspensionBias;
|
||||
if(i == 1 || i == 3) // rear
|
||||
if(i == CARWHEEL_REAR_LEFT || i == CARWHEEL_REAR_RIGHT)
|
||||
bias = 1.0f - bias;
|
||||
|
||||
ApplySpringCollisionAlt(pHandling->fSuspensionForceLevel,
|
||||
@ -823,7 +822,6 @@ CAutomobile::ProcessControl(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool gripCheat = true;
|
||||
fwdSpeed = DotProduct(m_vecMoveSpeed, GetForward());
|
||||
if(!strongGrip1 && !CVehicle::bCheat3)
|
||||
@ -1062,6 +1060,7 @@ CAutomobile::ProcessControl(void)
|
||||
}else if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier)){
|
||||
rearBrake = 0.0f;
|
||||
rearTraction = 0.0f;
|
||||
// BUG: missing timestep
|
||||
ApplyTurnForce(contactPoints[CARWHEEL_REAR_LEFT], -0.001f*m_fTurnMass*m_fSteerAngle*GetRight());
|
||||
}else if(m_fTireTemperature > 1.0f){
|
||||
rearTraction *= m_fTireTemperature;
|
||||
@ -1155,7 +1154,7 @@ CAutomobile::ProcessControl(void)
|
||||
}
|
||||
|
||||
if(m_doingBurnout && !mod_HandlingManager.HasFrontWheelDrive(pHandling->nIdentifier) &&
|
||||
(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING || m_aWheelState[CARWHEEL_REAR_RIGHT])){
|
||||
(m_aWheelState[CARWHEEL_REAR_LEFT] == WHEEL_STATE_SPINNING || m_aWheelState[CARWHEEL_REAR_RIGHT] == WHEEL_STATE_SPINNING)){
|
||||
m_fTireTemperature += 0.001f*CTimer::GetTimeStep();
|
||||
if(m_fTireTemperature > 3.0f)
|
||||
m_fTireTemperature = 3.0f;
|
||||
@ -1375,14 +1374,14 @@ CAutomobile::ProcessControl(void)
|
||||
|
||||
// Flying
|
||||
|
||||
bool foo = false;
|
||||
bool playRotorSound = false;
|
||||
if(GetStatus() != STATUS_PLAYER && GetStatus() != STATUS_PLAYER_REMOTE && GetStatus() != STATUS_PHYSICS){
|
||||
if(IsRealHeli()){
|
||||
bEngineOn = false;
|
||||
m_aWheelSpeed[1] = Max(m_aWheelSpeed[1]-0.0005f, 0.0f);
|
||||
if(GetModelIndex() != MI_RCRAIDER && GetModelIndex() != MI_RCGOBLIN)
|
||||
if(m_aWheelSpeed[1] < 0.154f && m_aWheelSpeed[1] > 0.0044f)
|
||||
foo = true;
|
||||
playRotorSound = true;
|
||||
}
|
||||
}else if((GetModelIndex() == MI_DODO || CVehicle::bAllDodosCheat) &&
|
||||
m_vecMoveSpeed.Magnitude() > 0.0f && CTimer::GetTimeStep() > 0.0f){
|
||||
@ -1476,10 +1475,25 @@ CAutomobile::ProcessControl(void)
|
||||
|
||||
if(GetModelIndex() != MI_RCRAIDER && GetModelIndex() != MI_RCGOBLIN)
|
||||
if(m_aWheelSpeed[1] < 0.154f && m_aWheelSpeed[1] > 0.0044f)
|
||||
foo = true;
|
||||
playRotorSound = true;
|
||||
}
|
||||
|
||||
//TODO(MIAMI): propeller stuff
|
||||
// Play rotor sound
|
||||
if(playRotorSound && m_aCarNodes[CAR_BONNET]){
|
||||
CVector camDist = TheCamera.GetPosition() - GetPosition();
|
||||
float distSq = camDist.MagnitudeSqr();
|
||||
if(distSq < SQR(20.0f) && Abs(m_fPropellerRotation - m_aWheelRotation[1]) > DEGTORAD(30.0f)){
|
||||
CMatrix mat;
|
||||
mat.Attach(RwFrameGetMatrix(m_aCarNodes[CAR_BONNET]));
|
||||
CVector blade = mat.GetRight();
|
||||
blade = GetMatrix() * blade;
|
||||
camDist /= Max(Sqrt(distSq), 0.01f);
|
||||
if(Abs(DotProduct(camDist, blade)) > 0.95f){
|
||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_31, 0.0f);
|
||||
m_fPropellerRotation = m_aWheelRotation[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1559,7 +1573,9 @@ CAutomobile::ProcessControl(void)
|
||||
for(i = 0; i < 4; i++){
|
||||
float suspChange = m_aSuspensionSpringRatioPrev[i] - m_aSuspensionSpringRatio[i];
|
||||
if(suspChange > 0.3f && !drivingInSand && speedsq > 0.04f){
|
||||
//TODO(MIAMI): depends on wheel status
|
||||
if(Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST)
|
||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP_2, suspChange);
|
||||
else
|
||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_JUMP, suspChange);
|
||||
if(suspChange > suspShake)
|
||||
suspShake = suspChange;
|
||||
@ -4192,12 +4208,12 @@ CAutomobile::VehicleDamage(float impulse, uint16 damagedPiece)
|
||||
pDriver &&
|
||||
m_pDamageEntity && m_pDamageEntity->IsVehicle() &&
|
||||
(this != FindPlayerVehicle() || ((CVehicle*)m_pDamageEntity)->VehicleCreatedBy == MISSION_VEHICLE) &&
|
||||
// TODO(MIAMI): enum
|
||||
((CVehicle*)m_pDamageEntity)->pDriver){
|
||||
// TODO(MIAMI)
|
||||
// if(GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR)
|
||||
// pDriver->Say(145);
|
||||
// else
|
||||
// pDriver->Say(144);
|
||||
if(GetVehicleAppearance() == VEHICLE_APPEARANCE_CAR)
|
||||
pDriver->Say(145);
|
||||
else
|
||||
pDriver->Say(144);
|
||||
}
|
||||
|
||||
int oldHealth = m_fHealth;
|
||||
@ -4828,7 +4844,6 @@ CAutomobile::BurstTyre(uint8 wheel, bool applyForces)
|
||||
case CAR_PIECE_WHEEL_LR: wheel = VEHWHEEL_REAR_LEFT; break;
|
||||
case CAR_PIECE_WHEEL_RF: wheel = VEHWHEEL_FRONT_RIGHT; break;
|
||||
case CAR_PIECE_WHEEL_RR: wheel = VEHWHEEL_REAR_RIGHT; break;
|
||||
default: assert(0 && "invalid wheel");
|
||||
}
|
||||
|
||||
int status = Damage.GetWheelStatus(wheel);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,10 +21,10 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
BIKESUSP_FRONT_1,
|
||||
BIKESUSP_FRONT_2,
|
||||
BIKESUSP_REAR_1,
|
||||
BIKESUSP_REAR_2,
|
||||
BIKESUSP_F1,
|
||||
BIKESUSP_F2,
|
||||
BIKESUSP_R1,
|
||||
BIKESUSP_R2,
|
||||
};
|
||||
|
||||
class CBike : public CVehicle
|
||||
@ -33,8 +33,8 @@ public:
|
||||
RwFrame *m_aBikeNodes[BIKE_NUM_NODES];
|
||||
bool bLeanMatrixClean;
|
||||
CMatrix m_leanMatrix;
|
||||
CVector wheelieNormal;
|
||||
CVector wheelieRight;
|
||||
CVector m_vecAvgSurfaceNormal;
|
||||
CVector m_vecAvgSurfaceRight;
|
||||
tBikeHandlingData *pBikeHandling;
|
||||
AssocGroupId m_bikeAnimType;
|
||||
uint8 m_wheelStatus[2];
|
||||
@ -58,7 +58,7 @@ public:
|
||||
float m_fFrontForkY;
|
||||
float m_fFrontForkZ;
|
||||
float m_fFrontForkSlope;
|
||||
float m_fBikeSteerAngle;
|
||||
float m_fWheelAngle;
|
||||
float m_fLeanLRAngle;
|
||||
float m_fLeanLRAngle2;
|
||||
float m_fLeanInput;
|
||||
@ -68,9 +68,9 @@ public:
|
||||
uint8 unused[3]; // looks like padding..but for what?
|
||||
uint8 m_bike_flag01 : 1;
|
||||
uint8 m_bike_flag02 : 1;
|
||||
uint8 m_bike_flag04 : 1;
|
||||
uint8 bWaterTight : 1;
|
||||
uint8 m_bike_flag08 : 1;
|
||||
uint8 m_bike_flag10 : 1;
|
||||
uint8 bIsStanding : 1;
|
||||
uint8 m_bike_flag20 : 1;
|
||||
uint8 m_bike_flag40 : 1;
|
||||
uint8 m_bike_flag80 : 1;
|
||||
@ -117,6 +117,9 @@ public:
|
||||
float GetHeightAboveRoad(void);
|
||||
void PlayCarHorn(void);
|
||||
|
||||
void VehicleDamage(void);
|
||||
void ProcessBuoyancy(void);
|
||||
void DoDriveByShootings(void);
|
||||
void PlayHornIfNecessary(void);
|
||||
void ResetSuspension(void);
|
||||
void SetupSuspensionLines(void);
|
||||
|
@ -926,7 +926,7 @@ CVehicle::ProcessBikeWheel(CVector &wheelFwd, CVector &wheelRight, CVector &whee
|
||||
if(bAlreadySkidding)
|
||||
adhesion *= pHandling->fTractionLoss;
|
||||
|
||||
if(special == BIKE_WHEEL_2 || special == BIKE_WHEEL_3)
|
||||
if(special == BIKE_WHEELSPEC_2 || special == BIKE_WHEELSPEC_3)
|
||||
contactSpeedRight = 0.0f;
|
||||
else
|
||||
contactSpeedRight = DotProduct(wheelContactSpeed, wheelRight);
|
||||
|
@ -128,11 +128,13 @@ enum eVehicleAppearance
|
||||
VEHICLE_APPEARANCE_PLANE,
|
||||
};
|
||||
|
||||
// TODO
|
||||
// TODO: what is this even?
|
||||
enum eBikeWheelSpecial
|
||||
{
|
||||
BIKE_WHEEL_2 = 2,
|
||||
BIKE_WHEEL_3,
|
||||
BIKE_WHEELSPEC_0, // both wheels on ground
|
||||
BIKE_WHEELSPEC_1, // rear wheel on ground
|
||||
BIKE_WHEELSPEC_2, // only front wheel on ground
|
||||
BIKE_WHEELSPEC_3, // can't happen
|
||||
};
|
||||
|
||||
enum
|
||||
|
Loading…
Reference in New Issue
Block a user