HPL1: Remove usage of std::abs

This commit is contained in:
Eugene Sandulenko 2022-12-16 00:44:59 +01:00
parent 4eaa2688d0
commit f7026c047c
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
24 changed files with 83 additions and 83 deletions

View File

@ -91,7 +91,7 @@ iVertexBuffer *cMeshCreator::CreateSkyBoxVertexBuffer(float afSize) {
for (int z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0)
continue;
if (std::abs(x) + std::abs(y) + std::abs(z) > 1)
if (ABS(x) + ABS(y) + ABS(z) > 1)
continue;
// Direction (could say inverse normal) of the quad.
@ -99,7 +99,7 @@ iVertexBuffer *cMeshCreator::CreateSkyBoxVertexBuffer(float afSize) {
cVector3f vSide;
cVector3f vAdd[4];
if (std::abs(x)) {
if (ABS(x)) {
vDir.x = (float)x;
vAdd[0].y = 1;
@ -110,7 +110,7 @@ iVertexBuffer *cMeshCreator::CreateSkyBoxVertexBuffer(float afSize) {
vAdd[2].z = -1;
vAdd[3].y = 1;
vAdd[3].z = -1;
} else if (std::abs(y)) {
} else if (ABS(y)) {
vDir.y = (float)y;
vAdd[0].z = 1;
@ -121,7 +121,7 @@ iVertexBuffer *cMeshCreator::CreateSkyBoxVertexBuffer(float afSize) {
vAdd[2].x = -1;
vAdd[3].z = 1;
vAdd[3].x = -1;
} else if (std::abs(z)) {
} else if (ABS(z)) {
vAdd[0].y = 1;
vAdd[0].x = 1;
vAdd[1].y = 1;
@ -177,7 +177,7 @@ iVertexBuffer *cMeshCreator::CreateBoxVertexBuffer(cVector3f avSize) {
for (int z = -1; z <= 1; z++) {
if (x == 0 && y == 0 && z == 0)
continue;
if (std::abs(x) + std::abs(y) + std::abs(z) > 1)
if (ABS(x) + ABS(y) + ABS(z) > 1)
continue;
// Direction (could say inverse normal) of the quad.
@ -185,7 +185,7 @@ iVertexBuffer *cMeshCreator::CreateBoxVertexBuffer(cVector3f avSize) {
cVector3f vSide;
cVector3f vAdd[4];
if (std::abs(x)) {
if (ABS(x)) {
vDir.x = (float)x;
vAdd[0].y = 1;
@ -196,7 +196,7 @@ iVertexBuffer *cMeshCreator::CreateBoxVertexBuffer(cVector3f avSize) {
vAdd[2].z = -1;
vAdd[3].y = 1;
vAdd[3].z = -1;
} else if (std::abs(y)) {
} else if (ABS(y)) {
vDir.y = (float)y;
vAdd[0].z = 1;
@ -207,7 +207,7 @@ iVertexBuffer *cMeshCreator::CreateBoxVertexBuffer(cVector3f avSize) {
vAdd[2].x = -1;
vAdd[3].z = 1;
vAdd[3].x = -1;
} else if (std::abs(z)) {
} else if (ABS(z)) {
vAdd[0].y = 1;
vAdd[0].x = 1;
vAdd[1].y = 1;
@ -259,13 +259,13 @@ iVertexBuffer *cMeshCreator::CreateBoxVertexBuffer(cVector3f avSize) {
cVector3f cMeshCreator::GetBoxTex(int i, int x, int y, int z, cVector3f *vAdd) {
cVector3f vTex;
if (std::abs(x)) {
if (ABS(x)) {
vTex.x = vAdd[i].z;
vTex.y = vAdd[i].y;
} else if (std::abs(y)) {
} else if (ABS(y)) {
vTex.x = vAdd[i].x;
vTex.y = vAdd[i].z;
} else if (std::abs(z)) {
} else if (ABS(z)) {
vTex.x = vAdd[i].x;
vTex.y = vAdd[i].y;
}

View File

@ -641,7 +641,7 @@ int iRenderState::CompareDepthTest(const iRenderState *apState) const {
//-----------------------------------------------------------------------
int iRenderState::CompareDepth(const iRenderState *apState) const {
if (std::abs(mfZ - apState->mfZ) < 0.00001f)
if (ABS(mfZ - apState->mfZ) < 0.00001f)
return 0;
else
return mfZ < apState->mfZ ? 1 : -1;

View File

@ -722,22 +722,22 @@ cVector2f cRenderer2D::CalcLineEnd(cVector3f avLight, cVector3f avPoint, float a
else
kX = dX / dY;
if (std::abs(dX) <= std::abs(dY) && dY > 0) {
if (ABS(dX) <= ABS(dY) && dY > 0) {
vEndPos.y = avClipPos.y + vSize.y;
float A = avPoint.y - kY * avPoint.x;
vEndPos.x = (vEndPos.y - A) / kY;
avSide.y = 1;
} else if (std::abs(dX) <= std::abs(dY) && dY <= 0) {
} else if (ABS(dX) <= ABS(dY) && dY <= 0) {
vEndPos.y = avClipPos.y - vSize.y;
float A = avPoint.y - kY * avPoint.x;
vEndPos.x = (vEndPos.y - A) / kY;
avSide.y = -1;
} else if (std::abs(dX) > std::abs(dY) && dX > 0) {
} else if (ABS(dX) > ABS(dY) && dX > 0) {
vEndPos.x = avClipPos.x + vSize.y;
float A = avPoint.x - kX * avPoint.y;
vEndPos.y = (vEndPos.x - A) / kX;
avSide.x = 1;
} else if (std::abs(dX) > std::abs(dY) && dX <= 0) {
} else if (ABS(dX) > ABS(dY) && dX <= 0) {
vEndPos.x = avClipPos.x - vSize.y;
float A = avPoint.x - kX * avPoint.y;
vEndPos.y = (vEndPos.x - A) / kX;

View File

@ -276,9 +276,9 @@ bool ContactProcessor::processNext() {
// Tangent speed
float fTanSpeed0 = NewtonMaterialGetContactTangentSpeed(_material, 0);
float fTanSpeed1 = NewtonMaterialGetContactTangentSpeed(_material, 1);
if (std::abs(_contactData.mfMaxContactTangentSpeed) < std::abs(fTanSpeed0))
if (ABS(_contactData.mfMaxContactTangentSpeed) < ABS(fTanSpeed0))
_contactData.mfMaxContactTangentSpeed = fTanSpeed0;
if (std::abs(_contactData.mfMaxContactTangentSpeed) < std::abs(fTanSpeed1))
if (ABS(_contactData.mfMaxContactTangentSpeed) < ABS(fTanSpeed1))
_contactData.mfMaxContactTangentSpeed = fTanSpeed1;
// Force
@ -322,22 +322,22 @@ void ContactProcessor::endProcessing() {
int lPrio2 = pMaterial2->GetSurfaceData()->GetPriority();
if (lPrio1 >= lPrio2) {
if (std::abs(_contactData.mfMaxContactNormalSpeed) > 0)
if (ABS(_contactData.mfMaxContactNormalSpeed) > 0)
pMaterial1->GetSurfaceData()->OnImpact(_contactData.mfMaxContactNormalSpeed,
_contactData.mvContactPosition,
_contacts, _contactBody0);
if (std::abs(_contactData.mfMaxContactTangentSpeed) > 0)
if (ABS(_contactData.mfMaxContactTangentSpeed) > 0)
pMaterial1->GetSurfaceData()->OnSlide(_contactData.mfMaxContactTangentSpeed,
_contactData.mvContactPosition,
_contacts, _contactBody0, _contactBody1);
}
if (lPrio2 >= lPrio1 && pMaterial2 != pMaterial1) {
if (std::abs(_contactData.mfMaxContactNormalSpeed) > 0)
if (ABS(_contactData.mfMaxContactNormalSpeed) > 0)
pMaterial2->GetSurfaceData()->OnImpact(_contactData.mfMaxContactNormalSpeed,
_contactData.mvContactPosition,
_contacts, _contactBody1);
if (std::abs(_contactData.mfMaxContactTangentSpeed) > 0)
if (ABS(_contactData.mfMaxContactTangentSpeed) > 0)
pMaterial2->GetSurfaceData()->OnSlide(_contactData.mfMaxContactTangentSpeed,
_contactData.mvContactPosition,
_contacts, _contactBody1, _contactBody0);

View File

@ -165,7 +165,7 @@ eFrustumCollision cFrustum::CollideBVSphere(cBoundingVolume *aBV) {
return eFrustumCollision_Outside;
}
if (std::abs(fDist) < aBV->GetRadius()) {
if (ABS(fDist) < aBV->GetRadius()) {
return eFrustumCollision_Intersect;
}
}

View File

@ -382,7 +382,7 @@ float cMath::Wrap(float afX, float afMin, float afMax) {
afMin = 0;
afX = afX - fOffSet;
float fNumOfMax = floor(std::abs(afX / afMax));
float fNumOfMax = floor(ABS(afX / afMax));
if (afX >= afMax)
afX = afX - fNumOfMax * afMax;
@ -421,12 +421,12 @@ float cMath::GetAngleDistance(float afAngle1, float afAngle2, float afMaxAngle)
return 0;
} else {
float fDist1 = afAngle2 - afAngle1;
float fDist2 = afMaxAngle - std::abs(fDist1);
float fDist2 = afMaxAngle - ABS(fDist1);
if (fDist1 > 0)
fDist2 = -fDist2;
if (std::abs(fDist1) < std::abs(fDist2))
if (ABS(fDist1) < ABS(fDist2))
return fDist1;
else
return fDist2;
@ -635,7 +635,7 @@ cVector3f cMath::ProjectVector3D(const cVector3f &avSrcVec, const cVector3f &avD
float cMath::Vector3Angle(const cVector3f &avVecA, const cVector3f &avVecB) {
float fCos = Vector3Dot(avVecA, avVecB);
if (std::abs(fCos - 1) <= kEpsilonf)
if (ABS(fCos - 1) <= kEpsilonf)
return 0;
return acos(fCos);
@ -842,7 +842,7 @@ cQuaternion cMath::QuaternionSlerp(float afT, const cQuaternion &aqA, const cQua
float fCos = QuaternionDot(aqA, aqB);
// If the rotations are the same, just return the first.
if (std::abs(fCos - 1) <= kEpsilonf) {
if (ABS(fCos - 1) <= kEpsilonf) {
return aqA;
}

View File

@ -72,8 +72,8 @@ public:
max = afMax;
val = afVal;
up_speed = std::abs(afUpSpeed);
down_speed = -std::abs(afDownSpeed);
up_speed = ABS(afUpSpeed);
down_speed = -ABS(afDownSpeed);
add = up_speed;
}

View File

@ -894,7 +894,7 @@ void iCharacterBody::Update(float afTimeStep) {
// if climbing there is no gravity working but we still want foot steps.
mbOnGround = true;
} else {
if (bCollide && vLastVelocity.y <= 0 && std::abs(mvVelolcity.y) < (std::abs(vLastVelocity.y) - 0.001f)) {
if (bCollide && vLastVelocity.y <= 0 && ABS(mvVelolcity.y) < (ABS(vLastVelocity.y) - 0.001f)) {
if (mbOnGround == false) {
if (mpCallback)
mpCallback->OnHitGround(this, vLastVelocity);

View File

@ -109,13 +109,13 @@ tFlag cCollider2D::CollideBody(cBody2D *apBody, cCollideData2D *apData) {
// reverse the latest push, maybe pos here instead?
if (lCollision) {
// If the current X push is grater use it instead.
if (std::abs(vPushVector.x) > std::abs(vLastPushVector.x)) {
if (ABS(vPushVector.x) > ABS(vLastPushVector.x)) {
vPos.x -= vLastPushVector.x;
} else {
bAlterX = false;
}
// If the current Y push is grater use it instead.
if (std::abs(vPushVector.y) > std::abs(vLastPushVector.y)) {
if (ABS(vPushVector.y) > ABS(vLastPushVector.y)) {
vPos.y -= vLastPushVector.y;
bAlterY = true;
} else {

View File

@ -118,7 +118,7 @@ void iPhysicsController::Update(float afTimeStep) {
////////////////////////////////////////
// Check if dest vale is reached
if (mEndType == ePhysicsControllerEnd_OnDest && mpJoint) {
if (std::abs(fValue - mfDestValue) < kEpsilonf) {
if (ABS(fValue - mfDestValue) < kEpsilonf) {
mbActive = false;
iPhysicsController *pNext = mpJoint->GetController(msNextController);
if (pNext)

View File

@ -276,7 +276,7 @@ void iPhysicsJoint::OnMinLimit() {
//-----------------------------------------------------------------------
void iPhysicsJoint::CalcSoundFreq(float afSpeed, float *apFreq, float *apVol) {
float fAbsSpeed = std::abs(afSpeed);
float fAbsSpeed = ABS(afSpeed);
float fFreq = 1;
float fVolume = 1;
@ -496,8 +496,8 @@ void iPhysicsJoint::CheckLimitAutoSleep(iPhysicsJoint *apJoint,
const float afMin, const float afMax,
const float afDist) {
if (apJoint->mbLimitAutoSleep) {
float fMinDiff = std::abs(afMin - afDist);
float fMaxDiff = std::abs(afMax - afDist);
float fMinDiff = ABS(afMin - afDist);
float fMaxDiff = ABS(afMax - afDist);
if (fMaxDiff < apJoint->mfLimitAutoSleepDist ||
fMinDiff < apJoint->mfLimitAutoSleepDist) {

View File

@ -388,11 +388,11 @@ bool iPhysicsWorld::CheckShapeWorldCollision(cVector3f *apNewPos,
cVector3f vPush = point.mvNormal * point.mfDepth;
if (std::abs(vPushVec.x) < std::abs(vPush.x))
if (ABS(vPushVec.x) < ABS(vPush.x))
vPushVec.x = vPush.x;
if (std::abs(vPushVec.y) < std::abs(vPush.y))
if (ABS(vPushVec.y) < ABS(vPush.y))
vPushVec.y = vPush.y;
if (std::abs(vPushVec.z) < std::abs(vPush.z))
if (ABS(vPushVec.z) < ABS(vPush.z))
vPushVec.z = vPush.z;
}
bCollide = true;

View File

@ -166,7 +166,7 @@ void cSurfaceData::OnSlide(float afSpeed, const cVector3f &avPos, int alContacts
if (apBody->GetScrapeSoundEntity() != NULL) {
// check if the sound should be stopped
float fMin = cMath::Max(mfMinScrapeSpeed - 0.7f, 0.02f);
if (std::abs(afSpeed) < fMin) {
if (ABS(afSpeed) < fMin) {
apBody->GetScrapeSoundEntity()->FadeOut(4.3f);
apBody->SetScrapeSoundEntity(NULL);
apBody->SetScrapeBody(NULL);
@ -177,7 +177,7 @@ void cSurfaceData::OnSlide(float afSpeed, const cVector3f &avPos, int alContacts
apBody->SetHasSlide(true);
// Change frequency according to speed.
float fAbsSpeed = std::abs(afSpeed);
float fAbsSpeed = ABS(afSpeed);
float fFreq = 1;
// Higher than middle
@ -213,7 +213,7 @@ void cSurfaceData::OnSlide(float afSpeed, const cVector3f &avPos, int alContacts
}
}
} else {
if (mfMinScrapeSpeed <= std::abs(afSpeed) && msScrapeSoundName != "") {
if (mfMinScrapeSpeed <= ABS(afSpeed) && msScrapeSoundName != "") {
apBody->SetHasSlide(true);
cSoundEntity *pEntity = pWorld->CreateSoundEntity("Scrape",
@ -312,15 +312,15 @@ void cSurfaceData::UpdateRollEffect(iPhysicsBody *apBody) {
float fRollingSpeed = 0;
// X
if (mRollAxisFlags & eRollAxisFlag_X)
fRollingSpeed = std::abs(vAngularSpeed.x);
fRollingSpeed = ABS(vAngularSpeed.x);
// Y
if (mRollAxisFlags & eRollAxisFlag_Y)
if (fRollingSpeed < std::abs(vAngularSpeed.y))
fRollingSpeed = std::abs(vAngularSpeed.y);
if (fRollingSpeed < ABS(vAngularSpeed.y))
fRollingSpeed = ABS(vAngularSpeed.y);
// Z
if (mRollAxisFlags & eRollAxisFlag_Z)
if (fRollingSpeed < std::abs(vAngularSpeed.z))
fRollingSpeed = std::abs(vAngularSpeed.z);
if (fRollingSpeed < ABS(vAngularSpeed.z))
fRollingSpeed = ABS(vAngularSpeed.z);
// Log("Rollspeed: %f\n",fRollingSpeed);

View File

@ -121,11 +121,11 @@ bool cAnimationState::IsOver() {
//-----------------------------------------------------------------------
void cAnimationState::FadeIn(float afTime) {
mfFadeStep = 1.0f / std::abs(afTime);
mfFadeStep = 1.0f / ABS(afTime);
}
void cAnimationState::FadeOut(float afTime) {
mfFadeStep = -1.0f / std::abs(afTime);
mfFadeStep = -1.0f / ABS(afTime);
}
//-----------------------------------------------------------------------

View File

@ -72,11 +72,11 @@ cVector3f cCamera2D::GetEyePosition() {
void cCamera2D::GetClipRect(cRect2f &aRect) {
float fDiv = 1;
if (mvPosition.z < 0) {
fDiv = 1 - std::abs(mvPosition.z / mfZMin);
fDiv = 1 - ABS(mvPosition.z / mfZMin);
if (fDiv <= 0)
fDiv = 0.0001f;
} else
fDiv = 1 + std::abs(mvPosition.z / mfZMax);
fDiv = 1 + ABS(mvPosition.z / mfZMax);
// Transform these depending on z
float lW = ((float)mvClipArea.x) * fDiv;

View File

@ -262,8 +262,8 @@ void cImageEntity::Render() {
for (int i = 0; i < (int)mvBaseVtx.size(); i++) {
// Slow as hell!! Change this perhaps?
// This also only works on square meshes...
mvBaseVtx[i].pos.x = std::abs(mvBaseVtx[i].pos.x) / mvBaseVtx[i].pos.x;
mvBaseVtx[i].pos.y = std::abs(mvBaseVtx[i].pos.y) / mvBaseVtx[i].pos.y;
mvBaseVtx[i].pos.x = ABS(mvBaseVtx[i].pos.x) / mvBaseVtx[i].pos.x;
mvBaseVtx[i].pos.y = ABS(mvBaseVtx[i].pos.y) / mvBaseVtx[i].pos.y;
mvBaseVtx[i].pos.x *= mvSize.x / 2;
mvBaseVtx[i].pos.y *= mvSize.y / 2;
@ -406,7 +406,7 @@ void cImageEntity::SetAlpha(float afX) {
void cImageEntity::Flash(float afAdd) {
mbFlashing = true;
mfFlashAdd = -std::abs(afAdd);
mfFlashAdd = -ABS(afAdd);
}
//-----------------------------------------------------------------------

View File

@ -133,7 +133,7 @@ void cSoundEntry::Update(float afTimeStep) {
}
}
if (std::abs(mfNormalVolumeFadeDest) < 0.001f && std::abs(mfNormalVolumeMul) < 0.001f && mfNormalVolumeFadeSpeed <= 0) {
if (ABS(mfNormalVolumeFadeDest) < 0.001f && ABS(mfNormalVolumeMul) < 0.001f && mfNormalVolumeFadeSpeed <= 0) {
mpSound->Stop();
}
}

View File

@ -276,12 +276,12 @@ void cCharacterMove::Update(float afTimeStep) {
/////////////////
// Rotate the body
if (std::abs(fAngleDist) < 0.001f) {
if (ABS(fAngleDist) < 0.001f) {
mbTurning = false;
mfTurnSpeed = 0;
}
if (mbTurning) {
mfTurnSpeed = cMath::Min(mfAngleDistTurnMul * std::abs(fAngleDist), mfMaxTurnSpeed);
mfTurnSpeed = cMath::Min(mfAngleDistTurnMul * ABS(fAngleDist), mfMaxTurnSpeed);
if (fAngleDist < 0)
mpCharBody->AddYaw(-mfTurnSpeed * afTimeStep);
@ -290,8 +290,8 @@ void cCharacterMove::Update(float afTimeStep) {
//////////////////////
// Break when making short turns
if (std::abs(fAngleDist) >= mfMinBreakAngle && mpCharBody->GetMoveSpeed(eCharDir_Forward) > 0.15f) {
float fBreakAcc = -mfBreakAngleMul * std::abs(fAngleDist);
if (ABS(fAngleDist) >= mfMinBreakAngle && mpCharBody->GetMoveSpeed(eCharDir_Forward) > 0.15f) {
float fBreakAcc = -mfBreakAngleMul * ABS(fAngleDist);
mpCharBody->Move(eCharDir_Forward, fBreakAcc, afTimeStep);
mfCurrentBreak = fBreakAcc;
@ -314,7 +314,7 @@ void cCharacterMove::Update(float afTimeStep) {
float fCos = cMath::Vector3Dot(vWantedDir, vRealDir);
if (fRealSpeed / fWantedSpeed < mfStuckLimit ||
(std::abs(fCos) < 0.3f && fWantedSpeed > 0.001f)) {
(ABS(fCos) < 0.3f && fWantedSpeed > 0.001f)) {
mfStuckCounter += afTimeStep;
// mpInit->mpEffectHandler->GetSubTitle()->Add(_W("ADD!\n"),1.0f/60.0f,false);
} else {

View File

@ -1297,10 +1297,10 @@ void iGameEnemy::UpdateAnimations(float afTimeStep) {
}
if (mbAnimationIsSpeedDependant) {
if (std::abs(fSpeed) > 0.05f)
mpCurrentAnimation->SetSpeed(std::abs(fSpeed) * mfAnimationSpeedMul);
if (ABS(fSpeed) > 0.05f)
mpCurrentAnimation->SetSpeed(ABS(fSpeed) * mfAnimationSpeedMul);
else
mpCurrentAnimation->SetSpeed(std::abs(fTurnSpeed) * mfAnimationSpeedMul * 2);
mpCurrentAnimation->SetSpeed(ABS(fTurnSpeed) * mfAnimationSpeedMul * 2);
}
}
////////////////////////////////
@ -1322,7 +1322,7 @@ void iGameEnemy::UpdateAnimations(float afTimeStep) {
mMoveState = eEnemyMoveState_Backward;
else if (fSpeed >= mfStoppedToWalkSpeed)
mMoveState = eEnemyMoveState_Walking;
else if (std::abs(fTurnSpeed) > 0.07f)
else if (ABS(fTurnSpeed) > 0.07f)
mMoveState = eEnemyMoveState_Walking;
break;
@ -1332,7 +1332,7 @@ void iGameEnemy::UpdateAnimations(float afTimeStep) {
if (fSpeed >= mfWalkToRunSpeed)
mMoveState = eEnemyMoveState_Running;
else if (fSpeed <= mfWalkToStoppedSpeed) {
if (std::abs(fTurnSpeed) < 0.03f)
if (ABS(fTurnSpeed) < 0.03f)
mMoveState = eEnemyMoveState_Stopped;
}
@ -1379,10 +1379,10 @@ void iGameEnemy::UpdateAnimations(float afTimeStep) {
/////////////////////////////////
// Update animation speed
if (mbAnimationIsSpeedDependant) {
if (std::abs(fSpeed) > 0.05f)
mpCurrentAnimation->SetSpeed(std::abs(fSpeed) * mfMoveAnimSpeedMul);
if (ABS(fSpeed) > 0.05f)
mpCurrentAnimation->SetSpeed(ABS(fSpeed) * mfMoveAnimSpeedMul);
else
mpCurrentAnimation->SetSpeed(std::abs(fTurnSpeed) * mfMoveAnimSpeedMul * 2);
mpCurrentAnimation->SetSpeed(ABS(fTurnSpeed) * mfMoveAnimSpeedMul * 2);
}
}
}

View File

@ -389,7 +389,7 @@ void iGameEntity::Damage(float afDamage, int alStrength) {
afDamage *= fDamageMul;
}
mfHealth -= std::abs(afDamage);
mfHealth -= ABS(afDamage);
if (mfHealth <= 0) {
OnDeath(afDamage);

View File

@ -73,7 +73,7 @@ void cGameObjectBodyCallback::OnCollide(iPhysicsBody *apBody, iPhysicsBody *apCo
float fSpeed = apBody->GetLinearVelocity().Length();
float fImpulseSize = fSpeed * apBody->GetMass();
if (fSpeed > 4.5f && fImpulseSize > 25 && std::abs(apContactData->mfMaxContactNormalSpeed) >= 1.0f) {
if (fSpeed > 4.5f && fImpulseSize > 25 && ABS(apContactData->mfMaxContactNormalSpeed) >= 1.0f) {
pEnemy->Damage(fImpulseSize * 0.1f, 1);
}
}
@ -86,7 +86,7 @@ void cGameObjectBodyCallback::OnCollide(iPhysicsBody *apBody, iPhysicsBody *apCo
apCollideBody->GetLinearVelocity().Length() * apCollideBody->GetMass();
if (fImpulseSize >= mpObject->mBreakProps.mfMinImpulse &&
std::abs(apContactData->mfMaxContactNormalSpeed) >= mpObject->mBreakProps.mfMinNormalSpeed) {
ABS(apContactData->mfMaxContactNormalSpeed) >= mpObject->mBreakProps.mfMinNormalSpeed) {
if (mpInit->mbDebugInteraction) {
Log("------ Breakage ----------\n");
Log(" Body '%s' by Body '%s'\n", apBody->GetName().c_str(), apCollideBody->GetName().c_str());
@ -580,8 +580,8 @@ void cGameObject::OnPlayerGravityCollide(iCharacterBody *apCharBody, cCollideDat
for (int i = 0; i < apCollideData->mlNumOfPoints; i++) {
cCollidePoint &point = apCollideData->mvContactPoints[i];
if (point.mvNormal.y > 0.001f &&
point.mvNormal.y > std::abs(point.mvNormal.x) &&
point.mvNormal.y > std::abs(point.mvNormal.z)) {
point.mvNormal.y > ABS(point.mvNormal.x) &&
point.mvNormal.y > ABS(point.mvNormal.z)) {
bPushDown = true;
}
}
@ -589,14 +589,14 @@ void cGameObject::OnPlayerGravityCollide(iCharacterBody *apCharBody, cCollideDat
if (bPushDown) {
////////////////////////////////////
// Check the impulse created by the player
float fImpulse = apCharBody->GetMass() * std::abs(apCharBody->GetForceVelocity().y);
float fImpulse = apCharBody->GetMass() * ABS(apCharBody->GetForceVelocity().y);
if (mBreakProps.mfMinPlayerImpulse <= fImpulse) {
if (mpInit->mbDebugInteraction) {
Log("------ Breakage ----------\n");
Log(" Body '%s' by Player\n", mvBodies[0]->GetName().c_str());
Log(" Impulse: %f : %fm/s * %fkg (from Player)\n", fImpulse,
std::abs(apCharBody->GetForceVelocity().y), apCharBody->GetMass());
ABS(apCharBody->GetForceVelocity().y), apCharBody->GetMass());
Log("-------------------------\n");
}

View File

@ -243,7 +243,7 @@ void cGameSwingDoor::SetLocked(bool abX) {
iPhysicsJointHinge *pHingeJoint = static_cast<iPhysicsJointHinge *>(pJoint);
if (mbLocked) {
if (std::abs(pHingeJoint->GetMinAngle()) > std::abs(pHingeJoint->GetMaxAngle()))
if (ABS(pHingeJoint->GetMinAngle()) > ABS(pHingeJoint->GetMaxAngle()))
pHingeJoint->SetMinAngle(cMath::ToRad(-1));
else
pHingeJoint->SetMaxAngle(cMath::ToRad(1));

View File

@ -165,7 +165,7 @@ void cPlayerState_Grab::OnUpdate(float afTimeStep) {
cVector3f vOmega = mpPushBody->GetAngularVelocity();
// Set speed to 0
if (std::abs(mfYRotation) < 0.001f || mbRotateWithPlayer == false) {
if (ABS(mfYRotation) < 0.001f || mbRotateWithPlayer == false) {
cVector3f vTorque = mRotatePid.Output(cVector3f(0, 0, 0) - vOmega, afTimeStep);
vTorque = vTorque / 5.0f;
@ -623,7 +623,7 @@ bool cPlayerState_Move::OnMoveSideways(float afMul, float afTimeStep) {
//-----------------------------------------------------------------------
bool cPlayerState_Move::OnAddYaw(float afVal) {
if (std::abs(afVal) > kEpsilonf) {
if (ABS(afVal) > kEpsilonf) {
cVector3f vForce = (mvRight * (afVal * 100.0f * mpPlayer->mfRightMul));
mpPushBody->AddForceAtPosition(vForce, mvPickPoint);
mlMoveCount = 20;
@ -638,7 +638,7 @@ bool cPlayerState_Move::OnAddYaw(float afVal) {
//-----------------------------------------------------------------------
bool cPlayerState_Move::OnAddPitch(float afVal) {
if (std::abs(afVal) > kEpsilonf) {
if (ABS(afVal) > kEpsilonf) {
cVector3f vForce = (mvUp * (-afVal * 100.0f * mpPlayer->mfUpMul)) +
(mvForward * (afVal * -80.0f * mpPlayer->mfForwardUpMul));
mpPushBody->AddForceAtPosition(vForce, mvPickPoint);

View File

@ -202,7 +202,7 @@ void cPlayerState_GrabHaptX::OnUpdate(float afTimeStep) {
cVector3f vOmega = mpPushBody->GetAngularVelocity();
// Set speed to 0
if (std::abs(mfYRotation) < 0.001f || mbRotateWithPlayer == false) {
if (ABS(mfYRotation) < 0.001f || mbRotateWithPlayer == false) {
mRotatePid.p = 0.8f;
mRotatePid.i = 0.0f;
mRotatePid.d = 0.0f;
@ -718,7 +718,7 @@ bool cPlayerState_MoveHaptX::OnMoveSideways(float afMul, float afTimeStep) {
//-----------------------------------------------------------------------
bool cPlayerState_MoveHaptX::OnAddYaw(float afVal) {
if (std::abs(afVal) > kEpsilonf) {
if (ABS(afVal) > kEpsilonf) {
cVector3f vForce = (mvRight * (afVal * 100.0f * mpPlayer->mfRightMul));
mpPushBody->AddForceAtPosition(vForce, mvPickPoint);
mlMoveCount = 20;
@ -733,7 +733,7 @@ bool cPlayerState_MoveHaptX::OnAddYaw(float afVal) {
//-----------------------------------------------------------------------
bool cPlayerState_MoveHaptX::OnAddPitch(float afVal) {
if (std::abs(afVal) > kEpsilonf) {
if (ABS(afVal) > kEpsilonf) {
cVector3f vForce = (mvUp * (-afVal * 100.0f * mpPlayer->mfUpMul)) +
(mvForward * (afVal * -80.0f * mpPlayer->mfForwardUpMul));
mpPushBody->AddForceAtPosition(vForce, mvPickPoint);