This commit is contained in:
arthurtilly authored and GitHub committed 2023-12-14 23:24:03 -05:00
1 parent 7de18d10fc
commit dcfcf50a80
3 files changed
+17 -30

No files matched your search

+16 -15
View File
@@ -63,11 +63,6 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode, struc
TerrainData type = SURFACE_DEFAULT;
s32 numCols = 0;
// Max collision radius = 200
if (radius > 200) {
radius = 200;
}
f32 margin_radius = radius - 1.0f;
// Stay in this loop until out of walls.
@@ -216,19 +211,25 @@ s32 find_wall_collisions(struct WallCollisionData *colData) {
}
// World (level) consists of a 16x16 grid. Find where the collision is on the grid (round toward -inf)
s32 cellX = GET_CELL_COORD(x);
s32 cellZ = GET_CELL_COORD(z);
s32 minCellX = GET_CELL_COORD(x - colData->radius);
s32 minCellZ = GET_CELL_COORD(z - colData->radius);
s32 maxCellX = GET_CELL_COORD(x + colData->radius);
s32 maxCellZ = GET_CELL_COORD(z + colData->radius);
if (!(gCollisionFlags & COLLISION_FLAG_EXCLUDE_DYNAMIC)) {
// Check for surfaces belonging to objects.
node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
numCollisions += find_wall_collisions_from_list(node, colData);
for (s32 cellX = minCellX; cellX <= maxCellX; cellX++) {
for (s32 cellZ = minCellZ; cellZ <= maxCellZ; cellZ++) {
if (!(gCollisionFlags & COLLISION_FLAG_EXCLUDE_DYNAMIC)) {
// Check for surfaces belonging to objects.
node = gDynamicSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
numCollisions += find_wall_collisions_from_list(node, colData);
}
// Check for surfaces that are a part of level geometry.
node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
numCollisions += find_wall_collisions_from_list(node, colData);
}
}
// Check for surfaces that are a part of level geometry.
node = gStaticSurfacePartition[cellZ][cellX][SPATIAL_PARTITION_WALLS].next;
numCollisions += find_wall_collisions_from_list(node, colData);
gCollisionFlags &= ~(COLLISION_FLAG_RETURN_FIRST | COLLISION_FLAG_EXCLUDE_DYNAMIC | COLLISION_FLAG_INCLUDE_INTANGIBLE);
#ifdef VANILLA_DEBUG
// Increment the debug tracker.
-14
View File
@@ -187,13 +187,6 @@ static s32 lower_cell_index(s32 coord) {
// [0, NUM_CELLS)
s32 index = coord / CELL_SIZE;
// Include extra cell if close to boundary
//! Some wall checks are larger than the buffer, meaning wall checks can
// miss walls that are near a cell border.
if (coord % CELL_SIZE < 50) {
index--;
}
// Potentially > NUM_CELLS - 1, but since the upper index is <= NUM_CELLS - 1, not exploitable
return MAX(0, index);
}
@@ -213,13 +206,6 @@ static s32 upper_cell_index(s32 coord) {
// [0, NUM_CELLS)
s32 index = coord / CELL_SIZE;
// Include extra cell if close to boundary
//! Some wall checks are larger than the buffer, meaning wall checks can
// miss walls that are near a cell border.
if (coord % CELL_SIZE > CELL_SIZE - 50) {
index++;
}
// Potentially < 0, but since lower index is >= 0, not exploitable
return MIN((NUM_CELLS - 1), index);
}