From: Garux Date: Sat, 9 Jun 2018 22:27:49 +0000 (+0300) Subject: picomodel: white default color of fm, md2 (was one white and rest black) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3ad35c718a0418a388f47bc2d425e6ab3c398788;p=xonotic%2Fnetradiant.git picomodel: white default color of fm, md2 (was one white and rest black) unified picoColor_white --- diff --git a/libs/picomodel.h b/libs/picomodel.h index 370afef9..eb0bc943 100644 --- a/libs/picomodel.h +++ b/libs/picomodel.h @@ -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 diff --git a/libs/picomodel/picointernal.c b/libs/picomodel/picointernal.c index 018ee3a1..19950c1d 100644 --- a/libs/picomodel/picointernal.c +++ b/libs/picomodel/picointernal.c @@ -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 ]; diff --git a/libs/picomodel/picointernal.h b/libs/picomodel/picointernal.h index 4bcbd4c2..4ffae1b5 100644 --- a/libs/picomodel/picointernal.h +++ b/libs/picomodel/picointernal.h @@ -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 ); diff --git a/libs/picomodel/picomodel.c b/libs/picomodel/picomodel.c index 311f6de7..79655ce8 100644 --- a/libs/picomodel/picomodel.c +++ b/libs/picomodel/picomodel.c @@ -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; diff --git a/libs/picomodel/pm_3ds.c b/libs/picomodel/pm_3ds.c index e72454a1..b802814a 100644 --- a/libs/picomodel/pm_3ds.c +++ b/libs/picomodel/pm_3ds.c @@ -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] ); diff --git a/libs/picomodel/pm_ase.c b/libs/picomodel/pm_ase.c index d73187c6..21c8e080 100644 --- a/libs/picomodel/pm_ase.c +++ b/libs/picomodel/pm_ase.c @@ -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 */ diff --git a/libs/picomodel/pm_fm.c b/libs/picomodel/pm_fm.c index c4086184..0df82a25 100644 --- a/libs/picomodel/pm_fm.c +++ b/libs/picomodel/pm_fm.c @@ -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++ ) { diff --git a/libs/picomodel/pm_md2.c b/libs/picomodel/pm_md2.c index 37b5466c..82975b88 100644 --- a/libs/picomodel/pm_md2.c +++ b/libs/picomodel/pm_md2.c @@ -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++ ) { diff --git a/libs/picomodel/pm_md3.c b/libs/picomodel/pm_md3.c index d31806b7..86742d73 100644 --- a/libs/picomodel/pm_md3.c +++ b/libs/picomodel/pm_md3.c @@ -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 */ diff --git a/libs/picomodel/pm_mdc.c b/libs/picomodel/pm_mdc.c index 235dcecf..be93e338 100644 --- a/libs/picomodel/pm_mdc.c +++ b/libs/picomodel/pm_mdc.c @@ -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 */ diff --git a/libs/picomodel/pm_ms3d.c b/libs/picomodel/pm_ms3d.c index 378265f3..1472de54 100644 --- a/libs/picomodel/pm_ms3d.c +++ b/libs/picomodel/pm_ms3d.c @@ -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 ] ); diff --git a/libs/picomodel/pm_terrain.c b/libs/picomodel/pm_terrain.c index a82e4b12..039af067 100644 --- a/libs/picomodel/pm_terrain.c +++ b/libs/picomodel/pm_terrain.c @@ -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 );