ASE support: support *node_name
authorRudolf Polzer <divverent@xonotic.org>
Sun, 5 Jun 2011 16:57:26 +0000 (18:57 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 5 Jun 2011 16:57:26 +0000 (18:57 +0200)
libs/picomodel/picomodel.c
libs/picomodel/pm_ase.c

index aed467c..2614622 100644 (file)
@@ -2214,7 +2214,7 @@ Chooses an appropriate surface based on the shader, or adds a new surface if nec
 
 void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals, 
                                                        int numSTs, picoVec2_t **st, int numColors, picoColor_t **colors,
-                                                       picoShader_t* shader, picoIndex_t* smoothingGroup )
+                                                       picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup )
 {
        int i,j;
        int vertDataIndex;
@@ -2224,6 +2224,7 @@ void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t**
        for ( i = 0 ; i < model->numSurfaces ; i++ )
        {
                workSurface = model->surface[i];
+               if ( !name || !strcmp(workSurface->name, name) )
                if ( workSurface->shader == shader )
                {                       
                        break;
@@ -2243,7 +2244,7 @@ void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t**
 
                /* do surface setup */
                PicoSetSurfaceType( workSurface, PICO_TRIANGLES );
-               PicoSetSurfaceName( workSurface, shader->name );
+               PicoSetSurfaceName( workSurface, name ? name : shader->name );
                PicoSetSurfaceShader( workSurface, shader );
        }
 
index 31c448e..6905431 100644 (file)
@@ -452,7 +452,7 @@ static void _ase_submit_triangles_unshared ( picoModel_t* model , aseMaterial_t*
 
 #endif
 
-static void _ase_submit_triangles( picoModel_t* model , aseMaterial_t* materials , aseVertex_t* vertices, aseTexCoord_t* texcoords, aseColor_t* colors, aseFace_t* faces, int numFaces )
+static void _ase_submit_triangles( picoModel_t* model , aseMaterial_t* materials , aseVertex_t* vertices, aseTexCoord_t* texcoords, aseColor_t* colors, aseFace_t* faces, int numFaces, const char *name )
 {
        aseFacesIter_t i = faces, end = faces + numFaces;
        for(; i != end; ++i)
@@ -492,7 +492,7 @@ static void _ase_submit_triangles( picoModel_t* model , aseMaterial_t* materials
                        }
 
                        /* submit the triangle to the model */
-                       PicoAddTriangleToModel ( model , xyz , normal , 1 , st , 1 , color , subMtl->shader, smooth );
+                       PicoAddTriangleToModel ( model , xyz , normal , 1 , st , 1 , color , subMtl->shader, name, smooth );
                }
        }
 }
@@ -599,7 +599,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD )
                else if (!_pico_stricmp(p->token,"*mesh"))
                {
                        /* finish existing surface */
-                       _ase_submit_triangles(model, materials, vertices, texcoords, colors, faces, numFaces);
+                       _ase_submit_triangles(model, materials, vertices, texcoords, colors, faces, numFaces, lastNodeName);
                        _pico_free(faces);
                        _pico_free(vertices);
                        _pico_free(texcoords);
@@ -1152,7 +1152,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD )
        }
        
        /* ydnar: finish existing surface */
-       _ase_submit_triangles(model, materials, vertices, texcoords, colors, faces, numFaces);
+       _ase_submit_triangles(model, materials, vertices, texcoords, colors, faces, numFaces, lastNodeName);
        _pico_free(faces);
        _pico_free(vertices);
        _pico_free(texcoords);