diff --git a/TODO.txt b/TODO.txt index 094536d..6ff42e6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,5 +1,6 @@ =========== GENERAL ============== +- try to speed up the slow culling - make a small txt game menual - test: - long replay diff --git a/data b/data index b2e3e6a..3a8e128 100644 --- a/data +++ b/data @@ -2,3 +2,99 @@ #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 #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 +: 0 ? 1 : -1) : 0; +} + #endif // guard diff --git a/map.h b/map.h index c3d7a82..650a776 100644 --- a/map.h +++ b/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,3,2) ADD(6,0,6) ADD(6,4,4) ADD(6,4,4) ADD(6,0,6) ADD(6,4,6) - break; default: break; diff --git a/racing.h b/racing.h index 4de8ba5..e1860fb 100644 --- a/racing.h +++ b/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 v, vBest; + TPE_Vec3 v, vBest = TPE_vec3(TPE_INFINITY,TPE_INFINITY,TPE_INFINITY); TPE_Unit d, dBest = TPE_INFINITY; uint8_t bx, by, bz; diff --git a/renderer.h b/renderer.h index 884ca87..98503e1 100644 --- a/renderer.h +++ b/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 { - S3L_Unit w = // triangle winding - (quad[(2 * (j + ((k + 1) % 3))) % 8 + 1] - - quad[(2 * (j + k)) % 8 + 1]) * - (tri[2 * i] - quad[(2 * (j + (k + 1) % 3)) % 8]) - - (quad[(2 * (j + ((k + 1) % 3))) % 8] - quad[(2 * (j + k)) % 8]) - * (tri[2 * i + 1] - quad[(2 * (j + (k + 1) % 3)) % 8 + 1]); + char w = + _LCR_triangleWinding( + quad[(2 * (j + (k + 1) % 3)) % 8], + quad[(2 * (j + ((k + 1) % 3))) % 8 + 1], + quad[(2 * (j + k)) % 8], + 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? @@ -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; // first: does the triangle alone cover the other one? - if (_LCR_rendererQuadLooksConvex(points2D +6) && + if (_LCR_rendererQuadLooksConvex(points2D + 6) && _LCR_rendererQuadCoversTri(points2D + 6,points2D)) result |= 1 << j; 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[2] + 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 = 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[13] = LCR_renderer.mapVerts[3 * t3[freeVert] + coordY]; - if (_LCR_rendererQuadLooksConvex(points2D +6) && + if (_LCR_rendererQuadLooksConvex(points2D + 6) && _LCR_rendererQuadCoversTri(points2D + 6,points2D)) { result |= 1 << j; diff --git a/settings.h b/settings.h index 3fbedff..fc79b43 100644 --- a/settings.h +++ b/settings.h @@ -66,7 +66,7 @@ #ifndef LCR_SETTING_TRIANGLE_CULLING_PERIOD /** This says how often (after how many triangles added) the map model 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 #ifndef LCR_SETTING_TEXTURE_SUBSAMPLE