Skip to content

Commit

Permalink
cleanup sr, ogre: for (, if (
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Nov 26, 2024
1 parent 97596f8 commit bfae59f
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions src/OgreCommon/GameEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct GameEntityTransform
Ogre::Vector3 vScale;
};


struct GameEntity
{
private:
Expand All @@ -43,13 +44,11 @@ struct GameEntity
//Your custom pointers go here, i.e. physics representation.
//used only by Logic thread (hkpEntity, btRigidBody, etc)

//----------------------------------------
// Used by both Logic and Graphics threads
//----------------------------------------
GameEntityTransform *mTransform[NUM_GAME_ENTITY_BUFFERS];
Ogre::SceneMemoryMgrTypes mType;

//----------------------------------------
// Read-only
//----------------------------------------
MovableObjectDefinition const *mMoDefinition;
Expand All @@ -64,11 +63,12 @@ struct GameEntity
mMoDefinition( moDefinition ),
mTransformBufferIdx( 0 )
{
for( int i=0; i<NUM_GAME_ENTITY_BUFFERS; ++i )
for (int i=0; i < NUM_GAME_ENTITY_BUFFERS; ++i)
mTransform[i] = 0;
}

Ogre::uint32 getId() const { return mId; }
Ogre::uint32 getId() const
{ return mId; }

bool operator < ( const GameEntity *_r ) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/OgreCommon/GameEntityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GameEntity* GameEntityManager::addGameEntity( Ogre::SceneMemoryMgrTypes type,
aquireTransformSlot( slot, bufferIdx );

gameEntity->mTransformBufferIdx = bufferIdx;
for( size_t i = 0; i < NUM_GAME_ENTITY_BUFFERS; ++i )
for (size_t i = 0; i < NUM_GAME_ENTITY_BUFFERS; ++i)
{
gameEntity->mTransform[i] = mTransformBuffers[bufferIdx] + slot + cNumTransforms * i;
memcpy( gameEntity->mTransform[i], &cge.initialTransform, sizeof(GameEntityTransform) );
Expand Down
4 changes: 2 additions & 2 deletions src/OgreCommon/GraphicsSystemCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void GraphicsSystem::loadHlmsDiskCache()

if( mUseHlmsDiskCache )
{
for( size_t i = HLMS_LOW_LEVEL + 1u; i < HLMS_MAX; ++i )
for (size_t i = HLMS_LOW_LEVEL + 1u; i < HLMS_MAX; ++i)
{
Hlms *hlms = hlmsManager->getHlms( static_cast<HlmsTypes>( i ) );
if( hlms )
Expand Down Expand Up @@ -159,7 +159,7 @@ void GraphicsSystem::saveHlmsDiskCache()

if( mUseHlmsDiskCache )
{
for( size_t i = HLMS_LOW_LEVEL + 1u; i < HLMS_MAX; ++i )
for (size_t i = HLMS_LOW_LEVEL + 1u; i < HLMS_MAX; ++i)
{
Hlms *hlms = hlmsManager->getHlms( static_cast<HlmsTypes>( i ) );
if( hlms )
Expand Down
2 changes: 1 addition & 1 deletion src/OgreCommon/GraphicsSystemEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void GraphicsSystem::gameEntityAdded( const GameEntityManager::CreatedGameEntity
StringVector materialNames = cge->gameEntity->mMoDefinition->submeshMaterials;
size_t minMaterials = std::min( materialNames.size(), item->getNumSubItems() );

for( size_t i=0; i<minMaterials; ++i )
for (size_t i=0; i<minMaterials; ++i)
{
item->getSubItem( i )->setDatablockOrMaterialName(
materialNames[i], cge->gameEntity->mMoDefinition->resourceGroup );
Expand Down
2 changes: 1 addition & 1 deletion src/OgreCommon/LogicSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LogicSystem::LogicSystem( GameState *gameState ) :
{
//mCurrentTransformIdx is 1, 0 and NUM_GAME_ENTITY_BUFFERS - 1 are taken by GraphicsSytem at startup
//The range to fill is then [2; NUM_GAME_ENTITY_BUFFERS-1]
for( Ogre::uint32 i=2; i<NUM_GAME_ENTITY_BUFFERS-1; ++i )
for (Ogre::uint32 i=2; i < NUM_GAME_ENTITY_BUFFERS-1; ++i)
mAvailableTransformIdx.push_back( i );
}
LogicSystem::~LogicSystem()
Expand Down
10 changes: 5 additions & 5 deletions src/OgreCommon/Utils/MiscUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Demo

//Calculate the weights
float fWeightSum = 0;
for( uint32 i=0; i<kernelRadius + 1u; ++i )
for (uint32 i=0; i < kernelRadius + 1u; ++i)
{
const float _X = i - fKernelRadius + ( 1.0f - 1.0f / stepSize );
float fWeight = 1.0f / std::sqrt ( 2.0f * Math::PI * gaussianDeviation * gaussianDeviation );
Expand All @@ -48,7 +48,7 @@ namespace Demo
fWeightSum = fWeightSum * 2.0f - weights[kernelRadius];

//Normalize the weights
for( uint32 i=0; i<kernelRadius + 1u; ++i )
for (uint32 i=0; i < kernelRadius + 1u; ++i)
weights[i] /= fWeightSum;

//Remove shader constants from previous calls (needed in case we've reduced the radius size)
Expand Down Expand Up @@ -76,7 +76,7 @@ namespace Demo
char tmp[32];
LwString weightsString( LwString::FromEmptyPointer( tmp, sizeof(tmp) ) );
const uint32 floatsPerParam = sizeof( ShaderParams::ManualParam().dataBytes ) / sizeof(float);
for( uint32 i=0; i<kernelRadius + 1u; i += floatsPerParam )
for (uint32 i=0; i < kernelRadius + 1u; i += floatsPerParam)
{
weightsString.clear();
if( bIsMetal )
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace Demo

//Calculate the weights
float fWeightSum = 0;
for( uint32 i=0; i<kernelRadius + 1u; ++i )
for (uint32 i=0; i < kernelRadius + 1u; ++i)
{
const float _X = i - fKernelRadius + ( 1.0f - 1.0f / stepSize );
float fWeight = 1.0f / std::sqrt ( 2.0f * Math::PI * gaussianDeviation * gaussianDeviation );
Expand All @@ -189,7 +189,7 @@ namespace Demo
fWeightSum = fWeightSum * 2.0f - weights[kernelRadius];

//Normalize the weights
for( uint32 i=0; i<kernelRadius + 1u; ++i )
for (uint32 i=0; i < kernelRadius + 1u; ++i)
weights[i] /= fWeightSum;

GpuProgramParametersSharedPtr psParams = pass->getFragmentProgramParameters();
Expand Down
2 changes: 1 addition & 1 deletion src/OgreCommon/Utils/ScreenSpaceReflections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace Demo
void ScreenSpaceReflections::update( Ogre::Camera *camera )
{
Ogre::Vector2 projectionAB = camera->getProjectionParamsAB();
for( int i=0; i<2; ++i )
for (int i=0; i<2; ++i)
{
//The division will keep "linearDepth" in the shader in the [0; 1] range.
//projectionAB.y /= camera->getFarClipDistance();
Expand Down
2 changes: 1 addition & 1 deletion src/OgreCommon/Utils/SmaaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Demo
else if( caps->isShaderProfileSupported( "glsl330" ) )
preprocessorDefines += "SMAA_GLSL_3=1,";

for( size_t i=0; i<sizeof(materialNames) / sizeof(materialNames[0]); ++i )
for (size_t i=0; i<sizeof(materialNames) / sizeof(materialNames[0]); ++i)
{
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().load(
materialNames[i],
Expand Down
2 changes: 1 addition & 1 deletion src/common/AppGui_CompositorUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Cam* AppGui::CreateCamera(String name,
const Ogre::Real eyeDistance = 0.5f;
const Ogre::Real eyeFocusDistance = 0.45f;

for( int i = 0; i < 2; ++i )
for (int i = 0; i < 2; ++i)
{
const Ogre::Vector3 camPos( eyeDistance * ( Ogre::Real( i ) * 2 - 1 ), 0, 0 );
mEyeCameras[i]->setPosition( camPos );
Expand Down
2 changes: 1 addition & 1 deletion src/common/AppGui_GI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void AppGui::GIVoxelizeScene()
++itor;
}

/*for( int i=0; i < 3 ; ++i)
/*for (int i=0; i < 3; ++i)
ifSet.mNumProbes[i] = 1u;
ifSet.mIrradianceResolution = 16u;
ifSet.mDepthProbeResolution = 32u;*/
Expand Down
26 changes: 13 additions & 13 deletions src/common/AppGui_SSAO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ void AppGui::InitSSAO()
{
// Create SSAO kernel samples
float kernelSamples[64][4];
for( size_t i = 0; i < 64u; ++i )
for (size_t i = 0; i < 64u; ++i)
{
// Vector3 sample( 10, 10, 10 );
// while( sample.squaredLength() > 1.0f )
// {
// sample = Vector3( Math::RangeRandom( -1.0f, 1.0f ),
// Math::RangeRandom( -1.0f, 1.0f ),
// Math::RangeRandom( 0.01f, 1.0f ) );
//// sample = Vector3( Math::RangeRandom( -0.1f, 0.1f ),
//// Math::RangeRandom( -0.1f, 0.1f ),
//// Math::RangeRandom( 0.5f, 1.0f ) );
// }
// Vector3 sample( 10, 10, 10 );
// while( sample.squaredLength() > 1.0f )
// {
// sample = Vector3( Math::RangeRandom( -1.0f, 1.0f ),
// Math::RangeRandom( -1.0f, 1.0f ),
// Math::RangeRandom( 0.01f, 1.0f ) );
//// sample = Vector3( Math::RangeRandom( -0.1f, 0.1f ),
//// Math::RangeRandom( -0.1f, 0.1f ),
//// Math::RangeRandom( 0.5f, 1.0f ) );
// }
Vector3 sample = Vector3( Math::RangeRandom( -1.0f, 1.0f ),
Math::RangeRandom( -1.0f, 1.0f ),
Math::RangeRandom( 0.0f, 1.0f ) );
Expand Down Expand Up @@ -81,9 +81,9 @@ void AppGui::InitSSAO()
stagingTexture->startMapRegion();
TextureBox texBox = stagingTexture->mapRegion( 2u, 2u, 1u, 1u, PFG_RGBA8_SNORM );

for( size_t j = 0; j < texBox.height; ++j )
for (size_t j = 0; j < texBox.height; ++j)
{
for( size_t i = 0; i < texBox.width; ++i )
for (size_t i = 0; i < texBox.width; ++i)
{
Vector3 noise = Vector3( Math::RangeRandom( -1.0f, 1.0f ),
Math::RangeRandom( -1.0f, 1.0f ), 0.0f );
Expand Down
8 changes: 4 additions & 4 deletions src/common/AppGui_Shadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void AppGui::createPcfShadowNode()
sp.numPssmSplits = min(4, max(2, pSet->g.shadow_count ));

sp.resolution[0].x = size1; sp.resolution[0].y = size1;
for( size_t i = 1u; i < 4u; ++i )
for (size_t i = 1u; i < 4u; ++i)
{ sp.resolution[i].x = size2; sp.resolution[i].y = size2; }
// [0 ]
// [ ]
Expand Down Expand Up @@ -409,7 +409,7 @@ void AppGui::createShadowMapDebugOverlays()
CompositorShadowNode *shadowNode = workspace->findShadowNode( shadowNodeName );
const CompositorShadowNodeDef *shadowNodeDef = shadowNode->getDefinition();

for( size_t i = 0u; i < 5u; ++i )
for (size_t i = 0u; i < 5u; ++i)
{
const String datablockName( "depthShadow" + StringConverter::toString( i ) );
HlmsUnlitDatablock *depthShadow =
Expand Down Expand Up @@ -439,7 +439,7 @@ void AppGui::createShadowMapDebugOverlays()
mDebugOverlayPSSM = mgr.create( "PSSM Overlays" );
mDebugOverlaySpotlights = mgr.create( "Spotlight overlays" );

for( int i = 0; i < 3; ++i )
for (int i = 0; i < 3; ++i)
{
// Create a panel
v1::OverlayContainer *panel =
Expand All @@ -452,7 +452,7 @@ void AppGui::createShadowMapDebugOverlays()
mDebugOverlayPSSM->add2D( panel );
}

for( int i = 3; i < 5; ++i )
for (int i = 3; i < 5; ++i)
{
// Create a panel
v1::OverlayContainer *panel =
Expand Down
8 changes: 4 additions & 4 deletions src/common/AppGui_UtilMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ void AppGui::unloadTexturesFromUnusedMaterials(
OGRE_ASSERT_HIGH( dynamic_cast<T *>( datablock ) );
T *derivedDatablock = static_cast<T *>( datablock );

for( size_t texUnit = 0; texUnit < MaxNumTextures; ++texUnit )
for (size_t texUnit = 0; texUnit < MaxNumTextures; ++texUnit)
{
// Check each texture from the material
TextureGpu *tex = derivedDatablock->getTexture( (uint8_t)texUnit );
if( tex )
if (tex)
{
// If getLinkedRenderables is empty, then the material is not in use,
// and thus so is potentially the texture
Expand All @@ -67,10 +67,10 @@ void AppGui::unloadTexturesFromUnusedMaterials()

// Check each material from each Hlms (except low level) to see if their material is
// currently in use. If it's not, then its textures may be not either
for( size_t i = HLMS_PBS; i < HLMS_MAX; ++i )
for (size_t i = HLMS_PBS; i < HLMS_MAX; ++i)
{
Hlms *hlms = hlmsManager->getHlms( static_cast<HlmsTypes>( i ) );
if( hlms )
if (hlms)
{
const Hlms::HlmsDatablockMap &datablocks = hlms->getDatablockMap();

Expand Down
2 changes: 1 addition & 1 deletion src/common/App_SceneObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void App::ToggleObjSim()
if (!objSim) // off sim
{
// Destroy blt world
for(int i = world->getNumCollisionObjects() - 1; i >= 0; i--)
for (int i = world->getNumCollisionObjects() - 1; i >= 0; i--)
{
btCollisionObject* obj = world->getCollisionObjectArray()[i];
delete obj->getCollisionShape();
Expand Down
6 changes: 3 additions & 3 deletions src/editor/App_SceneInitEd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ void App::BltWorldDestroy()
void App::BltClear()
{
if (world)
for(int i = world->getNumCollisionObjects() - 1; i >= 0; i--)
for (int i = world->getNumCollisionObjects() - 1; i >= 0; i--)
{
btCollisionObject* obj = world->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
Expand Down Expand Up @@ -732,13 +732,13 @@ void App::BltClear()
}
shapes.resize(0);
for(int i = 0; i < meshes.size(); i++)
for (int i = 0; i < meshes.size(); i++)
{
delete meshes[i];
}
meshes.resize(0);
for(int i = 0; i < actions.size(); i++)
for (int i = 0; i < actions.size(); i++)
{
world->removeAction(actions[i]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/road/SplineBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ Vector3 SplineBase::interpolate(int id, Real t) const
const Vector3& p1 = mP[id].pos, p2 = mP[id1].pos;

// special cases
if (t == 0.0f) return p1;
else if(t == 1.0f) return p2;
if (t == 0.0f) return p1;
else if (t == 1.0f) return p2;

const Vector3& n1 = mP[id].tan, n2 = mP[id1].tan;

Expand All @@ -117,8 +117,8 @@ Real SplineBase::interpWidth(int id, Real t) const
{
int id1 = getNext(id);
const Real& p1 = mP[id].width, p2 = mP[id1].width;
if (t == 0.0f) return p1;
else if(t == 1.0f) return p2;
if (t == 0.0f) return p1;
else if (t == 1.0f) return p2;
const Real& n1 = mP[id].wtan, n2 = mP[id1].wtan;

Real t2 = t*t, t3 = t2*t;
Expand Down
2 changes: 1 addition & 1 deletion src/vdrift/bucketed_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class hasher <std::string>
{
unsigned int hash = 5381;
unsigned int strlen = str.length();
for(std::size_t i = 0; i < strlen; ++i)
for (std::size_t i = 0; i < strlen; ++i)
{
hash = ((hash << 5) + hash) + str[i];
}
Expand Down
8 changes: 4 additions & 4 deletions src/vdrift/cardynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MATHVECTOR<Dbl,3> CARDYNAMICS::GetWheelPosition(WHEEL_POSITION wp, Dbl displacem
QUATERNION<Dbl> CARDYNAMICS::GetWheelOrientation(WHEEL_POSITION wp) const
{
QUATERNION<Dbl> siderot;
if(wp == FRONT_RIGHT || wp == REAR_RIGHT || wp == REAR2_RIGHT || wp == REAR3_RIGHT)
if (wp == FRONT_RIGHT || wp == REAR_RIGHT || wp == REAR2_RIGHT || wp == REAR3_RIGHT)
{
siderot.Rotate(PI_d, 0, 0, 1);
}
Expand Down Expand Up @@ -299,13 +299,13 @@ void CARDYNAMICS::ApplyForce(const MATHVECTOR<Dbl,3> & force, const MATHVECTOR<D
void CARDYNAMICS::ApplyTorque(const MATHVECTOR<Dbl,3> & torque)
{
body.ApplyTorque(torque);
//if(torque.MagnitudeSquared() > 1E-6)
//if (torque.MagnitudeSquared() > 1E-6)
// chassis->applyTorque(ToBulletVector(torque));
}

void CARDYNAMICS::UpdateWheelVelocity()
{
for(int i = 0; i < numWheels; ++i)
for (int i = 0; i < numWheels; ++i)
{
wheel_velocity[i] = body.GetVelocity(wheel_position[i] - body.GetPosition());
//btVector3 offset = ToBulletVector(wheel_position[i]) - chassis->getCenterOfMassPosition();
Expand All @@ -315,7 +315,7 @@ void CARDYNAMICS::UpdateWheelVelocity()

void CARDYNAMICS::UpdateWheelTransform()
{
for(int i = 0; i < numWheels; ++i)
for (int i = 0; i < numWheels; ++i)
{
wheel_position[i] = GetWheelPositionAtDisplacement(WHEEL_POSITION(i), suspension[i].GetDisplacementPercent());
wheel_orientation[i] = Orientation() * GetWheelSteeringAndSuspensionOrientation(WHEEL_POSITION(i));
Expand Down

0 comments on commit bfae59f

Please sign in to comment.