]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
don't emit obj materials more than once
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 21 Oct 2009 18:20:49 +0000 (18:20 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 21 Oct 2009 18:20:49 +0000 (18:20 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9372 d7cf8633-e32d-0410-b094-e92efae38249

model_shared.c

index ac16b9acf0bc8600a6381dd09b550d85c8924932..d46e2baf65d7234e880c7f8e29b9e6817e436fe7 100644 (file)
@@ -2534,13 +2534,14 @@ static void Mod_Decompile_OBJ(dp_model_t *model, const char *filename, const cha
                countvertices += surface->num_vertices;
                countfaces += surface->num_triangles;
                texname = (surface->texture && surface->texture->name[0]) ? surface->texture->name : "default";
-               for (textureindex = 0;textureindex < maxtextures && texturenames[textureindex*MAX_QPATH];textureindex++)
+               for (textureindex = 0;textureindex < counttextures;textureindex++)
                        if (!strcmp(texturenames + textureindex * MAX_QPATH, texname))
                                break;
+               if (textureindex < counttextures)
+                       continue; // already wrote this material entry
                if (textureindex >= maxtextures)
                        continue; // just a precaution
-               if (counttextures < textureindex + 1)
-                       counttextures = textureindex + 1;
+               textureindex = counttextures++;
                strlcpy(texturenames + textureindex * MAX_QPATH, texname, MAX_QPATH);
                if (outbufferpos >= outbuffermax >> 1)
                {