mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
perfect forwarding in C++ style ForAll RW functions
This commit is contained in:
parent
0fa6e0964b
commit
7d13fbc441
1 changed files with 8 additions and 8 deletions
|
@ -4,22 +4,22 @@
|
|||
#include <rpworld.h>
|
||||
|
||||
template <typename Pred>
|
||||
RwFrame* RwFrameForAllChildren(RwFrame* frame, Pred callback)
|
||||
RwFrame* RwFrameForAllChildren(RwFrame* frame, Pred&& callback)
|
||||
{
|
||||
for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next )
|
||||
{
|
||||
if ( callback(curFrame) == nullptr )
|
||||
if ( std::forward<Pred>(callback)(curFrame) == nullptr )
|
||||
break;
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
template <typename Pred>
|
||||
RwFrame* RwFrameForAllObjects(RwFrame* frame, Pred callback)
|
||||
RwFrame* RwFrameForAllObjects(RwFrame* frame, Pred&& callback)
|
||||
{
|
||||
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&frame->objectList); link != rwLinkListGetTerminator(&frame->objectList); link = rwLLLinkGetNext(link) )
|
||||
{
|
||||
if ( callback(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr )
|
||||
if ( std::forward<Pred>(callback)(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr )
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -27,22 +27,22 @@ RwFrame* RwFrameForAllObjects(RwFrame* frame, Pred callback)
|
|||
}
|
||||
|
||||
template <typename Pred>
|
||||
RpClump* RpClumpForAllAtomics(RpClump* clump, Pred callback)
|
||||
RpClump* RpClumpForAllAtomics(RpClump* clump, Pred&& callback)
|
||||
{
|
||||
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&clump->atomicList); link != rwLinkListGetTerminator(&clump->atomicList); link = rwLLLinkGetNext(link) )
|
||||
{
|
||||
if ( callback(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr )
|
||||
if ( std::forward<Pred>(callback)(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr )
|
||||
break;
|
||||
}
|
||||
return clump;
|
||||
}
|
||||
|
||||
template <typename Pred>
|
||||
RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, Pred callback)
|
||||
RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, Pred&& callback)
|
||||
{
|
||||
for ( RwInt32 i = 0, j = geometry->matList.numMaterials; i < j; i++ )
|
||||
{
|
||||
if ( callback(geometry->matList.materials[i]) == nullptr )
|
||||
if ( std::forward<Pred>(callback)(geometry->matList.materials[i]) == nullptr )
|
||||
break;
|
||||
}
|
||||
return geometry;
|
||||
|
|
Loading…
Reference in a new issue