From 02ad54ca72f5baf4614cb9b7c30f8dd780764d90 Mon Sep 17 00:00:00 2001 From: coco875 <59367621+coco875@users.noreply.github.com> Date: Sun, 7 Dec 2025 15:34:53 +0100 Subject: Refactor yaml and remove segment (#531) * move yaml (still need to fix header path) * fix header * change kart to karts and add migration * fix include * Update migration.py * fix common_texture_debug_font extraction * Update torch * update torch and header * unduplicate texture for tumble * Update torch * Update migration.py * put the sort by default * fix replace_segmented_textures_with_o2r_textures * Update torch * fix yamls * add manual_segments in data of course * comment out replace_segmented_textures_with_o2r_textures and segment 3 * remove segment 5 * (wip) remove segment 6 still plenty of thing to do * more vtx * more change * Update torch * small fix * Update BansheeBoardwalk.cpp * fix blockFort * Delete test.yaml * fix bowser castle and simplify track sections * fix choco mountain * clean banshee * fix dk jungle * fix double deck * fix macos * fix error * fix macos ci * Update torch * Update torch * fix frappe snowland * fix kalimari desert * fix koopa troopa beach * fix luigi raceway * fix mario raceway and simplify thing * fix moo moo farm * fix rainbow road * Update torch * Update torch * hopefully fix windows error * fix a small error * fix royal raceway (and podium in theory) * fix sherbet_land * fix skyscraper * fix toads turnpike * fix wario stadium * fix yoshi valley * update torch * more clang tidy rules * REMOVE totally SEGMENT (sorry for the PR) * remove unused field in course and props and unused packed asset * fix kart texture * fix particle * fix track section and transparency * try fix mode extra * fix macos build and render * fix collision in extra * small change and try fix windows error * a little of clean * more cleanup * forget header and more clean up * Update Makefile * fix credits * fix kart texture offset * remove LoadTextures and add Unload * fix definitevely mirror mode * add unload but it's not perfect * revert a bad fix * clean no longer used python script * fix crash with player * being able to load the same course twice * add a comment on DrawWater * fix render of transparent object * better hack * add a proper migration instruction * fix number * add basic modsmanager * add meta/mods.toml * Update EditorMath.h * Update ModsManager.cpp * basic modManager (maybe I should rename it ModLoader) * use range on dependencies * add information about mods.toml * fix coment * some rename around * Delete beta-to-v1.md * Update migrations.md * Update textures-pack.md * Update modding.md * Update modding.md * clean yamls_old * move to mods in engine * rename ModsManger to ModManager * move init and unload at the top * rename ModsMetadata to ModMetadata * fix header * Update ModManager.cpp * put core mods at top --- src/engine/ModelLoader.cpp | 94 ---------------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 src/engine/ModelLoader.cpp (limited to 'src/engine/ModelLoader.cpp') diff --git a/src/engine/ModelLoader.cpp b/src/engine/ModelLoader.cpp deleted file mode 100644 index b73d98aee..000000000 --- a/src/engine/ModelLoader.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "ModelLoader.h" -#include "port/Engine.h" -#include "engine/courses/Course.h" - -extern "C" { -#include "memory.h" -} - -void ModelLoader::Add(LoadModelList list) { - _deferredList.push_back(list); -} - -void ModelLoader::Load() { - if (_hasRan) { // Ensure this does not get ran multiple times - printf("ModelLoader.cpp has already been ran once.\n"); - return; - } - _hasRan = true; - - // Set to track processed courses - std::unordered_set> processedCourses; - - for (auto& list : _deferredList) { - // Check if the course has already been processed - if (processedCourses.find(list.course) != processedCourses.end()) { - continue; // Skip if already processed - } - - // Process the course - ModelLoader::Extract(list.course); - - // Mark this course as processed - processedCourses.insert(list.course); - } -} - -void ModelLoader::Extract(std::shared_ptr course) { - std::shared_ptr saveCourse = gWorldInstance.CurrentCourse; - gWorldInstance.CurrentCourse = course; // Quick hack so that `get_texture` will find the right textures. - - size_t vtxSize = (ResourceGetSizeByName(course->vtx) / sizeof(CourseVtx)) * sizeof(Vtx); - size_t texSegSize; - - // Convert course vtx to vtx - Vtx* vtx = reinterpret_cast(malloc(vtxSize)); - if (vtx == NULL) { - printf("ModelLoader: Failed to allocate vertex buffer for course: %s\n", course->Props.Name); - return; - } - func_802A86A8(reinterpret_cast(LOAD_ASSET_RAW(course->vtx)), vtx, vtxSize / sizeof(Vtx)); - - // Extract packed DLs - u8* packed = reinterpret_cast(LOAD_ASSET_RAW(course->gfx)); - Gfx* gfx = reinterpret_cast(malloc(sizeof(Gfx) * course->gfxSize)); // Size of unpacked DLs - if (gfx == NULL) { - printf("ModelLoader: Failed to allocate course displaylist memory for course: %s\n", course->Props.Name); - return; - } - - displaylist_unpack(reinterpret_cast(gfx), reinterpret_cast(packed), 0); - - // Now that the data has been retrieved, extract the model data and save to provided buffers. - for (auto& list : _deferredList) { - // Ensure the list matches the course being extracted. - if (list.course != course) { - return; - } - - memcpy(list.vtxBuffer, &vtx[list.vtxStart], list.vtxBufferSize * sizeof(Vtx)); - memcpy(list.gfxBuffer, &gfx[list.gfxStart], list.gfxBufferSize * sizeof(Gfx)); - - UpdateVtx(list); - - } - - free(vtx); - free(gfx); - - _deferredList.clear(); - gWorldInstance.CurrentCourse = saveCourse; -} - -void ModelLoader::UpdateVtx(LoadModelList list) { - for (size_t i = 0; i < list.gfxStart + list.gfxBufferSize; i++) { - Gfx* gfx = &list.gfxBuffer[i]; - - // Check if the current Gfx command is G_VTX - if (GFX_GET_OPCODE(gfx->words.w0) == (G_VTX << 24)) { - // Re-write the vtx to point at the provided vtx buffer. - size_t vtxIndex = (gfx->words.w1 / sizeof(Vtx)) - list.vtxStart; - gfx->words.w1 = reinterpret_cast(&list.vtxBuffer[vtxIndex]); - } - } -} -- cgit v1.2.3