mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-24 21:15:12 +00:00
Refactored actor geos in DynOS
This commit is contained in:
parent
18835a588a
commit
8b4a5f6d6d
10 changed files with 1387 additions and 1366 deletions
|
@ -688,13 +688,6 @@ s32 DynOS_String_Width(const u8 *aStr64);
|
|||
// Geo
|
||||
//
|
||||
|
||||
void DynOS_Geo_AddActorCustom(const SysPath &aPackFolder, const char *aActorName);
|
||||
const void *DynOS_Geo_GetActorLayoutFromName(const char *aActorName);
|
||||
bool DynOS_Geo_IsCustomActor(s32 aIndex);
|
||||
s32 DynOS_Geo_GetActorCount();
|
||||
const char *DynOS_Geo_GetActorName(s32 aIndex);
|
||||
const void *DynOS_Geo_GetActorLayout(s32 aIndex);
|
||||
s32 DynOS_Geo_GetActorIndex(const void *aGeoLayout);
|
||||
void *DynOS_Geo_GetGraphNode(const void *aGeoLayout, bool aKeepInMemory);
|
||||
|
||||
//
|
||||
|
@ -730,6 +723,11 @@ const char *DynOS_Warp_GetParamName(s32 aLevel, s32 aIndex);
|
|||
|
||||
const void* DynOS_Builtin_ScriptPtr_GetFromName(const char* aDataName);
|
||||
const char* DynOS_Builtin_ScriptPtr_GetFromData(const void* aData);
|
||||
const GeoLayout* DynOS_Builtin_Actor_GetFromName(const char* aDataName);
|
||||
const char* DynOS_Builtin_Actor_GetFromData(const GeoLayout* aData);
|
||||
const GeoLayout* DynOS_Builtin_Actor_GetFromIndex(s32 aIndex);
|
||||
const char* DynOS_Builtin_Actor_GetNameFromIndex(s32 aIndex);
|
||||
s32 DynOS_Builtin_Actor_GetCount();
|
||||
const GeoLayout* DynOS_Builtin_LvlGeo_GetFromName(const char* aDataName);
|
||||
const char* DynOS_Builtin_LvlGeo_GetFromData(const GeoLayout* aData);
|
||||
const Collision* DynOS_Builtin_LvlCol_GetFromName(const char* aDataName);
|
||||
|
@ -740,6 +738,18 @@ const void* DynOS_Builtin_Func_GetFromName(const char* aDataName);
|
|||
const void* DynOS_Builtin_Func_GetFromIndex(s32 aIndex);
|
||||
s32 DynOS_Builtin_Func_GetIndexFromData(const void* aData);
|
||||
|
||||
//
|
||||
// Actor Manager
|
||||
//
|
||||
|
||||
void DynOS_Actor_AddCustom(const SysPath &aPackFolder, const char *aActorName);
|
||||
s32 DynOS_Actor_GetCount();
|
||||
const char *DynOS_Actor_GetName(s32 aIndex);
|
||||
const void *DynOS_Actor_GetLayoutFromIndex(s32 aIndex);
|
||||
const void *DynOS_Actor_GetLayoutFromName(const char *aActorName);
|
||||
s32 DynOS_Actor_GetIndex(const void *aGeoLayout);
|
||||
bool DynOS_Actor_IsCustom(s32 aIndex);
|
||||
|
||||
//
|
||||
// Lvl Manager
|
||||
//
|
||||
|
|
|
@ -256,7 +256,7 @@ void DynOS_Actor_GeneratePack(const SysPath &aPackFolder) {
|
|||
bool foundActor = false;
|
||||
for (s32 i = prevGeoLayoutCount; i < geoLayoutCount; i++) {
|
||||
String _GeoRootName = _GfxData->mGeoLayouts[i]->mName;
|
||||
const void* actor = DynOS_Geo_GetActorLayoutFromName(_GeoRootName.begin());
|
||||
const void* actor = DynOS_Actor_GetLayoutFromName(_GeoRootName.begin());
|
||||
if (actor != NULL) {
|
||||
foundActor = true;
|
||||
_GfxData->mGenerateGeoLayouts.Add(_GfxData->mGeoLayouts[i]);
|
||||
|
|
|
@ -1459,12 +1459,9 @@ static LevelScript ParseLevelScriptSymbolArgInternal(GfxData* aGfxData, DataNode
|
|||
}
|
||||
|
||||
// Built-in actors
|
||||
s32 actorCount = DynOS_Geo_GetActorCount();
|
||||
for (s32 i = 0; i < actorCount; i++) {
|
||||
if (DynOS_Geo_IsCustomActor(i)) { break; }
|
||||
if (!strcmp(_Arg.begin(), DynOS_Geo_GetActorName(i))) {
|
||||
return (LevelScript)DynOS_Geo_GetActorLayout(i);
|
||||
}
|
||||
auto builtinActor = DynOS_Builtin_Actor_GetFromName(_Arg.begin());
|
||||
if (builtinActor != NULL) {
|
||||
return (LevelScript)builtinActor;
|
||||
}
|
||||
|
||||
// Built-in Lvl Geos
|
||||
|
|
|
@ -120,12 +120,9 @@ static PointerData GetDataFromPointer(const void* aPtr, GfxData* aGfxData) {
|
|||
}
|
||||
|
||||
// Built-in Actors
|
||||
s32 actorCount = DynOS_Geo_GetActorCount();
|
||||
for (s32 i = 0; i < actorCount; i++) {
|
||||
if (DynOS_Geo_IsCustomActor(i)) { break; }
|
||||
if (aPtr == DynOS_Geo_GetActorLayout(i)) {
|
||||
return { DynOS_Geo_GetActorName(i), 0 };
|
||||
}
|
||||
auto builtinActor = DynOS_Builtin_Actor_GetFromData((const GeoLayout*)aPtr);
|
||||
if (builtinActor != NULL) {
|
||||
return { builtinActor, 0 };
|
||||
}
|
||||
|
||||
// Built-in Lvl Geos
|
||||
|
@ -362,12 +359,9 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
|||
}
|
||||
|
||||
// Built-in Actors
|
||||
s32 actorCount = DynOS_Geo_GetActorCount();
|
||||
for (s32 i = 0; i < actorCount; i++) {
|
||||
if (DynOS_Geo_IsCustomActor(i)) { break; }
|
||||
if (!strcmp(aPtrName.begin(), DynOS_Geo_GetActorName(i))) {
|
||||
return (void*)DynOS_Geo_GetActorLayout(i);
|
||||
}
|
||||
auto builtinActor = DynOS_Builtin_Actor_GetFromName(aPtrName.begin());
|
||||
if (builtinActor != NULL) {
|
||||
return (void*)builtinActor;
|
||||
}
|
||||
|
||||
// Built-in Lvl Geos
|
||||
|
|
|
@ -81,11 +81,11 @@ void dynos_generate_packs(const char* directory) {
|
|||
// -- geos -- //
|
||||
|
||||
void dynos_add_actor_custom(const char *modPath, const char* geoName) {
|
||||
DynOS_Geo_AddActorCustom(modPath, geoName);
|
||||
DynOS_Actor_AddCustom(modPath, geoName);
|
||||
}
|
||||
|
||||
const void* dynos_geolayout_get(const char *name) {
|
||||
return DynOS_Geo_GetActorLayoutFromName(name);
|
||||
return DynOS_Actor_GetLayoutFromName(name);
|
||||
}
|
||||
|
||||
// -- collisions -- //
|
||||
|
|
|
@ -74,11 +74,11 @@ Array<String> DynOS_Gfx_Init() {
|
|||
|
||||
// Alloc and init the actors gfx list
|
||||
Array<ActorGfx> &pActorGfxList = DynOS_Gfx_GetActorList();
|
||||
pActorGfxList.Resize(DynOS_Geo_GetActorCount());
|
||||
for (s32 i = 0; i != DynOS_Geo_GetActorCount(); ++i) {
|
||||
pActorGfxList.Resize(DynOS_Actor_GetCount());
|
||||
for (s32 i = 0; i != DynOS_Actor_GetCount(); ++i) {
|
||||
pActorGfxList[i].mPackIndex = -1;
|
||||
pActorGfxList[i].mGfxData = NULL;
|
||||
pActorGfxList[i].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(DynOS_Geo_GetActorLayout(i), false);
|
||||
pActorGfxList[i].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(DynOS_Actor_GetLayoutFromIndex(i), false);
|
||||
}
|
||||
|
||||
// Scan the DynOS packs folder
|
||||
|
|
|
@ -52,7 +52,7 @@ void DynOS_Gfx_SwapAnimations(void *aPtr) {
|
|||
pDefaultAnimation = _Object->header.gfx.animInfo.curAnim;
|
||||
|
||||
// Actor index
|
||||
s32 _ActorIndex = DynOS_Geo_GetActorIndex(_Object->header.gfx.sharedChild->georef);
|
||||
s32 _ActorIndex = DynOS_Actor_GetIndex(_Object->header.gfx.sharedChild->georef);
|
||||
if (_ActorIndex == -1) {
|
||||
return;
|
||||
}
|
||||
|
@ -101,68 +101,66 @@ void DynOS_Gfx_SwapAnimations(void *aPtr) {
|
|||
//
|
||||
|
||||
void DynOS_Gfx_Update() {
|
||||
if (gObjectLists) {
|
||||
if (!gObjectLists) { return; }
|
||||
|
||||
// Check packs
|
||||
Array<bool> &_Enabled = DynOS_Gfx_GetPacksEnabled();
|
||||
const Array<PackData *> &pDynosPacks = DynOS_Gfx_GetPacks();
|
||||
while (_Enabled.Count() < pDynosPacks.Count()) {
|
||||
_Enabled.Add(true);
|
||||
}
|
||||
// Check packs
|
||||
Array<bool> &_Enabled = DynOS_Gfx_GetPacksEnabled();
|
||||
const Array<PackData *> &pDynosPacks = DynOS_Gfx_GetPacks();
|
||||
while (_Enabled.Count() < pDynosPacks.Count()) {
|
||||
_Enabled.Add(true);
|
||||
}
|
||||
|
||||
// Loop through all object lists
|
||||
for (s32 list : { OBJ_LIST_PLAYER, OBJ_LIST_DESTRUCTIVE, OBJ_LIST_GENACTOR, OBJ_LIST_PUSHABLE, OBJ_LIST_LEVEL, OBJ_LIST_DEFAULT, OBJ_LIST_SURFACE, OBJ_LIST_POLELIKE, OBJ_LIST_UNIMPORTANT }) {
|
||||
struct Object *_Head = (struct Object *) &gObjectLists[list];
|
||||
for (struct Object *_Object = (struct Object *) _Head->header.next; _Object != _Head; _Object = (struct Object *) _Object->header.next) {
|
||||
if (_Object->header.gfx.sharedChild) {
|
||||
// Loop through all object lists
|
||||
for (s32 list : { OBJ_LIST_PLAYER, OBJ_LIST_DESTRUCTIVE, OBJ_LIST_GENACTOR, OBJ_LIST_PUSHABLE, OBJ_LIST_LEVEL, OBJ_LIST_DEFAULT, OBJ_LIST_SURFACE, OBJ_LIST_POLELIKE, OBJ_LIST_UNIMPORTANT }) {
|
||||
struct Object *_Head = (struct Object *) &gObjectLists[list];
|
||||
for (struct Object *_Object = (struct Object *) _Head->header.next; _Object != _Head; _Object = (struct Object *) _Object->header.next) {
|
||||
// Make sure it's non-null
|
||||
if (!_Object->header.gfx.sharedChild) { continue; }
|
||||
|
||||
// Actor index
|
||||
s32 _ActorIndex = DynOS_Geo_GetActorIndex(_Object->header.gfx.sharedChild->georef);
|
||||
if (_ActorIndex != -1) {
|
||||
// Actor index
|
||||
s32 _ActorIndex = DynOS_Actor_GetIndex(_Object->header.gfx.sharedChild->georef);
|
||||
if (_ActorIndex == -1) { continue; }
|
||||
|
||||
// Replace the object's model and animations
|
||||
ActorGfx *_ActorGfx = &DynOS_Gfx_GetActorList()[_ActorIndex];
|
||||
// Replace the object's model and animations
|
||||
ActorGfx *_ActorGfx = &DynOS_Gfx_GetActorList()[_ActorIndex];
|
||||
|
||||
// Check for disabled downloaded models
|
||||
if (configDisableDownloadedModels && _ActorGfx->mPackIndex == 99) {
|
||||
extern const GeoLayout error_model_geo[];
|
||||
s32 actorIndex = DynOS_Geo_IsCustomActor(_ActorIndex) ? DynOS_Geo_GetActorIndex(error_model_geo) : _ActorIndex;
|
||||
const void* geoLayout = DynOS_Geo_GetActorLayout(actorIndex);
|
||||
_ActorGfx->mPackIndex = -1;
|
||||
_ActorGfx->mGfxData = NULL;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true);
|
||||
}
|
||||
// Check for disabled downloaded models
|
||||
if (configDisableDownloadedModels && _ActorGfx->mPackIndex == 99) {
|
||||
extern const GeoLayout error_model_geo[];
|
||||
s32 actorIndex = DynOS_Actor_IsCustom(_ActorIndex) ? DynOS_Actor_GetIndex(error_model_geo) : _ActorIndex;
|
||||
const void* geoLayout = DynOS_Actor_GetLayoutFromIndex(actorIndex);
|
||||
_ActorGfx->mPackIndex = -1;
|
||||
_ActorGfx->mGfxData = NULL;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true);
|
||||
}
|
||||
|
||||
for (s32 i = 0; i != pDynosPacks.Count(); ++i) {
|
||||
// If enabled and no pack is selected
|
||||
// load the pack's model and replace the default actor's model
|
||||
if (_Enabled[i] && _ActorGfx->mPackIndex == -1) {
|
||||
for (s32 i = 0; i != pDynosPacks.Count(); ++i) {
|
||||
// If enabled and no pack is selected
|
||||
// load the pack's model and replace the default actor's model
|
||||
if (_Enabled[i] && _ActorGfx->mPackIndex == -1) {
|
||||
|
||||
// Load Gfx data from binary
|
||||
GfxData *_GfxData = DynOS_Actor_LoadFromBinary(pDynosPacks[i]->mPath, DynOS_Geo_GetActorName(_ActorIndex));
|
||||
if (_GfxData) {
|
||||
_ActorGfx->mPackIndex = i;
|
||||
_ActorGfx->mGfxData = _GfxData;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode((*(_GfxData->mGeoLayouts.end() - 1))->mData, true);
|
||||
_ActorGfx->mGraphNode->georef = DynOS_Geo_GetActorLayout(_ActorIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If disabled and this pack is the one selected
|
||||
// replace the actor's model by the default one
|
||||
else if (!_Enabled[i] && _ActorGfx->mPackIndex == i) {
|
||||
_ActorGfx->mPackIndex = -1;
|
||||
_ActorGfx->mGfxData = NULL;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(DynOS_Geo_GetActorLayout(_ActorIndex), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Update object
|
||||
_Object->header.gfx.sharedChild = _ActorGfx->mGraphNode;
|
||||
// Load Gfx data from binary
|
||||
GfxData *_GfxData = DynOS_Actor_LoadFromBinary(pDynosPacks[i]->mPath, DynOS_Actor_GetName(_ActorIndex));
|
||||
if (_GfxData) {
|
||||
_ActorGfx->mPackIndex = i;
|
||||
_ActorGfx->mGfxData = _GfxData;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode((*(_GfxData->mGeoLayouts.end() - 1))->mData, true);
|
||||
_ActorGfx->mGraphNode->georef = DynOS_Actor_GetLayoutFromIndex(_ActorIndex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If disabled and this pack is the one selected
|
||||
// replace the actor's model by the default one
|
||||
else if (!_Enabled[i] && _ActorGfx->mPackIndex == i) {
|
||||
_ActorGfx->mPackIndex = -1;
|
||||
_ActorGfx->mGfxData = NULL;
|
||||
_ActorGfx->mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(DynOS_Actor_GetLayoutFromIndex(_ActorIndex), true);
|
||||
}
|
||||
}
|
||||
|
||||
// Update object
|
||||
_Object->header.gfx.sharedChild = _ActorGfx->mGraphNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
104
data/dynos_mgr_actor.cpp
Normal file
104
data/dynos_mgr_actor.cpp
Normal file
|
@ -0,0 +1,104 @@
|
|||
#include "dynos.cpp.h"
|
||||
|
||||
static Array<Pair<const char*, void *>> sDynosCustomActors;
|
||||
|
||||
// TODO: the cleanup/refactor didn't really go as planned.
|
||||
// clean up the actor management code more
|
||||
|
||||
void DynOS_Actor_AddCustom(const SysPath &aPackFolder, const char *aActorName) {
|
||||
// check for duplicates
|
||||
bool isUnique = true;
|
||||
s32 foundIndex = -1;
|
||||
for (s32 i = 0; i < DynOS_Actor_GetCount(); ++i) {
|
||||
if (!strcmp(DynOS_Actor_GetName(i), aActorName)) {
|
||||
isUnique = false;
|
||||
foundIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u16 actorLen = strlen(aActorName);
|
||||
char* actorName = (char*)calloc(1, sizeof(char) * (actorLen + 1));
|
||||
strcpy(actorName, aActorName);
|
||||
|
||||
GfxData *_GfxData = DynOS_Actor_LoadFromBinary(aPackFolder, actorName);
|
||||
if (!_GfxData) {
|
||||
free(actorName);
|
||||
return;
|
||||
}
|
||||
|
||||
void* geoLayout = (*(_GfxData->mGeoLayouts.end() - 1))->mData;
|
||||
if (!geoLayout) {
|
||||
free(actorName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to custom actors
|
||||
s32 index = DynOS_Actor_GetCount();
|
||||
if (isUnique) {
|
||||
sDynosCustomActors.Add({ actorName, geoLayout });
|
||||
} else {
|
||||
index = foundIndex;
|
||||
free(actorName);
|
||||
}
|
||||
|
||||
// Alloc and init the actors gfx list
|
||||
Array<ActorGfx> &pActorGfxList = DynOS_Gfx_GetActorList();
|
||||
pActorGfxList.Resize(DynOS_Actor_GetCount());
|
||||
pActorGfxList[index].mPackIndex = 99;
|
||||
pActorGfxList[index].mGfxData = _GfxData;
|
||||
pActorGfxList[index].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true);
|
||||
}
|
||||
|
||||
s32 DynOS_Actor_GetCount() {
|
||||
return (s32) DynOS_Builtin_Actor_GetCount() + sDynosCustomActors.Count();
|
||||
}
|
||||
|
||||
const char *DynOS_Actor_GetName(s32 aIndex) {
|
||||
s32 builtinCount = DynOS_Builtin_Actor_GetCount();
|
||||
if (aIndex < builtinCount) { return (const char *) DynOS_Builtin_Actor_GetNameFromIndex(aIndex); }
|
||||
return sDynosCustomActors[aIndex - builtinCount].first;
|
||||
}
|
||||
|
||||
const void *DynOS_Actor_GetLayoutFromIndex(s32 aIndex) {
|
||||
s32 builtinCount = DynOS_Builtin_Actor_GetCount();
|
||||
if (aIndex < builtinCount) { return (const void *) DynOS_Builtin_Actor_GetFromIndex(aIndex); }
|
||||
return sDynosCustomActors[aIndex - builtinCount].second;
|
||||
}
|
||||
|
||||
const void *DynOS_Actor_GetLayoutFromName(const char *aActorName) {
|
||||
if (aActorName == NULL) { return NULL; }
|
||||
|
||||
// check levels
|
||||
auto& levelsArray = DynOS_Lvl_GetArray();
|
||||
for (auto& lvl : levelsArray) {
|
||||
for (auto& geo : lvl.second->mGeoLayouts) {
|
||||
if (geo->mName == aActorName) {
|
||||
return geo->mData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check actors
|
||||
for (s32 i = 0; i < DynOS_Actor_GetCount(); ++i) {
|
||||
if (!strcmp(DynOS_Actor_GetName(i), aActorName)) {
|
||||
return DynOS_Actor_GetLayoutFromIndex(i);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32 DynOS_Actor_GetIndex(const void *aGeoLayout) {
|
||||
for (s32 i = 0; i < DynOS_Actor_GetCount(); ++i) {
|
||||
if (DynOS_Actor_GetLayoutFromIndex(i) == aGeoLayout) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool DynOS_Actor_IsCustom(s32 aIndex) {
|
||||
s32 builtinCount = DynOS_Builtin_Actor_GetCount();
|
||||
return aIndex >= builtinCount;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -16,29 +16,6 @@ extern "C" {
|
|||
#include "game/behavior_actions.h"
|
||||
#include "game/rendering_graph_node.h"
|
||||
#include "game/skybox.h"
|
||||
|
||||
#include "actors/common0.h"
|
||||
#include "actors/common1.h"
|
||||
#include "actors/group0.h"
|
||||
#include "actors/group1.h"
|
||||
#include "actors/group2.h"
|
||||
#include "actors/group3.h"
|
||||
#include "actors/group4.h"
|
||||
#include "actors/group5.h"
|
||||
#include "actors/group6.h"
|
||||
#include "actors/group7.h"
|
||||
#include "actors/group8.h"
|
||||
#include "actors/group9.h"
|
||||
#include "actors/group10.h"
|
||||
#include "actors/group11.h"
|
||||
#include "actors/group12.h"
|
||||
#include "actors/group13.h"
|
||||
#include "actors/group14.h"
|
||||
#include "actors/group15.h"
|
||||
#include "actors/group16.h"
|
||||
#include "actors/group17.h"
|
||||
#include "actors/custom0.h"
|
||||
#include "actors/zcustom0.h"
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -135,292 +112,6 @@ s32 DynOS_String_Width(const u8 *aStr64) {
|
|||
return _Width;
|
||||
}
|
||||
|
||||
//
|
||||
// Actors
|
||||
//
|
||||
|
||||
// &__Actors()
|
||||
#define define_actor(geo) (const void *) #geo, (const void *) geo
|
||||
static const void *sDynosActors[] = {
|
||||
define_actor(amp_geo),
|
||||
define_actor(birds_geo),
|
||||
define_actor(blargg_geo),
|
||||
define_actor(blue_coin_switch_geo),
|
||||
define_actor(black_bobomb_geo),
|
||||
define_actor(bobomb_buddy_geo),
|
||||
define_actor(boo_geo),
|
||||
define_actor(boo_castle_geo),
|
||||
define_actor(bookend_geo),
|
||||
define_actor(bookend_part_geo),
|
||||
define_actor(bowling_ball_geo),
|
||||
define_actor(bowling_ball_track_geo),
|
||||
define_actor(bowser_geo),
|
||||
define_actor(bowser2_geo),
|
||||
define_actor(bowser_bomb_geo),
|
||||
define_actor(bowser_flames_geo),
|
||||
define_actor(bowser_impact_smoke_geo),
|
||||
define_actor(bowser_1_yellow_sphere_geo),
|
||||
define_actor(invisible_bowser_accessory_geo),
|
||||
define_actor(bowser_key_geo),
|
||||
define_actor(bowser_key_cutscene_geo),
|
||||
define_actor(breakable_box_geo),
|
||||
define_actor(breakable_box_small_geo),
|
||||
define_actor(bub_geo),
|
||||
define_actor(bubba_geo),
|
||||
define_actor(bubble_geo),
|
||||
define_actor(bullet_bill_geo),
|
||||
define_actor(bully_geo),
|
||||
define_actor(bully_boss_geo),
|
||||
define_actor(burn_smoke_geo),
|
||||
define_actor(butterfly_geo),
|
||||
define_actor(cannon_barrel_geo),
|
||||
define_actor(cannon_base_geo),
|
||||
define_actor(cap_switch_geo),
|
||||
define_actor(cartoon_star_geo),
|
||||
define_actor(chain_chomp_geo),
|
||||
define_actor(checkerboard_platform_geo),
|
||||
define_actor(chilly_chief_geo),
|
||||
define_actor(chilly_chief_big_geo),
|
||||
define_actor(chuckya_geo),
|
||||
define_actor(clam_shell_geo),
|
||||
define_actor(yellow_coin_geo),
|
||||
define_actor(yellow_coin_no_shadow_geo),
|
||||
define_actor(blue_coin_geo),
|
||||
define_actor(blue_coin_no_shadow_geo),
|
||||
define_actor(red_coin_geo),
|
||||
define_actor(red_coin_no_shadow_geo),
|
||||
define_actor(dirt_animation_geo),
|
||||
define_actor(dorrie_geo),
|
||||
define_actor(cabin_door_geo),
|
||||
define_actor(castle_door_geo),
|
||||
define_actor(castle_door_0_star_geo),
|
||||
define_actor(castle_door_1_star_geo),
|
||||
define_actor(castle_door_3_stars_geo),
|
||||
define_actor(haunted_door_geo),
|
||||
define_actor(hazy_maze_door_geo),
|
||||
define_actor(metal_door_geo),
|
||||
define_actor(key_door_geo),
|
||||
define_actor(wooden_door_geo),
|
||||
define_actor(enemy_lakitu_geo),
|
||||
define_actor(exclamation_box_geo),
|
||||
define_actor(exclamation_box_outline_geo),
|
||||
define_actor(explosion_geo),
|
||||
define_actor(eyerok_left_hand_geo),
|
||||
define_actor(eyerok_right_hand_geo),
|
||||
define_actor(fish_geo),
|
||||
define_actor(cyan_fish_geo),
|
||||
define_actor(flyguy_geo),
|
||||
define_actor(red_flame_geo),
|
||||
define_actor(red_flame_shadow_geo),
|
||||
define_actor(blue_flame_geo),
|
||||
define_actor(fwoosh_geo),
|
||||
define_actor(goomba_geo),
|
||||
define_actor(haunted_cage_geo),
|
||||
define_actor(haunted_chair_geo),
|
||||
define_actor(heart_geo),
|
||||
define_actor(heave_ho_geo),
|
||||
define_actor(hoot_geo),
|
||||
define_actor(king_bobomb_geo),
|
||||
define_actor(klepto_geo),
|
||||
define_actor(koopa_with_shell_geo),
|
||||
define_actor(koopa_without_shell_geo),
|
||||
define_actor(koopa_flag_geo),
|
||||
define_actor(koopa_shell_geo),
|
||||
define_actor(lakitu_geo),
|
||||
define_actor(mad_piano_geo),
|
||||
define_actor(manta_seg5_geo_05008D14),
|
||||
define_actor(mario_geo),
|
||||
define_actor(marios_cap_geo),
|
||||
define_actor(marios_metal_cap_geo),
|
||||
define_actor(marios_wing_cap_geo),
|
||||
define_actor(marios_winged_metal_cap_geo),
|
||||
define_actor(metal_box_geo),
|
||||
define_actor(metallic_ball_geo),
|
||||
define_actor(mips_geo),
|
||||
define_actor(mist_geo),
|
||||
define_actor(moneybag_geo),
|
||||
define_actor(monty_mole_geo),
|
||||
define_actor(mr_blizzard_geo),
|
||||
define_actor(mr_blizzard_hidden_geo),
|
||||
define_actor(mr_i_geo),
|
||||
define_actor(mr_i_iris_geo),
|
||||
define_actor(mushroom_1up_geo),
|
||||
define_actor(number_geo),
|
||||
define_actor(peach_geo),
|
||||
define_actor(penguin_geo),
|
||||
define_actor(piranha_plant_geo),
|
||||
define_actor(pokey_head_geo),
|
||||
define_actor(pokey_body_part_geo),
|
||||
define_actor(purple_marble_geo),
|
||||
define_actor(purple_switch_geo),
|
||||
define_actor(scuttlebug_geo),
|
||||
define_actor(seaweed_geo),
|
||||
define_actor(skeeter_geo),
|
||||
define_actor(small_key_geo),
|
||||
define_actor(small_water_splash_geo),
|
||||
define_actor(smoke_geo),
|
||||
define_actor(snufit_geo),
|
||||
define_actor(sparkles_geo),
|
||||
define_actor(sparkles_animation_geo),
|
||||
define_actor(spindrift_geo),
|
||||
define_actor(spiny_geo),
|
||||
define_actor(spiny_ball_geo),
|
||||
define_actor(star_geo),
|
||||
define_actor(transparent_star_geo),
|
||||
define_actor(sushi_geo),
|
||||
define_actor(swoop_geo),
|
||||
define_actor(thwomp_geo),
|
||||
define_actor(toad_geo),
|
||||
define_actor(treasure_chest_base_geo),
|
||||
define_actor(treasure_chest_lid_geo),
|
||||
define_actor(bubbly_tree_geo),
|
||||
define_actor(spiky_tree_geo),
|
||||
define_actor(snow_tree_geo),
|
||||
define_actor(palm_tree_geo),
|
||||
define_actor(leaves_geo),
|
||||
define_actor(tweester_geo),
|
||||
define_actor(ukiki_geo),
|
||||
define_actor(unagi_geo),
|
||||
define_actor(warp_pipe_geo),
|
||||
define_actor(water_bomb_geo),
|
||||
define_actor(water_bomb_shadow_geo),
|
||||
define_actor(water_ring_geo),
|
||||
define_actor(water_splash_geo),
|
||||
define_actor(idle_water_wave_geo),
|
||||
define_actor(wave_trail_geo),
|
||||
define_actor(white_particle_geo),
|
||||
define_actor(white_puff_geo),
|
||||
define_actor(whomp_geo),
|
||||
define_actor(wiggler_head_geo),
|
||||
define_actor(wiggler_body_geo),
|
||||
define_actor(wooden_post_geo),
|
||||
define_actor(wooden_signpost_geo),
|
||||
define_actor(yellow_sphere_geo),
|
||||
define_actor(yoshi_geo),
|
||||
define_actor(yoshi_egg_geo),
|
||||
// coop models
|
||||
define_actor(error_model_geo),
|
||||
define_actor(luigi_geo),
|
||||
define_actor(luigis_cap_geo),
|
||||
define_actor(luigis_metal_cap_geo),
|
||||
define_actor(luigis_wing_cap_geo),
|
||||
define_actor(luigis_winged_metal_cap_geo),
|
||||
define_actor(toad_player_geo),
|
||||
define_actor(toads_cap_geo),
|
||||
define_actor(toads_metal_cap_geo),
|
||||
define_actor(toads_wing_cap_geo),
|
||||
define_actor(waluigi_geo),
|
||||
define_actor(waluigis_cap_geo),
|
||||
define_actor(waluigis_metal_cap_geo),
|
||||
define_actor(waluigis_wing_cap_geo),
|
||||
define_actor(waluigis_winged_metal_cap_geo),
|
||||
define_actor(wario_geo),
|
||||
define_actor(warios_cap_geo),
|
||||
define_actor(warios_metal_cap_geo),
|
||||
define_actor(warios_wing_cap_geo),
|
||||
define_actor(warios_winged_metal_cap_geo),
|
||||
};
|
||||
|
||||
static Array<Pair<const char*, void *>> sDynosCustomActors;
|
||||
|
||||
void DynOS_Geo_AddActorCustom(const SysPath &aPackFolder, const char *aActorName) {
|
||||
// check for duplicates
|
||||
bool isUnique = true;
|
||||
s32 foundIndex = -1;
|
||||
for (s32 i = 0; i < DynOS_Geo_GetActorCount(); ++i) {
|
||||
if (!strcmp(DynOS_Geo_GetActorName(i), aActorName)) {
|
||||
isUnique = false;
|
||||
foundIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u16 actorLen = strlen(aActorName);
|
||||
char* actorName = (char*)calloc(1, sizeof(char) * (actorLen + 1));
|
||||
strcpy(actorName, aActorName);
|
||||
|
||||
GfxData *_GfxData = DynOS_Actor_LoadFromBinary(aPackFolder, actorName);
|
||||
if (!_GfxData) {
|
||||
free(actorName);
|
||||
return;
|
||||
}
|
||||
|
||||
void* geoLayout = (*(_GfxData->mGeoLayouts.end() - 1))->mData;
|
||||
if (!geoLayout) {
|
||||
free(actorName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add to custom actors
|
||||
s32 index = DynOS_Geo_GetActorCount();
|
||||
if (isUnique) {
|
||||
sDynosCustomActors.Add({ actorName, geoLayout });
|
||||
} else {
|
||||
index = foundIndex;
|
||||
free(actorName);
|
||||
}
|
||||
|
||||
// Alloc and init the actors gfx list
|
||||
Array<ActorGfx> &pActorGfxList = DynOS_Gfx_GetActorList();
|
||||
pActorGfxList.Resize(DynOS_Geo_GetActorCount());
|
||||
pActorGfxList[index].mPackIndex = 99;
|
||||
pActorGfxList[index].mGfxData = _GfxData;
|
||||
pActorGfxList[index].mGraphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoLayout, true);
|
||||
}
|
||||
|
||||
s32 DynOS_Geo_GetActorCount() {
|
||||
s32 arrayCount = (s32) (sizeof(sDynosActors) / (2 * sizeof(sDynosActors[0])));
|
||||
return (s32) arrayCount + sDynosCustomActors.Count();
|
||||
}
|
||||
|
||||
const char *DynOS_Geo_GetActorName(s32 aIndex) {
|
||||
s32 arrayCount = (s32) (sizeof(sDynosActors) / (2 * sizeof(sDynosActors[0])));
|
||||
if (aIndex < arrayCount) { return (const char *) sDynosActors[2 * aIndex]; }
|
||||
return sDynosCustomActors[aIndex - arrayCount].first;
|
||||
}
|
||||
|
||||
const void *DynOS_Geo_GetActorLayout(s32 aIndex) {
|
||||
s32 arrayCount = (s32) (sizeof(sDynosActors) / (2 * sizeof(sDynosActors[0])));
|
||||
if (aIndex < arrayCount) { return (const void *) sDynosActors[2 * aIndex + 1]; }
|
||||
return sDynosCustomActors[aIndex - arrayCount].second;
|
||||
}
|
||||
|
||||
const void *DynOS_Geo_GetActorLayoutFromName(const char *aActorName) {
|
||||
if (aActorName == NULL) { return NULL; }
|
||||
|
||||
// check levels
|
||||
auto& levelsArray = DynOS_Lvl_GetArray();
|
||||
for (auto& lvl : levelsArray) {
|
||||
for (auto& geo : lvl.second->mGeoLayouts) {
|
||||
if (geo->mName == aActorName) {
|
||||
return geo->mData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check actors
|
||||
for (s32 i = 0; i < DynOS_Geo_GetActorCount(); ++i) {
|
||||
if (!strcmp(DynOS_Geo_GetActorName(i), aActorName)) {
|
||||
return DynOS_Geo_GetActorLayout(i);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32 DynOS_Geo_GetActorIndex(const void *aGeoLayout) {
|
||||
for (s32 i = 0; i < DynOS_Geo_GetActorCount(); ++i) {
|
||||
if (DynOS_Geo_GetActorLayout(i) == aGeoLayout) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool DynOS_Geo_IsCustomActor(s32 aIndex) {
|
||||
s32 arrayCount = (s32) (sizeof(sDynosActors) / (2 * sizeof(sDynosActors[0])));
|
||||
return aIndex >= arrayCount;
|
||||
}
|
||||
|
||||
//
|
||||
// Geo
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue