Move physics debug draw function
This commit is contained in:
parent
2dfad249ad
commit
4d5594a834
2 changed files with 21 additions and 15 deletions
15
game.h
15
game.h
|
@ -257,6 +257,19 @@ void LCR_drawPixelXYUnsafe(unsigned int x, unsigned int y,
|
|||
#endif
|
||||
}
|
||||
|
||||
void _LCR_physicdDebugDrawPixel(uint16_t x, uint16_t y, uint8_t color)
|
||||
{
|
||||
if (x > 1 && x < LCR_EFFECTIVE_RESOLUTION_X - 2 &&
|
||||
y > 1 && y < LCR_EFFECTIVE_RESOLUTION_Y - 2)
|
||||
{
|
||||
uint16_t c = 0x8101 | (0x8f1f << (2 * color));
|
||||
|
||||
for (int j = -1; j <= 2; ++j)
|
||||
for (int i = -1; i <= 2; ++i)
|
||||
LCR_drawPixelXYUnsafe(x + i,y + j,c);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void LCR_drawPixelXYSafe(unsigned int x, unsigned int y,
|
||||
uint_fast16_t color)
|
||||
{
|
||||
|
@ -577,7 +590,7 @@ void LCR_gameDraw3DView(void)
|
|||
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
||||
LCR_GameUnit camTr[7];
|
||||
LCR_rendererGetCameraTransform(camTr,camTr + 3,camTr + 6);
|
||||
LCR_physicsDebugDraw(camTr,camTr + 3,camTr[6]);
|
||||
LCR_physicsDebugDraw(camTr,camTr + 3,camTr[6],_LCR_physicdDebugDrawPixel);
|
||||
#endif
|
||||
|
||||
// GUI/HUD:
|
||||
|
|
21
racing.h
21
racing.h
|
@ -887,19 +887,6 @@ void LCR_racingGetCarBlockCoords(int coords[3])
|
|||
(LCR_GAME_UNIT * LCR_MAP_SIZE_BLOCKS) / 2) / LCR_GAME_UNIT;
|
||||
}
|
||||
|
||||
void _LCR_drawPhysicsDebugPixel(uint16_t x, uint16_t y, uint8_t color)
|
||||
{
|
||||
if (x > 1 && x < LCR_EFFECTIVE_RESOLUTION_X - 2 &&
|
||||
y > 1 && y < LCR_EFFECTIVE_RESOLUTION_Y - 2)
|
||||
{
|
||||
uint16_t c = 0x8101 | (0x8f1f << (2 * color));
|
||||
|
||||
for (int j = -1; j <= 2; ++j)
|
||||
for (int i = -1; i <= 2; ++i)
|
||||
LCR_drawPixelXYUnsafe(x + i,y + j,c); // TODO: should be separated, make this independent of game module
|
||||
}
|
||||
}
|
||||
|
||||
int LCR_racingCarWheelTouchesGround(int wheel)
|
||||
{
|
||||
return ((LCR_racing.wheelCollisions & (LCR_racing.wheelCollisions >> 4))
|
||||
|
@ -1395,7 +1382,8 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
Draws a simple 3D debug overlap of the physics world.
|
||||
*/
|
||||
void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||
LCR_GameUnit camFov)
|
||||
LCR_GameUnit camFov,
|
||||
void (*drawPixel)(uint16_t, uint16_t, uint8_t))
|
||||
{
|
||||
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
||||
LCR_LOG2("drawing physics debug");
|
||||
|
@ -1414,8 +1402,13 @@ void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
|||
cView.y = LCR_EFFECTIVE_RESOLUTION_Y;
|
||||
cView.z = (camFov * TPE_F) / LCR_GAME_UNIT;
|
||||
|
||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),drawPixel,
|
||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
||||
|
||||
/*
|
||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),_LCR_drawPhysicsDebugPixel,
|
||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue