Add more ramps
This commit is contained in:
parent
9f112e5869
commit
c79d21857b
3 changed files with 68 additions and 40 deletions
2
assets.h
2
assets.h
|
@ -44,6 +44,8 @@ LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,2,1,0,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_LEFT,9,0,20,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_LEFT,9,0,20,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,8,1,8,0,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,8,1,8,0,0),
|
||||||
|
|
||||||
|
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_WALL,3,4,4,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_FULL,15,0,0,LCR_BLOCK_MATERIAL_GRASS,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL,15,0,0,LCR_BLOCK_MATERIAL_GRASS,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0),
|
||||||
|
|
41
map.h
41
map.h
|
@ -552,24 +552,33 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LCR_BLOCK_RAMP_CURVED_PLAT:
|
||||||
|
ADD(0,0,6) ADD(0,4,5) ADD(0,4,6) // left
|
||||||
|
ADD(6,0,6) ADD(6,4,6) ADD(6,4,5) // right
|
||||||
|
ADD(0,4,5) ADD(6,4,5) ADD(0,4,6) // top
|
||||||
|
ADD(0,4,6) ADD(6,4,5) ADD(6,4,6)
|
||||||
case LCR_BLOCK_RAMP_CURVED:
|
case LCR_BLOCK_RAMP_CURVED:
|
||||||
ADD(0,0,0) ADD(6,0,0) ADD(0,1,4) // ramp
|
{
|
||||||
ADD(0,1,4) ADD(6,0,0) ADD(6,1,4)
|
uint8_t plusZ = blockType == LCR_BLOCK_RAMP_CURVED;
|
||||||
ADD(0,1,4) ADD(6,1,4) ADD(0,2,5) // ramp
|
|
||||||
ADD(0,2,5) ADD(6,1,4) ADD(6,2,5)
|
ADD(0,0,0) ADD(6,0,0) ADD(0,1,3 + plusZ) // ramp
|
||||||
ADD(0,2,5) ADD(6,2,5) ADD(0,4,6) // ramp
|
ADD(0,1,3 + plusZ) ADD(6,0,0) ADD(6,1,3 + plusZ)
|
||||||
ADD(0,4,6) ADD(6,2,5) ADD(6,4,6)
|
ADD(0,1,3 + plusZ) ADD(6,1,3 + plusZ) ADD(0,2,4 + plusZ) // ramp
|
||||||
ADD(0,0,0) ADD(0,1,4) ADD(0,0,6) // left
|
ADD(0,2,4 + plusZ) ADD(6,1,3 + plusZ) ADD(6,2,4 + plusZ)
|
||||||
ADD(0,0,6) ADD(0,1,4) ADD(0,2,5)
|
ADD(0,2,4 + plusZ) ADD(6,2,4 + plusZ) ADD(0,4,5 + plusZ) // ramp
|
||||||
ADD(0,0,6) ADD(0,2,5) ADD(0,4,6)
|
ADD(0,4,5 + plusZ) ADD(6,2,4 + plusZ) ADD(6,4,5 + plusZ)
|
||||||
ADD(6,0,0) ADD(6,0,6) ADD(6,1,4) // right
|
ADD(0,0,0) ADD(0,1,3 + plusZ) ADD(0,0,6) // left
|
||||||
ADD(6,0,6) ADD(6,2,5) ADD(6,1,4)
|
ADD(0,0,6) ADD(0,1,3 + plusZ) ADD(0,2,4 + plusZ)
|
||||||
ADD(6,0,6) ADD(6,4,6) ADD(6,2,5)
|
ADD(0,0,6) ADD(0,2,4 + plusZ) ADD(0,4,5 + plusZ)
|
||||||
ADD(0,0,6) ADD(0,4,6) ADD(6,0,6) // back
|
ADD(6,0,0) ADD(6,0,6) ADD(6,1,3 + plusZ) // right
|
||||||
ADD(6,0,6) ADD(0,4,6) ADD(6,4,6)
|
ADD(6,0,6) ADD(6,2,4 + plusZ) ADD(6,1,3 + plusZ)
|
||||||
ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom
|
ADD(6,0,6) ADD(6,4,5 + plusZ) ADD(6,2,4 + plusZ)
|
||||||
ADD(0,0,0) ADD(0,0,6) ADD(6,0,6)
|
ADD(0,0,6) ADD(0,4,6) ADD(6,0,6) // back
|
||||||
|
ADD(6,0,6) ADD(0,4,6) ADD(6,4,6)
|
||||||
|
ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom
|
||||||
|
ADD(0,0,0) ADD(0,0,6) ADD(6,0,6)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LCR_BLOCK_RAMP_CURVED_WALL:
|
case LCR_BLOCK_RAMP_CURVED_WALL:
|
||||||
ADD(0,0,0) ADD(5,0,0) ADD(0,1,3) // ramp
|
ADD(0,0,0) ADD(5,0,0) ADD(0,1,3) // ramp
|
||||||
|
|
65
racing.h
65
racing.h
|
@ -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 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
|
||||||
{
|
{
|
||||||
|
TPE_Vec3 v, vBest;
|
||||||
|
TPE_Unit d, dBest = TPE_INFINITY;
|
||||||
|
|
||||||
uint8_t bx, by, bz;
|
uint8_t bx, by, bz;
|
||||||
LCR_mapBlockGetCoords(block,&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;
|
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:
|
case LCR_BLOCK_RAMP_CURVED:
|
||||||
{
|
{
|
||||||
TPE_Vec3 v, vBest;
|
TPE_Unit sides[6];
|
||||||
TPE_Unit sides[6], d, dBest;
|
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[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[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;
|
sides[5] = LCR_PHYSICS_UNIT / 4;
|
||||||
|
|
||||||
vBest = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2);
|
_CHECK_NEXT(TPE_envAATriPrism(point,
|
||||||
dBest = TPE_dist(point,vBest);
|
TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2))
|
||||||
|
|
||||||
if (dBest != 0)
|
sides[0] = -1 * LCR_PHYSICS_UNIT / 2;
|
||||||
{
|
sides[1] = -1 * LCR_PHYSICS_UNIT / 4;
|
||||||
sides[0] = -1 * LCR_PHYSICS_UNIT / 4;
|
sides[2] = LCR_PHYSICS_UNIT / 2 - rampShift;
|
||||||
sides[1] = -1 * LCR_PHYSICS_UNIT / 4;
|
sides[3] = -1 * LCR_PHYSICS_UNIT / 4;
|
||||||
sides[2] = LCR_PHYSICS_UNIT / 2;
|
sides[4] = LCR_PHYSICS_UNIT / 2 - rampShift;
|
||||||
sides[3] = -1 * LCR_PHYSICS_UNIT / 4;
|
sides[5] = 0;
|
||||||
sides[4] = LCR_PHYSICS_UNIT / 2;
|
|
||||||
sides[5] = 0;
|
|
||||||
|
|
||||||
v = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2);
|
_CHECK_NEXT(TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT
|
||||||
d = TPE_dist(point,v);
|
,2));
|
||||||
|
|
||||||
if (d < dBest)
|
|
||||||
{
|
|
||||||
vBest = v;
|
|
||||||
dBest = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
point = vBest;
|
point = vBest;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef _CHECK_NEXT
|
||||||
|
|
||||||
case LCR_BLOCK_RAMP:
|
case LCR_BLOCK_RAMP:
|
||||||
case LCR_BLOCK_RAMP_34:
|
case LCR_BLOCK_RAMP_34:
|
||||||
case LCR_BLOCK_RAMP_12:
|
case LCR_BLOCK_RAMP_12:
|
||||||
|
|
Loading…
Reference in a new issue