Skip to content

Commit

Permalink
Code simplify, remove unused, replace list to vector, lower scope code
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek committed Oct 7, 2022
1 parent 79ef6b1 commit faf8edc
Show file tree
Hide file tree
Showing 51 changed files with 273 additions and 334 deletions.
11 changes: 7 additions & 4 deletions Components/Hlms/Pbs/src/Cubemaps/OgreCubemapProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ namespace Ogre
{
if( !mCreator->getAutomaticMode() )
{
const bool useManual = mTexture->getNumMipmaps() > 1u;
if( useManual )
if( mTexture )
{
TextureGpu *channel = mWorkspace->getExternalRenderTargets()[0];
mCreator->releaseTmpRtt( channel );
const bool useManual = mTexture->getNumMipmaps() > 1u;
if( useManual )
{
TextureGpu *channel = mWorkspace->getExternalRenderTargets()[0];
mCreator->releaseTmpRtt( channel );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Components/Hlms/Pbs/src/Vct/OgreVoxelizedMeshCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ namespace Ogre
}
}

itor = mMeshes.insert( std::pair<IdString, VoxelizedMesh>( meshName, voxelizedMesh ) ).first;
itor = mMeshes.emplace( meshName, voxelizedMesh ).first;

sceneManager->destroyItem( tmpItem );
}
Expand Down
6 changes: 2 additions & 4 deletions Components/MeshLodGenerator/src/OgreLodCollapseCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ namespace Ogre
computeVertexCollapseCost( data, vertexi, collapseCost, collapseToi );

vertex->collapseToi = collapseToi;
vertex->costHeapPosition = data->mCollapseCostHeap.insert(
LodData::CollapseCostHeap::value_type( collapseCost, vertexi ) );
vertex->costHeapPosition = data->mCollapseCostHeap.emplace( collapseCost, vertexi );
}

void LodCollapseCost::updateVertexCollapseCost( LodData *data, LodData::VertexI vertexi )
Expand All @@ -103,8 +102,7 @@ namespace Ogre
if( collapseCost != LodData::UNINITIALIZED_COLLAPSE_COST )
{
vertex->collapseToi = collapseToi;
vertex->costHeapPosition = data->mCollapseCostHeap.insert(
LodData::CollapseCostHeap::value_type( collapseCost, vertexi ) );
vertex->costHeapPosition = data->mCollapseCostHeap.emplace( collapseCost, vertexi );
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace Ogre
e.cost = it->cost;
OgreAssert( e.cost >= 0 && e.cost != LodData::UNINITIALIZED_COLLAPSE_COST,
"Invalid collapse cost" );
mProfileLookup.insert( ProfileLookup::value_type( *src, e ) );
mProfileLookup.emplace( *src, e );
}
}

Expand Down
4 changes: 2 additions & 2 deletions Components/MeshLodGenerator/src/OgreLodOutsideMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,11 @@ namespace Ogre
// because those are not on the horizon.
if( a <= b )
{
edges.push_back( CHEdgeList::value_type( a, b ) );
edges.emplace_back( a, b );
}
else
{
edges.push_back( CHEdgeList::value_type( b, a ) );
edges.emplace_back( b, a );
}
}

Expand Down
5 changes: 2 additions & 3 deletions Components/Overlay/include/OgreFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ namespace Ogre
}
else
{
mCodePointMap.insert( CodePointMap::value_type(
id, GlyphInfo( id, UVRect( u1, v1, u2, v2 ),
textureAspect * ( u2 - u1 ) / ( v2 - v1 ) ) ) );
mCodePointMap.emplace( id, GlyphInfo( id, UVRect( u1, v1, u2, v2 ),
textureAspect * ( u2 - u1 ) / ( v2 - v1 ) ) );
}
}
/** Gets the aspect ratio (width / height) of this character. */
Expand Down
4 changes: 2 additions & 2 deletions Components/Overlay/src/OgreOverlayContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace Ogre
"OverlayContainer::addChild" );
}

mChildren.insert( ChildMap::value_type( name, elem ) );
mChildren.emplace( name, elem );
// tell child about parent & Z-order
elem->_notifyParent( this, mOverlay );
elem->_notifyViewport();
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace Ogre
*/

// Now add to specific map too
mChildContainers.insert( ChildContainerMap::value_type( cont->getName(), cont ) );
mChildContainers.emplace( cont->getName(), cont );
}
//---------------------------------------------------------------------
void OverlayContainer::removeChild( const String &name )
Expand Down
2 changes: 1 addition & 1 deletion Components/Overlay/src/OgreOverlayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ namespace Ogre
OverlayElement *newElem = createOverlayElementFromFactory( typeName, instanceName );

// Register
elementMap.insert( ElementMap::value_type( instanceName, newElem ) );
elementMap.emplace( instanceName, newElem );

return newElem;
}
Expand Down
16 changes: 6 additions & 10 deletions OgreMain/include/OgreRenderSystemCapabilitiesSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace Ogre

inline void addCapabilitiesMapping( String name, Capabilities cap )
{
mCapabilitiesMap.insert( CapabilitiesMap::value_type( name, cap ) );
mCapabilitiesMap.emplace( name, cap );
}

// capabilities lines for parsing are collected along with their line numbers for debugging
Expand All @@ -135,7 +135,7 @@ namespace Ogre

inline void addKeywordType( String keyword, CapabilityKeywordType type )
{
mKeywordTypeMap.insert( KeywordTypeMap::value_type( keyword, type ) );
mKeywordTypeMap.emplace( keyword, type );
}

inline CapabilityKeywordType getKeywordType( const String &keyword ) const
Expand All @@ -152,8 +152,7 @@ namespace Ogre

inline void addSetStringMethod( String keyword, SetStringMethod method )
{
mSetStringMethodDispatchTable.insert(
SetStringMethodDispatchTable::value_type( keyword, method ) );
mSetStringMethodDispatchTable.emplace( keyword, method );
}

inline void callSetStringMethod( String &keyword, String &val )
Expand All @@ -173,8 +172,7 @@ namespace Ogre

inline void addSetIntMethod( String keyword, SetIntMethod method )
{
mSetIntMethodDispatchTable.insert(
SetIntMethodDispatchTable::value_type( keyword, method ) );
mSetIntMethodDispatchTable.emplace( keyword, method );
}

inline void callSetIntMethod( String &keyword, ushort val )
Expand All @@ -193,8 +191,7 @@ namespace Ogre

inline void addSetBoolMethod( String keyword, SetBoolMethod method )
{
mSetBoolMethodDispatchTable.insert(
SetBoolMethodDispatchTable::value_type( keyword, method ) );
mSetBoolMethodDispatchTable.emplace( keyword, method );
}

inline void callSetBoolMethod( String &keyword, bool val )
Expand All @@ -214,8 +211,7 @@ namespace Ogre

inline void addSetRealMethod( String keyword, SetRealMethod method )
{
mSetRealMethodDispatchTable.insert(
SetRealMethodDispatchTable::value_type( keyword, method ) );
mSetRealMethodDispatchTable.emplace( keyword, method );
}

inline void callSetRealMethod( String &keyword, Real val )
Expand Down
4 changes: 1 addition & 3 deletions OgreMain/src/Animation/OgreSkeletonAnimationDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ namespace Ogre
TimestampsPerBlock::iterator itKeyframes = timestampsByBlock.find( blockIdx );
if( itKeyframes == timestampsByBlock.end() )
{
itKeyframes =
timestampsByBlock.insert( std::make_pair( (size_t)blockIdx, emptyVec ) )
.first;
itKeyframes = timestampsByBlock.emplace( (size_t)blockIdx, emptyVec ).first;
}

itKeyframes->second.reserve( track->getNumKeyFrames() + (size_t)extraKeyFrameAtEnd );
Expand Down
5 changes: 4 additions & 1 deletion OgreMain/src/OgreAnimationState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ namespace Ogre
mParent->_notifyDirty();
}
//---------------------------------------------------------------------
AnimationState::~AnimationState() {}
AnimationState::~AnimationState()
{
destroyBlendMask();
}
//---------------------------------------------------------------------
AnimationState::AnimationState( const String &animName, AnimationStateSet *parent, Real timePos,
Real length, Real weight, bool enabled ) :
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreArchiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace Ogre
//-----------------------------------------------------------------------
void ArchiveManager::addArchiveFactory( ArchiveFactory *factory )
{
mArchFactories.insert( ArchiveFactoryMap::value_type( factory->getType(), factory ) );
mArchFactories.emplace( factory->getType(), factory );
LogManager::getSingleton().logMessage( "ArchiveFactory for archive type " + factory->getType() +
" registered." );
}
Expand Down
5 changes: 2 additions & 3 deletions OgreMain/src/OgreConvexBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ namespace Ogre
const Vector3 &a = p.getVertex( j );
const Vector3 &b = p.getVertex( ( j + 1 ) % p.getVertexCount() );

edgeMap.insert( Polygon::Edge( a, b ) );
edgeMap.emplace( a, b );
}
}

Expand Down Expand Up @@ -1112,8 +1112,7 @@ namespace Ogre
// insert intersection polygon only, if there are two vertices present
if( pIntersect->getVertexCount() == 2 )
{
intersectionEdges.insert(
Polygon::Edge( pIntersect->getVertex( 0 ), pIntersect->getVertex( 1 ) ) );
intersectionEdges.emplace( pIntersect->getVertex( 0 ), pIntersect->getVertex( 1 ) );
}

// delete intersection polygon
Expand Down
9 changes: 4 additions & 5 deletions OgreMain/src/OgreEdgeListBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,9 @@ namespace Ogre
else
{
// Not found, create new edge
mEdgeMap.insert( EdgeMap::value_type(
std::pair<size_t, size_t>( sharedVertIndex0, sharedVertIndex1 ),
std::pair<size_t, size_t>( vertexSet,
mEdgeData->edgeGroups[vertexSet].edges.size() ) ) );
mEdgeMap.emplace( std::pair<size_t, size_t>( sharedVertIndex0, sharedVertIndex1 ),
std::pair<size_t, size_t>(
vertexSet, mEdgeData->edgeGroups[vertexSet].edges.size() ) );
EdgeData::Edge e;
e.degenerate = true; // initialise as degenerate

Expand All @@ -392,7 +391,7 @@ namespace Ogre
// the common vertex by EXACT same position.
// Hint: We can use quantize method for welding almost same position vertex fastest.
std::pair<CommonVertexMap::iterator, bool> inserted =
mCommonVertexMap.insert( CommonVertexMap::value_type( vec, mVertices.size() ) );
mCommonVertexMap.emplace( vec, mVertices.size() );
if( !inserted.second )
{
// Already existing, return old one
Expand Down
5 changes: 1 addition & 4 deletions OgreMain/src/OgreEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,10 +1387,7 @@ namespace Ogre
if( it == mSchemeHardwareAnim.end() )
{
// evaluate the animation hardware value
it = mSchemeHardwareAnim
.insert(
SchemeHardwareAnimMap::value_type( schemeIndex, calcVertexProcessing() ) )
.first;
it = mSchemeHardwareAnim.emplace( schemeIndex, calcVertexProcessing() ).first;
}
return it->second;
}
Expand Down
4 changes: 2 additions & 2 deletions OgreMain/src/OgreGpuProgramManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ namespace Ogre
MicrocodeMap::iterator foundIter = mMicrocodeCache.find( hash );
if( foundIter == mMicrocodeCache.end() )
{
mMicrocodeCache.insert( std::make_pair( hash, microcode ) );
mMicrocodeCache.emplace( hash, microcode );
// if cache is modified, mark it as dirty.
mCacheDirty = true;
}
Expand Down Expand Up @@ -362,7 +362,7 @@ namespace Ogre
microcodeOfShader->seek( 0 );
stream->read( microcodeOfShader->getPtr(), microcodeLength );

mMicrocodeCache.insert( std::make_pair( shaderHash, microcodeOfShader ) );
mMicrocodeCache.emplace( shaderHash, microcodeOfShader );
}

// if cache is not modified, mark it as clean.
Expand Down
4 changes: 2 additions & 2 deletions OgreMain/src/OgreGpuProgramParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ namespace Ogre
for( size_t i = 0; i < maxArrayIndex; i++ )
{
arrayName = paramName + "[" + StringConverter::toString( i ) + "]";
map.insert( GpuConstantDefinitionMap::value_type( arrayName, arrayDef ) );
map.emplace( arrayName, arrayDef );
// increment location
arrayDef.physicalIndex += arrayDef.elementSize;
}
Expand Down Expand Up @@ -3314,7 +3314,7 @@ namespace Ogre
//---------------------------------------------------------------------
void GpuProgramParameters::setSubroutine( size_t index, const String &subroutine )
{
mSubroutineMap.insert( std::make_pair( index, subroutine ) );
mSubroutineMap.emplace( index, subroutine );
}
//---------------------------------------------------------------------------
void GpuProgramParameters::setNamedAutoConstant( const String &name, AutoConstantType acType,
Expand Down
13 changes: 5 additions & 8 deletions OgreMain/src/OgreHardwareBufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ namespace Ogre
{
OGRE_LOCK_MUTEX( mTempBuffersMutex );
// Add copy to free temporary vertex buffers
mFreeTempVertexBufferMap.insert(
FreeTemporaryVertexBufferMap::value_type( sourceBuffer.get(), copy ) );
mFreeTempVertexBufferMap.emplace( sourceBuffer.get(), copy );
}
//-----------------------------------------------------------------------
HardwareVertexBufferSharedPtr HardwareBufferManagerBase::allocateVertexBufferCopy(
Expand Down Expand Up @@ -205,9 +204,9 @@ namespace Ogre
}

// Insert copy into licensee list
mTempVertexBufferLicenses.insert( TemporaryVertexBufferLicenseMap::value_type(
mTempVertexBufferLicenses.emplace(
vbuf.get(), VertexBufferLicense( sourceBuffer.get(), licenseType,
EXPIRED_DELAY_FRAME_THRESHOLD, vbuf, licensee ) ) );
EXPIRED_DELAY_FRAME_THRESHOLD, vbuf, licensee ) );
return vbuf;
}
}
Expand All @@ -225,8 +224,7 @@ namespace Ogre

vbl.licensee->licenseExpired( vbl.buffer.get() );

mFreeTempVertexBufferMap.insert(
FreeTemporaryVertexBufferMap::value_type( vbl.originalBufferPtr, vbl.buffer ) );
mFreeTempVertexBufferMap.emplace( vbl.originalBufferPtr, vbl.buffer );
mTempVertexBufferLicenses.erase( i );
}
}
Expand Down Expand Up @@ -298,8 +296,7 @@ namespace Ogre
{
vbl.licensee->licenseExpired( vbl.buffer.get() );

mFreeTempVertexBufferMap.insert(
FreeTemporaryVertexBufferMap::value_type( vbl.originalBufferPtr, vbl.buffer ) );
mFreeTempVertexBufferMap.emplace( vbl.originalBufferPtr, vbl.buffer );
mTempVertexBufferLicenses.erase( icur );
}
}
Expand Down
4 changes: 2 additions & 2 deletions OgreMain/src/OgreHlms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ namespace Ogre
bool syntaxError = false;

outArgs.clear();
outArgs.push_back( String() );
outArgs.emplace_back();

String::const_iterator it = subString.begin();
String::const_iterator en = subString.end();
Expand All @@ -1042,7 +1042,7 @@ namespace Ogre
else if( c == ',' )
{
expressionState = 0;
outArgs.push_back( String() );
outArgs.emplace_back();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreLodStrategyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace Ogre
}

// Insert the strategy into the map with its name as the key
mStrategies.insert( std::make_pair( strategy->getName(), strategy ) );
mStrategies.emplace( strategy->getName(), strategy );
}
//-----------------------------------------------------------------------
LodStrategy *LodStrategyManager::removeStrategy( const String &name )
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreLogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Ogre
mDefaultLog = newLog;
}

mLogs.insert( LogList::value_type( name, newLog ) );
mLogs.emplace( name, newLog );

return newLog;
}
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreMaterialSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ namespace Ogre
writeTessellationHullProgramRef( pPass );
}

if( pPass->hasTessellationHullProgram() )
if( pPass->hasTessellationDomainProgram() )
{
writeTessellationDomainProgramRef( pPass );
}
Expand Down
3 changes: 1 addition & 2 deletions OgreMain/src/OgreMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,7 @@ namespace Ogre
//-----------------------------------------------------------------------
void Mesh::addBoneAssignment( const VertexBoneAssignment &vertBoneAssign )
{
mBoneAssignments.insert(
VertexBoneAssignmentList::value_type( vertBoneAssign.vertexIndex, vertBoneAssign ) );
mBoneAssignments.emplace( vertBoneAssign.vertexIndex, vertBoneAssign );
mBoneAssignmentsOutOfDate = true;
}
//-----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreOldNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ namespace Ogre
"OldNode::addChild" );
}

mChildren.insert( ChildOldNodeMap::value_type( child->getName(), child ) );
mChildren.emplace( child->getName(), child );
child->setParent( this );
}
//-----------------------------------------------------------------------
Expand Down
Loading

0 comments on commit faf8edc

Please sign in to comment.