Continue HUD
This commit is contained in:
parent
b177e924dd
commit
7c3eac7d9f
4 changed files with 117 additions and 32 deletions
75
racing.h
75
racing.h
|
@ -512,6 +512,39 @@ LCR_GameUnit _LCR_racingSmoothRot(LCR_GameUnit angleNew, LCR_GameUnit angleOld)
|
|||
return angleOld + diff / 2;
|
||||
}
|
||||
|
||||
|
||||
void _LCR_racingUpdateCarPosRot(void)
|
||||
{
|
||||
TPE_Vec3 tmpVec = LCR_racing.carPositions[0];
|
||||
|
||||
TPE_Vec3 wheelAverage = _LCR_TPE_vec3DividePlain(
|
||||
TPE_vec3Plus(
|
||||
TPE_vec3Plus(
|
||||
LCR_racing.carBody.joints[0].position,
|
||||
LCR_racing.carBody.joints[1].position),
|
||||
TPE_vec3Plus(
|
||||
LCR_racing.carBody.joints[2].position,
|
||||
LCR_racing.carBody.joints[3].position)),4);
|
||||
|
||||
LCR_racing.carPositions[0] = _LCR_TPE_vec3DividePlain(
|
||||
TPE_vec3TimesPlain(wheelAverage,LCR_GAME_UNIT),LCR_PHYSICS_UNIT);
|
||||
|
||||
LCR_racing.carPositions[0] = // smooth the position
|
||||
TPE_vec3KeepWithinBox(LCR_racing.carPositions[1],LCR_racing.carPositions[0],
|
||||
TPE_vec3(
|
||||
LCR_PHYSICS_UNIT / 64, // TODO: constant
|
||||
LCR_PHYSICS_UNIT / 64,
|
||||
LCR_PHYSICS_UNIT / 64));
|
||||
|
||||
LCR_racing.carPositions[1] = tmpVec;
|
||||
|
||||
tmpVec = _LCR_TPE_vec3DividePlain(TPE_vec3TimesPlain(TPE_bodyGetRotation(
|
||||
&(LCR_racing.carBody),0,2,1),LCR_GAME_UNIT),TPE_F);
|
||||
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
LCR_racing.carRotations[0] = tmpVec;
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes new run.
|
||||
*/
|
||||
|
@ -530,12 +563,6 @@ void LCR_racingRestart(void)
|
|||
LCR_racing.carSpeed = 0;
|
||||
LCR_racing.carDrifting = 0;
|
||||
|
||||
LCR_racing.carPositions[0] = TPE_vec3(0,0,0);
|
||||
LCR_racing.carPositions[1] = LCR_racing.carPositions[0];
|
||||
|
||||
LCR_racing.carRotations[0] = TPE_vec3(0,0,0);
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
|
||||
// make the car body:
|
||||
TPE_makeCenterRectFull(LCR_racing.carJoints,
|
||||
LCR_racing.carConnections,
|
||||
|
@ -582,6 +609,16 @@ for (int i = 0; i < LCR_CAR_JOINTS; ++i)
|
|||
LCR_racing.carNotOKCount = 0;
|
||||
|
||||
|
||||
LCR_racing.carPositions[0] = TPE_vec3(0,0,0);
|
||||
LCR_racing.carPositions[1] = LCR_racing.carPositions[0];
|
||||
LCR_racing.carRotations[0] = TPE_vec3(0,0,0);
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
|
||||
_LCR_racingUpdateCarPosRot();
|
||||
|
||||
LCR_racing.carPositions[1] = LCR_racing.carPositions[0];
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -628,11 +665,11 @@ void LCR_racingGetCarTransform(LCR_GameUnit position[3],
|
|||
position[2] = v.z;
|
||||
|
||||
rotation[0] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].x,
|
||||
LCR_racing.carRotations[1].x);
|
||||
LCR_racing.carRotations[1].x);
|
||||
rotation[1] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].y,
|
||||
LCR_racing.carRotations[1].y);
|
||||
LCR_racing.carRotations[1].y);
|
||||
rotation[2] = _LCR_racingSmoothRot(LCR_racing.carRotations[0].z,
|
||||
LCR_racing.carRotations[1].z);
|
||||
LCR_racing.carRotations[1].z);
|
||||
#else
|
||||
position[0] = LCR_racing.carPositions[0].x;
|
||||
position[1] = LCR_racing.carPositions[0].y;
|
||||
|
@ -982,7 +1019,9 @@ if (TPE_vec3Dot(carVel,carForw) < 0)
|
|||
|
||||
|
||||
|
||||
_LCR_racingUpdateCarPosRot();
|
||||
|
||||
/*
|
||||
TPE_Vec3 tmpVec = LCR_racing.carPositions[0];
|
||||
|
||||
TPE_Vec3 wheelAverage = _LCR_TPE_vec3DividePlain(
|
||||
|
@ -1011,6 +1050,9 @@ if (TPE_vec3Dot(carVel,carForw) < 0)
|
|||
|
||||
LCR_racing.carRotations[1] = LCR_racing.carRotations[0];
|
||||
LCR_racing.carRotations[0] = tmpVec;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
TPE_Unit angle = TPE_vec3Dot(carUp,TPE_vec3Normalized(TPE_vec3Minus(
|
||||
LCR_racing.carBody.joints[4].position,
|
||||
|
@ -1020,7 +1062,7 @@ if (TPE_vec3Dot(carVel,carForw) < 0)
|
|||
{
|
||||
LCR_LOG2("roof squeezed, applying anti force")
|
||||
|
||||
tmpVec = TPE_vec3Times(carUp,LCR_PHYSICS_UNIT / 16); // TODO: 16 magic con.
|
||||
TPE_Vec3 tmpVec = TPE_vec3Times(carUp,LCR_PHYSICS_UNIT / 16); // TODO: 16 magic con.
|
||||
|
||||
angle = TPE_F - 4 * angle; // 4 comes from above TPE_F / 4
|
||||
|
||||
|
@ -1029,7 +1071,16 @@ if (TPE_vec3Dot(carVel,carForw) < 0)
|
|||
if (angle <= 0)
|
||||
{
|
||||
LCR_LOG1("roof flipped over, fixing")
|
||||
LCR_racing.carBody.joints[4].position = wheelAverage;
|
||||
LCR_racing.carBody.joints[4].position =
|
||||
_LCR_TPE_vec3DividePlain(
|
||||
TPE_vec3Plus(
|
||||
TPE_vec3Plus(
|
||||
LCR_racing.carBody.joints[0].position,
|
||||
LCR_racing.carBody.joints[1].position),
|
||||
TPE_vec3Plus(
|
||||
LCR_racing.carBody.joints[2].position,
|
||||
LCR_racing.carBody.joints[3].position)),4);
|
||||
|
||||
angle = 0;
|
||||
}
|
||||
|
||||
|
@ -1126,6 +1177,7 @@ if (TPE_vec3Dot(carVel,carForw) < 0)
|
|||
void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||
LCR_GameUnit camFov)
|
||||
{
|
||||
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
||||
LCR_LOG2("drawing physics debug overlay");
|
||||
|
||||
TPE_Vec3 cPos, cRot, cView;
|
||||
|
@ -1144,6 +1196,7 @@ void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
|||
|
||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),_LCR_drawPhysicsDebugPixel,
|
||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue