Add more ramps

This commit is contained in:
Miloslav Ciz 2024-10-04 00:59:15 +02:00
parent 9f112e5869
commit c79d21857b
3 changed files with 68 additions and 40 deletions

View file

@ -67,6 +67,9 @@ TPE_Vec3 _LCR_TPE_vec3DividePlain(TPE_Vec3 v, TPE_Unit d)
TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
{
TPE_Vec3 v, vBest;
TPE_Unit d, dBest = TPE_INFINITY;
uint8_t bx, by, bz;
LCR_mapBlockGetCoords(block,&bx,&by,&bz);
@ -127,45 +130,59 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
break;
}
#define _CHECK_NEXT(check)\
v = check;\
d = TPE_dist(point,v);\
if (d < dBest) {\
vBest = v;\
dBest = d;}\
if (dBest == 0) {\
point = vBest;\
break;}
case LCR_BLOCK_RAMP_CURVED_WALL:
_CHECK_NEXT(TPE_envAABox(point,TPE_vec3(5 * LCR_PHYSICS_UNIT / 12,0,0),
TPE_vec3(LCR_PHYSICS_UNIT / 12,LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT
/ 2)));
case LCR_BLOCK_RAMP_CURVED_PLAT:
_CHECK_NEXT(TPE_envAABox(point,TPE_vec3(0,0,5 * LCR_PHYSICS_UNIT / 12),
TPE_vec3(LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT / 12
)));
case LCR_BLOCK_RAMP_CURVED:
{
TPE_Vec3 v, vBest;
TPE_Unit sides[6], d, dBest;
TPE_Unit sides[6];
TPE_Unit rampShift = block[0] != LCR_BLOCK_RAMP_CURVED ?
LCR_PHYSICS_UNIT / 6 : 0;
sides[0] = LCR_PHYSICS_UNIT / 8;
sides[0] = LCR_PHYSICS_UNIT / 8 - rampShift;
sides[1] = -1 * LCR_PHYSICS_UNIT / 4;
sides[2] = LCR_PHYSICS_UNIT / 2;
sides[2] = LCR_PHYSICS_UNIT / 2 - rampShift;
sides[3] = -1 * LCR_PHYSICS_UNIT / 4;
sides[4] = LCR_PHYSICS_UNIT / 2;
sides[4] = LCR_PHYSICS_UNIT / 2 - rampShift;
sides[5] = LCR_PHYSICS_UNIT / 4;
vBest = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2);
dBest = TPE_dist(point,vBest);
_CHECK_NEXT(TPE_envAATriPrism(point,
TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2))
if (dBest != 0)
{
sides[0] = -1 * LCR_PHYSICS_UNIT / 4;
sides[1] = -1 * LCR_PHYSICS_UNIT / 4;
sides[2] = LCR_PHYSICS_UNIT / 2;
sides[3] = -1 * LCR_PHYSICS_UNIT / 4;
sides[4] = LCR_PHYSICS_UNIT / 2;
sides[5] = 0;
sides[0] = -1 * LCR_PHYSICS_UNIT / 2;
sides[1] = -1 * LCR_PHYSICS_UNIT / 4;
sides[2] = LCR_PHYSICS_UNIT / 2 - rampShift;
sides[3] = -1 * LCR_PHYSICS_UNIT / 4;
sides[4] = LCR_PHYSICS_UNIT / 2 - rampShift;
sides[5] = 0;
v = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2);
d = TPE_dist(point,v);
if (d < dBest)
{
vBest = v;
dBest = d;
}
}
_CHECK_NEXT(TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT
,2));
point = vBest;
break;
}
#undef _CHECK_NEXT
case LCR_BLOCK_RAMP:
case LCR_BLOCK_RAMP_34:
case LCR_BLOCK_RAMP_12: