]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/picomodel/pm_obj.c
Fix over allocating vertexes for OBJ models with multiple surfaces
[xonotic/netradiant.git] / libs / picomodel / pm_obj.c
index a97cf5264e4c298d4987f844044ea32ee57be20c..32bdbd258213588c314d24a5c2f374d090ac4f3b 100644 (file)
 
 /* dependencies */
 #include "picointernal.h"
+#include "globaldefs.h"
 
 /* disable warnings */
-#ifdef WIN32
+#if GDEF_COMPILER_MSVC
 #pragma warning( disable:4100 )                /* unref param */
 #endif
 
@@ -523,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 ); } \
@@ -539,7 +541,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){
        /* helper */
 #define _obj_error_return( m ) \
        { \
-               _pico_printf( PICO_ERROR,"%s in OBJ, line %d.",m,p->curLine ); \
+               _pico_printf( PICO_ERROR, "%s in OBJ %s, line %d.", m, model->fileName, p->curLine ); \
                _pico_free_parser( p ); \
                FreeObjVertexData( vertexData ); \
                PicoFreeModel( model ); \