Begin to purge engine of this disease I like to call “macro type casting”
diff --git a/src/engine/GPURenderer/r_animation.cpp b/src/engine/GPURenderer/r_animation.cpp
index 18d3293..dc59c69 100644
--- a/src/engine/GPURenderer/r_animation.cpp
+++ b/src/engine/GPURenderer/r_animation.cpp
@@ -56,11 +56,11 @@ static sint R_MDRCullModel( mdrHeader_t* header, trRefEntity_t* ent )
mdrFrame_t* oldFrame, *newFrame;
sint i, frameSize;
- frameSize = ( uint64 )( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
+ frameSize = reinterpret_cast<uint64>( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
// compute frame pointers
- newFrame = ( mdrFrame_t* )( ( uchar8* ) header + header->ofsFrames + frameSize * ent->e.frame );
- oldFrame = ( mdrFrame_t* )( ( uchar8* ) header + header->ofsFrames + frameSize * ent->e.oldframe );
+ newFrame = ( mdrFrame_t* )( reinterpret_cast<uchar8*>( header + header->ofsFrames + frameSize * ent->e.frame ) );
+ oldFrame = ( mdrFrame_t* )( reinterpret_cast<uchar8*>( header + header->ofsFrames + frameSize * ent->e.oldframe ) );
// cull bounding sphere ONLY if this is not an upscaled entity
if( !ent->e.nonNormalizedAxes )
@@ -162,10 +162,10 @@ sint R_MDRComputeFogNum( mdrHeader_t* header, trRefEntity_t* ent )
}
- frameSize = ( uint64 )( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
+ frameSize = reinterpret_cast<uint64>( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
// FIXME: non-normalized axis issues
- mdrFrame = ( mdrFrame_t* )( ( uchar8* ) header + header->ofsFrames + frameSize * ent->e.frame );
+ mdrFrame = ( mdrFrame_t* )( reinterpret_cast<uchar8*>( header + header->ofsFrames + frameSize * ent->e.frame ) );
VectorAdd( ent->e.origin, mdrFrame->localOrigin, localOrigin );
for( i = 1 ; i < tr.world->numfogs ; i++ )
{
@@ -259,10 +259,10 @@ void R_MDRAddAnimSurfaces( trRefEntity_t* ent )
if( header->numLODs <= lodnum )
lodnum = header->numLODs - 1;
- lod = ( mdrLOD_t* )( ( uchar8* )header + header->ofsLODs );
+ lod = ( mdrLOD_t* )( reinterpret_cast<uchar8*>( header + header->ofsLODs ) );
for( i = 0; i < lodnum; i++ )
{
- lod = ( mdrLOD_t* )( ( uchar8* ) lod + lod->ofsEnd );
+ lod = ( mdrLOD_t* )( reinterpret_cast<uchar8*>( lod ) + lod->ofsEnd );
}
// set up lighting
@@ -276,7 +276,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t* ent )
cubemapIndex = R_CubemapForPoint( ent->e.origin );
- surface = ( mdrSurface_t* )( ( uchar8* )lod + lod->ofsSurfaces );
+ surface = ( mdrSurface_t* )( reinterpret_cast<uchar8*>( lod ) + lod->ofsSurfaces );
for( i = 0 ; i < lod->numSurfaces ; i++ )
{
@@ -326,7 +326,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t* ent )
if( !personalModel )
R_AddDrawSurf( ( surfaceType_t* )surface, shader, fogNum, false, false, cubemapIndex );
- surface = ( mdrSurface_t* )( ( uchar8* )surface + surface->ofsEnd );
+ surface = ( mdrSurface_t* )( reinterpret_cast<uchar8*>( surface ) + surface->ofsEnd );
}
}
@@ -364,18 +364,18 @@ void RB_MDRSurfaceAnim( mdrSurface_t* surface )
frontlerp = 1.0f - backlerp;
}
- header = ( mdrHeader_t* )( ( uchar8* )surface + surface->ofsHeader );
+ header = ( mdrHeader_t* )( reinterpret_cast<uchar8*>( surface ) + surface->ofsHeader );
- frameSize = ( uint64 )( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
+ frameSize = reinterpret_cast<uint64>( &( ( mdrFrame_t* )0 )->bones[ header->numBones ] );
- frame = ( mdrFrame_t* )( ( uchar8* )header + header->ofsFrames +
+ frame = ( mdrFrame_t* )( reinterpret_cast<uchar8*>( header ) + header->ofsFrames +
backEnd.currentEntity->e.frame * frameSize );
- oldFrame = ( mdrFrame_t* )( ( uchar8* )header + header->ofsFrames +
+ oldFrame = ( mdrFrame_t* )( reinterpret_cast<uchar8*>( header ) + header->ofsFrames +
backEnd.currentEntity->e.oldframe * frameSize );
RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles * 3 );
- triangles = ( sint* )( ( uchar8* )surface + surface->ofsTriangles );
+ triangles = reinterpret_cast<sint*>( ( reinterpret_cast<uchar8*>( surface ) + surface->ofsTriangles ) );
indexes = surface->numTriangles * 3;
baseIndex = tess.numIndexes;
baseVertex = tess.numVertexes;
@@ -401,7 +401,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t* surface )
for( i = 0 ; i < header->numBones * 12 ; i++ )
{
- ( ( float32* )bonePtr )[i] = frontlerp * ( ( float32* )frame->bones )[i] + backlerp * ( ( float32* )oldFrame->bones )[i];
+ ( reinterpret_cast<float32*>( bonePtr ) )[i] = frontlerp * ( reinterpret_cast<float32*>( frame->bones ) )[i] + backlerp * ( reinterpret_cast<float32*>( oldFrame->bones ) )[i];
}
}
@@ -409,7 +409,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t* surface )
// deform the vertexes by the lerped bones
//
numVerts = surface->numVerts;
- v = ( mdrVertex_t* )( ( uchar8* )surface + surface->ofsVerts );
+ v = ( mdrVertex_t* )( reinterpret_cast<uchar8*>( surface ) + surface->ofsVerts );
for( j = 0; j < numVerts; j++ )
{
vec3_t tempVert, tempNormal;
@@ -494,53 +494,53 @@ void MC_UnCompress( float32 mat[3][4], const uchar8* comp )
{
sint val;
- val = ( sint )( ( uchar16* )( comp ) )[0];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[0] );
val -= 1 << ( MC_BITS_X - 1 );
- mat[0][3] = ( ( float32 )( val ) ) * MC_SCALE_X;
+ mat[0][3] = ( static_cast<float32>( val ) ) * MC_SCALE_X;
- val = ( sint )( ( uchar16* )( comp ) )[1];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[1] );
val -= 1 << ( MC_BITS_Y - 1 );
- mat[1][3] = ( ( float32 )( val ) ) * MC_SCALE_Y;
+ mat[1][3] = ( static_cast<float32>( val ) ) * MC_SCALE_Y;
- val = ( sint )( ( uchar16* )( comp ) )[2];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[2] );
val -= 1 << ( MC_BITS_Z - 1 );
- mat[2][3] = ( ( float32 )( val ) ) * MC_SCALE_Z;
+ mat[2][3] = ( static_cast<float32>( val ) ) * MC_SCALE_Z;
- val = ( sint )( ( uchar16* )( comp ) )[3];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[3] );
val -= 1 << ( MC_BITS_VECT - 1 );
- mat[0][0] = ( ( float32 )( val ) ) * MC_SCALE_VECT;
+ mat[0][0] = ( static_cast<float32>( val ) ) * MC_SCALE_VECT;
- val = ( sint )( ( uchar16* )( comp ) )[4];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[4] );
val -= 1 << ( MC_BITS_VECT - 1 );
- mat[0][1] = ( ( float32 )( val ) ) * MC_SCALE_VECT;
+ mat[0][1] = ( static_cast<float32>( val ) ) * MC_SCALE_VECT;
- val = ( sint )( ( uchar16* )( comp ) )[5];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[5] );
val -= 1 << ( MC_BITS_VECT - 1 );
- mat[0][2] = ( ( float32 )( val ) ) * MC_SCALE_VECT;
+ mat[0][2] = ( static_cast<float32>( val ) ) * MC_SCALE_VECT;
- val = ( sint )( ( uchar16* )( comp ) )[6];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[6] );
val -= 1 << ( MC_BITS_VECT - 1 );
- mat[1][0] = ( ( float32 )( val ) ) * MC_SCALE_VECT;
+ mat[1][0] = ( static_cast<float32>( val ) ) * MC_SCALE_VECT;
- val = ( sint )( ( uchar16* )( comp ) )[7];
+ val = static_cast<sint>( const_cast<uchar16*>( reinterpret_cast<const uchar16*>( comp ) )[7] );
val -= 1 << ( MC_BITS_VECT - 1 );
- mat[1][1] = ( ( float32 )( val ) ) * MC_SCALE_VECT;
+ mat[1][1] = ( static_cast<float32>( val ) ) * MC_SCALE_VECT;
[... diff too long, it was truncated ...]
GitHub
sha: 55bcbc8b