mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-23 18:42:21 +00:00
model pool fix
better fix than 1bfe9d509c
just checks the level pool for session models
This commit is contained in:
parent
56577a4a20
commit
7dc31e3780
3 changed files with 47 additions and 36 deletions
|
|
@ -62,6 +62,30 @@ void DynOS_Model_Dump() {
|
|||
}
|
||||
}
|
||||
|
||||
static struct GraphNode *DynOS_Model_CheckMap(int index, u32* aId, void* aAsset, bool aDeDuplicate) {
|
||||
auto& map = sAssetMap[index];
|
||||
if (aDeDuplicate) {
|
||||
auto it = map.find(aAsset);
|
||||
if (it != map.end()) {
|
||||
auto& found = it->second;
|
||||
|
||||
if (index != MODEL_POOL_PERMANENT) {
|
||||
if (*aId && *aId != found.id) {
|
||||
sOverwriteMap[*aId] = found.id;
|
||||
}
|
||||
*aId = found.id;
|
||||
return found.graphNode;
|
||||
}
|
||||
|
||||
if (!*aId || *aId == found.id) {
|
||||
if (!*aId) { *aId = found.id; }
|
||||
return found.graphNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct GraphNode* DynOS_Model_LoadCommonInternal(u32* aId, enum ModelPool aModelPool, void* aAsset, u8 aLayer, struct GraphNode* aGraphNode, bool aDeDuplicate, enum ModelLoadType mlt) {
|
||||
// sanity check pool
|
||||
if (aModelPool >= MODEL_POOL_MAX) { return NULL; }
|
||||
|
|
@ -71,32 +95,20 @@ static struct GraphNode* DynOS_Model_LoadCommonInternal(u32* aId, enum ModelPool
|
|||
sModelPools[aModelPool] = dynamic_pool_init();
|
||||
}
|
||||
|
||||
// check perm map
|
||||
auto& permMap = sAssetMap[MODEL_POOL_PERMANENT];
|
||||
if (aDeDuplicate && permMap.count(aAsset)) {
|
||||
auto& found = permMap[aAsset];
|
||||
if (*aId && *aId == found.id) {
|
||||
return found.graphNode;
|
||||
}
|
||||
if (*aId == 0) {
|
||||
*aId = found.id;
|
||||
return found.graphNode;
|
||||
}
|
||||
// check maps, permanent pool is always checked
|
||||
struct GraphNode *node = NULL;
|
||||
#define CHECK_POOL(pool) if (node = DynOS_Model_CheckMap(pool, aId, aAsset, aDeDuplicate)) { return node; }
|
||||
CHECK_POOL(MODEL_POOL_PERMANENT);
|
||||
if (aModelPool == MODEL_POOL_SESSION) {
|
||||
CHECK_POOL(MODEL_POOL_SESSION);
|
||||
CHECK_POOL(MODEL_POOL_LEVEL);
|
||||
}
|
||||
|
||||
// check map
|
||||
auto& map = sAssetMap[aModelPool];
|
||||
if (aDeDuplicate && map.count(aAsset)) {
|
||||
auto& found = map[aAsset];
|
||||
if (*aId && *aId != found.id) {
|
||||
sOverwriteMap[*aId] = found.id;
|
||||
}
|
||||
*aId = found.id;
|
||||
return found.graphNode;
|
||||
if (aModelPool == MODEL_POOL_LEVEL) {
|
||||
CHECK_POOL(MODEL_POOL_LEVEL);
|
||||
}
|
||||
|
||||
// load geo
|
||||
struct GraphNode* node = NULL;
|
||||
auto& map = sAssetMap[aModelPool];
|
||||
switch (mlt) {
|
||||
case MLT_GEO:
|
||||
node = process_geo_layout(sModelPools[aModelPool], aAsset);
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ s16 obj_turn_toward_object(struct Object *obj, struct Object *target, s16 angleI
|
|||
|
||||
void obj_set_parent_relative_pos(struct Object *obj, s16 relX, s16 relY, s16 relZ) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->oParentRelativePosX = relX;
|
||||
obj->oParentRelativePosY = relY;
|
||||
obj->oParentRelativePosZ = relZ;
|
||||
|
|
@ -542,7 +542,7 @@ void obj_set_parent_relative_pos(struct Object *obj, s16 relX, s16 relY, s16 rel
|
|||
|
||||
void obj_set_pos(struct Object *obj, s16 x, s16 y, s16 z) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->oPosX = x;
|
||||
obj->oPosY = y;
|
||||
obj->oPosZ = z;
|
||||
|
|
@ -550,7 +550,7 @@ void obj_set_pos(struct Object *obj, s16 x, s16 y, s16 z) {
|
|||
|
||||
void obj_set_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->oFaceAnglePitch = pitch;
|
||||
obj->oFaceAngleYaw = yaw;
|
||||
obj->oFaceAngleRoll = roll;
|
||||
|
|
@ -562,7 +562,7 @@ void obj_set_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
|||
|
||||
void obj_set_move_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->oMoveAnglePitch = pitch;
|
||||
obj->oMoveAngleYaw = yaw;
|
||||
obj->oMoveAngleRoll = roll;
|
||||
|
|
@ -570,7 +570,7 @@ void obj_set_move_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
|||
|
||||
void obj_set_face_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->oFaceAnglePitch = pitch;
|
||||
obj->oFaceAngleYaw = yaw;
|
||||
obj->oFaceAngleRoll = roll;
|
||||
|
|
@ -578,7 +578,7 @@ void obj_set_face_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
|||
|
||||
void obj_set_gfx_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->header.gfx.angle[0] = pitch;
|
||||
obj->header.gfx.angle[1] = yaw;
|
||||
obj->header.gfx.angle[2] = roll;
|
||||
|
|
@ -586,7 +586,7 @@ void obj_set_gfx_angle(struct Object *obj, s16 pitch, s16 yaw, s16 roll) {
|
|||
|
||||
void obj_set_gfx_pos(struct Object *obj, f32 x, f32 y, f32 z) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->header.gfx.pos[0] = x;
|
||||
obj->header.gfx.pos[1] = y;
|
||||
obj->header.gfx.pos[2] = z;
|
||||
|
|
@ -594,7 +594,7 @@ void obj_set_gfx_pos(struct Object *obj, f32 x, f32 y, f32 z) {
|
|||
|
||||
void obj_set_gfx_scale(struct Object *obj, f32 x, f32 y, f32 z) {
|
||||
if (obj == NULL) { return; }
|
||||
|
||||
|
||||
obj->header.gfx.scale[0] = x;
|
||||
obj->header.gfx.scale[1] = y;
|
||||
obj->header.gfx.scale[2] = z;
|
||||
|
|
@ -1970,14 +1970,14 @@ void cur_obj_set_billboard_if_vanilla_cam(void) {
|
|||
|
||||
void obj_set_hitbox_radius_and_height(struct Object *o, f32 radius, f32 height) {
|
||||
if (o == NULL) { return; }
|
||||
|
||||
|
||||
o->hitboxRadius = radius;
|
||||
o->hitboxHeight = height;
|
||||
}
|
||||
|
||||
void obj_set_hurtbox_radius_and_height(struct Object *o, f32 radius, f32 height) {
|
||||
if (o == NULL) { return; }
|
||||
|
||||
|
||||
o->hurtboxRadius = radius;
|
||||
o->hurtboxHeight = height;
|
||||
}
|
||||
|
|
@ -2548,7 +2548,7 @@ void cur_obj_spawn_particles(struct SpawnParticlesInfo *info) {
|
|||
if (gPrevFrameObjectCount > (OBJECT_POOL_CAPACITY * 150 / 240) && numParticles > 10) {
|
||||
numParticles = 10;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// We're close to running out of object slots, so don't spawn particles at
|
||||
// all
|
||||
|
|
@ -2745,7 +2745,7 @@ s32 cur_obj_progress_direction_table(void) {
|
|||
if (tableLength < 0 || index < 0 || tableLength >= 150 || index >= tableLength) {
|
||||
ret = table[0];
|
||||
o->oToxBoxMovementStep = 0;
|
||||
LOG_ERROR("Exceeded direction table! tableLength %d, index %d\n", tableLength, index);
|
||||
LOG_ERROR("Exceeded direction table! tableLength %d, index %d", tableLength, index);
|
||||
} else if (table[index] != -1) {
|
||||
ret = table[index];
|
||||
o->oToxBoxMovementStep++;
|
||||
|
|
|
|||
|
|
@ -665,10 +665,9 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
|
|||
gNetworkType = NT_NONE;
|
||||
}
|
||||
|
||||
dynos_model_clear_pool(MODEL_POOL_SESSION);
|
||||
|
||||
if (exiting) { return; }
|
||||
|
||||
dynos_model_clear_pool(MODEL_POOL_SESSION);
|
||||
dynos_model_restore_vanilla_display_lists();
|
||||
|
||||
// reset other stuff
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue