diff --git a/assets.h b/assets.h index 576b6fe..02af77d 100644 --- a/assets.h +++ b/assets.h @@ -32,13 +32,10 @@ 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_RAMP_CURVED,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_STEEP,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_RAMP_STEEP,8,2,5,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_270 | LCR_BLOCK_TRANSFORM_FLIP_V), +LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED,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), @@ -47,8 +44,6 @@ 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_CORNER_12,3,1,5,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), diff --git a/map.h b/map.h index 2dae1cc..d8cc7ce 100644 --- a/map.h +++ b/map.h @@ -80,13 +80,22 @@ #define LCR_BLOCK_RAMP_34 0x06 ///< plain ramp, 3/4 size #define LCR_BLOCK_RAMP_12 0x07 ///< plain ramp, 1/2 size #define LCR_BLOCK_RAMP_14 0x08 ///< plain ramp, 1/4 size -#define LCR_BLOCK_RAMP_CURVED 0x09 -#define LCR_BLOCK_RAMP_CURVED_SHORT 0x0a -#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b +#define LCR_BLOCK_RAMP_CURVED_PLAT 0x09 ///< curved ramp with top platgform +#define LCR_BLOCK_RAMP_CURVED 0x0a ///< curv. ramp without top platf. +#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b ///< curved ramp plus small wall #define LCR_BLOCK_RAMP_STEEP 0x0c ///< extremely steep ramp #define LCR_BLOCK_CORNER 0x0d ///< diagonal corner #define LCR_BLOCK_CORNER_12 0x0e ///< diagonal corner (1/2 wide) +/* + TODO: + - ramp corner??? + - curved corner? + - curved out corner? + - curved "hill" + - bumpy road +*/ + #define LCR_BLOCK_FULL_ACCEL 0x20 #define LCR_BLOCK_FULL_FAN 0x30 @@ -188,8 +197,10 @@ uint32_t LCR_mapBlockCoordsToCoordNumber(uint8_t x, uint8_t y, uint8_t z) return LCR_mapBlockGetCoordNumber(b); } -void LCR_rampGetDimensions(uint8_t rampType, - uint8_t *height4ths, +/** + Gets dimensions of a non-curved ramp. +*/ +void LCR_rampGetDimensions(uint8_t rampType, uint8_t *height4ths, uint8_t *length6ths) { *height4ths = @@ -201,17 +212,6 @@ void LCR_rampGetDimensions(uint8_t rampType, *length6ths = rampType != LCR_BLOCK_RAMP_STEEP ? 6 : 1; } -/* -int LCR_rampHeight4ths(uint8_t rampType) -{ - return - (rampType == LCR_BLOCK_RAMP_14) + - (rampType == LCR_BLOCK_RAMP) * 4 + - (rampType == LCR_BLOCK_RAMP_12 || rampType == LCR_BLOCK_RAMP_34) * 2 + - (rampType == LCR_BLOCK_RAMP_34); -} -*/ - uint8_t *LCR_getMapBlockAtCoordNumber(uint32_t coord) { // binary search the block: @@ -552,6 +552,25 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform, break; } + case LCR_BLOCK_RAMP_CURVED: + ADD(0,0,0) ADD(6,0,0) ADD(0,1,4) // ramp + ADD(0,1,4) ADD(6,0,0) ADD(6,1,4) + ADD(0,1,4) ADD(6,1,4) ADD(0,2,5) // ramp + ADD(0,2,5) ADD(6,1,4) ADD(6,2,5) + ADD(0,2,5) ADD(6,2,5) ADD(0,4,6) // ramp + ADD(0,4,6) ADD(6,2,5) ADD(6,4,6) + ADD(0,0,0) ADD(0,1,4) ADD(0,0,6) // left + ADD(0,0,6) ADD(0,1,4) ADD(0,2,5) + ADD(0,0,6) ADD(0,2,5) ADD(0,4,6) + ADD(6,0,0) ADD(6,0,6) ADD(6,1,4) // right + ADD(6,0,6) ADD(6,2,5) ADD(6,1,4) + ADD(6,0,6) ADD(6,4,6) ADD(6,2,5) + ADD(0,0,6) ADD(0,4,6) ADD(6,0,6) // back + ADD(6,0,6) ADD(0,4,6) ADD(6,4,6) + ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom + ADD(0,0,0) ADD(0,0,6) ADD(6,0,6) + break; + case LCR_BLOCK_RAMP_CURVED_WALL: ADD(0,0,0) ADD(5,0,0) ADD(0,1,3) // ramp ADD(0,1,3) ADD(5,0,0) ADD(5,1,3) diff --git a/racing.h b/racing.h index ac39674..cd27ab2 100644 --- a/racing.h +++ b/racing.h @@ -127,6 +127,45 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block) break; } + case LCR_BLOCK_RAMP_CURVED: + { + TPE_Vec3 v, vBest; + TPE_Unit sides[6], d, dBest; + + sides[0] = LCR_PHYSICS_UNIT / 8; + sides[1] = -1 * LCR_PHYSICS_UNIT / 4; + sides[2] = LCR_PHYSICS_UNIT / 2; + sides[3] = -1 * LCR_PHYSICS_UNIT / 4; + sides[4] = LCR_PHYSICS_UNIT / 2; + sides[5] = LCR_PHYSICS_UNIT / 4; + + vBest = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2); + dBest = TPE_dist(point,vBest); + + if (dBest != 0) + { + sides[0] = -1 * LCR_PHYSICS_UNIT / 4; + sides[1] = -1 * LCR_PHYSICS_UNIT / 4; + sides[2] = LCR_PHYSICS_UNIT / 2; + sides[3] = -1 * LCR_PHYSICS_UNIT / 4; + sides[4] = LCR_PHYSICS_UNIT / 2; + sides[5] = 0; + + v = TPE_envAATriPrism(point,TPE_vec3(0,0,0),sides,LCR_PHYSICS_UNIT,2); + d = TPE_dist(point,v); + + if (d < dBest) + { + vBest = v; + dBest = d; + } + } + + point = vBest; + + break; + } + case LCR_BLOCK_RAMP: case LCR_BLOCK_RAMP_34: case LCR_BLOCK_RAMP_12: