Only update platforms on change
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
// CUSTOM/PATCH
|
|
||||||
|
|
||||||
#include "../shim.h"
|
#include "../shim.h"
|
||||||
#include "surface_collision.h"
|
#include "surface_collision.h"
|
||||||
#include "../include/surface_terrains.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;
|
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 nx = surf->normal.x;
|
||||||
f32 ny = surf->normal.y;
|
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;
|
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 ) {
|
for( int i = 0; i < count; ++i ) {
|
||||||
surf = loaded_surface_get_at_index(i);
|
surf = loaded_surface_get_at_index(i);
|
||||||
|
|
||||||
|
|
||||||
// Do the check normally done in add_surface_to_cell
|
// Do the check normally done in add_surface_to_cell
|
||||||
if( surf->normal.y <= 0.01f ) continue;
|
if( surf->normal.y <= 0.01f ) continue;
|
||||||
|
|
||||||
|
|
||||||
x1 = surf->vertex1[0];
|
x1 = surf->vertex1[0];
|
||||||
z1 = surf->vertex1[2];
|
z1 = surf->vertex1[2];
|
||||||
x2 = surf->vertex2[0];
|
x2 = surf->vertex2[0];
|
||||||
@@ -133,17 +115,6 @@ static struct Surface *find_floor_from_list( s32 x, s32 y, s32 z, f32 *pheight)
|
|||||||
continue;
|
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;
|
nx = surf->normal.x;
|
||||||
ny = surf->normal.y;
|
ny = surf->normal.y;
|
||||||
nz = surf->normal.z;
|
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;
|
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;
|
return floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,14 +163,12 @@ static s32 find_wall_collisions_from_list( struct WallCollisionData *data) {
|
|||||||
for( int i = 0; i < count; ++i ) {
|
for( int i = 0; i < count; ++i ) {
|
||||||
surf = loaded_surface_get_at_index(i);
|
surf = loaded_surface_get_at_index(i);
|
||||||
|
|
||||||
|
|
||||||
// Do the check normally done in add_surface_to_cell
|
// 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.y < -0.01f || surf->normal.y > 0.01f ) continue;
|
||||||
if( surf->normal.x < -0.707f || surf->normal.x > 0.707f ) {
|
if( surf->normal.x < -0.707f || surf->normal.x > 0.707f ) {
|
||||||
surf->flags |= SURFACE_FLAG_X_PROJECTION;
|
surf->flags |= SURFACE_FLAG_X_PROJECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Exclude a large number of walls immediately to optimize.
|
// Exclude a large number of walls immediately to optimize.
|
||||||
if (y < surf->lowerY || y > surf->upperY) {
|
if (y < surf->lowerY || y > surf->upperY) {
|
||||||
continue;
|
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,
|
//! (Wall Overlaps) Because this doesn't update the x and z local variables,
|
||||||
// multiple walls can push mario more than is required.
|
// multiple walls can push mario more than is required.
|
||||||
data->x += surf->normal.x * (radius - offset);
|
data->x += surf->normal.x * (radius - offset);
|
||||||
@@ -317,10 +256,6 @@ static s32 find_wall_collisions_from_list( struct WallCollisionData *data) {
|
|||||||
return numCols;
|
return numCols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius)
|
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius)
|
||||||
{
|
{
|
||||||
struct WallCollisionData collision;
|
struct WallCollisionData collision;
|
||||||
|
|||||||
@@ -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.
|
* (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) {
|
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 GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
|
||||||
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next;
|
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next;
|
||||||
struct MarioBodyState *bodyState = &gBodyStates[0];
|
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) {
|
if (callContext == GEO_CONTEXT_RENDER) {
|
||||||
scaleNode->scale = 1.0f;
|
scaleNode->scale = 1.0f;
|
||||||
if (asGenerated->parameter == bodyState->punchState >> 6) {
|
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;
|
bodyState->punchState -= 1;
|
||||||
sMarioAttackAnimCounter = gAreaUpdateCounter;
|
g_state->msMarioAttackAnimCounter = gAreaUpdateCounter;
|
||||||
}
|
}
|
||||||
scaleNode->scale =
|
scaleNode->scale =
|
||||||
gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)]
|
gMarioAttackScaleAnimation[asGenerated->parameter * 6 + (bodyState->punchState & 0x3F)]
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct GlobalState
|
|||||||
|
|
||||||
// mario_misc.c
|
// mario_misc.c
|
||||||
struct MarioBodyState mgBodyStates[2];
|
struct MarioBodyState mgBodyStates[2];
|
||||||
|
s16 msMarioAttackAnimCounter;
|
||||||
|
|
||||||
// rendering_graph_node.c
|
// rendering_graph_node.c
|
||||||
u16 mgAreaUpdateCounter;
|
u16 mgAreaUpdateCounter;
|
||||||
|
|||||||
+8
-24
@@ -76,28 +76,6 @@ static void free_area( struct Area *area )
|
|||||||
free( 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 )
|
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
||||||
{
|
{
|
||||||
if( s_init_global )
|
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.stickY = 64.0f * inputs->stickY;
|
||||||
gController.stickMag = sqrtf( gController.stickX*gController.stickX + gController.stickY*gController.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 );
|
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 )
|
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 )
|
SM64_LIB_FN void sm64_surface_object_move( uint32_t objectId, const struct SM64ObjectTransform *transform )
|
||||||
{
|
{
|
||||||
surface_object_update_transform( objectId, transform );
|
surface_object_update_transform( objectId, transform );
|
||||||
|
update_dynamic_surface_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId )
|
SM64_LIB_FN void sm64_surface_object_delete( uint32_t objectId )
|
||||||
{
|
{
|
||||||
surfaces_unload_object( objectId );
|
surfaces_unload_object( objectId );
|
||||||
|
update_dynamic_surface_list();
|
||||||
}
|
}
|
||||||
@@ -203,6 +203,8 @@ static void engine_surface_from_lib_surface( struct Surface *surface, const stru
|
|||||||
|
|
||||||
void update_dynamic_surface_list( void )
|
void update_dynamic_surface_list( void )
|
||||||
{
|
{
|
||||||
|
// TODO, this is way more expensive than it needs to be.
|
||||||
|
|
||||||
free( s_dynamic_surface_list );
|
free( s_dynamic_surface_list );
|
||||||
s_dynamic_surface_count = 0;
|
s_dynamic_surface_count = 0;
|
||||||
s_dynamic_surface_list = NULL;
|
s_dynamic_surface_list = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user