2017-03-27 21:17:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <rwcore.h>
|
|
|
|
#include <rpworld.h>
|
|
|
|
|
|
|
|
template <typename Pred>
|
2017-04-02 18:45:16 +02:00
|
|
|
RwFrame* RwFrameForAllChildren(RwFrame* frame, Pred&& callback)
|
2017-03-27 21:17:43 +02:00
|
|
|
{
|
|
|
|
for ( RwFrame* curFrame = frame->child; curFrame != nullptr; curFrame = curFrame->next )
|
|
|
|
{
|
2017-04-02 18:45:16 +02:00
|
|
|
if ( std::forward<Pred>(callback)(curFrame) == nullptr )
|
2017-03-27 21:17:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Pred>
|
2017-04-02 18:45:16 +02:00
|
|
|
RwFrame* RwFrameForAllObjects(RwFrame* frame, Pred&& callback)
|
2017-03-27 21:17:43 +02:00
|
|
|
{
|
|
|
|
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&frame->objectList); link != rwLinkListGetTerminator(&frame->objectList); link = rwLLLinkGetNext(link) )
|
|
|
|
{
|
2017-04-02 18:45:16 +02:00
|
|
|
if ( std::forward<Pred>(callback)(&rwLLLinkGetData(link, RwObjectHasFrame, lFrame)->object) == nullptr )
|
2017-03-27 21:17:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Pred>
|
2017-04-02 18:45:16 +02:00
|
|
|
RpClump* RpClumpForAllAtomics(RpClump* clump, Pred&& callback)
|
2017-03-27 21:17:43 +02:00
|
|
|
{
|
|
|
|
for ( RwLLLink* link = rwLinkListGetFirstLLLink(&clump->atomicList); link != rwLinkListGetTerminator(&clump->atomicList); link = rwLLLinkGetNext(link) )
|
|
|
|
{
|
2017-04-02 18:45:16 +02:00
|
|
|
if ( std::forward<Pred>(callback)(rwLLLinkGetData(link, RpAtomic, inClumpLink)) == nullptr )
|
2017-03-27 21:17:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return clump;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Pred>
|
2017-04-02 18:45:16 +02:00
|
|
|
RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, Pred&& callback)
|
2017-03-27 21:17:43 +02:00
|
|
|
{
|
|
|
|
for ( RwInt32 i = 0, j = geometry->matList.numMaterials; i < j; i++ )
|
|
|
|
{
|
2017-04-02 18:45:16 +02:00
|
|
|
if ( std::forward<Pred>(callback)(geometry->matList.materials[i]) == nullptr )
|
2017-03-27 21:17:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return geometry;
|
|
|
|
}
|