tAlgorythm fed namespace T3D for better library interoperability. resulted in the need to specify usage in... a few places.

This commit is contained in:
Azaezel 2017-12-19 16:04:46 -06:00
parent 83449bbc06
commit 491a7dcfdd
20 changed files with 70 additions and 69 deletions

View file

@ -131,7 +131,7 @@ bool DecalDataFile::write( Stream& stream )
{ {
DecalInstance *inst = allDecals[i]; DecalInstance *inst = allDecals[i];
dataIter = find( allDatablocks.begin(), allDatablocks.end(), inst->mDataBlock ); dataIter = T3D::find( allDatablocks.begin(), allDatablocks.end(), inst->mDataBlock );
U8 dataIndex = dataIter - allDatablocks.begin(); U8 dataIndex = dataIter - allDatablocks.begin();
stream.write( dataIndex ); stream.write( dataIndex );

View file

@ -47,7 +47,7 @@ WindEmitter::WindEmitter()
WindEmitter::~WindEmitter() WindEmitter::~WindEmitter()
{ {
WindEmitterList::iterator iter = find( smAllEmitters.begin(), smAllEmitters.end(), this ); WindEmitterList::iterator iter = T3D::find( smAllEmitters.begin(), smAllEmitters.end(), this );
smAllEmitters.erase( iter ); smAllEmitters.erase( iter );
} }

View file

@ -330,7 +330,7 @@ void ClippedPolyList::cullUnusedVerts()
for ( vIter = mVertexList.begin(); vIter != mVertexList.end(); vIter++, i++ ) for ( vIter = mVertexList.begin(); vIter != mVertexList.end(); vIter++, i++ )
{ {
// Is this vertex used? // Is this vertex used?
iNextIter = find( mIndexList.begin(), mIndexList.end(), i ); iNextIter = T3D::find( mIndexList.begin(), mIndexList.end(), i );
if ( iNextIter != mIndexList.end() ) if ( iNextIter != mIndexList.end() )
continue; continue;
@ -346,7 +346,7 @@ void ClippedPolyList::cullUnusedVerts()
for ( nextVIter = vIter + 1; nextVIter != mVertexList.end(); nextVIter++, n++ ) for ( nextVIter = vIter + 1; nextVIter != mVertexList.end(); nextVIter++, n++ )
{ {
iNextIter = find( mIndexList.begin(), mIndexList.end(), n ); iNextIter = T3D::find( mIndexList.begin(), mIndexList.end(), n );
// If we found a used vertex // If we found a used vertex
// grab its index for later use // grab its index for later use

View file

@ -33,7 +33,7 @@ String SimObjectList::smSortScriptCallbackFn;
bool SimObjectList::pushBack(SimObject* obj) bool SimObjectList::pushBack(SimObject* obj)
{ {
if (find(begin(),end(),obj) == end()) if (T3D::find(begin(),end(),obj) == end())
{ {
push_back(obj); push_back(obj);
return true; return true;
@ -44,7 +44,7 @@ bool SimObjectList::pushBack(SimObject* obj)
bool SimObjectList::pushBackForce(SimObject* obj) bool SimObjectList::pushBackForce(SimObject* obj)
{ {
iterator itr = find(begin(),end(),obj); iterator itr = T3D::find(begin(),end(),obj);
if (itr == end()) if (itr == end())
{ {
push_back(obj); push_back(obj);
@ -64,7 +64,7 @@ bool SimObjectList::pushBackForce(SimObject* obj)
bool SimObjectList::pushFront(SimObject* obj) bool SimObjectList::pushFront(SimObject* obj)
{ {
if (find(begin(),end(),obj) == end()) if (T3D::find(begin(),end(),obj) == end())
{ {
push_front(obj); push_front(obj);
return true; return true;
@ -75,7 +75,7 @@ bool SimObjectList::pushFront(SimObject* obj)
bool SimObjectList::remove(SimObject* obj) bool SimObjectList::remove(SimObject* obj)
{ {
iterator ptr = find(begin(),end(),obj); iterator ptr = T3D::find(begin(),end(),obj);
if (ptr != end()) if (ptr != end())
{ {
erase(ptr); erase(ptr);
@ -87,7 +87,7 @@ bool SimObjectList::remove(SimObject* obj)
bool SimObjectList::removeStable(SimObject* obj) bool SimObjectList::removeStable(SimObject* obj)
{ {
iterator ptr = find(begin(),end(),obj); iterator ptr = T3D::find(begin(),end(),obj);
if (ptr != end()) if (ptr != end())
{ {
erase(ptr); erase(ptr);

View file

@ -154,9 +154,9 @@ class SimSet : public SimObject, public TamlChildren
value operator[] (S32 index) { return objectList[U32(index)]; } value operator[] (S32 index) { return objectList[U32(index)]; }
inline iterator find( iterator first, iterator last, SimObject *obj) inline iterator find( iterator first, iterator last, SimObject *obj)
{ return ::find(first, last, obj); } { return T3D::find(first, last, obj); }
inline iterator find(SimObject *obj) inline iterator find(SimObject *obj)
{ return ::find(begin(), end(), obj); } { return T3D::find(begin(), end(), obj); }
/// Reorder the position of "obj" to either be the last object in the list or, if /// Reorder the position of "obj" to either be the last object in the list or, if
/// "target" is given, to come before "target" in the list of children. /// "target" is given, to come before "target" in the list of children.

View file

@ -23,40 +23,41 @@
#ifndef _TALGORITHM_H_ #ifndef _TALGORITHM_H_
#define _TALGORITHM_H_ #define _TALGORITHM_H_
namespace T3D
/// Finds the first matching value within the container
/// returning the the element or last if its not found.
template <class Iterator, class Value>
Iterator find(Iterator first, Iterator last, Value value)
{ {
while (first != last && *first != value) /// Finds the first matching value within the container
++first; /// returning the the element or last if its not found.
return first; template <class Iterator, class Value>
Iterator find(Iterator first, Iterator last, Value value)
{
while (first != last && *first != value)
++first;
return first;
}
/// Exchanges the values of the two elements.
template <typename T>
inline void swap(T &left, T &right)
{
T temp = right;
right = left;
left = temp;
}
/// Steps thru the elements of an array calling detete for each.
template <class Iterator, class Functor>
void for_each(Iterator first, Iterator last, Functor func)
{
for (; first != last; first++)
func(*first);
}
/// Functor for deleting a pointer.
/// @see for_each
struct delete_pointer
{
template <typename T>
void operator()(T *ptr) { delete ptr; }
};
} }
/// Exchanges the values of the two elements.
template <typename T>
inline void swap( T &left, T &right )
{
T temp = right;
right = left;
left = temp;
}
/// Steps thru the elements of an array calling detete for each.
template <class Iterator, class Functor>
void for_each( Iterator first, Iterator last, Functor func )
{
for ( ; first != last; first++ )
func( *first );
}
/// Functor for deleting a pointer.
/// @see for_each
struct delete_pointer
{
template <typename T>
void operator()(T *ptr){ delete ptr;}
};
#endif //_TALGORITHM_H_ #endif //_TALGORITHM_H_

View file

@ -213,7 +213,7 @@ bool ForestData::write( const char *path )
Vector<ForestItem>::const_iterator iter = items.begin(); Vector<ForestItem>::const_iterator iter = items.begin();
for ( ; iter != items.end(); iter++ ) for ( ; iter != items.end(); iter++ )
{ {
U8 dataIndex = find( allDatablocks.begin(), allDatablocks.end(), iter->getData() ) - allDatablocks.begin(); U8 dataIndex = T3D::find( allDatablocks.begin(), allDatablocks.end(), iter->getData() ) - allDatablocks.begin();
stream.write( dataIndex ); stream.write( dataIndex );
@ -770,7 +770,7 @@ U32 ForestData::getDatablocks( Vector<ForestItemData*> *outVector ) const
{ {
ForestItemData *data = item->getData(); ForestItemData *data = item->getData();
if ( find( outVector->begin(), outVector->end(), data ) != outVector->end() ) if (T3D::find( outVector->begin(), outVector->end(), data ) != outVector->end() )
continue; continue;
count++; count++;

View file

@ -85,7 +85,7 @@ void ForestWindMgr::addEmitter( ForestWindEmitter *emitter )
void ForestWindMgr::removeEmitter( ForestWindEmitter *emitter ) void ForestWindMgr::removeEmitter( ForestWindEmitter *emitter )
{ {
ForestWindEmitterList::iterator iter = find( mEmitters.begin(), ForestWindEmitterList::iterator iter = T3D::find( mEmitters.begin(),
mEmitters.end(), mEmitters.end(),
emitter ); emitter );
@ -161,7 +161,7 @@ void ForestWindMgr::processTick()
PROFILE_SCOPE( ForestWindMgr_AdvanceTime_SwapSources ); PROFILE_SCOPE( ForestWindMgr_AdvanceTime_SwapSources );
AssertFatal( mPrevSources->isEmpty(), "prev sources not empty!" ); AssertFatal( mPrevSources->isEmpty(), "prev sources not empty!" );
swap( mSources, mPrevSources ); T3D::swap( mSources, mPrevSources );
AssertFatal( mSources->isEmpty(), "swap failed!" ); AssertFatal( mSources->isEmpty(), "swap failed!" );
} }

View file

@ -1015,7 +1015,7 @@ void GuiEditCtrl::removeSelection( GuiControl* ctrl )
{ {
if( selectionContains( ctrl ) ) if( selectionContains( ctrl ) )
{ {
Vector< GuiControl* >::iterator i = ::find( mSelectedControls.begin(), mSelectedControls.end(), ctrl ); Vector< GuiControl* >::iterator i = T3D::find( mSelectedControls.begin(), mSelectedControls.end(), ctrl );
if ( i != mSelectedControls.end() ) if ( i != mSelectedControls.end() )
mSelectedControls.erase( i ); mSelectedControls.erase( i );

View file

@ -103,7 +103,7 @@ ProcessedMaterial::ProcessedMaterial()
ProcessedMaterial::~ProcessedMaterial() ProcessedMaterial::~ProcessedMaterial()
{ {
for_each( mPasses.begin(), mPasses.end(), delete_pointer() ); T3D::for_each( mPasses.begin(), mPasses.end(), T3D::delete_pointer() );
} }
void ProcessedMaterial::_setBlendState(Material::BlendOp blendOp, GFXStateBlockDesc& desc ) void ProcessedMaterial::_setBlendState(Material::BlendOp blendOp, GFXStateBlockDesc& desc )

View file

@ -228,7 +228,7 @@ void PolyhedronBoxIntersector< Polyhedron >::_preprocess( const MatrixF& objToWo
Point2F p = _project( i, v2 ); // Second point on line. Point2F p = _project( i, v2 ); // Second point on line.
if( frontFace != 0 ) if( frontFace != 0 )
swap( p, q ); T3D::swap( p, q );
Point2F normal( - ( p.y - q.y ), p.x - q.x ); Point2F normal( - ( p.y - q.y ), p.x - q.x );
normal.normalize(); normal.normalize();

View file

@ -441,7 +441,7 @@ U32 PlaneSet< T >::clipPolygon( const Point3F* inVertices, U32 inNumVertices, Po
// Make the output of the last iteration the // Make the output of the last iteration the
// input of this iteration. // input of this iteration.
swap( tempPolygon, clippedPolygon ); T3D::swap( tempPolygon, clippedPolygon );
numTempPolygonVertices = numClippedPolygonVertices; numTempPolygonVertices = numClippedPolygonVertices;
if( maxOutVertices < numTempPolygonVertices + 1 ) if( maxOutVertices < numTempPolygonVertices + 1 )

View file

@ -1706,7 +1706,7 @@ bool clipFrustumByPolygon( const Point3F* points, U32 numPoints, const RectI& vi
// Make the output of the last iteration the // Make the output of the last iteration the
// input of this iteration. // input of this iteration.
swap( tempPolygon, clippedPolygon ); T3D::swap( tempPolygon, clippedPolygon );
numTempPolygonVertices = numClippedPolygonVertices; numTempPolygonVertices = numClippedPolygonVertices;
// Clip our current remainder of the original polygon // Clip our current remainder of the original polygon

View file

@ -198,7 +198,7 @@ bool PostEffectManager::_addEffect( PostEffect *effect )
bool PostEffectManager::_removeEffect( PostEffect *effect ) bool PostEffectManager::_removeEffect( PostEffect *effect )
{ {
// Check the end of frame list. // Check the end of frame list.
EffectVector::iterator iter = find( mEndOfFrameList.begin(), mEndOfFrameList.end(), effect ); EffectVector::iterator iter = T3D::find( mEndOfFrameList.begin(), mEndOfFrameList.end(), effect );
if ( iter != mEndOfFrameList.end() ) if ( iter != mEndOfFrameList.end() )
{ {
mEndOfFrameList.erase( iter ); mEndOfFrameList.erase( iter );
@ -206,7 +206,7 @@ bool PostEffectManager::_removeEffect( PostEffect *effect )
} }
// Check the diffuse list. // Check the diffuse list.
iter = find( mAfterDiffuseList.begin(), mAfterDiffuseList.end(), effect ); iter = T3D::find( mAfterDiffuseList.begin(), mAfterDiffuseList.end(), effect );
if ( iter != mAfterDiffuseList.end() ) if ( iter != mAfterDiffuseList.end() )
{ {
mAfterDiffuseList.erase( iter ); mAfterDiffuseList.erase( iter );
@ -218,7 +218,7 @@ bool PostEffectManager::_removeEffect( PostEffect *effect )
for( ; mapIter != mAfterBinMap.end(); mapIter++ ) for( ; mapIter != mAfterBinMap.end(); mapIter++ )
{ {
EffectVector &effects = mapIter->value; EffectVector &effects = mapIter->value;
iter = find( effects.begin(), effects.end(), effect ); iter = T3D::find( effects.begin(), effects.end(), effect );
if ( iter != effects.end() ) if ( iter != effects.end() )
{ {
effects.erase( iter ); effects.erase( iter );
@ -230,7 +230,7 @@ bool PostEffectManager::_removeEffect( PostEffect *effect )
for( ; mapIter != mBeforeBinMap.end(); mapIter++ ) for( ; mapIter != mBeforeBinMap.end(); mapIter++ )
{ {
EffectVector &effects = mapIter->value; EffectVector &effects = mapIter->value;
iter = find( effects.begin(), effects.end(), effect ); iter = T3D::find( effects.begin(), effects.end(), effect );
if ( iter != effects.end() ) if ( iter != effects.end() )
{ {
effects.erase( iter ); effects.erase( iter );

View file

@ -183,7 +183,7 @@ bool SceneContainer::removeObject(SceneObject* obj)
// Remove water and physical zone types from the special vector. // Remove water and physical zone types from the special vector.
if ( obj->getTypeMask() & ( WaterObjectType | PhysicalZoneObjectType ) ) if ( obj->getTypeMask() & ( WaterObjectType | PhysicalZoneObjectType ) )
{ {
Vector<SceneObject*>::iterator iter = find( mWaterAndZones.begin(), mWaterAndZones.end(), obj ); Vector<SceneObject*>::iterator iter = T3D::find( mWaterAndZones.begin(), mWaterAndZones.end(), obj );
if( iter != mTerrains.end() ) if( iter != mTerrains.end() )
mWaterAndZones.erase_fast(iter); mWaterAndZones.erase_fast(iter);
} }
@ -191,7 +191,7 @@ bool SceneContainer::removeObject(SceneObject* obj)
// Remove terrain objects from special vector. // Remove terrain objects from special vector.
if( obj->getTypeMask() & TerrainObjectType ) if( obj->getTypeMask() & TerrainObjectType )
{ {
Vector< SceneObject* >::iterator iter = find( mTerrains.begin(), mTerrains.end(), obj ); Vector< SceneObject* >::iterator iter = T3D::find( mTerrains.begin(), mTerrains.end(), obj );
if( iter != mTerrains.end() ) if( iter != mTerrains.end() )
mTerrains.erase_fast(iter); mTerrains.erase_fast(iter);
} }

View file

@ -142,7 +142,7 @@ void SFXController::_compileList( SFXPlayList* playList )
{ {
// Randomly exchange slots in the list. // Randomly exchange slots in the list.
for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i ) for( U32 i = 0; i < SFXPlayList::NUM_SLOTS; ++ i )
swap( slotList[ gRandGen.randI( 0, SFXPlayList::NUM_SLOTS - 1 ) ], slotList[ i ] ); T3D::swap( slotList[ gRandGen.randI( 0, SFXPlayList::NUM_SLOTS - 1 ) ], slotList[ i ] );
} }
break; break;

View file

@ -165,7 +165,7 @@ void SFXDevice::_removeBuffer( SFXBuffer* buffer )
{ {
AssertFatal( buffer, "SFXDevice::_removeBuffer() - Got a null buffer!" ); AssertFatal( buffer, "SFXDevice::_removeBuffer() - Got a null buffer!" );
BufferIterator iter = find( mBuffers.begin(), mBuffers.end(), buffer ); BufferIterator iter = T3D::find( mBuffers.begin(), mBuffers.end(), buffer );
if( iter != mBuffers.end() ) if( iter != mBuffers.end() )
{ {
SFXBuffer* buffer = *iter; SFXBuffer* buffer = *iter;
@ -201,7 +201,7 @@ void SFXDevice::_removeVoice( SFXVoice* voice )
{ {
AssertFatal( voice, "SFXDevice::_removeVoice() - Got null voice!" ); AssertFatal( voice, "SFXDevice::_removeVoice() - Got null voice!" );
VoiceIterator iter = find( mVoices.begin(), mVoices.end(), voice ); VoiceIterator iter = T3D::find( mVoices.begin(), mVoices.end(), voice );
if( iter != mVoices.end() ) if( iter != mVoices.end() )
{ {
mStatNumVoices --; mStatNumVoices --;

View file

@ -647,7 +647,7 @@ void SFXSystem::deleteWhenStopped( SFXSource* source )
// If the source isn't already on the play-once source list, // If the source isn't already on the play-once source list,
// put it there now. // put it there now.
Vector< SFXSource* >::iterator iter = find( mPlayOnceSources.begin(), mPlayOnceSources.end(), source ); Vector< SFXSource* >::iterator iter = T3D::find( mPlayOnceSources.begin(), mPlayOnceSources.end(), source );
if( iter == mPlayOnceSources.end() ) if( iter == mPlayOnceSources.end() )
mPlayOnceSources.push_back( source ); mPlayOnceSources.push_back( source );
} }
@ -674,7 +674,7 @@ void SFXSystem::_onRemoveSource( SFXSource* source )
{ {
// Check if it was a play once source. // Check if it was a play once source.
Vector< SFXSource* >::iterator iter = find( mPlayOnceSources.begin(), mPlayOnceSources.end(), source ); Vector< SFXSource* >::iterator iter = T3D::find( mPlayOnceSources.begin(), mPlayOnceSources.end(), source );
if ( iter != mPlayOnceSources.end() ) if ( iter != mPlayOnceSources.end() )
mPlayOnceSources.erase_fast( iter ); mPlayOnceSources.erase_fast( iter );
@ -684,7 +684,7 @@ void SFXSystem::_onRemoveSource( SFXSource* source )
if( dynamic_cast< SFXSound* >( source ) ) if( dynamic_cast< SFXSound* >( source ) )
{ {
SFXSoundVector::iterator iter = find( mSounds.begin(), mSounds.end(), static_cast< SFXSound* >( source ) ); SFXSoundVector::iterator iter = T3D::find( mSounds.begin(), mSounds.end(), static_cast< SFXSound* >( source ) );
if( iter != mSounds.end() ) if( iter != mSounds.end() )
mSounds.erase_fast( iter ); mSounds.erase_fast( iter );

View file

@ -289,7 +289,7 @@ void TerrainCellMaterial::init( TerrainBlock *block,
// The pass failed to be generated... give up. // The pass failed to be generated... give up.
mPasses.last().materials.clear(); mPasses.last().materials.clear();
mPasses.clear(); mPasses.clear();
for_each( materials.begin(), materials.end(), delete_pointer() ); T3D::for_each( materials.begin(), materials.end(), T3D::delete_pointer() );
return; return;
} }
@ -298,7 +298,7 @@ void TerrainCellMaterial::init( TerrainBlock *block,
} }
// Cleanup any remaining matinfo. // Cleanup any remaining matinfo.
for_each( materials.begin(), materials.end(), delete_pointer() ); T3D::for_each( materials.begin(), materials.end(), T3D::delete_pointer() );
// If we have attached mats then update them too. // If we have attached mats then update them too.
if ( mDeferredMat ) if ( mDeferredMat )

View file

@ -101,7 +101,7 @@ TSLastDetail::~TSLastDetail()
mMaterial->deleteObject(); mMaterial->deleteObject();
// Remove ourselves from the list. // Remove ourselves from the list.
Vector<TSLastDetail*>::iterator iter = find( smLastDetails.begin(), smLastDetails.end(), this ); Vector<TSLastDetail*>::iterator iter = T3D::find( smLastDetails.begin(), smLastDetails.end(), this );
smLastDetails.erase( iter ); smLastDetails.erase( iter );
} }