Small improvements to object loading within rooms (#580)
* Small improvements to object loading within rooms * Only check if Mario is in the same room as the object once * Implement object render distance within rooms (from thecozies) * Remove sLevelsWithRooms (also from thecozies) Honestly surprised this wasn't already in Hacker * Remove comment for sLevelsWithRooms in config_game * Make compatible with the painting objects PR Move room detection to get_room_at_pos (from Arceveti) * address enum comment
This commit is contained in:
1 parent
337dac828f
commit
be753ae220
6 files changed
+54
-33
No files matched your search
@@ -820,11 +820,11 @@ void cur_obj_update(void) {
|
||||
BhvCommandProc bhvCmdProc;
|
||||
s32 bhvProcResult;
|
||||
|
||||
s32 inRoom = is_mario_in_room();
|
||||
|
||||
if (!(objFlags & OBJ_FLAG_PROCESS_OUTSIDE_ROOM)) {
|
||||
if (o->oRoom != -1 && gMarioCurrentRoom != 0 && !is_room_loaded()) {
|
||||
cur_obj_disable_rendering();
|
||||
o->activeFlags |= ACTIVE_FLAG_IN_DIFFERENT_ROOM;
|
||||
gNumRoomedObjectsNotInMarioRoom++;
|
||||
if (inRoom == MARIO_OUTSIDE_ROOM) {
|
||||
cur_obj_enable_disable_room_rendering(MARIO_OUTSIDE_ROOM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -928,7 +928,16 @@ void cur_obj_update(void) {
|
||||
// Handle visibility of object
|
||||
if (o->oRoom != -1) {
|
||||
// If the object is in a room, only show it when Mario is in the room.
|
||||
cur_obj_enable_rendering_if_mario_in_room();
|
||||
if (
|
||||
(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)
|
||||
|| distanceFromMario < o->oDrawingDistance
|
||||
) {
|
||||
cur_obj_enable_disable_room_rendering(inRoom);
|
||||
o->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY;
|
||||
} else {
|
||||
o->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
|
||||
o->activeFlags |= ACTIVE_FLAG_FAR_AWAY;
|
||||
}
|
||||
} else if (
|
||||
o->collisionData == NULL
|
||||
&& (objFlags & OBJ_FLAG_COMPUTE_DIST_TO_MARIO)
|
||||
|
||||
@@ -640,6 +640,20 @@ f32 find_room_floor(f32 x, f32 y, f32 z, struct Surface **pfloor) {
|
||||
return find_floor(x, y, z, pfloor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the room index at a given position.
|
||||
*/
|
||||
s32 get_room_at_pos(f32 x, f32 y, f32 z) {
|
||||
if (gCurrentArea->surfaceRooms != NULL) {
|
||||
struct Surface *floor;
|
||||
find_room_floor(x, y, z, &floor);
|
||||
if (floor) {
|
||||
return floor->room;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the highest water floor under a given position and return the height.
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,7 @@ ALWAYS_INLINE f32 find_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil)
|
||||
f32 find_floor_height(f32 x, f32 y, f32 z);
|
||||
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor);
|
||||
f32 find_room_floor(f32 x, f32 y, f32 z, struct Surface **pfloor);
|
||||
s32 get_room_at_pos(f32 x, f32 y, f32 z);
|
||||
s32 find_water_level_and_floor(s32 x, s32 y, s32 z, struct Surface **pfloor);
|
||||
s32 find_water_level(s32 x, s32 z);
|
||||
s32 find_poison_gas_level(s32 x, s32 z);
|
||||
|
||||
Reference in new issue
Block a user