Clean a bit and stuff
This commit is contained in:
parent
e42212d7c1
commit
b79b83e56a
6 changed files with 99 additions and 88 deletions
73
renderer.h
73
renderer.h
|
@ -206,10 +206,9 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
|
||||
if (pixel->modelIndex < 8)
|
||||
{
|
||||
uint8_t tData =
|
||||
(LCR_renderer.mapTriangleData +
|
||||
LCR_renderer.chunkStarts[LCR_renderer.loadedChunks[
|
||||
pixel->modelIndex]])[pixel->triangleIndex];
|
||||
uint8_t tData = (LCR_renderer.mapTriangleData +
|
||||
LCR_renderer.chunkStarts[LCR_renderer.loadedChunks[
|
||||
pixel->modelIndex]])[pixel->triangleIndex];
|
||||
|
||||
switch (tData & 0x0f)
|
||||
{
|
||||
|
@ -218,19 +217,31 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
case 5: LCR_renderer.flatAndTransparent |= 0x0010; break; // ice
|
||||
case 6: LCR_renderer.flatAndTransparent |= 0x8080; break; // acc
|
||||
case 7: LCR_renderer.flatAndTransparent &= ~(0x4208); break; // fan
|
||||
|
||||
case LCR_RENDERER_MAT_CP0:
|
||||
LCR_renderer.flatAndTransparent = LCR_SETTING_CHECKPOINT_0_COLOR;
|
||||
break;
|
||||
|
||||
case LCR_RENDERER_MAT_CP1:
|
||||
LCR_renderer.flatAndTransparent = LCR_SETTING_CHECKPOINT_1_COLOR;
|
||||
break;
|
||||
|
||||
case LCR_RENDERER_MAT_FIN:
|
||||
LCR_renderer.flatAndTransparent = LCR_SETTING_FINISH_COLOR;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
tData &= 0x30;
|
||||
tData &= 0x30; // isolate type
|
||||
|
||||
LCR_renderer.flatAndTransparent |=
|
||||
(((uint16_t) (tData)) >> 4) |
|
||||
(((uint16_t) (tData)) << 2) |
|
||||
(((uint16_t) (tData)) << 7);
|
||||
LCR_renderer.flatAndTransparent |= (((uint16_t) (tData)) >> 4) |
|
||||
(((uint16_t) (tData)) << 2) | (((uint16_t) (tData)) << 7);
|
||||
}
|
||||
else
|
||||
LCR_renderer.flatAndTransparent >>= 1; // car, darken
|
||||
|
||||
// alter each triangle's color slightly:
|
||||
LCR_renderer.flatAndTransparent += pixel->triangleIndex % 4;
|
||||
}
|
||||
|
||||
|
@ -258,28 +269,21 @@ void _LCR_pixelFunc3D(S3L_PixelInfo *pixel)
|
|||
LCR_loadImage(LCR_IMAGE_CAR);
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
LCR_renderer.triUVs[i] =
|
||||
(LCR_carUvs[2 * LCR_carTriangleUvs[
|
||||
3 * pixel->triangleIndex + i / 2] + i % 2] * (LCR_IMAGE_SIZE + 1))
|
||||
/ 512;
|
||||
}
|
||||
LCR_renderer.triUVs[i] = (LCR_carUvs[2 * LCR_carTriangleUvs[3 *
|
||||
pixel->triangleIndex + i / 2] + i % 2] * (LCR_IMAGE_SIZE + 1)) / 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
// map model
|
||||
const S3L_Index *t =
|
||||
LCR_renderer.models[pixel->modelIndex].triangles +
|
||||
3 * pixel->triangleIndex;
|
||||
S3L_Unit *v[3];
|
||||
const S3L_Index *t = LCR_renderer.models[pixel->modelIndex].triangles +
|
||||
3 * pixel->triangleIndex;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
v[i] = LCR_renderer.mapVerts + 3 * t[i];
|
||||
|
||||
const uint8_t *triData =
|
||||
LCR_renderer.mapTriangleData +
|
||||
LCR_renderer.chunkStarts[LCR_renderer.loadedChunks[
|
||||
pixel->modelIndex]];
|
||||
const uint8_t *triData = LCR_renderer.mapTriangleData +
|
||||
LCR_renderer.chunkStarts[LCR_renderer.loadedChunks[pixel->modelIndex]];
|
||||
|
||||
uint8_t type = triData[pixel->triangleIndex] >> 4;
|
||||
uint8_t mat = triData[pixel->triangleIndex] & 0x0f;
|
||||
|
@ -426,8 +430,7 @@ S3L_Index _LCR_rendererAddMapVert(S3L_Unit x, S3L_Unit y, S3L_Unit z)
|
|||
return LCR_renderer.mapModel.vertexCount - 1;
|
||||
}
|
||||
|
||||
LCR_LOG0("couldn't add map vertex!");
|
||||
|
||||
LCR_LOG0("couldn't add map vertex");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -442,8 +445,7 @@ void _LCR_rendererAddMapTri(S3L_Index a, S3L_Index b, S3L_Index c, uint8_t mat)
|
|||
*t = b; t++;
|
||||
*t = c;
|
||||
|
||||
LCR_renderer.mapTriangleData[LCR_renderer.mapModel.triangleCount] =
|
||||
mat;
|
||||
LCR_renderer.mapTriangleData[LCR_renderer.mapModel.triangleCount] = mat;
|
||||
|
||||
LCR_renderer.mapModel.triangleCount++;
|
||||
}
|
||||
|
@ -543,8 +545,7 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1,
|
|||
{
|
||||
if (S3L_abs(vertices[0][0] - vertices[3][0]) +
|
||||
S3L_abs(vertices[0][1] - vertices[3][1]) +
|
||||
S3L_abs(vertices[0][2] - vertices[3][2]) >
|
||||
2 * LCR_RENDERER_UNIT)
|
||||
S3L_abs(vertices[0][2] - vertices[3][2]) > 2 * LCR_RENDERER_UNIT)
|
||||
return 0; // quick manhattan distance bailout condition
|
||||
|
||||
for (int j = 0; j < 2; ++j)
|
||||
|
@ -1008,7 +1009,6 @@ uint8_t LCR_rendererInit(void)
|
|||
LCR_LOG0("initializing renderer");
|
||||
|
||||
LCR_renderer.frame = 0;
|
||||
|
||||
LCR_renderer.carModel = LCR_renderer.models + 8;
|
||||
LCR_renderer.ghostModel = LCR_renderer.models + 9;
|
||||
|
||||
|
@ -1123,17 +1123,18 @@ void LCR_rendererMoveCamera(LCR_GameUnit forwRightUpOffset[3],
|
|||
LCR_renderer.scene.camera.transform.rotation.x +=
|
||||
(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) \
|
||||
LCR_renderer.scene.camera.transform.translation.c = l;
|
||||
|
||||
chk(<,x,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
chk(>,x,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
chk(<,y,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4)
|
||||
chk(>,y,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4)
|
||||
chk(<,z,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
chk(>,z,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
CHK(<,x,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
CHK(>,x,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
CHK(<,y,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4)
|
||||
CHK(>,y,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 4)
|
||||
CHK(<,z,-1 * LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
CHK(>,z,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||
|
||||
#undef CHK
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue