Only update platforms on change

This commit is contained in:
jaburns
2020-10-28 23:00:11 -06:00
parent 07c6b80df9
commit 0843c23fe9
5 changed files with 13 additions and 92 deletions
-65
View File
@@ -1,5 +1,3 @@
// CUSTOM/PATCH
#include "../shim.h"
#include "surface_collision.h"
#include "../include/surface_terrains.h"
@@ -44,17 +42,6 @@ static struct Surface *find_ceil_from_list( s32 x, s32 y, s32 z, f32 *pheight) {
continue;
}
// // Determine if checking for the camera or not.
// if (gCheckingSurfaceCollisionsForCamera != 0) {
// if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
// continue;
// }
// }
// // Ignore camera only surfaces.
// else if (surf->type == SURFACE_CAMERA_BOUNDARY) {
// continue;
// }
{
f32 nx = surf->normal.x;
f32 ny = surf->normal.y;
@@ -85,9 +72,6 @@ static struct Surface *find_ceil_from_list( s32 x, s32 y, s32 z, f32 *pheight) {
}
}
}
//! (Surface Cucking) Since only the first ceil is returned and not the lowest,
// lower ceilings can be "cucked" by higher ceilings.
return ceil;
}
@@ -107,11 +91,9 @@ static struct Surface *find_floor_from_list( s32 x, s32 y, s32 z, f32 *pheight)
for( int i = 0; i < count; ++i ) {
surf = loaded_surface_get_at_index(i);
// Do the check normally done in add_surface_to_cell
if( surf->normal.y <= 0.01f ) continue;
x1 = surf->vertex1[0];
z1 = surf->vertex1[2];
x2 = surf->vertex2[0];
@@ -133,17 +115,6 @@ static struct Surface *find_floor_from_list( s32 x, s32 y, s32 z, f32 *pheight)
continue;
}
// // Determine if we are checking for the camera or not.
// if (gCheckingSurfaceCollisionsForCamera != 0) {
// if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
// continue;
// }
// }
// // If we are not checking for the camera, ignore camera only floors.
// else if (surf->type == SURFACE_CAMERA_BOUNDARY) {
// continue;
// }
nx = surf->normal.x;
ny = surf->normal.y;
nz = surf->normal.z;
@@ -167,9 +138,6 @@ static struct Surface *find_floor_from_list( s32 x, s32 y, s32 z, f32 *pheight)
floor = surf;
}
}
//! (Surface Cucking) Since only the first floor is returned and not the highest,
// higher floors can be "cucked" by lower floors.
return floor;
}
@@ -195,14 +163,12 @@ static s32 find_wall_collisions_from_list( struct WallCollisionData *data) {
for( int i = 0; i < count; ++i ) {
surf = loaded_surface_get_at_index(i);
// Do the check normally done in add_surface_to_cell
if( surf->normal.y < -0.01f || surf->normal.y > 0.01f ) continue;
if( surf->normal.x < -0.707f || surf->normal.x > 0.707f ) {
surf->flags |= SURFACE_FLAG_X_PROJECTION;
}
// Exclude a large number of walls immediately to optimize.
if (y < surf->lowerY || y > surf->upperY) {
continue;
@@ -272,33 +238,6 @@ static s32 find_wall_collisions_from_list( struct WallCollisionData *data) {
}
}
// Determine if checking for the camera or not.
// if (gCheckingSurfaceCollisionsForCamera) {
// if (surf->flags & SURFACE_FLAG_NO_CAM_COLLISION) {
// continue;
// }
// } else {
// // Ignore camera only surfaces.
// if (surf->type == SURFACE_CAMERA_BOUNDARY) {
// continue;
// }
// // If an object can pass through a vanish cap wall, pass through.
// if (surf->type == SURFACE_VANISH_CAP_WALLS) {
// // If an object can pass through a vanish cap wall, pass through.
// if (gCurrentObject != NULL
// && (gCurrentObject->activeFlags & ACTIVE_FLAG_MOVE_THROUGH_GRATE)) {
// continue;
// }
// // If Mario has a vanish cap, pass through the vanish cap wall.
// if (gCurrentObject != NULL && gCurrentObject == gMarioObject
// && (gMarioState->flags & MARIO_VANISH_CAP)) {
// continue;
// }
// }
// }
//! (Wall Overlaps) Because this doesn't update the x and z local variables,
// multiple walls can push mario more than is required.
data->x += surf->normal.x * (radius - offset);
@@ -317,10 +256,6 @@ static s32 find_wall_collisions_from_list( struct WallCollisionData *data) {
return numCols;
}
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius)
{
struct WallCollisionData collision;
+2 -3
View File
@@ -466,7 +466,6 @@ Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4
* (such as in the mirror room) results in a faster and desynced punch / kick animation.
*/
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
static s16 sMarioAttackAnimCounter = 0;
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next;
struct MarioBodyState *bodyState = &gBodyStates[0];
@@ -474,9 +473,9 @@ Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED
if (callContext == GEO_CONTEXT_RENDER) {
scaleNode->scale = 1.0f;
if (asGenerated->parameter == bodyState->punchState >> 6) {
if (sMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0) {
if (g_state->msMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0) {
bodyState->punchState -= 1;
sMarioAttackAnimCounter = gAreaUpdateCounter;
g_state->msMarioAttackAnimCounter = gAreaUpdateCounter;
}
scaleNode->scale =
gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)]
+1
View File
@@ -21,6 +21,7 @@ struct GlobalState
// mario_misc.c
struct MarioBodyState mgBodyStates[2];
s16 msMarioAttackAnimCounter;
// rendering_graph_node.c
u16 mgAreaUpdateCounter;
+8 -24
View File
@@ -76,28 +76,6 @@ static void free_area( struct Area *area )
free( area );
}
static void update_terrain_objects( void )
{
// TODO, this is way more expensive than it needs to be.
update_dynamic_surface_list();
}
static void update_non_terrain_objects( void )
{
bhv_mario_update();
}
static void update_objects( void )
{
update_mario_platform();
//clear_dynamic_surfaces();
update_terrain_objects();
apply_mario_platform_displacement();
//detect_object_collisions();
update_non_terrain_objects();
}
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
{
if( s_init_global )
@@ -204,7 +182,9 @@ SM64_LIB_FN void sm64_mario_tick( uint32_t marioId, const struct SM64MarioInputs
gController.stickY = 64.0f * inputs->stickY;
gController.stickMag = sqrtf( gController.stickX*gController.stickX + gController.stickY*gController.stickY );
update_objects();
update_mario_platform();
apply_mario_platform_displacement();
bhv_mario_update();
gfx_adapter_bind_output_buffers( outBuffers );
@@ -238,15 +218,19 @@ SM64_LIB_FN void sm64_mario_delete( uint32_t marioId )
SM64_LIB_FN uint32_t sm64_surface_object_create( const struct SM64SurfaceObject *surfaceObject )
{
return surfaces_load_object( surfaceObject );
uint32_t id = surfaces_load_object( surfaceObject );
update_dynamic_surface_list();
return id;
}
SM64_LIB_FN void sm64_surface_object_move( uint32_t objectId, const struct SM64ObjectTransform *transform )
{
surface_object_update_transform( objectId, transform );
update_dynamic_surface_list();
}
SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId )
{
surfaces_unload_object( objectId );
update_dynamic_surface_list();
}
+2
View File
@@ -203,6 +203,8 @@ static void engine_surface_from_lib_surface( struct Surface *surface, const stru
void update_dynamic_surface_list( void )
{
// TODO, this is way more expensive than it needs to be.
free( s_dynamic_surface_list );
s_dynamic_surface_count = 0;
s_dynamic_surface_list = NULL;