Fix chunk bug

This commit is contained in:
Miloslav Ciz 2025-03-25 16:57:59 +01:00
parent cacd5f84a9
commit ca0fc67738
4 changed files with 30 additions and 26 deletions

View file

@ -14,8 +14,6 @@
out for bugs due to false positives) out for bugs due to false positives)
- improve the car unstucking? maybe we can just keep the position of the car - improve the car unstucking? maybe we can just keep the position of the car
and ONE wheel (other joint positions can be computed) and ONE wheel (other joint positions can be computed)
- some kind of special map block that would say where 3D triangles don't have
to be drawn? could optimize rendering and map loading a lot
- maps to make: - maps to make:
- there should be these maps: - there should be these maps:
- compiled in: - compiled in:
@ -44,7 +42,6 @@
- something with multiple finishes - something with multiple finishes
- U-ramp to build speed and jump up to catch a CP (done) - U-ramp to build speed and jump up to catch a CP (done)
- jump through air ring with CP - jump through air ring with CP
- try to speed up the slow culling
- test: - test:
- long replay - long replay
- replay stretching works - replay stretching works
@ -61,6 +58,8 @@
=========== BUGS ================= =========== BUGS =================
- sometimes during long loading the screen goes black, seems to have appeared
after adding LCR_LOADING_COMMAND
- immediately after starting the map countdown seems to be lower - immediately after starting the map countdown seems to be lower
- the pinch collision test seems to sometimes stop the car e.g. after falling - the pinch collision test seems to sometimes stop the car e.g. after falling
from bigger height or when running into ramp at high speed (or not?) - FIX from bigger height or when running into ramp at high speed (or not?) - FIX
@ -80,6 +79,8 @@
those nasty piercing bugs those nasty piercing bugs
- replays are bugged, seem to not steer - replays are bugged, seem to not steer
- make the U-ramp map taller due to new physics - make the U-ramp map taller due to new physics
- some kind of special map block that would say where 3D triangles don't have
to be drawn? could optimize rendering and map loading a lot <-- PROLLY NOT
- on 1st map the camera is obscured by the wall at the start, fix it somehow - on 1st map the camera is obscured by the wall at the start, fix it somehow
(not the best first impression) <-- shifted start pos. (not the best first impression) <-- shifted start pos.
- replay format should probably record game version - replay format should probably record game version

6
data
View file

@ -1,4 +1,2 @@
#RLCtiny1;00LCtiny1;7e39e006 0000336:0011:0143:0051:0079:0081:0073:0051:00e3:0021:00b9:0031:0139:00a1:00a9:0051:00e3:0041:0093:0031:00d3:0051:0013:0031:0053:0017:0016:0017:0016:0012:0163:0101:0023:0021:0083:0031:0215:0031:01d3:0041:0099:0031:00b9 "#MAAA;4321 0 "
#BLCtiny1; ":*&31 :^&11"
#RLCtiny5;00LCtiny5;5c14d8b6 0000298:0011:00f3:0071:0049:00b1:0013:0081:0019:0101:0013:00f1:00b9:0051:0063:0041:0069:0041:0033:00c1:0043:0111:0099:0081:0023:0091:00e3:0091:0063:0071:00b3:0051:00f5:0041:00e9:0051:0023:0071:0059:0051:0073
#BLCtiny5;

View file

@ -5,7 +5,7 @@
#define DATA_FILE_NAME "data" #define DATA_FILE_NAME "data"
#define LCR_LOADING_COMMAND SDL_PumpEvents(); SDL_RenderPresent(renderer); #define LCR_LOADING_COMMAND SDL_PumpEvents();
SDL_Window *window; SDL_Window *window;
SDL_Renderer *renderer; SDL_Renderer *renderer;

View file

@ -838,24 +838,30 @@ void _LCR_makeMapChunks(void)
LCR_renderer.chunkStarts[chunkNo] = start; LCR_renderer.chunkStarts[chunkNo] = start;
chunkCorner[0] = (chunkNo & 0x03) * LCR_RENDERER_CHUNK_SIZE_HORIZONTAL; chunkCorner[0] =
chunkCorner[1] = ((chunkNo >> 2) & 0x03) * (LCR_RENDERER_CHUNK_SIZE_HORIZONTAL / 2); (chunkNo & 0x03) * LCR_RENDERER_CHUNK_SIZE_HORIZONTAL;
chunkCorner[2] = ((chunkNo >> 4) & 0x03) * LCR_RENDERER_CHUNK_SIZE_HORIZONTAL; chunkCorner[1] =
((chunkNo >> 2) & 0x03) * (LCR_RENDERER_CHUNK_SIZE_HORIZONTAL / 2);
chunkCorner[2] =
((chunkNo >> 4) & 0x03) * LCR_RENDERER_CHUNK_SIZE_HORIZONTAL;
chunkCorner[0] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2; chunkCorner[0] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2;
chunkCorner[1] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4; chunkCorner[1] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4;
chunkCorner[2] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2; chunkCorner[2] -= LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2;
for (int i = start; i < LCR_renderer.mapModel.triangleCount; ++i) for (int i = start; i < LCR_renderer.mapModel.triangleCount; ++i)
{ {
const S3L_Unit *v = LCR_renderer.mapVerts + 3 * tri[0]; const S3L_Unit *v = LCR_renderer.mapVerts + 3 * tri[0];
if (v[0] >= chunkCorner[0] && if (v[0] >= chunkCorner[0] &&
v[0] < chunkCorner[0] + LCR_RENDERER_CHUNK_SIZE_HORIZONTAL && v[0] < chunkCorner[0] + LCR_RENDERER_CHUNK_SIZE_HORIZONTAL +
((chunkNo & 0x03) == 0x03) && // includes last edge
v[1] >= chunkCorner[1] && v[1] >= chunkCorner[1] &&
v[1] < chunkCorner[1] + (LCR_RENDERER_CHUNK_SIZE_HORIZONTAL / 2) && v[1] < chunkCorner[1] + (LCR_RENDERER_CHUNK_SIZE_HORIZONTAL / 2) +
(((chunkNo >> 2) & 0x03) == 0x03) &&
v[2] >= chunkCorner[2] && v[2] >= chunkCorner[2] &&
v[2] < chunkCorner[2] + LCR_RENDERER_CHUNK_SIZE_HORIZONTAL) v[2] < chunkCorner[2] + LCR_RENDERER_CHUNK_SIZE_HORIZONTAL +
(((chunkNo >> 4) & 0x03) == 0x03))
{ {
_LCR_rendererSwapMapTris(i,start); _LCR_rendererSwapMapTris(i,start);
start++; start++;
@ -898,7 +904,7 @@ uint8_t _LCR_buildMapModel(void)
const uint8_t *block = LCR_currentMap.blocks + j * LCR_BLOCK_SIZE; const uint8_t *block = LCR_currentMap.blocks + j * LCR_BLOCK_SIZE;
uint8_t uint8_t
blockType = block[0], blockType = block[0],
edgeBits, // bottom, top, left, right, front, bottom edgeBits, // touching bounds? bottom, top, left, right, front, back
bx, by, bz, // block coords bx, by, bz, // block coords
vx, vy, vz, // vertex coords vx, vy, vz, // vertex coords
vi = 0; // vertex index (0, 1 or 2) vi = 0; // vertex index (0, 1 or 2)
@ -918,16 +924,15 @@ uint8_t _LCR_buildMapModel(void)
for (int i = 0; i < blockShapeByteCount; ++i) for (int i = 0; i < blockShapeByteCount; ++i)
{ {
if (vi == 0) if (vi == 0)
edgeBits = (by == 0) | edgeBits =
((by == LCR_MAP_SIZE_BLOCKS - 1) << 1) | (by == 0) | ((by == LCR_MAP_SIZE_BLOCKS - 1) << 1) |
((bx == 0) << 2) | ((bx == 0) << 2) | ((bx == LCR_MAP_SIZE_BLOCKS - 1) << 3) |
((bx == LCR_MAP_SIZE_BLOCKS - 1) << 3) | ((bz == 0) << 4) | ((bz == LCR_MAP_SIZE_BLOCKS - 1) << 5);
((bz == 0) << 4) |
((bz == LCR_MAP_SIZE_BLOCKS - 1) << 5);
LCR_decodeMapBlockCoords(blockShapeBytes[i],&vx,&vy,&vz); LCR_decodeMapBlockCoords(blockShapeBytes[i],&vx,&vy,&vz);
edgeBits &= (vy == 0) | ((vy == LCR_BLOCK_SHAPE_COORD_MAX) << 1) | edgeBits &=
(vy == 0) | ((vy == LCR_BLOCK_SHAPE_COORD_MAX) << 1) |
((vx == 0) << 2) | ((vx == LCR_BLOCK_SHAPE_COORD_MAX) << 3) | ((vx == 0) << 2) | ((vx == LCR_BLOCK_SHAPE_COORD_MAX) << 3) |
((vz == 0) << 4) | ((vz == LCR_BLOCK_SHAPE_COORD_MAX) << 5); ((vz == 0) << 4) | ((vz == LCR_BLOCK_SHAPE_COORD_MAX) << 5);
@ -941,9 +946,9 @@ uint8_t _LCR_buildMapModel(void)
if (vi < 2) if (vi < 2)
vi++; vi++;
else else // 3 indices => create and add triangle
{ {
// don't add triangles completely at the floor or ceiling of the map // don't add triangles completely at the boundary of the map
if (!edgeBits) if (!edgeBits)
{ {
uint8_t triData; uint8_t triData;
@ -1246,7 +1251,7 @@ void LCR_rendererMoveCamera(LCR_GameUnit forwRightUpOffset[3],
LCR_renderer.scene.camera.transform.rotation.x += LCR_renderer.scene.camera.transform.rotation.x +=
(yawPitchOffset[1] * S3L_F) / LCR_GAME_UNIT; (yawPitchOffset[1] * S3L_F) / LCR_GAME_UNIT;
#define CHK(o,c,l) \ #define CHK(o,c,l) \
if (LCR_renderer.scene.camera.transform.translation.c o l) \ if (LCR_renderer.scene.camera.transform.translation.c o l) \
LCR_renderer.scene.camera.transform.translation.c = l; LCR_renderer.scene.camera.transform.translation.c = l;