Com compiles without warnings on gcc 7.2.0. Might just test clang too

This commit is contained in:
sago007
2018-02-10 13:43:56 +01:00
parent a099619f9e
commit 57b2e3c0fd
2 changed files with 36 additions and 76 deletions

View File

@@ -40,7 +40,7 @@ R_LoadMDO
================= =================
*/ */
qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_name ) { qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_name ) {
int i, j, k, lodindex; int i, j, lodindex;
mdoHeader_t *pinmodel, *mdo; mdoHeader_t *pinmodel, *mdo;
mdoFrame_t *frame; mdoFrame_t *frame;
mdoLOD_t *lod; mdoLOD_t *lod;
@@ -103,7 +103,7 @@ qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_na
mod->numLods = mdo->numLODs; // ... don't forget this or LODs won't work mod->numLods = mdo->numLODs; // ... don't forget this or LODs won't work
// swap all the frames // swap all the frames
frameSize = (int)( &((mdoFrame_t *)0)->bones[ mdo->numBones ] ); frameSize = (size_t)( &((mdoFrame_t *)0)->bones[ mdo->numBones ] );
for ( i = 0 ; i < mdo->numFrames ; i++, frame++) { for ( i = 0 ; i < mdo->numFrames ; i++, frame++) {
frame = (mdoFrame_t *) ( (byte *)mdo + mdo->ofsFrames + i * frameSize ); frame = (mdoFrame_t *) ( (byte *)mdo + mdo->ofsFrames + i * frameSize );
frame->radius = LittleFloat( frame->radius ); frame->radius = LittleFloat( frame->radius );
@@ -206,7 +206,7 @@ qboolean R_LoadMDO( model_t *mod, void *buffer, int filesize, const char *mod_na
// find the next LOD // find the next LOD
lod = (mdoLOD_t *)( (byte *)lod + lod->ofsEnd ); lod = (mdoLOD_t *)( (byte *)lod + lod->ofsEnd );
} }
return qtrue; return qtrue;
} }
@@ -357,7 +357,7 @@ void R_AddMDOSurfaces( trRefEntity_t *ent ) {
mdoLOD_t *lod; mdoLOD_t *lod;
shader_t *shader; shader_t *shader;
skin_t *skin; skin_t *skin;
int i, j, k; int i, j;
int lodnum = 0; int lodnum = 0;
int fogNum = 0; int fogNum = 0;
int cull; int cull;
@@ -581,8 +581,6 @@ md3Tag_t *R_GetMDOTag( mdoHeader_t *mod, int framenum, const char *tagName, md3T
if ( !strcmp( bone->name, tagName ) ) if ( !strcmp( bone->name, tagName ) )
{ {
vec4_t quat;
vec3_t trans;
float matrix[3][4]; float matrix[3][4];
Q_strncpyz(dest->name, bone->name, sizeof(dest->name)); Q_strncpyz(dest->name, bone->name, sizeof(dest->name));
@@ -618,7 +616,7 @@ void RB_SurfaceMDO( mdoSurface_t *surface )
{ {
int i, j, k; int i, j, k;
int frameSize; int frameSize;
float frontlerp, backlerp; float backlerp;
int *triangles; int *triangles;
int indexes; int indexes;
int baseIndex, baseVertex; int baseIndex, baseVertex;
@@ -629,8 +627,7 @@ void RB_SurfaceMDO( mdoSurface_t *surface )
mdoHeader_t *header; mdoHeader_t *header;
mdoFrame_t *frame; mdoFrame_t *frame;
mdoFrame_t *oldFrame; mdoFrame_t *oldFrame;
boneMatrix_t bones[MDO_MAX_BONES], *bonePtr, *bone; boneMatrix_t bones[MDO_MAX_BONES], *bonePtr, *bone;
mdoBoneInfo_t *boneInfo;
refEntity_t *ent; refEntity_t *ent;
ent = &backEnd.currentEntity->e; ent = &backEnd.currentEntity->e;
@@ -640,12 +637,10 @@ void RB_SurfaceMDO( mdoSurface_t *surface )
if (ent->oldframe == ent->frame) if (ent->oldframe == ent->frame)
{ {
backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used
frontlerp = 1;
} }
else else
{ {
backlerp = ent->backlerp; backlerp = ent->backlerp;
frontlerp = 1.0f - backlerp;
} }
header = (mdoHeader_t *)((byte *)surface - surface->ofsHeader); header = (mdoHeader_t *)((byte *)surface - surface->ofsHeader);
@@ -678,9 +673,6 @@ void RB_SurfaceMDO( mdoSurface_t *surface )
boneRefList = ( int * )( (byte *)surface + surface->ofsBoneRefs ); boneRefList = ( int * )( (byte *)surface + surface->ofsBoneRefs );
boneRef = boneRefList; boneRef = boneRefList;
// boneInfos
boneInfo = (mdoBoneInfo_t *)((byte *)header + header->ofsBones);
bonePtr = bones; bonePtr = bones;
for( i = 0 ; i < surface->numBoneRefs ; i++, boneRef++ ) for( i = 0 ; i < surface->numBoneRefs ; i++, boneRef++ )
{ {

View File

@@ -1150,7 +1150,7 @@ void RB_CalcEnvironmentTexCoordsR( float *st )
vec3_t sundy; vec3_t sundy;
float size; float size;
float dist; float dist;
vec3_t origin, vec1, vec2; vec3_t vec1, vec2;
v = tess.xyz[0]; v = tess.xyz[0];
normal = tess.normal[0]; normal = tess.normal[0];
@@ -1196,7 +1196,7 @@ void RB_CalcCelTexCoords( float *st )
{ {
int i; int i;
float *v, *normal; float *v, *normal;
vec3_t viewer, reflected, lightdir, directedLight, lightdured; vec3_t viewer, reflected, lightdir, directedLight;
float d, l, p; float d, l, p;
@@ -1385,12 +1385,12 @@ void RB_CalcRotateTexCoords( float degsPerSecond, float *st )
void RB_CalcAtlasTexCoords( const atlas_t *at, float *st ) void RB_CalcAtlasTexCoords( const atlas_t *at, float *st )
{ {
float p;
texModInfo_t tmi; texModInfo_t tmi;
int w = (int)at->width; int w = (int)at->width;
int h = (int)at->height; int h = (int)at->height;
int framex, framey; int framex = 0;
int framey = 0;
// modes: // modes:
// 0 - static / animated // 0 - static / animated
@@ -1707,28 +1707,16 @@ static void RB_CalcDiffuseColor_scalar( unsigned char *colors )
// leilei - reveal normals to GLSL for light processing. HACK HACK HACK HACK HACK HACK // leilei - reveal normals to GLSL for light processing. HACK HACK HACK HACK HACK HACK
void RB_CalcNormal( unsigned char *colors ) void RB_CalcNormal( unsigned char *colors )
{ {
int i, j;
float *v; float *v;
float *normal = ( float * ) tess.normal; float *normal = ( float * ) tess.normal;
float incoming;
trRefEntity_t *ent;
int ambientLightInt;
vec3_t ambientLight;
vec3_t lightDir;
vec3_t directedLight;
vec3_t n, m; vec3_t n, m;
int numVertexes; int numVertexes;
float mult = r_shownormals->value - 1;
ent = backEnd.currentEntity;
ambientLightInt = ent->ambientLightInt;
v = tess.xyz[0]; v = tess.xyz[0];
//normal = tess.normal[0]; //normal = tess.normal[0];
numVertexes = tess.numVertexes; numVertexes = tess.numVertexes;
for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) { for (int i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) {
int y; int y;
float mid; float mid;
for (y=0;y<3;y++){ for (y=0;y<3;y++){
@@ -1765,7 +1753,6 @@ void RB_CalcNormal( unsigned char *colors )
void RB_CalcDiffuseColor_Specular( unsigned char *colors ) void RB_CalcDiffuseColor_Specular( unsigned char *colors )
{ {
int i, j; int i, j;
int speccap = 0;
float spec; float spec;
float *v, *normal; float *v, *normal;
float incoming; float incoming;
@@ -1825,16 +1812,13 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
{ {
float ilength; float ilength;
int b;
vec3_t viewer, reflected; vec3_t viewer, reflected;
float l, d;
// int b;
VectorCopy( backEnd.currentEntity->lightDir, lightDir ); VectorCopy( backEnd.currentEntity->lightDir, lightDir );
VectorNormalizeFast( lightDir ); VectorNormalizeFast( lightDir );
// calculate the specular color // calculate the specular color
d = DotProduct (normal, lightDir); float d = DotProduct (normal, lightDir);
// we don't optimize for the d < 0 case since this tends to // we don't optimize for the d < 0 case since this tends to
// cause visual artifacts such as faceted "snapping" // cause visual artifacts such as faceted "snapping"
@@ -1844,7 +1828,7 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
VectorSubtract (backEnd.or.viewOrigin, v, viewer); VectorSubtract (backEnd.or.viewOrigin, v, viewer);
ilength = Q_rsqrt( DotProduct( viewer, viewer ) ); ilength = Q_rsqrt( DotProduct( viewer, viewer ) );
l = DotProduct (reflected, viewer); float l = DotProduct (reflected, viewer);
l *= ilength; l *= ilength;
if (l < 0) { if (l < 0) {
@@ -1869,14 +1853,20 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
} }
j = ri.ftol(ambientLight[0] + incoming * directedLight[0]); j = ri.ftol(ambientLight[0] + incoming * directedLight[0]);
if ( j > shadecap ) {j = shadecap ; j += ri.ftol(spec * specularLight[0]); } if ( j > shadecap ) {
j = shadecap;
j += ri.ftol(spec * specularLight[0]);
}
// j += specularLight[0]; // j += specularLight[0];
if ( j > 255) j = 255; if ( j > 255) j = 255;
colors[i*4+0] = j; colors[i*4+0] = j;
j = ri.ftol(ambientLight[1] + incoming * directedLight[1]); j = ri.ftol(ambientLight[1] + incoming * directedLight[1]);
if ( j > shadecap ) { j = shadecap ; j += ri.ftol(spec * specularLight[1]); } if ( j > shadecap ) {
j = shadecap;
j += ri.ftol(spec * specularLight[1]);
}
// j += specularLight[1]; // j += specularLight[1];
if ( j > 255) j = 255; if ( j > 255) j = 255;
@@ -1885,7 +1875,10 @@ void RB_CalcDiffuseColor_Specular( unsigned char *colors )
colors[i*4+1] = j; colors[i*4+1] = j;
j = ri.ftol(ambientLight[2] + incoming * directedLight[2]); j = ri.ftol(ambientLight[2] + incoming * directedLight[2]);
if ( j > shadecap ) {j = shadecap ; j += ri.ftol(spec * specularLight[2]); } if ( j > shadecap ) {
j = shadecap;
j += ri.ftol(spec * specularLight[2]);
}
// j += specularLight[2]; // j += specularLight[2];
if ( j > 255) j = 255; if ( j > 255) j = 255;
@@ -1925,7 +1918,7 @@ void RB_CalcUniformColor( unsigned char *colors )
int i; int i;
trRefEntity_t *ent; trRefEntity_t *ent;
vec3_t ambientLight; vec3_t ambientLight;
vec3_t directedLight; //vec3_t directedLight;
vec4_t uniformLight; vec4_t uniformLight;
int numVertexes; int numVertexes;
float normalize; float normalize;
@@ -1933,7 +1926,7 @@ void RB_CalcUniformColor( unsigned char *colors )
ent = backEnd.currentEntity; ent = backEnd.currentEntity;
VectorCopy( ent->ambientLight, ambientLight ); VectorCopy( ent->ambientLight, ambientLight );
VectorCopy( ent->directedLight, directedLight ); //VectorCopy( ent->directedLight, directedLight );
VectorAdd( ambientLight, ambientLight/*directedLight*/, uniformLight ); VectorAdd( ambientLight, ambientLight/*directedLight*/, uniformLight );
@@ -1990,22 +1983,11 @@ void RB_CalcFlatAmbient( unsigned char *colors )
{ {
int i, j; int i, j;
float *v, *normal; float *v, *normal;
float incoming;
trRefEntity_t *ent; trRefEntity_t *ent;
int ambientLightInt;
vec3_t ambientLight; vec3_t ambientLight;
vec3_t lightDir;
vec3_t directedLight;
int numVertexes; int numVertexes;
ent = backEnd.currentEntity; ent = backEnd.currentEntity;
ambientLightInt = ent->ambientLightInt;
VectorCopy( ent->ambientLight, ambientLight ); VectorCopy( ent->ambientLight, ambientLight );
//VectorCopy( ent->directedLight, directedLight );
lightDir[0] = 0;
lightDir[1] = 0;
lightDir[2] = 1;
v = tess.xyz[0]; v = tess.xyz[0];
normal = tess.normal[0]; normal = tess.normal[0];
@@ -2038,15 +2020,11 @@ void RB_CalcFlatDirect( unsigned char *colors )
{ {
int i, j; int i, j;
float *v, *normal; float *v, *normal;
float incoming;
trRefEntity_t *ent; trRefEntity_t *ent;
int ambientLightInt;
vec3_t ambientLight; vec3_t ambientLight;
vec3_t lightDir;
vec3_t directedLight; vec3_t directedLight;
int numVertexes; int numVertexes;
ent = backEnd.currentEntity; ent = backEnd.currentEntity;
ambientLightInt = ent->ambientLightInt;
VectorCopy( ent->ambientLight, ambientLight ); VectorCopy( ent->ambientLight, ambientLight );
VectorCopy( ent->directedLight, directedLight ); VectorCopy( ent->directedLight, directedLight );
@@ -2060,10 +2038,6 @@ void RB_CalcFlatDirect( unsigned char *colors )
if (directedLight[1] < 0) directedLight[1] = 0; if (directedLight[1] < 0) directedLight[1] = 0;
if (directedLight[2] < 0) directedLight[2] = 0; if (directedLight[2] < 0) directedLight[2] = 0;
lightDir[0] = 0;
lightDir[1] = 0;
lightDir[2] = 1;
v = tess.xyz[0]; v = tess.xyz[0];
normal = tess.normal[0]; normal = tess.normal[0];
@@ -2118,14 +2092,12 @@ void RB_CalcEyes( float *st, qboolean theothereye)
{ {
int i; int i;
float *v, *normal; float *v, *normal;
vec3_t viewer, reflected, eyepos, eyelook, stare; vec3_t viewer, reflected, eyepos, stare;
float d, l, erp; float d;
int idk; int idk;
vec3_t stareat, staree; vec3_t stareat;
float dilation = 2;
VectorCopy(lightOrigin, staree);
VectorCopy(backEnd.or.viewOrigin, stareat); VectorCopy(backEnd.or.viewOrigin, stareat);
@@ -2156,11 +2128,11 @@ void RB_CalcEyes( float *st, qboolean theothereye)
// We need to adjust the stareat vectors to local coordinates // We need to adjust the stareat vectors to local coordinates
vec3_t temp; vec3_t temp;
VectorSubtract( stareat, backEnd.currentEntity->e.origin, temp ); VectorSubtract( stareat, backEnd.currentEntity->e.origin, temp );
stareat[0] = DotProduct( temp, backEnd.currentEntity->e.axis[0] ); stareat[0] = DotProduct( temp, backEnd.currentEntity->e.axis[0] );
stareat[1] = DotProduct( temp, backEnd.currentEntity->e.axis[1] ); stareat[1] = DotProduct( temp, backEnd.currentEntity->e.axis[1] );
stareat[2] = DotProduct( temp, backEnd.currentEntity->e.axis[2] ); stareat[2] = DotProduct( temp, backEnd.currentEntity->e.axis[2] );
@@ -2195,8 +2167,6 @@ if (r_leidebugeye->integer == 2)
for (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 ) for (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 )
{ {
float norm1, norm2;
// Base eye position // Base eye position
VectorSubtract (backEnd.or.viewOrigin, v, viewer); VectorSubtract (backEnd.or.viewOrigin, v, viewer);
//VectorSubtract (backEnd.currentEntity->e.eyepos[0], v, viewer); //VectorSubtract (backEnd.currentEntity->e.eyepos[0], v, viewer);
@@ -2228,8 +2198,6 @@ if (r_leidebugeye->integer == 2)
VectorSubtract (stareat, v, stare); VectorSubtract (stareat, v, stare);
VectorNormalizeFast (stare); VectorNormalizeFast (stare);
erp = DotProduct (normal, stare);
// Limit the eye's turning so it doesn't have dead eyes // Limit the eye's turning so it doesn't have dead eyes
for (idk=0;idk<3;idk++){ for (idk=0;idk<3;idk++){
stare[idk] *= 22; stare[idk] *= 22;