A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KCollisionTypes.hh
Go to the documentation of this file.
1#pragma once
19
20#include <egg/math/Vector.hh>
21
22// Credit: em-eight/mkw
23
25#define KCL_ATTRIBUTE_TYPE(x) ((x)&0x1f)
28#define KCL_TYPE_BIT(x) (1 << (x))
30#define KCL_ATTRIBUTE_TYPE_BIT(x) KCL_TYPE_BIT(KCL_ATTRIBUTE_TYPE(x))
32#define KCL_VARIANT_TYPE(x) ((x >> 5) & 7)
33
34// KCL attribute types
71
72#define KCL_SOFT_WALL_MASK 0x8000
73#define KCL_ANY 0xffffffff
74#define KCL_NONE 0x00000000
75
77#define KCL_TYPE_DIRECTIONAL \
78 (KCL_TYPE_BIT(COL_TYPE_FALL_BOUNDARY) | KCL_TYPE_BIT(COL_TYPE_SOUND_TRIGGER) | \
79 KCL_TYPE_BIT(COL_TYPE_FORCE_RECALCULATE_ROUTE) | \
80 KCL_TYPE_BIT(COL_TYPE_EFFECT_TRIGGER) | KCL_TYPE_BIT(COL_TYPE_CANNON_TRIGGER))
81
83#define KCL_TYPE_SOLID_SURFACE \
84 (KCL_ANY & \
85 (~KCL_TYPE_BIT(COL_TYPE_FALL_BOUNDARY) & ~KCL_TYPE_BIT(COL_TYPE_CANNON_TRIGGER) & \
86 ~KCL_TYPE_BIT(COL_TYPE_FORCE_RECALCULATE_ROUTE) & \
87 ~KCL_TYPE_BIT(COL_TYPE_SOUND_TRIGGER) & ~KCL_TYPE_BIT(COL_TYPE_WEAK_WALL) & \
88 ~KCL_TYPE_BIT(COL_TYPE_EFFECT_TRIGGER) & \
89 ~KCL_TYPE_BIT(COL_TYPE_ITEM_STATE_MODIFIER)))
90
92#define KCL_TYPE_FLOOR \
93 (KCL_TYPE_BIT(COL_TYPE_ROAD) | KCL_TYPE_BIT(COL_TYPE_SLIPPERY_ROAD) | \
94 KCL_TYPE_BIT(COL_TYPE_WEAK_OFF_ROAD) | KCL_TYPE_BIT(COL_TYPE_OFF_ROAD) | \
95 KCL_TYPE_BIT(COL_TYPE_HEAVY_OFF_ROAD) | KCL_TYPE_BIT(COL_TYPE_SLIPPERY_ROAD_2) | \
96 KCL_TYPE_BIT(COL_TYPE_BOOST_PAD) | KCL_TYPE_BIT(COL_TYPE_BOOST_RAMP) | \
97 KCL_TYPE_BIT(COL_TYPE_JUMP_PAD) | KCL_TYPE_BIT(COL_TYPE_ITEM_ROAD) | \
98 KCL_TYPE_BIT(COL_TYPE_SOLID_OOB) | KCL_TYPE_BIT(COL_TYPE_MOVING_WATER) | \
99 KCL_TYPE_BIT(COL_TYPE_HALFPIPE_RAMP) | KCL_TYPE_BIT(COL_TYPE_MOVING_ROAD) | \
100 KCL_TYPE_BIT(COL_TYPE_STICKY_ROAD) | KCL_TYPE_BIT(COL_TYPE_ROAD2) | \
101 KCL_TYPE_BIT(COL_TYPE_ROTATING_ROAD))
102
104#define KCL_TYPE_DRIVER_FLOOR (KCL_TYPE_FLOOR & ~KCL_TYPE_BIT(COL_TYPE_ITEM_ROAD))
105
107#define KCL_TYPE_WALL \
108 (KCL_TYPE_BIT(COL_TYPE_WALL) | KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL) | \
109 KCL_TYPE_BIT(COL_TYPE_ITEM_WALL) | KCL_TYPE_BIT(COL_TYPE_WALL_2) | \
110 KCL_TYPE_BIT(COL_TYPE_PLAYER_WALL) | KCL_TYPE_BIT(COL_TYPE_HALFPIPE_INVISIBLE_WALL) | \
111 KCL_TYPE_BIT(COL_TYPE_SPECIAL_WALL) | KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL2))
112
114#define KCL_TYPE_DRIVER_WALL \
115 (KCL_TYPE_WALL & ~KCL_TYPE_BIT(COL_TYPE_ITEM_WALL) & \
116 ~KCL_TYPE_BIT(COL_TYPE_HALFPIPE_INVISIBLE_WALL))
117
119#define KCL_TYPE_DRIVER_WALL_NO_INVISIBLE_WALL \
120 (KCL_TYPE_DRIVER_WALL & ~KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL))
121
123#define KCL_TYPE_DRIVER_WALL_NO_INVISIBLE_WALL2 \
124 (KCL_TYPE_DRIVER_WALL & ~KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL2))
125
127#define KCL_TYPE_4010D000 \
128 (KCL_TYPE_DRIVER_WALL_NO_INVISIBLE_WALL & ~KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL2) | \
129 KCL_TYPE_BIT(COL_TYPE_ITEM_WALL))
130
132#define KCL_TYPE_VEHICLE_INTERACTABLE \
133 (~KCL_TYPE_BIT(COL_TYPE_ITEM_ROAD) & ~KCL_TYPE_BIT(COL_TYPE_ITEM_WALL) & \
134 ~KCL_TYPE_BIT(COL_TYPE_HALFPIPE_INVISIBLE_WALL))
135
137#define KCL_TYPE_VEHICLE_COLLIDEABLE \
138 (KCL_TYPE_VEHICLE_INTERACTABLE & ~KCL_TYPE_BIT(COL_TYPE_SOUND_TRIGGER) & \
139 ~KCL_TYPE_BIT(COL_TYPE_EFFECT_TRIGGER) & ~KCL_TYPE_BIT(COL_TYPE_FALL_BOUNDARY) & \
140 ~KCL_TYPE_BIT(COL_TYPE_CANNON_TRIGGER) & \
141 ~KCL_TYPE_BIT(COL_TYPE_FORCE_RECALCULATE_ROUTE))
142
144#define KCL_TYPE_NON_DIRECTIONAL \
145 (KCL_TYPE_VEHICLE_COLLIDEABLE & ~KCL_TYPE_BIT(COL_TYPE_ITEM_STATE_MODIFIER) & \
146 ~KCL_TYPE_BIT(COL_TYPE_WEAK_WALL))
147
149#define KCL_TYPE_DRIVER_SOLID_SURFACE \
150 (KCL_TYPE_VEHICLE_COLLIDEABLE | KCL_TYPE_BIT(COL_TYPE_CANNON_TRIGGER))
151
153#define KCL_TYPE_B0E82DFF \
154 (KCL_TYPE_DRIVER_FLOOR | KCL_TYPE_BIT(COL_TYPE_HALFPIPE_INVISIBLE_WALL) | \
155 KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL) | \
156 KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL2) & ~KCL_TYPE_BIT(COL_TYPE_ITEM_ROAD))
157
158#define KCL_TYPE_64EBDFFF \
159 (KCL_TYPE_FLOOR | KCL_TYPE_BIT(COL_TYPE_SPECIAL_WALL) | \
160 KCL_TYPE_BIT(COL_TYPE_EFFECT_TRIGGER) | KCL_TYPE_BIT(COL_TYPE_CANNON_TRIGGER) | \
161 KCL_TYPE_BIT(COL_TYPE_FALL_BOUNDARY) | KCL_TYPE_BIT(COL_TYPE_WALL_2) | \
162 KCL_TYPE_BIT(COL_TYPE_ITEM_WALL) | KCL_TYPE_BIT(COL_TYPE_WALL))
163
164STATIC_ASSERT(KCL_TYPE_64EBDFFF == 0x64EBDFFF);
165
167#define KCL_TYPE_INVISIBLE_WALL \
168 (KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL) | KCL_TYPE_BIT(COL_TYPE_INVISIBLE_WALL2))
169
171#define KCL_TYPE_ANY_INVISIBLE_WALL \
172 (KCL_TYPE_INVISIBLE_WALL | KCL_TYPE_BIT(COL_TYPE_HALFPIPE_INVISIBLE_WALL))
173
174namespace Field {
191STATIC_ASSERT(sizeof(KColHeader) == 0x3c);
192
193typedef u32 KCLTypeMask;
194
195} // namespace Field
@ COL_TYPE_OFF_ROAD
Moderate off-road slowdown.
@ COL_TYPE_MOVING_WATER
Koopa Cape and DS Yoshi Falls.
@ COL_TYPE_STICKY_ROAD
Player sticks if within 200 units (rBC stairs).
@ COL_TYPE_BOOST_RAMP
Trickable. Variant affects boost duration.
@ COL_TYPE_ITEM_WALL
Wall that is only solid for items.
@ COL_TYPE_FORCE_RECALCULATE_ROUTE
Forces CPU pathing recalculation.
@ COL_TYPE_INVISIBLE_WALL
Solid wall that is (typically) invisible.
@ COL_TYPE_WALL
Default wall.
@ COL_TYPE_SOUND_TRIGGER
Triggers for changing sound effects per-course.
@ COL_TYPE_WEAK_OFF_ROAD
Slight off-road slowdown.
@ COL_TYPE_INVISIBLE_WALL2
Identical to COL_TYPE_INVISIBLE_WALL.
@ COL_TYPE_ITEM_STATE_MODIFIER
Stops items when leaving curved TF conveyers.
@ COL_TYPE_WALL_2
Difference to COL_TYPE_WALL is unknown.
@ COL_TYPE_ROAD2
COL_TYPE_ROAD but with more variants.
@ COL_TYPE_HALFPIPE_RAMP
Bowser's Castle half-pipe ramps.
@ COL_TYPE_HALFPIPE_INVISIBLE_WALL
Invisible wall after a half-pipe jump, like in BC.
@ COL_TYPE_WEAK_WALL
Pushes player away only at low speeds.
@ COL_TYPE_SPECIAL_WALL
Various other wall types, determined by variant.
@ COL_TYPE_SLIPPERY_ROAD_2
N64 Sherbet Land.
@ COL_TYPE_ROAD
Default road.
@ COL_TYPE_ITEM_ROAD
Road that is only solid for items.
@ COL_TYPE_FALL_BOUNDARY
Non-solid out-of-bounds trigger.
@ COL_TYPE_SLIPPERY_ROAD
Like Dry Dry Ruins.
@ COL_TYPE_BOOST_PAD
Boost panel.
@ COL_TYPE_ROTATING_ROAD
Chain Chomp Roulette.
@ COL_TYPE_PLAYER_WALL
Allows items to pass through but not players.
@ COL_TYPE_CANNON_TRIGGER
Launches player to a destination "cannon point".
@ COL_TYPE_SOLID_OOB
Solid out-of-bounds trigger.
@ COL_TYPE_JUMP_PAD
Like GBA Shy Guy Beach.
@ COL_TYPE_MOVING_ROAD
TF conveyers and CM escalators.
@ COL_TYPE_EFFECT_TRIGGER
Activates various effects based on variant.
@ COL_TYPE_HEAVY_OFF_ROAD
Heavy off-road slowdown.
Pertains to collision.
A 3D float vector.
Definition Vector.hh:83
The header of the KCL file format. It is 0x3C bytes long (for Mario Kart Wii).
u32 block_data_offset
Offset to collision octree blocks.
u32 area_y_width_mask
The y dimension of the octree's bounding box.
f32 prism_thickness
Depth of a triangular prism along its normal vector.
f32 sphere_radius
Clamps the sphere we check collision against.
u32 area_x_blocks_shift
Used to initialize octree navigation.
u32 area_x_width_mask
The x dimension of the octree's bounding box.
EGG::Vector3f area_min_pos
Smallest possible coordinate in the model.
u32 prism_data_offset
1-indexed offset to array of normal vectors.
u32 area_xy_blocks_shift
Used to initialize octree navigation.
u32 block_width_shift
Used to initialize octree navigation.
u32 pos_data_offset
0-indexed offset to array of position vectors.
u32 area_z_width_mask
The z dimension of the octree's bounding box.
u32 nrm_data_offset
0-indexed offset to array of normal vectors.