]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
picomodel: white default color of fm, md2 (was one white and rest black)
authorGarux <garux@mail.ru>
Sat, 9 Jun 2018 22:27:49 +0000 (01:27 +0300)
committerThomas Debesse <dev@illwieckz.net>
Tue, 27 Apr 2021 01:45:03 +0000 (03:45 +0200)
unified picoColor_white

12 files changed:
libs/picomodel.h
libs/picomodel/picointernal.c
libs/picomodel/picointernal.h
libs/picomodel/picomodel.c
libs/picomodel/pm_3ds.c
libs/picomodel/pm_ase.c
libs/picomodel/pm_fm.c
libs/picomodel/pm_md2.c
libs/picomodel/pm_md3.c
libs/picomodel/pm_mdc.c
libs/picomodel/pm_ms3d.c
libs/picomodel/pm_terrain.c

index 370afef92266fb994ab5b5a14aeb631ca9d30488..eb0bc9432b0ef76844982d90f22490c994d3f7c2 100644 (file)
@@ -263,7 +263,7 @@ void                        PicoSetSurfaceShader( picoSurface_t *surface, picoSh
 void                        PicoSetSurfaceXYZ( picoSurface_t *surface, int num, picoVec3_t xyz );
 void                        PicoSetSurfaceNormal( picoSurface_t *surface, int num, picoVec3_t normal );
 void                        PicoSetSurfaceST( picoSurface_t *surface, int array, int num, picoVec2_t st );
-void                        PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, picoColor_t color );
+void                        PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, const picoColor_t color );
 void                        PicoSetSurfaceIndex( picoSurface_t *surface, int num, picoIndex_t index );
 void                        PicoSetSurfaceIndexes( picoSurface_t *surface, int num, picoIndex_t *index, int count );
 void                        PicoSetFaceNormal( picoSurface_t *surface, int num, picoVec3_t normal );
@@ -336,12 +336,12 @@ picoVertexCombinationHash_t *PicoFindVertexCombinationInHashTable( picoVertexCom
 picoVertexCombinationHash_t *PicoAddVertexCombinationToHashTable( picoVertexCombinationHash_t **hashTable, picoVec3_t xyz, picoVec3_t normal, picoVec3_t st, picoColor_t color, picoIndex_t index );
 
 /* specialized functions */
-int                         PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, picoColor_t *color, picoIndex_t smoothingGroup );
+int                         PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, const picoColor_t *color, picoIndex_t smoothingGroup );
 void                        PicoFixSurfaceNormals( picoSurface_t *surface );
 int                         PicoRemapModel( picoModel_t *model, char *remapFile );
 
 
-void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals, int numSTs, picoVec2_t **st, int numColors, picoColor_t **colors, picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup );
+void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals, int numSTs, picoVec2_t **st, int numColors, const picoColor_t **colors, picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup );
 
 /* end marker */
 #ifdef __cplusplus
index 018ee3a130295869d9294409545e6ca6a7792cb6..19950c1deeaae55300de80e05580a04cbd8092d9 100644 (file)
@@ -462,6 +462,8 @@ picoVec_t _pico_calc_plane( picoVec4_t plane, picoVec3_t a, picoVec3_t b, picoVe
        return _pico_normalize_vec( plane );
 }
 
+const picoColor_t picoColor_white = { 255, 255, 255, 255 };
+
 /* separate from _pico_set_vec4 */
 void _pico_set_color( picoColor_t c, int r, int g, int b, int a ){
        c[ 0 ] = r;
@@ -470,7 +472,7 @@ void _pico_set_color( picoColor_t c, int r, int g, int b, int a ){
        c[ 3 ] = a;
 }
 
-void _pico_copy_color( picoColor_t src, picoColor_t dest ){
+void _pico_copy_color( const picoColor_t src, picoColor_t dest ){
        dest[ 0 ] = src[ 0 ];
        dest[ 1 ] = src[ 1 ];
        dest[ 2 ] = src[ 2 ];
index 4bcbd4c281ae026efd4ad87ea7375f17ee4adb45..4ffae1b5370faa883f0d6e22f51addb5f7c5439d 100644 (file)
@@ -77,6 +77,8 @@ extern "C"
 #define PICO_IOEOF  1
 #define PICO_IOERR  2
 
+const picoColor_t picoColor_white;
+
 /* types */
 typedef struct picoParser_s
 {
@@ -148,7 +150,7 @@ void            _pico_zero_vec4( picoVec4_t vec );
 void            _pico_set_vec( picoVec3_t v, float a, float b, float c );
 void            _pico_set_vec4( picoVec4_t v, float a, float b, float c, float d );
 void            _pico_set_color( picoColor_t c, int r, int g, int b, int a );
-void            _pico_copy_color( picoColor_t src, picoColor_t dest );
+void            _pico_copy_color( const picoColor_t src, picoColor_t dest );
 void            _pico_copy_vec( picoVec3_t src, picoVec3_t dest );
 void            _pico_copy_vec2( picoVec2_t src, picoVec2_t dest );
 picoVec_t       _pico_normalize_vec( picoVec3_t vec );
index 311f6de760c7791bb9e94f717d481a192c46dfdc..79655ce842689a4eaf7b4db4a746184f7e57ae60 100644 (file)
@@ -991,7 +991,7 @@ void PicoSetSurfaceST( picoSurface_t *surface, int array, int num, picoVec2_t st
 
 
 
-void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, picoColor_t color ){
+void PicoSetSurfaceColor( picoSurface_t *surface, int array, int num, const picoColor_t color ){
        if ( surface == NULL || num < 0 || color == NULL ) {
                return;
        }
@@ -1603,7 +1603,7 @@ picoVertexCombinationHash_t *PicoAddVertexCombinationToHashTable( picoVertexComb
    fixme: needs non-naive algorithm
  */
 
-int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, picoColor_t *color, picoIndex_t smoothingGroup ){
+int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t normal, int numSTs, picoVec2_t *st, int numColors, const picoColor_t *color, picoIndex_t smoothingGroup ){
        int i, j;
 
 
@@ -1647,7 +1647,7 @@ int PicoFindSurfaceVertexNum( picoSurface_t *surface, picoVec3_t xyz, picoVec3_t
                if ( numColors > 0 && color != NULL ) {
                        for ( j = 0; j < numSTs; j++ )
                        {
-                               if ( *( (int*) surface->color[ j ] ) != *( (int*) color[ j ] ) ) {
+                               if ( *( (const int*) surface->color[ j ] ) != *( (const int*) color[ j ] ) ) {
                                        break;
                                }
                        }
@@ -2248,7 +2248,7 @@ int PicoRemapModel( picoModel_t *model, char *remapFile ){
  */
 
 void PicoAddTriangleToModel( picoModel_t *model, picoVec3_t** xyz, picoVec3_t** normals,
-                                                        int numSTs, picoVec2_t **st, int numColors, picoColor_t **colors,
+                                                        int numSTs, picoVec2_t **st, int numColors, const picoColor_t **colors,
                                                         picoShader_t* shader, const char *name, picoIndex_t* smoothingGroup ){
        int i,j;
        int vertDataIndex;
index e72454a170a6d851599d15ac2f4c38f3d2863e5f..b802814accbf2205d1fcade246a91f0331369bff 100644 (file)
@@ -35,9 +35,6 @@
 /* dependencies */
 #include "picointernal.h"
 
-/* ydnar */
-static picoColor_t white = { 255,255,255,255 };
-
 /* remarks:
  * - 3ds file version is stored in pico special field 0 on load (ydnar: removed)
  * todo:
@@ -294,7 +291,7 @@ static int GetMeshVertices( T3dsLoaderPers *pers ){
 
                /* add current vertex */
                PicoSetSurfaceXYZ( pers->surface,i,v );
-               PicoSetSurfaceColor( pers->surface,0,i,white ); /* ydnar */
+               PicoSetSurfaceColor( pers->surface, 0, i, picoColor_white );
 
 #ifdef DEBUG_PM_3DS_EX
                printf( "Vertex: x: %f y: %f z: %f\n",v[0],v[1],v[2] );
index d73187c6ec706c2131b8282f89ec28a5f1f35eca..21c8e0801a78f8b742e9854fbb292233dce6e0db 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 */
index c4086184c317cf15547c4f42637dff9f9d32b85b..0df82a25c9698a7b66aed41fabd52e11f9b781a5 100644 (file)
@@ -212,7 +212,6 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
        picoShader_t    *picoShader;
        picoVec3_t xyz, normal;
        picoVec2_t st;
-       picoColor_t color;
 
 
        bb0 = bb = (picoByte_t*) _pico_alloc( bufSize );
@@ -587,6 +586,9 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
                st[ 0 ] =  ( ( texCoord[p_index_LUT[i].ST].s ) / ( (float)fm_head->skinWidth ) );
                st[ 1 ] =  ( texCoord[p_index_LUT[i].ST].t / ( (float)fm_head->skinHeight ) );
                PicoSetSurfaceST( picoSurface, 0, i, st );
+
+               /* set color */
+               PicoSetSurfaceColor( picoSurface, 0, i, picoColor_white );
        }
 
        if ( dups ) {
@@ -609,12 +611,12 @@ static picoModel_t *_fm_load( PM_PARAMS_LOAD ){
                        st[ 0 ] =  ( ( texCoord[p_index_LUT_DUPS[i].ST].s ) / ( (float)fm_head->skinWidth ) );
                        st[ 1 ] =  ( texCoord[p_index_LUT_DUPS[i].ST].t / ( (float)fm_head->skinHeight ) );
                        PicoSetSurfaceST( picoSurface, 0, i + fm_head->numXYZ, st );
+
+                       /* set color */
+                       PicoSetSurfaceColor( picoSurface, 0, i + fm_head->numXYZ, picoColor_white );
                }
        }
 
-       /* set color */
-       PicoSetSurfaceColor( picoSurface, 0, 0, color );
-
        // Free up malloc'ed LL entries
        for ( i = 0; i < fm_head->numXYZ; i++ )
        {
index 37b5466c56f712e3c36c39dd6d72aaf4dc10d667..82975b887ff60213bc035c0543db805b2c1ac668 100644 (file)
@@ -339,7 +339,6 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
        picoShader_t    *picoShader;
        picoVec3_t xyz, normal;
        picoVec2_t st;
-       picoColor_t color;
 
 
        /* set as md2 */
@@ -584,6 +583,9 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
                st[ 0 ] =  ( ( texCoord[p_index_LUT[i].ST].s ) / ( (float)md2->skinWidth ) );
                st[ 1 ] =  ( texCoord[p_index_LUT[i].ST].t / ( (float)md2->skinHeight ) );
                PicoSetSurfaceST( picoSurface, 0, i, st );
+
+               /* set color */
+               PicoSetSurfaceColor( picoSurface, 0, i, picoColor_white );
        }
 
        if ( dups ) {
@@ -606,12 +608,12 @@ static picoModel_t *_md2_load( PM_PARAMS_LOAD ){
                        st[ 0 ] =  ( ( texCoord[p_index_LUT_DUPS[i].ST].s ) / ( (float)md2->skinWidth ) );
                        st[ 1 ] =  ( texCoord[p_index_LUT_DUPS[i].ST].t / ( (float)md2->skinHeight ) );
                        PicoSetSurfaceST( picoSurface, 0, i + md2->numXYZ, st );
+
+                       /* set color */
+                       PicoSetSurfaceColor( picoSurface, 0, i + md2->numXYZ, picoColor_white );
                }
        }
 
-       /* set color */
-       PicoSetSurfaceColor( picoSurface, 0, 0, color );
-
        // Free up malloc'ed LL entries
        for ( i = 0; i < md2->numXYZ; i++ )
        {
index d31806b7e85fb6c67e09af1c11feeb75b0db2bba..86742d734a643bb1f1f1a822b45650d70070db3b 100644 (file)
@@ -186,7 +186,6 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
        picoShader_t    *picoShader;
        picoVec3_t xyz, normal;
        picoVec2_t st;
-       picoColor_t color;
 
 
        /* -------------------------------------------------
@@ -361,7 +360,6 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
                /* copy vertexes */
                texCoord = (md3TexCoord_t*) ( (picoByte_t *) surface + surface->ofsSt );
                vertex = (md3Vertex_t*) ( (picoByte_t*) surface + surface->ofsVertexes + surface->numVerts * frameNum * sizeof( md3Vertex_t ) );
-               _pico_set_color( color, 255, 255, 255, 255 );
 
                for ( j = 0; j < surface->numVerts; j++, texCoord++, vertex++ )
                {
@@ -387,7 +385,7 @@ static picoModel_t *_md3_load( PM_PARAMS_LOAD ){
                        PicoSetSurfaceST( picoSurface, 0, j, st );
 
                        /* set color */
-                       PicoSetSurfaceColor( picoSurface, 0, j, color );
+                       PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
                }
 
                /* get next surface */
index 235dcecf9467c0ca90d1508e0fef403e1adf285e..be93e3382f32c63362843e6f7888993c1c40b9ff 100644 (file)
@@ -460,7 +460,6 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
        picoShader_t        *picoShader;
        picoVec3_t xyz, normal;
        picoVec2_t st;
-       picoColor_t color;
 
 
        /* -------------------------------------------------
@@ -667,7 +666,6 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
                                vertexComp = (mdcXyzCompressed_t *) ( (picoByte_t *) surface + surface->ofsXyzCompressed ) + ( *mdcCompVert * surface->numVerts );
                        }
                }
-               _pico_set_color( color, 255, 255, 255, 255 );
 
                for ( j = 0; j < surface->numVerts; j++, texCoord++, mdcShort += 4 )
                {
@@ -711,7 +709,7 @@ static picoModel_t *_mdc_load( PM_PARAMS_LOAD ){
                        PicoSetSurfaceST( picoSurface, 0, j, st );
 
                        /* set color */
-                       PicoSetSurfaceColor( picoSurface, 0, j, color );
+                       PicoSetSurfaceColor( picoSurface, 0, j, picoColor_white );
                }
 
                /* get next surface */
index 378265f30a5504d59206c95b08d6f43fb103bce7..1472de549e0d128eb31c1152ea965a780acd0557 100644 (file)
@@ -51,9 +51,6 @@
  #define DEBUG_PM_MS3D
  #define DEBUG_PM_MS3D_EX
 
-/* plain white */
-static picoColor_t white = { 255,255,255,255 };
-
 /* ms3d limits */
 const int MS3D_MAX_VERTS      = 8192;
 const int MS3D_MAX_TRIS       = 16384;
@@ -351,7 +348,7 @@ static picoModel_t *_ms3d_load( PM_PARAMS_LOAD ){
                                PicoSetSurfaceXYZ( surface,vertexIndex,vertex->xyz );
 
                                /* store vertex color */
-                               PicoSetSurfaceColor( surface,0,vertexIndex,white );
+                               PicoSetSurfaceColor( surface, 0, vertexIndex, picoColor_white );
 
                                /* store vertex normal */
                                PicoSetSurfaceNormal( surface,vertexIndex,triangle->vertexNormals[ m ] );
index a82e4b122277916d9a3c4910ab3ce22017446e1e..039af0679a1ef324c187ab5b65318adf1d950437 100644 (file)
@@ -537,7 +537,7 @@ static picoModel_t *_terrain_load( PM_PARAMS_LOAD ) {
                                _pico_set_color( color, colorPixel[ 0 ], colorPixel[ 1 ], colorPixel[ 2 ], colorPixel[ 3 ] );
                        }
                        else{
-                               _pico_set_color( color, 255, 255, 255, 255 );
+                               _pico_copy_color( picoColor_white, color );
                        }
                        PicoSetSurfaceColor( picoSurface, 0, v, color );