From 35b6b522b4b9300121a15f94c1065273bab3e9a5 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 27 Sep 2002 05:49:29 +0000 Subject: [PATCH] alias mdl/md2 models now have a mdlmd2data_triangleneighbors array git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2451 d7cf8633-e32d-0410-b094-e92efae38249 --- model_alias.c | 7 ++++++- model_shared.c | 3 +-- model_shared.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/model_alias.c b/model_alias.c index c62cb9c9..8e4545de 100644 --- a/model_alias.c +++ b/model_alias.c @@ -528,6 +528,9 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) loadmodel->Draw = R_DrawQ1Q2AliasModel; loadmodel->DrawSky = NULL; loadmodel->DrawShadow = NULL; + + loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3])); + Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris); } static void Mod_MD2_ConvertVerts (vec3_t scale, vec3_t translate, trivertx_t *v, trivertx_t *out, int *vertremap) @@ -781,6 +784,9 @@ void Mod_LoadQ2AliasModel (model_t *mod, void *buffer) loadmodel->yawmins[0] = loadmodel->yawmins[1] = -(loadmodel->yawmaxs[0] = loadmodel->yawmaxs[1] = modelyawradius); loadmodel->yawmins[2] = loadmodel->normalmins[2]; loadmodel->yawmaxs[2] = loadmodel->normalmaxs[2]; + + loadmodel->mdlmd2data_triangleneighbors = Mem_Alloc(loadmodel->mempool, loadmodel->numtris * sizeof(int[3])); + Mod_BuildTriangleNeighbors(loadmodel->mdlmd2data_triangleneighbors, loadmodel->mdlmd2data_indices, loadmodel->numtris); } static void zymswapintblock(int *m, int size) @@ -989,4 +995,3 @@ void Mod_LoadZymoticModel(model_t *mod, void *buffer) loadmodel->DrawSky = NULL; loadmodel->DrawShadow = NULL; } - diff --git a/model_shared.c b/model_shared.c index 0d3eacfd..a2ac48e6 100644 --- a/model_shared.c +++ b/model_shared.c @@ -398,7 +398,7 @@ int Mod_FindTriangleWithEdge(int *elements, int numtriangles, int start, int end return -1; } -int *Mod_BuildTriangleNeighbors(int *neighbors, int *elements, int numtriangles) +void 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) @@ -407,5 +407,4 @@ int *Mod_BuildTriangleNeighbors(int *neighbors, int *elements, int numtriangles) 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 898d30be..9d4c3047 100644 --- a/model_shared.h +++ b/model_shared.h @@ -186,6 +186,7 @@ typedef struct model_s float *mdlmd2data_texcoords; md2frame_t *mdlmd2data_frames; trivertx_t *mdlmd2data_pose; + int *mdlmd2data_triangleneighbors; // for Zymotic models void *zymdata_header; @@ -236,7 +237,7 @@ 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); +void Mod_BuildTriangleNeighbors(int *neighbors, int *elements, int numtriangles); #endif // __MODEL__ -- 2.39.2