Skip to content

Commit

Permalink
Fix over allocating vertexes for OBJ models with multiple surfaces
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zturtleman committed Oct 31, 2018
1 parent 2e64b0b commit 3705dcf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/picomodel/pm_obj.c
Expand Up @@ -524,8 +524,9 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
newSurface = PicoNewSurface( model ); \ newSurface = PicoNewSurface( model ); \
if ( newSurface == NULL ) { \ if ( newSurface == NULL ) { \
_obj_error_return( "Error allocating surface" ); } \ _obj_error_return( "Error allocating surface" ); } \
/* reset face index for surface */ \ /* reset face index and vertex index for surface */ \
curFace = 0; \ curFace = 0; \
curVertex = 0; \
/* if we can, assign the previous shader to this surface */ \ /* if we can, assign the previous shader to this surface */ \
if ( curSurface ) { \ if ( curSurface ) { \
PicoSetSurfaceShader( newSurface, curSurface->shader ); } \ PicoSetSurfaceShader( newSurface, curSurface->shader ); } \
Expand Down

0 comments on commit 3705dcf

Please sign in to comment.