Continue block collisions
This commit is contained in:
parent
f1bbb1e1b6
commit
011cd891c1
5 changed files with 99 additions and 12 deletions
12
assets.h
12
assets.h
|
@ -26,11 +26,15 @@ static const uint8_t map1[] =
|
||||||
10,
|
10,
|
||||||
0,
|
0,
|
||||||
|
|
||||||
|
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_RAMP,36,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_RAMP,36,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_34,20,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_RAMP,35,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_12,32,0,37,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_RAMP,34,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_14,32,0,20,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_RAMP,33,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
|
||||||
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,0,33,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,0,34,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,0,35,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,0,36,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LCR_MAP_BLOCK(LCR_BLOCK_FULL_ACCEL,0,0,0,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
LCR_MAP_BLOCK(LCR_BLOCK_FULL_ACCEL,0,0,0,LCR_BLOCK_MATERIAL_CONCRETE,0),
|
||||||
|
|
1
map.h
1
map.h
|
@ -84,7 +84,6 @@
|
||||||
#define LCR_BLOCK_RAMP_CURVED_SHORT 0x0a
|
#define LCR_BLOCK_RAMP_CURVED_SHORT 0x0a
|
||||||
#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b
|
#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b
|
||||||
|
|
||||||
|
|
||||||
#define LCR_BLOCK_FULL_ACCEL 0x20
|
#define LCR_BLOCK_FULL_ACCEL 0x20
|
||||||
#define LCR_BLOCK_FULL_FAN 0x30
|
#define LCR_BLOCK_FULL_FAN 0x30
|
||||||
|
|
||||||
|
|
74
racing.h
74
racing.h
|
@ -70,8 +70,80 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
|
||||||
(((int) bz) - LCR_MAP_SIZE_BLOCKS / 2) * LCR_PHYSICS_UNIT
|
(((int) bz) - LCR_MAP_SIZE_BLOCKS / 2) * LCR_PHYSICS_UNIT
|
||||||
+ LCR_PHYSICS_UNIT / 2);
|
+ LCR_PHYSICS_UNIT / 2);
|
||||||
|
|
||||||
|
point = TPE_vec3Minus(point,center); // shift to origin
|
||||||
|
|
||||||
|
// TODO: transform
|
||||||
|
|
||||||
|
switch (block[0])
|
||||||
|
{
|
||||||
|
case LCR_BLOCK_FULL:
|
||||||
|
case LCR_BLOCK_BOTTOM:
|
||||||
|
case LCR_BLOCK_LEFT:
|
||||||
|
case LCR_BLOCK_BOTTOM_LEFT:
|
||||||
|
case LCR_BLOCK_BOTTOM_LEFT_FRONT:
|
||||||
|
case LCR_BLOCK_FULL_ACCEL:
|
||||||
|
case LCR_BLOCK_FULL_FAN:
|
||||||
|
{
|
||||||
|
TPE_Vec3
|
||||||
|
offset = TPE_vec3(0,0,0),
|
||||||
|
size = TPE_vec3(LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4,
|
||||||
|
LCR_PHYSICS_UNIT / 2);
|
||||||
|
|
||||||
|
if (block[0] == LCR_BLOCK_BOTTOM ||
|
||||||
|
block[0] == LCR_BLOCK_BOTTOM_LEFT ||
|
||||||
|
block[0] == LCR_BLOCK_BOTTOM_LEFT_FRONT)
|
||||||
|
{
|
||||||
|
offset.y -= LCR_PHYSICS_UNIT / 8;
|
||||||
|
size.y = LCR_PHYSICS_UNIT / 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block[0] == LCR_BLOCK_LEFT ||
|
||||||
|
block[0] == LCR_BLOCK_BOTTOM_LEFT ||
|
||||||
|
block[0] == LCR_BLOCK_BOTTOM_LEFT_FRONT)
|
||||||
|
{
|
||||||
|
offset.x -= LCR_PHYSICS_UNIT / 4;
|
||||||
|
size.x = LCR_PHYSICS_UNIT / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block[0] == LCR_BLOCK_BOTTOM_LEFT_FRONT)
|
||||||
|
{
|
||||||
|
offset.z -= LCR_PHYSICS_UNIT / 4;
|
||||||
|
size.z = LCR_PHYSICS_UNIT / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
point = TPE_envAABox(point,offset,size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LCR_BLOCK_RAMP:
|
||||||
|
case LCR_BLOCK_RAMP_34:
|
||||||
|
case LCR_BLOCK_RAMP_12:
|
||||||
|
case LCR_BLOCK_RAMP_14:
|
||||||
|
{
|
||||||
|
TPE_Unit sides[6];
|
||||||
|
sides[0] = -1 * LCR_PHYSICS_UNIT / 2; sides[1] = -1 * LCR_PHYSICS_UNIT / 2;
|
||||||
|
sides[2] = LCR_PHYSICS_UNIT / 2; sides[3] = -1 * LCR_PHYSICS_UNIT / 2;
|
||||||
|
sides[4] = LCR_PHYSICS_UNIT / 2; sides[5] = LCR_PHYSICS_UNIT / 2;
|
||||||
|
|
||||||
|
point = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
point = TPE_vec3(0,0,LCR_MAP_SIZE_BLOCKS * LCR_PHYSICS_UNIT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: untransform
|
||||||
|
|
||||||
|
point = TPE_vec3Plus(point,center); // shift back
|
||||||
|
|
||||||
|
return point;
|
||||||
|
|
||||||
|
/*
|
||||||
return TPE_envAABox(point,center,TPE_vec3(LCR_PHYSICS_UNIT / 2,
|
return TPE_envAABox(point,center,TPE_vec3(LCR_PHYSICS_UNIT / 2,
|
||||||
LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT / 2));
|
LCR_PHYSICS_UNIT / 4,LCR_PHYSICS_UNIT / 2));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
TPE_Vec3 _LCR_racingEnvironmentFunction(TPE_Vec3 point, TPE_Unit maxDist)
|
TPE_Vec3 _LCR_racingEnvironmentFunction(TPE_Vec3 point, TPE_Unit maxDist)
|
||||||
|
@ -504,7 +576,7 @@ void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||||
cView.z = (camFov * TPE_F) / LCR_GAME_UNIT;
|
cView.z = (camFov * TPE_F) / LCR_GAME_UNIT;
|
||||||
|
|
||||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),_LCR_drawPhysicsDebugPixel,
|
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),_LCR_drawPhysicsDebugPixel,
|
||||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4);
|
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
10
renderer.h
10
renderer.h
|
@ -615,6 +615,16 @@ uint8_t _LCR_buildMapModel(void)
|
||||||
S3L_model3DInit(LCR_renderer.mapVerts,0,LCR_renderer.mapTris,0,
|
S3L_model3DInit(LCR_renderer.mapVerts,0,LCR_renderer.mapTris,0,
|
||||||
&LCR_renderer.mapModel);
|
&LCR_renderer.mapModel);
|
||||||
|
|
||||||
|
// TEMPORARY FIX: this scales the map so that it better aligns with the
|
||||||
|
// physics world -- dunno why it's not aligned by default, investigate (if it's
|
||||||
|
// numerical errors then at least make this a const)
|
||||||
|
LCR_renderer.mapModel.transform.scale.x =
|
||||||
|
(S3L_F * 1009) / 1000;
|
||||||
|
LCR_renderer.mapModel.transform.scale.y =
|
||||||
|
LCR_renderer.mapModel.transform.scale.x;
|
||||||
|
LCR_renderer.mapModel.transform.scale.z =
|
||||||
|
LCR_renderer.mapModel.transform.scale.x;
|
||||||
|
|
||||||
for (int j = 0; j < LCR_currentMap.blockCount; ++j)
|
for (int j = 0; j < LCR_currentMap.blockCount; ++j)
|
||||||
{
|
{
|
||||||
if ((j + 1) % LCR_SETTING_TRIANGLE_CULLING_PERIOD == 0)
|
if ((j + 1) % LCR_SETTING_TRIANGLE_CULLING_PERIOD == 0)
|
||||||
|
|
|
@ -539,7 +539,7 @@ TPE_Vec3 TPE_bodyGetCenterOfMass(const TPE_Body *body);
|
||||||
e.g. 16). */
|
e.g. 16). */
|
||||||
void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
||||||
TPE_Vec3 camPos, TPE_Vec3 camRot, TPE_Vec3 camView, uint16_t envGridRes,
|
TPE_Vec3 camPos, TPE_Vec3 camRot, TPE_Vec3 camView, uint16_t envGridRes,
|
||||||
TPE_Unit envGridSize);
|
TPE_Unit envGridSize, TPE_Unit offset);
|
||||||
|
|
||||||
#define TPE_DEBUG_COLOR_CONNECTION 0
|
#define TPE_DEBUG_COLOR_CONNECTION 0
|
||||||
#define TPE_DEBUG_COLOR_JOINT 1
|
#define TPE_DEBUG_COLOR_JOINT 1
|
||||||
|
@ -592,7 +592,7 @@ TPE_Vec3 TPE_envLineSegment(TPE_Vec3 point, TPE_Vec3 a, TPE_Vec3 b);
|
||||||
TPE_Vec3 TPE_envHeightmap(TPE_Vec3 point, TPE_Vec3 center, TPE_Unit gridSize,
|
TPE_Vec3 TPE_envHeightmap(TPE_Vec3 point, TPE_Vec3 center, TPE_Unit gridSize,
|
||||||
TPE_Unit (*heightFunction)(int32_t x, int32_t y), TPE_Unit maxDist);
|
TPE_Unit (*heightFunction)(int32_t x, int32_t y), TPE_Unit maxDist);
|
||||||
|
|
||||||
/** Environment function for triagnular prism, e.g. for ramps. The sides array
|
/** Environment function for triangular prism, e.g. for ramps. The sides array
|
||||||
contains three 2D coordinates of points of the triangle in given plane with
|
contains three 2D coordinates of points of the triangle in given plane with
|
||||||
respect to the center. WARNING: the points must be specified in counter
|
respect to the center. WARNING: the points must be specified in counter
|
||||||
clowckwise direction! The direction var specified axis direction (0, 1 or
|
clowckwise direction! The direction var specified axis direction (0, 1 or
|
||||||
|
@ -2079,7 +2079,7 @@ void _TPE_drawDebugPixel(
|
||||||
|
|
||||||
void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
||||||
TPE_Vec3 camPos, TPE_Vec3 camRot, TPE_Vec3 camView, uint16_t envGridRes,
|
TPE_Vec3 camPos, TPE_Vec3 camRot, TPE_Vec3 camView, uint16_t envGridRes,
|
||||||
TPE_Unit envGridSize)
|
TPE_Unit envGridSize, TPE_Unit offset)
|
||||||
{
|
{
|
||||||
#define Z_LIMIT 250
|
#define Z_LIMIT 250
|
||||||
if (world->environmentFunction != 0)
|
if (world->environmentFunction != 0)
|
||||||
|
@ -2092,6 +2092,8 @@ void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
||||||
|
|
||||||
TPE_Vec3 center;
|
TPE_Vec3 center;
|
||||||
|
|
||||||
|
offset %= envGridSize;
|
||||||
|
|
||||||
if (envGridRes != 0)
|
if (envGridRes != 0)
|
||||||
{
|
{
|
||||||
center = TPE_vec3(0,TPE_sin(camRot.x),TPE_cos(camRot.x));
|
center = TPE_vec3(0,TPE_sin(camRot.x),TPE_cos(camRot.x));
|
||||||
|
@ -2101,9 +2103,9 @@ void TPE_worldDebugDraw(TPE_World *world, TPE_DebugDrawFunction drawFunc,
|
||||||
center = TPE_vec3Times(center,gridHalfSize);
|
center = TPE_vec3Times(center,gridHalfSize);
|
||||||
center = TPE_vec3Plus(camPos,center);
|
center = TPE_vec3Plus(camPos,center);
|
||||||
|
|
||||||
center.x = (center.x / envGridSize) * envGridSize;
|
center.x = (center.x / envGridSize) * envGridSize + offset;
|
||||||
center.y = (center.y / envGridSize) * envGridSize;
|
center.y = (center.y / envGridSize) * envGridSize + offset;
|
||||||
center.z = (center.z / envGridSize) * envGridSize;
|
center.z = (center.z / envGridSize) * envGridSize + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
testPoint.y = center.y - gridHalfSize;
|
testPoint.y = center.y - gridHalfSize;
|
||||||
|
|
Loading…
Reference in a new issue