Clear all references to every object's oFloor each frame when using with dynamic collision (#616)
This commit is contained in:
1 parent
18d8c51e3d
commit
7348ba8976
4 files changed
+20
No files matched your search
@@ -568,6 +568,8 @@ void load_area_terrain(s32 index, TerrainData *data, RoomData *surfaceRooms, s16
|
||||
void clear_dynamic_surfaces(void) {
|
||||
PUPPYPRINT_GET_SNAPSHOT();
|
||||
if (!(gTimeStopState & TIME_STOP_ACTIVE)) {
|
||||
clear_dynamic_surface_references();
|
||||
|
||||
gSurfacesAllocated = gNumStaticSurfaces;
|
||||
gSurfaceNodesAllocated = gNumStaticSurfaceNodes;
|
||||
gDynamicSurfacePoolEnd = gDynamicSurfacePool;
|
||||
|
||||
@@ -616,6 +616,22 @@ UNUSED static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all floors tied to dynamic collision, as they become invalid once the dynamic
|
||||
* surfaces are cleared.
|
||||
*
|
||||
* NOTE: Checking over the full object pool is slower than checking against the linked lists of active
|
||||
* objects until the active object pool is around half capacity, after which, this is faster.
|
||||
* Change this function to use a linked list instead if you add any additional logic here whatsoever.
|
||||
*/
|
||||
void clear_dynamic_surface_references(void) {
|
||||
for (s32 i = 0; i < OBJECT_POOL_CAPACITY; i++) {
|
||||
if (gObjectPool[i].oFloor && gObjectPool[i].oFloor->flags & SURFACE_FLAG_DYNAMIC) {
|
||||
gObjectPool[i].oFloor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all objects. This includes script execution, object collision detection,
|
||||
* and object surface management.
|
||||
|
||||
@@ -141,6 +141,7 @@ void set_object_respawn_info_bits(struct Object *obj, u8 bits);
|
||||
void unload_objects_from_area(UNUSED s32 unused, s32 areaIndex);
|
||||
void spawn_objects_from_info(UNUSED s32 unused, struct SpawnInfo *spawnInfo);
|
||||
void clear_objects(void);
|
||||
void clear_dynamic_surface_references(void);
|
||||
void update_objects(UNUSED s32 unused);
|
||||
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ void clear_object_lists(struct ObjectNode *objLists) {
|
||||
void unload_object(struct Object *obj) {
|
||||
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
obj->prevObj = NULL;
|
||||
obj->oFloor = NULL;
|
||||
|
||||
obj->header.gfx.throwMatrix = NULL;
|
||||
stop_sounds_from_source(obj->header.gfx.cameraToObject);
|
||||
|
||||
Reference in new issue
Block a user