mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 18:32:42 +01:00
- replace FixFloorSigned macro calls with divisions
This commit is contained in:
parent
20d32a16ca
commit
3304fc1adb
@ -1035,7 +1035,7 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
|
||||
cd[0].length[1] = car_cos->colBox.vx + 15;
|
||||
|
||||
if (handlingType[cp->hndType].fourWheelDrive == 1 || cp->hndType == 5)
|
||||
cd[0].length[1] = FixFloorSigned(cd[0].length[1] * 13, 4);
|
||||
cd[0].length[1] = (cd[0].length[1] * 13) / 16;
|
||||
}
|
||||
|
||||
cd[0].avel = FIXEDH(cp->st.n.angularVelocity[1]) * 5 >> 5;
|
||||
@ -1197,16 +1197,16 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
|
||||
pointVel[2] += 700000;
|
||||
}
|
||||
|
||||
strikeVel = -(FixFloorSigned(pointVel[0], 8) * FixFloorSigned(collisionResult.surfNormal.vx, 4) +
|
||||
FixFloorSigned(pointVel[1], 8) * FixFloorSigned(collisionResult.surfNormal.vy, 4) +
|
||||
FixFloorSigned(pointVel[2], 8) * FixFloorSigned(collisionResult.surfNormal.vz, 4));
|
||||
strikeVel = -((pointVel[0] / 256) * (collisionResult.surfNormal.vx / 16) +
|
||||
(pointVel[1] / 256) * (collisionResult.surfNormal.vy / 16) +
|
||||
(pointVel[2] / 256) * (collisionResult.surfNormal.vz / 16));
|
||||
|
||||
if (strikeVel > 0)
|
||||
{
|
||||
if (cp->controlType == CONTROL_TYPE_PLAYER)
|
||||
{
|
||||
if (strikeVel < 32)
|
||||
scale = ((strikeVel << 0x17) >> 0x10);
|
||||
scale = ((strikeVel << 23) >> 16);
|
||||
else
|
||||
scale = 0x1000;
|
||||
|
||||
@ -1218,9 +1218,9 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
|
||||
|
||||
collisionResult.hit.vy = -collisionResult.hit.vy;
|
||||
|
||||
velocity.vx = FixFloorSigned(cp->st.n.linearVelocity[0], ONE_BITS);
|
||||
velocity.vx = cp->st.n.linearVelocity[0] / ONE;
|
||||
velocity.vy = -17;
|
||||
velocity.vz = FixFloorSigned(cp->st.n.linearVelocity[2], ONE_BITS);
|
||||
velocity.vz = cp->st.n.linearVelocity[2] / ONE;
|
||||
|
||||
if ((model->flags2 & 0x800) != 0)
|
||||
{
|
||||
@ -1321,11 +1321,11 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop
|
||||
else
|
||||
denom = (strikeVel / displacement) * 4096;
|
||||
|
||||
denom = FixFloorSigned(denom, 6);
|
||||
denom = denom / 64;
|
||||
|
||||
reaction[0] = denom * FixFloorSigned(collisionResult.surfNormal.vx, 6);
|
||||
reaction[1] = denom * FixFloorSigned(collisionResult.surfNormal.vy, 6);
|
||||
reaction[2] = denom * FixFloorSigned(collisionResult.surfNormal.vz, 6);
|
||||
reaction[0] = denom * (collisionResult.surfNormal.vx / 64);
|
||||
reaction[1] = denom * (collisionResult.surfNormal.vy / 64);
|
||||
reaction[2] = denom * (collisionResult.surfNormal.vz / 64);
|
||||
|
||||
cp->hd.aacc[1] += FIXEDH(lever[2] * reaction[0]) - FIXEDH(lever[0] * reaction[2]);
|
||||
|
||||
|
@ -350,7 +350,7 @@ int sdHeightOnPlane(VECTOR *pos, _sdPlane *plane)
|
||||
curve = Driver2CurvesPtr + ((plane->surface & 0x1fff) - 32);
|
||||
angle = ratan2(curve->Midz - pos->vz, curve->Midx - pos->vx);
|
||||
|
||||
return FixFloorSigned(curve->gradient * (angle + 2048 & 0xfff), ONE_BITS) - curve->height;
|
||||
return ((curve->gradient * (angle + 2048 & 0xfff)) / ONE) - curve->height;
|
||||
}
|
||||
|
||||
i = plane->b;
|
||||
|
@ -918,7 +918,7 @@ ushort GetEngineRevs(_CAR_DATA *cp)
|
||||
|
||||
if (iVar8 < 1)
|
||||
{
|
||||
sVar7 = FixFloorSigned(-iVar8, 11);
|
||||
sVar7 = -iVar8 / 2048;
|
||||
uVar6 = 0;
|
||||
iVar9 = uVar10 * 4;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3582,7 +3582,8 @@ int TannerCarCollisionCheck(VECTOR* pPos, int dir, int bQuick)
|
||||
pointVel[0] = FIXEDH(pcdTanner->st.n.angularVelocity[1] * lever[2] - pcdTanner->st.n.angularVelocity[2] * lever[1]) + pcdTanner->st.n.linearVelocity[0];
|
||||
pointVel[2] = FIXEDH(pcdTanner->st.n.angularVelocity[0] * lever[1] - pcdTanner->st.n.angularVelocity[1] * lever[0]) + pcdTanner->st.n.linearVelocity[2];
|
||||
|
||||
strikeVel = FixFloorSigned(pointVel[0], 8) * FixFloorSigned(-collisionResult.surfNormal.vx, 4) + FixFloorSigned(pointVel[2], 8) * FixFloorSigned(-collisionResult.surfNormal.vz, 4);
|
||||
strikeVel = (pointVel[0] / 256) * (-collisionResult.surfNormal.vx / 16) +
|
||||
(pointVel[2] / 256) * (-collisionResult.surfNormal.vz / 16);
|
||||
|
||||
if (strikeVel < 0)
|
||||
{
|
||||
@ -3594,17 +3595,17 @@ int TannerCarCollisionCheck(VECTOR* pPos, int dir, int bQuick)
|
||||
twistRateY = car_cos->twistRateY;
|
||||
|
||||
lever_dot_n = FIXEDH(lever[0] * -collisionResult.surfNormal.vx + lever[2] * -collisionResult.surfNormal.vz);
|
||||
displacementsquared = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - lever_dot_n * lever_dot_n) * twistRateY) + 0x1000;
|
||||
displacementsquared = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - lever_dot_n * lever_dot_n) * twistRateY) + ONE;
|
||||
|
||||
if (-strikeVel < 0x7f001)
|
||||
denom = (strikeVel * -0x1000) / displacementsquared;
|
||||
if (-strikeVel < 520193)
|
||||
denom = (strikeVel * -ONE) / displacementsquared;
|
||||
else
|
||||
denom = -strikeVel / displacementsquared << 0xc;
|
||||
denom = -strikeVel / displacementsquared * ONE;
|
||||
|
||||
denom = FixFloorSigned(denom, 6);
|
||||
denom /= 64;
|
||||
|
||||
reaction[0] = denom * FixFloorSigned(-collisionResult.surfNormal.vx, 6);
|
||||
reaction[2] = denom * FixFloorSigned(-collisionResult.surfNormal.vz, 6);
|
||||
reaction[0] = denom * (-collisionResult.surfNormal.vx / 64);
|
||||
reaction[2] = denom * (-collisionResult.surfNormal.vz / 64);
|
||||
|
||||
pcdTanner->st.n.linearVelocity[0] += pcdTanner->st.n.linearVelocity[0] + reaction[0];
|
||||
pcdTanner->st.n.linearVelocity[2] += pcdTanner->st.n.linearVelocity[2] + reaction[2];
|
||||
|
@ -281,14 +281,8 @@ void StepOneCar(_CAR_DATA* cp)
|
||||
cp->hd.acc[2] = 0;
|
||||
|
||||
// calculate car speed
|
||||
a = FIXEDH(_cl.vel[0]);
|
||||
b = FIXEDH(_cl.vel[2]);
|
||||
|
||||
if (a < 0)
|
||||
a = -a;
|
||||
|
||||
if (b < 0)
|
||||
b = -b;
|
||||
a = ABS(FIXEDH(_cl.vel[0]));
|
||||
b = ABS(FIXEDH(_cl.vel[2]));
|
||||
|
||||
if (a < b)
|
||||
speed = b + a / 2;
|
||||
@ -686,7 +680,7 @@ void ConvertTorqueToAngularAcceleration(_CAR_DATA* cp, CAR_LOCALS* cl)
|
||||
cp->hd.aacc[i] = cp->hd.aacc[i] * twistY + FIXEDH(cp->hd.where.m[i][2] * (twistZ - twistY) * zd - cl->avel[i] * 128);
|
||||
|
||||
if (cl->extraangulardamping == 1)
|
||||
cp->hd.aacc[i] -= FixFloorSigned(cl->avel[i], 3);
|
||||
cp->hd.aacc[i] -= cl->avel[i] / 8;
|
||||
|
||||
i++;
|
||||
} while (i < 3);
|
||||
@ -1125,7 +1119,7 @@ void AddWheelForcesDriver1(_CAR_DATA* cp, CAR_LOCALS* cl)
|
||||
}
|
||||
else
|
||||
{
|
||||
cp->hd.wheel_speed = FixFloorSigned(cl->vel[0], 6) * FixFloorSigned(cdx, 6) + FixFloorSigned(cl->vel[2], 6) * FixFloorSigned(cdz, 6);
|
||||
cp->hd.wheel_speed = cdz / 64 * (cl->vel[2] / 64) + cdx / 64 * (cl->vel[0] / 64);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user