mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +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) {
|
||||
gLoadedGraphNodes[val1] =
|
||||
(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;
|
||||
|
@ -397,7 +397,7 @@ static void level_cmd_load_model_from_geo(void) {
|
|||
|
||||
if (arg0 < 256) {
|
||||
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;
|
||||
|
@ -424,7 +424,7 @@ static void level_cmd_23(void) {
|
|||
// is being stored to the array, so cast the pointer.
|
||||
gLoadedGraphNodes[model] =
|
||||
(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;
|
||||
|
|
|
@ -36,11 +36,12 @@ struct ModelUtilsInfo {
|
|||
enum ModelExtendedId id;
|
||||
const void* asset;
|
||||
u8 layer;
|
||||
bool isDisplayList;
|
||||
u8 cacheId;
|
||||
};
|
||||
|
||||
#define MODEL_UTIL_GEO(x, y) [x] = { .id = x, .asset = y, .layer = LAYER_OPAQUE, .cacheId = 0xFF }
|
||||
#define MODEL_UTIL_DL(x, y, z) [x] = { .id = x, .asset = y, .layer = z, .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, .isDisplayList = true, .cacheId = 0xFF }
|
||||
|
||||
struct ModelUtilsInfo sModels[] = {
|
||||
MODEL_UTIL_GEO(E_MODEL_MARIO, mario_geo),
|
||||
|
@ -226,11 +227,12 @@ struct ModelUtilsInfo sModels[] = {
|
|||
|
||||
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];
|
||||
c->id = modelId;
|
||||
c->layer = layer;
|
||||
c->asset = asset;
|
||||
c->isDisplayList = isDisplayList;
|
||||
}
|
||||
|
||||
void smlua_model_util_clear(void) {
|
||||
|
@ -277,12 +279,16 @@ u8 smlua_model_util_load(enum ModelExtendedId id) {
|
|||
|
||||
// load
|
||||
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);
|
||||
//LOG_INFO("Loaded at runtime");
|
||||
|
||||
// remember
|
||||
smlua_model_util_remember(emptyCacheId, info->layer, info->asset);
|
||||
smlua_model_util_remember(emptyCacheId, info->layer, info->asset, info->isDisplayList);
|
||||
info->cacheId = emptyCacheId;
|
||||
|
||||
return emptyCacheId;
|
||||
|
|
|
@ -183,7 +183,7 @@ enum ModelExtendedId {
|
|||
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);
|
||||
u8 smlua_model_util_load(enum ModelExtendedId id);
|
||||
|
||||
|
|
Loading…
Reference in a new issue