Fix collision bug

This commit is contained in:
Miloslav Ciz 2024-09-26 21:29:36 +02:00
parent fa66324833
commit 28a1256a88
2 changed files with 30 additions and 18 deletions

View file

@ -20,6 +20,9 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
#include "tinyphysicsengine.h"
// TODO: move some of this to constants?
#if 0
#define LCR_GRAVITY (LCR_PHYSICS_UNIT / 100)
#define LCR_CAR_FORWARD_FRICTION (TPE_F / 11)
#define LCR_CAR_TURN_FRICTION (4 * TPE_F / 4)
@ -28,6 +31,20 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
#define LCR_CAR_TURN_SPEED (LCR_GAME_UNIT / 20)
#define LCR_CAR_TURN_MAX (LCR_GAME_UNIT / 4)
#else
#define LCR_GRAVITY (LCR_PHYSICS_UNIT / 140)
#define LCR_CAR_FORWARD_FRICTION (TPE_F / 9)
#define LCR_CAR_TURN_FRICTION (4 * TPE_F / 4)
#define LCR_CAR_ELASTICITY (TPE_F / 110)
#define LCR_CAR_ACCELERATION (LCR_PHYSICS_UNIT / 16)
#define LCR_CAR_TURN_SPEED (LCR_GAME_UNIT / 20)
#define LCR_CAR_TURN_MAX (LCR_GAME_UNIT / 4)
#endif
#define LCR_CAR_JOINTS 5
#define LCR_CAR_CONNECTIONS 10
@ -61,7 +78,7 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
{
uint8_t bx, by, bz;
LCR_mapBlockGetCoords(block,&bx,&by,&bz);
TPE_Vec3 blockOffset = TPE_vec3(
(((int) bx) - LCR_MAP_SIZE_BLOCKS / 2) * LCR_PHYSICS_UNIT,
(((int) by) - LCR_MAP_SIZE_BLOCKS / 2) * (LCR_PHYSICS_UNIT / 2),
@ -72,11 +89,11 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
uint8_t transform =
LCR_mapBlockOppositeTransform(LCR_mapBlockGetTransform(block));
LCR_TRANSFORM_COORDS(transform,point.x,point.y,point.z,(LCR_PHYSICS_UNIT / 2),
(LCR_PHYSICS_UNIT / 4))
LCR_TRANSFORM_COORDS(transform,point.x,point.y,point.z,LCR_PHYSICS_UNIT,
(LCR_PHYSICS_UNIT / 2))
point = TPE_vec3Minus(point,TPE_vec3(
LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT / 2));
point = TPE_vec3Minus(point,
TPE_vec3(LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT / 2));
switch (block[0])
{