]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Fix over allocating vertexes for OBJ models with multiple surfaces 107/head
authorZack Middleton <zack@cloemail.com>
Wed, 31 Oct 2018 01:21:16 +0000 (20:21 -0500)
committerZack Middleton <zack@cloemail.com>
Wed, 31 Oct 2018 21:14:19 +0000 (16:14 -0500)
Loading Wavefront OBJ models in picomodel (used by radiant and q3map2)
did not reset the surface vertex index when starting a new surface. This
caused there to be unused vertexes, equal to the number of vertexes in
all previous surfaces, at the beginning of each surface. Exponential OBJ
vertex memory usage as number of surfaces increases. It did not affect
displaying or processing the surface faces.

libs/picomodel/pm_obj.c

index e342ab0882eb0530a690a6dabb8819c4e064a099..32bdbd258213588c314d24a5c2f374d090ac4f3b 100644 (file)
@@ -524,8 +524,9 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
                newSurface = PicoNewSurface( model ); \
                if ( newSurface == NULL ) {     \
                        _obj_error_return( "Error allocating surface" ); } \
-               /* reset face index for surface */ \
+               /* reset face index and vertex index for surface */ \
                curFace = 0; \
+               curVertex = 0; \
                /* if we can, assign the previous shader to this surface */     \
                if ( curSurface ) {     \
                        PicoSetSurfaceShader( newSurface, curSurface->shader ); } \