mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Add support for display-list based extended models
This commit is contained in:
parent
1131fb02db
commit
168bd78f47
3 changed files with 15 additions and 9 deletions
|
|
@ -385,7 +385,7 @@ static void level_cmd_load_model_from_dl(void) {
|
||||||
if (val1 < 256) {
|
if (val1 < 256) {
|
||||||
gLoadedGraphNodes[val1] =
|
gLoadedGraphNodes[val1] =
|
||||||
(struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, val2, val3);
|
(struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, val2, val3);
|
||||||
smlua_model_util_remember(val1, val2, val3);
|
smlua_model_util_remember(val1, val2, val3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sCurrentCmd = CMD_NEXT;
|
sCurrentCmd = CMD_NEXT;
|
||||||
|
|
@ -397,7 +397,7 @@ static void level_cmd_load_model_from_geo(void) {
|
||||||
|
|
||||||
if (arg0 < 256) {
|
if (arg0 < 256) {
|
||||||
gLoadedGraphNodes[arg0] = process_geo_layout(sLevelPool, arg1);
|
gLoadedGraphNodes[arg0] = process_geo_layout(sLevelPool, arg1);
|
||||||
smlua_model_util_remember(arg0, LAYER_OPAQUE, arg1);
|
smlua_model_util_remember(arg0, LAYER_OPAQUE, arg1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sCurrentCmd = CMD_NEXT;
|
sCurrentCmd = CMD_NEXT;
|
||||||
|
|
@ -424,7 +424,7 @@ static void level_cmd_23(void) {
|
||||||
// is being stored to the array, so cast the pointer.
|
// is being stored to the array, so cast the pointer.
|
||||||
gLoadedGraphNodes[model] =
|
gLoadedGraphNodes[model] =
|
||||||
(struct GraphNode *) init_graph_node_scale(sLevelPool, 0, arg0H, arg1, arg2.f);
|
(struct GraphNode *) init_graph_node_scale(sLevelPool, 0, arg0H, arg1, arg2.f);
|
||||||
smlua_model_util_remember(model, arg0H, arg1);
|
smlua_model_util_remember(model, arg0H, arg1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sCurrentCmd = CMD_NEXT;
|
sCurrentCmd = CMD_NEXT;
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,12 @@ struct ModelUtilsInfo {
|
||||||
enum ModelExtendedId id;
|
enum ModelExtendedId id;
|
||||||
const void* asset;
|
const void* asset;
|
||||||
u8 layer;
|
u8 layer;
|
||||||
|
bool isDisplayList;
|
||||||
u8 cacheId;
|
u8 cacheId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MODEL_UTIL_GEO(x, y) [x] = { .id = x, .asset = y, .layer = LAYER_OPAQUE, .cacheId = 0xFF }
|
#define MODEL_UTIL_GEO(x, y) [x] = { .id = x, .asset = y, .layer = LAYER_OPAQUE, .isDisplayList = false, .cacheId = 0xFF }
|
||||||
#define MODEL_UTIL_DL(x, y, z) [x] = { .id = x, .asset = y, .layer = z, .cacheId = 0xFF }
|
#define MODEL_UTIL_DL(x, y, z) [x] = { .id = x, .asset = y, .layer = z, .isDisplayList = true, .cacheId = 0xFF }
|
||||||
|
|
||||||
struct ModelUtilsInfo sModels[] = {
|
struct ModelUtilsInfo sModels[] = {
|
||||||
MODEL_UTIL_GEO(E_MODEL_MARIO, mario_geo),
|
MODEL_UTIL_GEO(E_MODEL_MARIO, mario_geo),
|
||||||
|
|
@ -226,11 +227,12 @@ struct ModelUtilsInfo sModels[] = {
|
||||||
|
|
||||||
struct ModelUtilsInfo sCachedAssets[256] = { 0 };
|
struct ModelUtilsInfo sCachedAssets[256] = { 0 };
|
||||||
|
|
||||||
void smlua_model_util_remember(u8 modelId, u8 layer, const void* asset) {
|
void smlua_model_util_remember(u8 modelId, u8 layer, const void* asset, u8 isDisplayList) {
|
||||||
struct ModelUtilsInfo* c = &sCachedAssets[modelId];
|
struct ModelUtilsInfo* c = &sCachedAssets[modelId];
|
||||||
c->id = modelId;
|
c->id = modelId;
|
||||||
c->layer = layer;
|
c->layer = layer;
|
||||||
c->asset = asset;
|
c->asset = asset;
|
||||||
|
c->isDisplayList = isDisplayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void smlua_model_util_clear(void) {
|
void smlua_model_util_clear(void) {
|
||||||
|
|
@ -277,12 +279,16 @@ u8 smlua_model_util_load(enum ModelExtendedId id) {
|
||||||
|
|
||||||
// load
|
// load
|
||||||
struct AllocOnlyPool* pool = alloc_only_pool_init(main_pool_available() - sizeof(struct AllocOnlyPool), MEMORY_POOL_LEFT);
|
struct AllocOnlyPool* pool = alloc_only_pool_init(main_pool_available() - sizeof(struct AllocOnlyPool), MEMORY_POOL_LEFT);
|
||||||
gLoadedGraphNodes[emptyCacheId] = process_geo_layout(pool, (void*)info->asset);
|
if (info->isDisplayList) {
|
||||||
|
gLoadedGraphNodes[emptyCacheId] = (struct GraphNode *) init_graph_node_display_list(pool, NULL, info->layer, (void*)info->asset);
|
||||||
|
} else {
|
||||||
|
gLoadedGraphNodes[emptyCacheId] = process_geo_layout(pool, (void*)info->asset);
|
||||||
|
}
|
||||||
alloc_only_pool_resize(pool, pool->usedSpace);
|
alloc_only_pool_resize(pool, pool->usedSpace);
|
||||||
//LOG_INFO("Loaded at runtime");
|
//LOG_INFO("Loaded at runtime");
|
||||||
|
|
||||||
// remember
|
// remember
|
||||||
smlua_model_util_remember(emptyCacheId, info->layer, info->asset);
|
smlua_model_util_remember(emptyCacheId, info->layer, info->asset, info->isDisplayList);
|
||||||
info->cacheId = emptyCacheId;
|
info->cacheId = emptyCacheId;
|
||||||
|
|
||||||
return emptyCacheId;
|
return emptyCacheId;
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ enum ModelExtendedId {
|
||||||
E_MODEL_MAX
|
E_MODEL_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
void smlua_model_util_remember(u8 modelId, u8 layer, const void* asset);
|
void smlua_model_util_remember(u8 modelId, u8 layer, const void* asset, u8 isDisplayList);
|
||||||
void smlua_model_util_clear(void);
|
void smlua_model_util_clear(void);
|
||||||
u8 smlua_model_util_load(enum ModelExtendedId id);
|
u8 smlua_model_util_load(enum ModelExtendedId id);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue