Fix roof bug

This commit is contained in:
Miloslav Ciz 2025-06-02 15:12:17 +02:00
parent 0f0e4f4889
commit a199a84d31
2 changed files with 26 additions and 0 deletions

View file

@ -39,6 +39,15 @@
will stop being compatible. It's still possible to make other changes to
this module (such as optimizations or comments) without having to change
physics version.
- The physics car body has joints numbered like this:
front
l (2)---(3) r
e |\ /| i
f | (4) | g
t |/ \| h
(0)---(1) t
rear
*/
typedef int32_t LCR_GameUnit; ///< abstract game unit
@ -1147,6 +1156,22 @@ int _LCR_racingCarShapeOK(void)
TPE_Unit bodyTension = 0;
TPE_Connection *c = LCR_racing.carConnections;
if (TPE_vec3Dot( // checks if roof is on the correct side (can be pushed down)
TPE_vec3Minus(
LCR_racing.carBody.joints[4].position,
LCR_racing.carBody.joints[0].position),
TPE_vec3Cross(
TPE_vec3Minus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[2].position),
TPE_vec3Minus(
LCR_racing.carBody.joints[0].position,
LCR_racing.carBody.joints[1].position))) <= 0)
{
LCR_LOG1("roof flipped over");
return 0;
}
for (int i = 0; i < LCR_CAR_CONNECTIONS; ++i) // joint tension
{
bodyTension += TPE_abs(