]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
alias mdl/md2 models now have a mdlmd2data_triangleneighbors array
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 27 Sep 2002 05:49:29 +0000 (05:49 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 27 Sep 2002 05:49:29 +0000 (05:49 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2451 d7cf8633-e32d-0410-b094-e92efae38249

model_alias.c
model_shared.c
model_shared.h

index c62cb9c98d47324777a0b8a6320a463a306e0077..8e4545de5ca65e014b067b367074e32af24481c6 100644 (file)
@@ -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;
 }
-
index 0d3eacfd0642c16c27e332dbc81d1e12f659aa4a..a2ac48e6afda20853e9bb1e81e51b97da5784726 100644 (file)
@@ -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;
 }
index 898d30beb89bec148d1c8b8606034dd84ecb1e1b..9d4c30478a17fb4358f340a1beab6668eb5bdf01 100644 (file)
@@ -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__