Fix another culling bug
This commit is contained in:
parent
dfd1393dba
commit
2c2f1a4c9f
8 changed files with 130 additions and 15 deletions
1
TODO.txt
1
TODO.txt
|
@ -1,5 +1,6 @@
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
|
- try to speed up the slow culling
|
||||||
- make a small txt game menual
|
- make a small txt game menual
|
||||||
- test:
|
- test:
|
||||||
- long replay
|
- long replay
|
||||||
|
|
96
data
96
data
|
@ -2,3 +2,99 @@
|
||||||
#Bnomap
|
#Bnomap
|
||||||
#Rrep2;testmap;482f70f9 00000843:0173:0081:0029:0111:0039:0071:00a3:0061:0169:0051:00b3:0041:0073:0081:0033:0041:0033:0231:0030:0098:0029:0011:0163:00f1:0053:0081:0033:0051:0023:0031:00f0:0032:0023:0131:00b9:0081:0023:00a1:0119:00e1:00c9:0071:0039:00a1:00d3:0021:01f9:0091:0079:0091:0039:0051:0049:0021:0083:0031:0083:0031:0083:0061:0089:0121:00a0:0058:002c:0048:0061:0013:0150:0052:00c0:00a1:0053:0041:0043:0031:0020:0092:0063:0181:0010:00a2:0013:0071:00e0:0028:00e9:0078:00a9:0043:0032:0123:0042:0080:0038:004c:01a8:0050:0032:0033:0101
|
#Rrep2;testmap;482f70f9 00000843:0173:0081:0029:0111:0039:0071:00a3:0061:0169:0051:00b3:0041:0073:0081:0033:0041:0033:0231:0030:0098:0029:0011:0163:00f1:0053:0081:0033:0051:0023:0031:00f0:0032:0023:0131:00b9:0081:0023:00a1:0119:00e1:00c9:0071:0039:00a1:00d3:0021:01f9:0091:0079:0091:0039:0051:0049:0021:0083:0031:0083:0031:0083:0061:0089:0121:00a0:0058:002c:0048:0061:0013:0150:0052:00c0:00a1:0053:0041:0043:0031:0020:0092:0063:0181:0010:00a2:0013:0071:00e0:0028:00e9:0078:00a9:0043:0032:0123:0042:0080:0038:004c:01a8:0050:0032:0033:0101
|
||||||
#Btestmap;
|
#Btestmap;
|
||||||
|
|
||||||
|
#Mmap2;4321 0
|
||||||
|
:*B3mL
|
||||||
|
|
||||||
|
:!x6G
|
||||||
|
:+L2H
|
||||||
|
:+D38
|
||||||
|
|
||||||
|
:=z09 :f83D
|
||||||
|
:'B2j :f511
|
||||||
|
:'B2pI :f511
|
||||||
|
:=H0k :fa1s
|
||||||
|
:=H0D :fa29
|
||||||
|
:-A29 :f61C
|
||||||
|
:=C0j :f347
|
||||||
|
|
||||||
|
:=H0q2 :f42c
|
||||||
|
|
||||||
|
:xB2k :f625
|
||||||
|
:-w29 :f41e
|
||||||
|
:xH0r :f35b
|
||||||
|
:=G0C :f561
|
||||||
|
:^G5CJ :^K5CL
|
||||||
|
|
||||||
|
:=H0o1 :f412
|
||||||
|
|
||||||
|
:;R0q :f16l
|
||||||
|
:;E0ML :fc61
|
||||||
|
|
||||||
|
:=v09 :fc2g
|
||||||
|
|
||||||
|
:;R0l :f125
|
||||||
|
:;L0jJ :f521
|
||||||
|
|
||||||
|
:=G0f1 :f545
|
||||||
|
|
||||||
|
:uQ2L| :f141
|
||||||
|
:\R0LI| :f161
|
||||||
|
:\Q0ML :f161
|
||||||
|
|
||||||
|
:\R0k :f121
|
||||||
|
:\Q0jL| :f121
|
||||||
|
:uQ1kI
|
||||||
|
|
||||||
|
:=v062 :fc33
|
||||||
|
:=v052 :fc71
|
||||||
|
:=v362 :fc11
|
||||||
|
:^v462I :^G462I
|
||||||
|
|
||||||
|
:-w5u :f31d
|
||||||
|
:'w5G :f311
|
||||||
|
|
||||||
|
:=A2a2 :f12f
|
||||||
|
:=w0o :f331
|
||||||
|
:^A3a2
|
||||||
|
|
||||||
|
:=v072 :f14i
|
||||||
|
:=G072 :f14d
|
||||||
|
|
||||||
|
:'G1lL :f113
|
||||||
|
:<H1lL :f113
|
||||||
|
:/M1z :f311
|
||||||
|
|
||||||
|
:<G2DL :f118
|
||||||
|
|
||||||
|
:'C2qI :f311
|
||||||
|
:^C3pI :f311
|
||||||
|
:<C4oI :f311
|
||||||
|
:-C4l :f313
|
||||||
|
:<C4k :f311
|
||||||
|
:^C3j :f311
|
||||||
|
:'C2i :f311
|
||||||
|
|
||||||
|
:)C3o- :f311
|
||||||
|
:)C3k-I :f311
|
||||||
|
|
||||||
|
:=v4i :f613 :nv4i| :nA4i
|
||||||
|
|
||||||
|
:'w28I :fa11
|
||||||
|
:^w37I :fa11
|
||||||
|
:^w46I :fa11
|
||||||
|
:'w2n :f411
|
||||||
|
:^x3o :f211
|
||||||
|
|
||||||
|
:)Q1rJ :f11c
|
||||||
|
:)Q2DJ :f118
|
||||||
|
|
||||||
|
:uB2o :uF2oJ :uB2kL :uF2kI
|
||||||
|
|
||||||
|
:]G2kL :]G2oL
|
||||||
|
|
||||||
|
:nv0v2| :f151 :nw0v2 :f151 :nv0w2J| :f151 :nw0w2L :f151
|
||||||
|
:ny0v2| :f151 :nz3v2 :f121 :ny0w2J| :f151 :nz3w2L :f121
|
||||||
|
|
||||||
|
:nv0G2| :f151 :nw0G2 :f151 :nv0H2J| :f151 :nw0H2L :f151
|
||||||
|
:ny0G2| :f151 :nz3G2 :f121 :ny0H2J| :f151 :nz3H2L :f121
|
||||||
|
|
|
@ -82,7 +82,8 @@ uint8_t LCR_keyPressed(uint8_t key)
|
||||||
keyboardState[SDL_SCANCODE_D] | keyboardState[SDL_SCANCODE_RIGHT]; break;
|
keyboardState[SDL_SCANCODE_D] | keyboardState[SDL_SCANCODE_RIGHT]; break;
|
||||||
|
|
||||||
case LCR_KEY_DOWN: return
|
case LCR_KEY_DOWN: return
|
||||||
keyboardState[SDL_SCANCODE_S] | keyboardState[SDL_SCANCODE_DOWN]; break;
|
keyboardState[SDL_SCANCODE_S] | keyboardState[SDL_SCANCODE_DOWN] |
|
||||||
|
keyboardState[SDL_SCANCODE_SPACE]; break;
|
||||||
|
|
||||||
case LCR_KEY_LEFT: return
|
case LCR_KEY_LEFT: return
|
||||||
keyboardState[SDL_SCANCODE_A] | keyboardState[SDL_SCANCODE_LEFT]; break;
|
keyboardState[SDL_SCANCODE_A] | keyboardState[SDL_SCANCODE_LEFT]; break;
|
||||||
|
|
|
@ -82,4 +82,10 @@ int _LCR_strCmp(const char *s1, const char *s2)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char _LCR_triangleWinding(int x0, int y0, int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
x0 = (y1 - y0) * (x2 - x1) - (x1 - x0) * (y2 - y1);
|
||||||
|
return x0 != 0 ? (x0 > 0 ? 1 : -1) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
1
map.h
1
map.h
|
@ -915,7 +915,6 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
|
||||||
ADD(6,2,1) ADD(6,0,6) ADD(6,3,2)
|
ADD(6,2,1) ADD(6,0,6) ADD(6,3,2)
|
||||||
ADD(6,3,2) ADD(6,0,6) ADD(6,4,4)
|
ADD(6,3,2) ADD(6,0,6) ADD(6,4,4)
|
||||||
ADD(6,4,4) ADD(6,0,6) ADD(6,4,6)
|
ADD(6,4,4) ADD(6,0,6) ADD(6,4,6)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
|
2
racing.h
2
racing.h
|
@ -390,7 +390,7 @@ int LCR_replayRecordEvent(uint32_t frame, uint8_t input)
|
||||||
*/
|
*/
|
||||||
TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
|
TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block)
|
||||||
{
|
{
|
||||||
TPE_Vec3 v, vBest;
|
TPE_Vec3 v, vBest = TPE_vec3(TPE_INFINITY,TPE_INFINITY,TPE_INFINITY);
|
||||||
TPE_Unit d, dBest = TPE_INFINITY;
|
TPE_Unit d, dBest = TPE_INFINITY;
|
||||||
|
|
||||||
uint8_t bx, by, bz;
|
uint8_t bx, by, bz;
|
||||||
|
|
34
renderer.h
34
renderer.h
|
@ -550,14 +550,16 @@ int _LCR_rendererQuadCoversTri(const S3L_Unit quad[8], const S3L_Unit tri[6])
|
||||||
|
|
||||||
for (int k = 0; k < 3; ++k) // for each subtriangle side
|
for (int k = 0; k < 3; ++k) // for each subtriangle side
|
||||||
{
|
{
|
||||||
S3L_Unit w = // triangle winding
|
char w =
|
||||||
(quad[(2 * (j + ((k + 1) % 3))) % 8 + 1] -
|
_LCR_triangleWinding(
|
||||||
quad[(2 * (j + k)) % 8 + 1]) *
|
quad[(2 * (j + (k + 1) % 3)) % 8],
|
||||||
(tri[2 * i] - quad[(2 * (j + (k + 1) % 3)) % 8]) -
|
quad[(2 * (j + ((k + 1) % 3))) % 8 + 1],
|
||||||
(quad[(2 * (j + ((k + 1) % 3))) % 8] - quad[(2 * (j + k)) % 8])
|
quad[(2 * (j + k)) % 8],
|
||||||
* (tri[2 * i + 1] - quad[(2 * (j + (k + 1) % 3)) % 8 + 1]);
|
quad[(2 * (j + k)) % 8 + 1],
|
||||||
|
tri[2 * i],
|
||||||
|
tri[2 * i + 1]);
|
||||||
|
|
||||||
winds |= (w > 0) | ((w < 0) << 1 );
|
winds |= (w > 0) | ((w < 0) << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (winds != 3) // no opposite winds?
|
if (winds != 3) // no opposite winds?
|
||||||
|
@ -631,7 +633,7 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
||||||
points2D[13] = (4 * points2D[7] + 3 * points2D[9] + points2D[11]) / 8;
|
points2D[13] = (4 * points2D[7] + 3 * points2D[9] + points2D[11]) / 8;
|
||||||
|
|
||||||
// first: does the triangle alone cover the other one?
|
// first: does the triangle alone cover the other one?
|
||||||
if (_LCR_rendererQuadLooksConvex(points2D +6) &&
|
if (_LCR_rendererQuadLooksConvex(points2D + 6) &&
|
||||||
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
||||||
result |= 1 << j;
|
result |= 1 << j;
|
||||||
else
|
else
|
||||||
|
@ -654,9 +656,19 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
||||||
LCR_renderer.mapVerts[3 * t3[1] + plane] ==
|
LCR_renderer.mapVerts[3 * t3[1] + plane] ==
|
||||||
LCR_renderer.mapVerts[3 * t3[2] + plane] &&
|
LCR_renderer.mapVerts[3 * t3[2] + plane] &&
|
||||||
LCR_renderer.mapVerts[3 * t3[0] + plane] ==
|
LCR_renderer.mapVerts[3 * t3[0] + plane] ==
|
||||||
LCR_renderer.mapVerts[3 * t1[0] + plane])
|
LCR_renderer.mapVerts[3 * t1[0] + plane] &&
|
||||||
|
_LCR_triangleWinding(
|
||||||
|
points2D[6],points2D[7],points2D[8],points2D[9],
|
||||||
|
points2D[10],points2D[11]) ==
|
||||||
|
_LCR_triangleWinding(
|
||||||
|
LCR_renderer.mapVerts[3 * t3[0] + coordX],
|
||||||
|
LCR_renderer.mapVerts[3 * t3[0] + coordY],
|
||||||
|
LCR_renderer.mapVerts[3 * t3[1] + coordX],
|
||||||
|
LCR_renderer.mapVerts[3 * t3[1] + coordY],
|
||||||
|
LCR_renderer.mapVerts[3 * t3[2] + coordX],
|
||||||
|
LCR_renderer.mapVerts[3 * t3[2] + coordY]))
|
||||||
{
|
{
|
||||||
// here shares exactly two vertices and is in the same plane
|
// here shares exactly 2 verts + is in the same plane + same winding
|
||||||
|
|
||||||
uint8_t freeVert =
|
uint8_t freeVert =
|
||||||
sharedVerts == 3 ? 2 : (sharedVerts == 5 ? 1 : 0);
|
sharedVerts == 3 ? 2 : (sharedVerts == 5 ? 1 : 0);
|
||||||
|
@ -664,7 +676,7 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, const S3L_Index *t2)
|
||||||
points2D[12] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordX];
|
points2D[12] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordX];
|
||||||
points2D[13] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordY];
|
points2D[13] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordY];
|
||||||
|
|
||||||
if (_LCR_rendererQuadLooksConvex(points2D +6) &&
|
if (_LCR_rendererQuadLooksConvex(points2D + 6) &&
|
||||||
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
_LCR_rendererQuadCoversTri(points2D + 6,points2D))
|
||||||
{
|
{
|
||||||
result |= 1 << j;
|
result |= 1 << j;
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
#ifndef LCR_SETTING_TRIANGLE_CULLING_PERIOD
|
#ifndef LCR_SETTING_TRIANGLE_CULLING_PERIOD
|
||||||
/** This says how often (after how many triangles added) the map model
|
/** This says how often (after how many triangles added) the map model
|
||||||
triangles will be culled. This value may affect how quickly maps load. */
|
triangles will be culled. This value may affect how quickly maps load. */
|
||||||
#define LCR_SETTING_TRIANGLE_CULLING_PERIOD 64
|
#define LCR_SETTING_TRIANGLE_CULLING_PERIOD 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LCR_SETTING_TEXTURE_SUBSAMPLE
|
#ifndef LCR_SETTING_TEXTURE_SUBSAMPLE
|
||||||
|
|
Loading…
Reference in a new issue