Modify wheel collisions

This commit is contained in:
Miloslav Ciz 2025-02-22 14:40:28 +01:00
parent d794784bab
commit e43ed793a3
3 changed files with 28 additions and 22 deletions

View file

@ -12,20 +12,29 @@
- maps to make: - maps to make:
- there should be these maps: - there should be these maps:
- compiled in: - compiled in:
- standard maps, let's say 10? - standard maps, let's say 5?
- additionally a few (5?) extremely simple maps, compile time option to - additionally a few (5?) extremely simple maps, compile time option to
only include these, for very weak devices with limited block/triangle only include these, for very weak devices with limited block/triangle
count count
- bonus maps in the external file - bonus maps in the external file (also 5?)
- map types: - map types:
- traveling salesman kind of maze - traveling salesman kind of maze, with fans n shit
- city map?
- some kinda buggy bumpy downhill - some kinda buggy bumpy downhill
- dirt map
- ice map
- boss map
- text or picture from blocks?
- chessboard from different materials
- falling tube map?
- grass hills as decoration?
- something with multiple roads - something with multiple roads
- RPG kinda map? could be in bonus maps - RPG kinda map? could be in bonus maps
- some speed map - some speed map (mostly flat to prevent high speed bugs)
- some (at least partially) interior map - some (at least partially) interior map
- something with multiple finishes - something with multiple finishes
- U-ramp to build speed and jump up to catch a CP - U-ramp to build speed and jump up to catch a CP (done)
- jump through air ring with CP
- try to speed up the slow culling - try to speed up the slow culling
- make a small txt game menual - make a small txt game menual
- test: - test:
@ -46,6 +55,7 @@
=========== BUGS ================= =========== BUGS =================
- immediately after starting the map countdown seems to be lower
- the pinch collision test seems to sometimes stop the car e.g. after falling - the pinch collision test seems to sometimes stop the car e.g. after falling
from bigger height or when running into ramp at high speed (or not?) - FIX from bigger height or when running into ramp at high speed (or not?) - FIX

View file

@ -94,7 +94,7 @@ static const char *LCR_internalDataFile =
"#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044" "#Rrep1;testmap;482f70f9 00000188:00c1:0089:0111:00b9:0091:0109:0028:0050:00c1:0093:0030:00d1:0069:0041:0020:0071:0013:0012:0023:0022:0050:0032:0020:0022:0060:0024:00bc:0044"
// MAP 1: // MAP 1:
"#MLicar1;4321 0 " "#MLC1;4321 0 "
":*B2mL:!x6G:+L2H:+D38" // start, finish, CPs ":*B2mL:!x6G:+L2H:+D38" // start, finish, CPs
// pillars: // pillars:
":nw0w2L:f151:m151" ":nw0w2L:f151:m151"

View file

@ -875,9 +875,9 @@ void _LCR_racingUpdateCarPosRot(void)
LCR_racing.carPositions[0] = // smooth the position LCR_racing.carPositions[0] = // smooth the position
TPE_vec3KeepWithinBox(LCR_racing.carPositions[1],LCR_racing.carPositions[0], TPE_vec3KeepWithinBox(LCR_racing.carPositions[1],LCR_racing.carPositions[0],
TPE_vec3( TPE_vec3(
LCR_PHYSICS_UNIT / 64, // TODO: constant LCR_PHYSICS_UNIT / 128, // hardcoded consts
LCR_PHYSICS_UNIT / 64, LCR_PHYSICS_UNIT / 128,
LCR_PHYSICS_UNIT / 64)); LCR_PHYSICS_UNIT / 128));
LCR_racing.carPositions[1] = tmpVec; LCR_racing.carPositions[1] = tmpVec;
@ -1047,12 +1047,6 @@ void LCR_racingGetCarBlockCoords(int coords[3])
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT; (LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT;
} }
int LCR_racingCarWheelTouchesGround(int wheel)
{
return ((LCR_racing.wheelCollisions & (LCR_racing.wheelCollisions >> 4))
>> wheel) & 0x01;
}
LCR_GameUnit LCR_racingGetWheelRotation(void) LCR_GameUnit LCR_racingGetWheelRotation(void)
{ {
return LCR_racing.wheelAngle; return LCR_racing.wheelAngle;
@ -1160,7 +1154,10 @@ uint32_t LCR_racingStep(unsigned int input)
LCR_racing.carBody.joints[4].velocity[1], LCR_racing.carBody.joints[4].velocity[1],
LCR_racing.carBody.joints[4].velocity[2]); LCR_racing.carBody.joints[4].velocity[2]);
if ((LCR_racing.wheelCollisions & 0x0f) != 0x0f) // EXPERIMENTAL: don't apply gravity with all wheels on ground // apply gravity only if wheels are on the ground (prevents sliding a bit):
if (((LCR_racing.wheelCollisions | (LCR_racing.wheelCollisions >> 4))
& 0x0f) != 0x0f)
TPE_bodyApplyGravity(&(LCR_racing.carBody),LCR_GRAVITY); TPE_bodyApplyGravity(&(LCR_racing.carBody),LCR_GRAVITY);
if (LCR_racing.wheelCollisions) // at least one wheel on ground? if (LCR_racing.wheelCollisions) // at least one wheel on ground?
@ -1229,8 +1226,7 @@ uint32_t LCR_racingStep(unsigned int input)
{ {
unsigned char steering = 0; unsigned char steering = 0;
if ((input & LCR_RACING_INPUT_BACK) && if ((input & LCR_RACING_INPUT_BACK) && LCR_racing.wheelCollisions == 0x00)
(LCR_racing.wheelCollisions & 0x0f) == 0x00) // in air?
{ {
LCR_LOG2("air brake"); LCR_LOG2("air brake");
@ -1243,7 +1239,7 @@ uint32_t LCR_racingStep(unsigned int input)
if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)) if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))
{ {
LCR_GameUnit rotateBy = LCR_GameUnit rotateBy =
(LCR_racing.wheelCollisions & 0x0f) ? // on ground slow down wheel rot. LCR_racing.wheelCollisions ? // on ground slow down wheel rot.
(LCR_racingGetCarSpeedUnsigned() / LCR_CAR_WHEEL_GROUND_SPEED_DIV) : (LCR_racingGetCarSpeedUnsigned() / LCR_CAR_WHEEL_GROUND_SPEED_DIV) :
LCR_CAR_WHEEL_AIR_ROTATION_SPEED; LCR_CAR_WHEEL_AIR_ROTATION_SPEED;
@ -1274,7 +1270,7 @@ uint32_t LCR_racingStep(unsigned int input)
-1 * LCR_CAR_STEER_MAX); -1 * LCR_CAR_STEER_MAX);
} }
if ((LCR_racing.wheelCollisions & 0x0c)) // back wheel on ground? if ((LCR_racing.wheelCollisions & 0xcc)) // back wheel on ground?
{ {
if (input & LCR_RACING_INPUT_FORW) if (input & LCR_RACING_INPUT_FORW)
{ {
@ -1291,7 +1287,7 @@ uint32_t LCR_racingStep(unsigned int input)
TPE_Unit driftFriction = 0; // average wheel friction (absolute value) TPE_Unit driftFriction = 0; // average wheel friction (absolute value)
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
if (LCR_racing.wheelCollisions & (0x01 << i)) // wheel on ground? if (LCR_racing.wheelCollisions & (0x11 << i)) // wheel on ground?
{ {
TPE_Vec3 jv = TPE_vec3( // joint velocity TPE_Vec3 jv = TPE_vec3( // joint velocity
LCR_racing.carBody.joints[i].velocity[0], LCR_racing.carBody.joints[i].velocity[0],
@ -1346,7 +1342,7 @@ uint32_t LCR_racingStep(unsigned int input)
if (steering && if (steering &&
(input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)) && (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK)) &&
(LCR_racing.wheelCollisions & 0x0f)) (LCR_racing.wheelCollisions & 0x33))
{ {
/* When steering, also slightly spin the car. This helps fix the car /* When steering, also slightly spin the car. This helps fix the car
getting "stuck" by its side to a wall when too close, becoming unable getting "stuck" by its side to a wall when too close, becoming unable