From 1c74d2fca77f8fecef650fc0ec390ae6165a01d6 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 27 Sep 2002 05:23:34 +0000 Subject: [PATCH] added Mod_FindTriangleWithEdge and Mod_BuildTriangleNeighbors functions (not used by anything) added Mod_LoadModels function, which is called when renderer is restarted or "modelflush" is used, it reloads all models that are used git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2450 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 40 ++++++++++++++++++++++++++++++++++++++++ model_shared.h | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/model_shared.c b/model_shared.c index 9da66893..0d3eacfd 100644 --- a/model_shared.c +++ b/model_shared.c @@ -75,6 +75,7 @@ static void mod_start(void) for (i = 0;i < MAX_MOD_KNOWN;i++) if (mod_known[i].name[0]) Mod_UnloadModel(&mod_known[i]); + Mod_LoadModels(); Mod_SetupNoTexture(); Mod_BrushStartup(); @@ -270,6 +271,17 @@ void Mod_PurgeUnused(void) Mod_FreeModel(mod); } +void Mod_LoadModels(void) +{ + int i; + model_t *mod; + + for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++) + if (mod->name[0]) + if (mod->used) + Mod_CheckLoaded(mod); +} + /* ================== Mod_FindName @@ -368,4 +380,32 @@ static void Mod_Flush (void) for (i = 0;i < MAX_MOD_KNOWN;i++) if (mod_known[i].name[0]) Mod_UnloadModel(&mod_known[i]); + Mod_LoadModels(); +} + +int Mod_FindTriangleWithEdge(int *elements, int numtriangles, int start, int end) +{ + int i; + for (i = 0;i < numtriangles;i++, elements += 3) + { + if (elements[0] == start && elements[1] == end) + return i; + if (elements[1] == start && elements[2] == end) + return i; + if (elements[2] == start && elements[0] == end) + return i; + } + return -1; +} + +int *Mod_BuildTriangleNeighbors(int *neighbors, int *elements, int numtriangles) +{ + int i, *e, *n; + for (i = 0, e = elements, n = neighbors;i < numtriangles;i++, e += 3, n += 3) + { + n[0] = Mod_FindTriangleWithEdge(elements, numtriangles, e[1], e[0]); + n[1] = Mod_FindTriangleWithEdge(elements, numtriangles, e[2], e[1]); + n[2] = Mod_FindTriangleWithEdge(elements, numtriangles, e[0], e[2]); + } + return neighbors; } diff --git a/model_shared.h b/model_shared.h index 4fb9af4f..898d30be 100644 --- a/model_shared.h +++ b/model_shared.h @@ -230,9 +230,13 @@ void Mod_UnloadModel (model_t *mod); void Mod_ClearUsed(void); void Mod_PurgeUnused(void); +void Mod_LoadModels(void); extern model_t *loadmodel; extern char loadname[32]; // for hunk tags +int Mod_FindTriangleWithEdge(int *elements, int numtriangles, int start, int end); +int *Mod_BuildTriangleNeighbors(int *neighbors, int *elements, int numtriangles); + #endif // __MODEL__ -- 2.39.2