Add block cache
This commit is contained in:
parent
ac5bddd9f4
commit
f248981676
3 changed files with 86 additions and 9 deletions
43
renderer.h
43
renderer.h
|
@ -776,8 +776,6 @@ uint8_t _LCR_buildMapModel(void)
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: also cull the triangles in the loop by some N steps
|
||||
|
||||
_LCR_cullHiddenMapTris();
|
||||
|
||||
LCR_LOG1("map model built");
|
||||
|
@ -806,6 +804,47 @@ void _LCR_rendererComputeLOD(void)
|
|||
}
|
||||
}
|
||||
|
||||
void LCR_rendererMarkTakenCP(int x, int y, int z)
|
||||
{
|
||||
for (int i = 0; i < LCR_renderer.mapModel.triangleCount; ++i)
|
||||
if ((LCR_renderer.mapTriangleData[i] & 0x0f) == LCR_RENDERER_MAT_CP0)
|
||||
{
|
||||
S3L_Unit point[3];
|
||||
|
||||
point[0] = 0;
|
||||
point[1] = 0;
|
||||
point[2] = 0;
|
||||
|
||||
for (int j = 0; j < 2; ++j)
|
||||
for (int k = 0; k < 3; ++k)
|
||||
point[k] += LCR_renderer.mapModel.vertices[
|
||||
3 * LCR_renderer.mapModel.triangles[3 * i + j] + k] +
|
||||
(LCR_MAP_SIZE_BLOCKS / 2) *
|
||||
(k == 1 ? LCR_RENDERER_UNIT / 2 : LCR_RENDERER_UNIT);
|
||||
|
||||
point[0] /= 2;
|
||||
point[1] /= 2;
|
||||
point[2] /= 2;
|
||||
|
||||
if (point[0] / LCR_RENDERER_UNIT == x &&
|
||||
point[1] / (LCR_RENDERER_UNIT / 2) == y &&
|
||||
point[2] / LCR_RENDERER_UNIT == z)
|
||||
LCR_renderer.mapTriangleData[i] = (LCR_renderer.mapTriangleData[i]
|
||||
& 0xf0) | LCR_RENDERER_MAT_CP1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Call to reset currently loaded map, i.e. mark all checkpoints as untaken etc.
|
||||
*/
|
||||
void LCR_rendererRestart(void)
|
||||
{
|
||||
for (int i = 0; i < LCR_renderer.mapModel.triangleCount; ++i)
|
||||
if ((LCR_renderer.mapTriangleData[i] & 0x0f) == LCR_RENDERER_MAT_CP1)
|
||||
LCR_renderer.mapTriangleData[i] = (LCR_renderer.mapTriangleData[i] & 0xf0)
|
||||
| LCR_RENDERER_MAT_CP0;
|
||||
}
|
||||
|
||||
uint8_t LCR_rendererInit(void)
|
||||
{
|
||||
LCR_LOG0("initializing renderer");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue