]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/picomodel/pm_ase.c
Merge commit 'ff48e71434a414958e6e56628ccf04284d030784' into master-merge
[xonotic/netradiant.git] / libs / picomodel / pm_ase.c
index d73187c6ec706c2131b8282f89ec28a5f1f35eca..81bb99dbb6c358635a2bb4d1325645d1ca6e79bf 100644 (file)
@@ -44,9 +44,6 @@
 #include "time.h"
 #endif
 
-/* plain white */
-static picoColor_t white = { 255, 255, 255, 255 };
-
 /* jhefty - multi-subobject material support */
 
 /* Material/SubMaterial management */
@@ -402,7 +399,7 @@ static void _ase_submit_triangles_unshared( picoModel_t* model, aseMaterial_t* m
                                        }
                                        else
                                        {
-                                               PicoSetSurfaceColor( surface, 0, numVertexes, white );
+                                               PicoSetSurfaceColor( surface, 0, numVertexes, picoColor_white );
                                        }
 
                                        PicoSetSurfaceSmoothingGroup( surface, numVertexes, ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup );
@@ -431,7 +428,7 @@ static void _ase_submit_triangles( picoModel_t* model, aseMaterial_t* materials,
                        picoVec3_t* xyz[3];
                        picoVec3_t* normal[3];
                        picoVec2_t* st[3];
-                       picoColor_t* color[3];
+                       const picoColor_t* color[3];
                        picoIndex_t smooth[3];
                        int j;
                        /* we pull the data from the vertex, color and texcoord arrays using the face index data */
@@ -446,7 +443,7 @@ static void _ase_submit_triangles( picoModel_t* model, aseMaterial_t* materials,
                                }
                                else
                                {
-                                       color[j] = &white;
+                                       color[j] = &picoColor_white;
                                }
 
                                smooth[j] = ( vertices[( *i ).indices[j]].id * ( 1 << 16 ) ) + ( *i ).smoothingGroup; /* don't merge vertices */
@@ -459,17 +456,6 @@ static void _ase_submit_triangles( picoModel_t* model, aseMaterial_t* materials,
        }
 }
 
-static void shadername_convert( char* shaderName ){
-       /* unix-style path separators */
-       char* s = shaderName;
-       for (; *s != '\0'; ++s )
-       {
-               if ( *s == '\\' ) {
-                       *s = '/';
-               }
-       }
-}
-
 
 /* _ase_load:
  *  loads a 3dsmax ase model file.
@@ -525,7 +511,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
        PicoSetModelFileName( model, fileName );
 
        /* initialize some stuff */
-       memset( lastNodeName,0,sizeof( lastNodeName ) );
+       memset( lastNodeName, 0, sizeof( lastNodeName ) );
 
        /* parse ase model file */
        while ( 1 )
@@ -554,7 +540,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
                        }
 
                        /* remember node name */
-                       strncpy( lastNodeName,ptr,sizeof( lastNodeName ) );
+                       strncpy( lastNodeName, ptr, sizeof( lastNodeName ) - 1 );
                }
                /* model mesh (originally contained within geomobject) */
                else if ( !_pico_stricmp( p->token,"*mesh" ) ) {
@@ -886,7 +872,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
                                if ( level == subMaterialLevel ) {
                                        /* set material name */
                                        _pico_first_token( materialName );
-                                       shadername_convert( materialName );
+                                       _pico_unixify( materialName );
                                        PicoSetShaderName( shader, materialName );
 
                                        /* set shader's transparency */
@@ -1055,6 +1041,9 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
                                                        if ( name == NULL ) {
                                                                _ase_error_return( "Missing material map bitmap name" );
                                                        }
+                                                       else if( !_pico_stricmp( name, "none" ) ){ // standard empty bitmap name
+                                                               name = "";
+                                                       }
                                                        mapname = _pico_alloc( strlen( name ) + 1 );
                                                        strcpy( mapname, name );
                                                        /* skip rest and continue with next token */
@@ -1076,7 +1065,7 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
                                }
 
                                /* set material name */
-                               shadername_convert( materialName );
+                               _pico_unixify( materialName );
                                PicoSetShaderName( shader,materialName );
 
                                /* set shader's transparency */
@@ -1100,34 +1089,6 @@ static picoModel_t *_ase_load( PM_PARAMS_LOAD ){
                                /* set material map name */
                                PicoSetShaderMapName( shader, mapname );
 
-                               /* extract shadername from bitmap path */
-                               if ( mapname != NULL ) {
-                                       char* p = mapname;
-
-                                       /* convert to shader-name format */
-                                       shadername_convert( mapname );
-                                       {
-                                               /* remove extension */
-                                               char* last_period = strrchr( p, '.' );
-                                               if ( last_period != NULL ) {
-                                                       *last_period = '\0';
-                                               }
-                                       }
-
-                                       /* find shader path */
-                                       for (; *p != '\0'; ++p )
-                                       {
-                                               if ( _pico_strnicmp( p, "models/", 7 ) == 0 || _pico_strnicmp( p, "textures/", 9 ) == 0 ) {
-                                                       break;
-                                               }
-                                       }
-
-                                       if ( *p != '\0' ) {
-                                               /* set material name */
-                                               PicoSetShaderName( shader,p );
-                                       }
-                               }
-
                                /* this is just a material with 1 submaterial */
                                subMaterial = _ase_add_submaterial( &materials, index, 0, shader );
                        }