mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:54:25 +02:00
Templatize item culling
This commit is contained in:
parent
c8d3342aca
commit
bf68f2f2fa
3 changed files with 11 additions and 44 deletions
|
@ -56,7 +56,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
|||
context->getItemsConfig().opaque.numFeed = count;
|
||||
})
|
||||
)));
|
||||
_jobs.push_back(Job(new CullItemsOpaque::JobModel("CullOpaque", _jobs.back().getOutput())));
|
||||
_jobs.push_back(Job(new CullItems<RenderDetails::OPAQUE_ITEM>::JobModel("CullOpaque", _jobs.back().getOutput())));
|
||||
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortOpaque", _jobs.back().getOutput())));
|
||||
auto& renderedOpaques = _jobs.back().getOutput();
|
||||
|
||||
|
@ -67,7 +67,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
|||
context->getItemsConfig().transparent.numFeed = count;
|
||||
})
|
||||
)));
|
||||
_jobs.push_back(Job(new CullItemsTransparent::JobModel("CullTransparent", _jobs.back().getOutput())));
|
||||
_jobs.push_back(Job(new CullItems<RenderDetails::TRANSLUCENT_ITEM>::JobModel("CullTransparent", _jobs.back().getOutput())));
|
||||
_jobs.push_back(Job(new DepthSortItems::JobModel("DepthSortTransparent", _jobs.back().getOutput(), DepthSortItems(false))));
|
||||
auto& renderedTransparents = _jobs.back().getOutput();
|
||||
|
||||
|
|
|
@ -111,34 +111,6 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
|
|||
}
|
||||
}
|
||||
|
||||
void CullItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
RenderArgs* args = renderContext->getArgs();
|
||||
args->_details.pointTo(RenderDetails::OTHER_ITEM);
|
||||
cullItems(sceneContext, renderContext, inItems, outItems);
|
||||
}
|
||||
|
||||
void CullItemsOpaque::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
RenderArgs* args = renderContext->getArgs();
|
||||
args->_details.pointTo(RenderDetails::OPAQUE_ITEM);
|
||||
cullItems(sceneContext, renderContext, inItems, outItems);
|
||||
}
|
||||
|
||||
void CullItemsTransparent::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
RenderArgs* args = renderContext->getArgs();
|
||||
args->_details.pointTo(RenderDetails::TRANSLUCENT_ITEM);
|
||||
cullItems(sceneContext, renderContext, inItems, outItems);
|
||||
}
|
||||
|
||||
|
||||
struct ItemBound {
|
||||
float _centerDepth = 0.0f;
|
||||
float _nearDepth = 0.0f;
|
||||
|
@ -261,9 +233,10 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
|
|||
inItems.emplace_back(ItemIDAndBounds(id, item.getBound()));
|
||||
}
|
||||
|
||||
RenderArgs* args = renderContext->getArgs();
|
||||
|
||||
ItemIDsBounds culledItems;
|
||||
culledItems.reserve(inItems.size());
|
||||
RenderArgs* args = renderContext->getArgs();
|
||||
args->_details.pointTo(RenderDetails::OTHER_ITEM);
|
||||
cullItems(sceneContext, renderContext, inItems, culledItems);
|
||||
|
||||
|
|
|
@ -239,24 +239,18 @@ public:
|
|||
typedef Job::ModelO<FetchItems, ItemIDsBounds> JobModel;
|
||||
};
|
||||
|
||||
template<RenderDetails::Type T = RenderDetails::Type::OTHER_ITEM>
|
||||
class CullItems {
|
||||
public:
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
renderContext->getArgs()->_details.pointTo(T);
|
||||
render::cullItems(sceneContext, renderContext, inItems, outItems);
|
||||
}
|
||||
typedef Job::ModelIO<CullItems, ItemIDsBounds, ItemIDsBounds> JobModel;
|
||||
};
|
||||
|
||||
class CullItemsOpaque {
|
||||
public:
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
|
||||
typedef Job::ModelIO<CullItemsOpaque, ItemIDsBounds, ItemIDsBounds> JobModel;
|
||||
};
|
||||
|
||||
class CullItemsTransparent {
|
||||
public:
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems);
|
||||
typedef Job::ModelIO<CullItemsTransparent, ItemIDsBounds, ItemIDsBounds> JobModel;
|
||||
};
|
||||
|
||||
class DepthSortItems {
|
||||
public:
|
||||
bool _frontToBack = true;
|
||||
|
|
Loading…
Reference in a new issue