diff --git a/TODO.txt b/TODO.txt index 40affe4..a2ed219 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,10 +1,5 @@ +- allow car to be flipped upside down on start? with start block transform - maybe change sticker to fan? could me more fun: TEST and see -- based viewing distance idea: limit number of rendered map triangles to N, keep - sorting the triangle array by distance continually! e.g. in each frame handle - one of the N visible triangles like this -- in the non-visible triangles - find one that is closer than this and switch them (if found). -- sky images could be just composed of 4x4 normal images? then we only need - one type of image - map actually in ASCII format? how will humans edit it? - make a simple rendering setting: - will exclude images and only draw solid colors, let's say only 16, so that @@ -16,19 +11,7 @@ - then iterate over the strip that should have the sky texture and only draw to pixels where depth buffer was not overwritten (this step can be left out in case we have depth buffer or sky turned off) -TOTAL SIZE OF TEXTURES: - - 64 x 64 x 2 = 8192, 6 x floor + 2 x wall + 1 x car = 8 * 8192 = 73728 - - (128 x 128 x 1) x 3 background = 49152 - - total = 122880 -- OK so materials (final?): - - concrete: normal \ - - accelerator: accelerates (adds some constant to speed?) > same wall texture? - - maybe jumppad (big "fan")? / - - dirt: a bit slippery (maybe also a bit slows down?) \ - - magnet: pulls car downwards (allows riding on ceiling etc.) > same wall texture? - - ice: extremely slippery (can barely turn) / - camera behavior? what if car is riding upside down (on magnet) etc? -- track size: 64x64x64 - EFFICINT MAP DRAWING: - map will be subdivided into subblocks (probably 16x16x16 or 8x8x8), only nearest subblocks (and possibly only those in viewing direction will be @@ -41,14 +24,6 @@ TOTAL SIZE OF TEXTURES: subblocks we want to draw. - THIS??? Draw further blocks in a simplified way, e.g. just splatting literal squares with constant color? See how it looks :) -- Architecture (modules): - - map: loads map n stuff - - racing engine (depends on map): handles physics of car with given inputs - - rendering engine (depends on map): hanles rendering of the map - - game (depends on all): joins it all together - - settings, constants etc. - - individual frontends - - ...? - Textures: size? format? They will likely take a lot of mem, weak computers will have to do without them. - possibility of simple procedural textures to save space! <-- SOUNDS NICE @@ -140,4 +115,27 @@ TOTAL SIZE OF TEXTURES: BUGS: -DONE: +HANDLED: + +- track size: 64x64x64 +- sky images could be just composed of 4x4 normal images? then we only need + one type of image +TOTAL SIZE OF TEXTURES: + - 64 x 64 x 2 = 8192, 6 x floor + 2 x wall + 1 x car = 8 * 8192 = 73728 + - (128 x 128 x 1) x 3 background = 49152 + - total = 122880 +- OK so materials (final?): + - concrete: normal \ + - accelerator: accelerates (adds some constant to speed?) > same wall texture? + - maybe jumppad (big "fan")? / + - dirt: a bit slippery (maybe also a bit slows down?) \ + - magnet: pulls car downwards (allows riding on ceiling etc.) > same wall texture? + - ice: extremely slippery (can barely turn) / +- Architecture (modules): + - map: loads map n stuff + - racing engine (depends on map): handles physics of car with given inputs + - rendering engine (depends on map): hanles rendering of the map + - game (depends on all): joins it all together + - settings, constants etc. + - individual frontends + - ...? diff --git a/assets.h b/assets.h index e8eecaf..0ca3918 100644 --- a/assets.h +++ b/assets.h @@ -24,20 +24,39 @@ static const uint8_t map1[] = 10, 0, -LCR_MAP_BLOCK(LCR_BLOCK_RAMP,36,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0), -LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,1,0,0), +LCR_MAP_BLOCK(LCR_BLOCK_START,1,1,1,0,0), -LCR_MAP_BLOCK(LCR_BLOCK_RAMP,46,0,33,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_90), -LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,1,1,10,0,0), +LCR_MAP_BLOCK(LCR_BLOCK_FULL,0,0,0,LCR_BLOCK_MATERIAL_CONCRETE,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,15,1,20,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_FULL,0,0,20,LCR_BLOCK_MATERIAL_CONCRETE,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,15,1,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_RAMP,0,1,19,LCR_BLOCK_MATERIAL_CONCRETE,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,8,1,1,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_RAMP,8,1,5,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_270), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,1,1,8,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_LEFT,5,1,5,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_90), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,2,1,0,0), + + +LCR_MAP_BLOCK(LCR_BLOCK_LEFT,9,0,20,LCR_BLOCK_MATERIAL_CONCRETE,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,8,1,8,0,0), + + +LCR_MAP_BLOCK(LCR_BLOCK_FULL,15,0,0,LCR_BLOCK_MATERIAL_GRASS,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_FULL,25,0,0,LCR_BLOCK_MATERIAL_ICE,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0), + +LCR_MAP_BLOCK(LCR_BLOCK_FULL,35,0,0,LCR_BLOCK_MATERIAL_DIRT,0), +LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,15,0,0), -LCR_MAP_BLOCK(LCR_BLOCK_LEFT,36,0,33,LCR_BLOCK_MATERIAL_CONCRETE,0), -LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,1,10,0,0), -LCR_MAP_BLOCK(LCR_BLOCK_FULL,36,0,43,LCR_BLOCK_MATERIAL_CONCRETE,0), -LCR_MAP_BLOCK(LCR_BLOCK_CUBOID_FILL,10,4,1,0,0), -LCR_MAP_BLOCK(LCR_BLOCK_FULL,32,0,32,0,0), -LCR_MAP_BLOCK(LCR_BLOCK_START,32,1,32,0,LCR_BLOCK_TRANSFORM_ROT_180), LCR_MAP_TERMINATOR diff --git a/racing.h b/racing.h index 3859619..65d6e07 100644 --- a/racing.h +++ b/racing.h @@ -454,6 +454,21 @@ void _LCR_racingWheelAccelerate(unsigned int wheel, TPE_Vec3 dir) (dir.z * LCR_CAR_ACCELERATION) / TPE_F; } +int _LCR_racingCarShapeOK(void) +{ + int r = 1; + + for (int i = 0; i < LCR_racing.carBody.jointCount; ++i) + r &= TPE_connectionTension(TPE_dist( + LCR_racing.carBody.joints[ + LCR_racing.carBody.connections[i].joint1].position, + LCR_racing.carBody.joints[ + LCR_racing.carBody.connections[i].joint2].position), + LCR_racing.carBody.connections[i].length) < TPE_F / 16; // TODO: const + + return r; +} + /** Updates the racing physics world, call every LCR_RACING_TICK_MS milliseconds. */ @@ -645,33 +660,8 @@ LCR_racing.carPositions[0] = } } -// now try to decide if car shape is OK -TPE_Unit v1, v2; - -v1 = TPE_vec3Dot( - TPE_vec3Minus( - LCR_racing.carBody.joints[1].position, - LCR_racing.carBody.joints[0].position), - TPE_vec3Minus( - LCR_racing.carBody.joints[3].position, - LCR_racing.carBody.joints[0].position)); - -v2 = TPE_vec3Dot( - TPE_vec3Minus( - LCR_racing.carBody.joints[1].position, - LCR_racing.carBody.joints[2].position), - TPE_vec3Minus( - LCR_racing.carBody.joints[3].position, - LCR_racing.carBody.joints[2].position)); - -v1 = v1 > v2 ? ((v1 * LCR_GAME_UNIT) / TPE_nonZero(v2)) : - ((v2 * LCR_GAME_UNIT) / TPE_nonZero(v1)); - -#define _TOLERANCE (LCR_GAME_UNIT / 8) - if ((LCR_racing.carBody.flags & TPE_BODY_FLAG_UNRESOLVED) || - v1 < (LCR_GAME_UNIT - _TOLERANCE) || - v1 > (LCR_GAME_UNIT + _TOLERANCE)) + !_LCR_racingCarShapeOK()) { // car not OK diff --git a/tinyphysicsengine.h b/tinyphysicsengine.h index ed3e6a2..e48ec74 100644 --- a/tinyphysicsengine.h +++ b/tinyphysicsengine.h @@ -640,8 +640,7 @@ static inline TPE_Unit TPE_nonZero(TPE_Unit x) static inline TPE_Unit TPE_connectionTension(TPE_Unit length, TPE_Unit desiredLength) { - return (length * TPE_F) / desiredLength - - TPE_F; + return (length * TPE_F) / desiredLength - TPE_F; } TPE_Joint TPE_joint(TPE_Vec3 position, TPE_Unit size)