callback for picomodel.lib
*/
-void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize )
+void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize )
{
- *bufSize = vfsLoadFile( (const char*) name, (void**) buffer, 0 );
+ *bufSize = vfsLoadFile( name, (void**) buffer, 0 );
}
Error( "MAX_MODELS (%d) exceeded, there are too many model files referenced by the map.", MAX_MODELS );
/* attempt to parse model */
- *pm = PicoLoadModel( (char*) name, frame );
+ *pm = PicoLoadModel( name, frame );
/* if loading failed, make a bogus model to silence the rest of the warnings */
if( *pm == NULL )
return NULL;
/* set data */
- PicoSetModelName( *pm, (char*) name );
+ PicoSetModelName( *pm, name );
PicoSetModelFrameNum( *pm, frame );
}
void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle )
{
- int i, j, k, s, numSurfaces;
+ int i, j, s, numSurfaces;
m4x4_t identity, nTransform;
picoModel_t *model;
picoShader_t *shader;
char *skinfilecontent;
int skinfilesize;
char *skinfileptr, *skinfilenextptr;
- FILE *skinfilehandle;
/* get model */
/* load skin file */
snprintf(skinfilename, sizeof(skinfilename), "%s_%d.skin", name, skin);
skinfilename[sizeof(skinfilename)-1] = 0;
- skinfilehandle = fopen(skinfilename, "r");
skinfilesize = vfsLoadFile(skinfilename, (void**) &skinfilecontent, 0);
- if(skinfilesize < 0)
+ if(skinfilesize < 0 && skin != 0)
{
/* fallback to skin 0 if invalid */
snprintf(skinfilename, sizeof(skinfilename), "%s_0.skin", name);
skinfilename[sizeof(skinfilename)-1] = 0;
skinfilesize = vfsLoadFile(skinfilename, (void**) &skinfilecontent, 0);
- if(skinfilesize < 0)
+ if(skinfilesize >= 0)
Sys_Printf( "Skin %d of %s does not exist, using 0 instead\n", skin, name );
}
sf = NULL;
sf = safe_malloc( sizeof( *sf ) );
sf->next = sf2;
- sprintf(format, "replace %%%ds %%%ds%%n", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1);
- pos = 0;
- if(sscanf(skinfileptr, format, &sf->name, &sf->to, &pos) > 0 && pos > 0)
+ sprintf(format, "replace %%%ds %%%ds", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1);
+ if(sscanf(skinfileptr, format, sf->name, sf->to) == 2)
continue;
- sprintf(format, "%%%ds,%%%ds%%n", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1);
- pos = 0;
- if(sscanf(skinfileptr, format, &sf->name, &sf->to, &pos) > 0 && pos > 0)
+ sprintf(format, " %%%d[^, ] ,%%%ds", (int)sizeof(sf->name)-1, (int)sizeof(sf->to)-1);
+ if((pos = sscanf(skinfileptr, format, sf->name, sf->to)) == 2)
continue;
/* invalid input line -> discard sf struct */
+ Sys_Printf( "Discarding skin directive in %s: %s\n", skinfilename, skinfileptr );
free(sf);
sf = sf2;
}
if( PicoGetSurfaceType( surface ) != PICO_TRIANGLES )
continue;
- /* allocate a surface (ydnar: gs mods) */
- ds = AllocDrawSurface( SURFACE_TRIANGLES );
- ds->entityNum = eNum;
- ds->castShadows = castShadows;
- ds->recvShadows = recvShadows;
-
/* get shader name */
shader = PicoGetSurfaceShader( surface );
if( shader == NULL )
else
si = ShaderInfoForShader( picoShaderName );
+ /* allocate a surface (ydnar: gs mods) */
+ ds = AllocDrawSurface( SURFACE_TRIANGLES );
+ ds->entityNum = eNum;
+ ds->castShadows = castShadows;
+ ds->recvShadows = recvShadows;
+
/* set shader */
ds->shaderInfo = si;
/* copy xyz */
VectorCopy( dv->xyz, points[ j ] );
- VectorCopy( dv->xyz, backs[ j ] );
-
- /* find nearest axial to normal and push back points opposite */
- /* note: this doesn't work as well as simply using the plane of the triangle, below */
- for( k = 0; k < 3; k++ )
- {
- if( fabs( dv->normal[ k ] ) >= fabs( dv->normal[ (k + 1) % 3 ] ) &&
- fabs( dv->normal[ k ] ) >= fabs( dv->normal[ (k + 2) % 3 ] ) )
- {
- backs[ j ][ k ] += dv->normal[ k ] < 0.0f ? 64.0f : -64.0f;
- break;
- }
- }
}
VectorCopy( points[0], points[3] ); // for cyclic usage