mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Trying to introduce the Filtering step after the full scene culling
This commit is contained in:
parent
91a28c597a
commit
76d8135fdc
3 changed files with 54 additions and 7 deletions
|
@ -66,8 +66,11 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
|||
const auto transparents = addJob<DepthSortItems>("DepthSortTransparent", culledTransparents, DepthSortItems(false));
|
||||
*/
|
||||
// CPU: Fetch the renderOpaques
|
||||
const auto opaqueSelection = addJob<FetchSpatialTree>("FetchOpaque");
|
||||
const auto culledOpaques = addJob<CullSpatialSelection>("CullOpaque", opaqueSelection, cullFunctor);
|
||||
auto sceneFilter = ItemFilter::Builder::opaqueShape().withTransparent().withTypeLight();
|
||||
const auto sceneSelection = addJob<FetchSpatialTree>("FetchSceneSelection", sceneFilter);
|
||||
const auto culledSceneSelection = addJob<CullSpatialSelection>("CullSceneSelection", sceneSelection, cullFunctor, RenderDetails::OPAQUE_ITEM, ItemFilter::Builder::opaqueShape().withoutLayered());
|
||||
|
||||
const auto culledOpaques = addJob<FilterItemSelection>("FilterOpaque", culledSceneSelection);
|
||||
const auto opaques = addJob<DepthSortItems>("DepthSortOpaque", culledOpaques);
|
||||
|
||||
// CPU only, create the list of renderedTransparents items
|
||||
|
@ -112,8 +115,8 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
|||
|
||||
// Scene Octree Debuging job
|
||||
{
|
||||
addJob<DrawSceneOctree>("DrawSceneOctree", opaqueSelection);
|
||||
addJob<DrawItemSelection>("DrawItemSelection", opaqueSelection);
|
||||
addJob<DrawSceneOctree>("DrawSceneOctree", sceneSelection);
|
||||
addJob<DrawItemSelection>("DrawItemSelection", sceneSelection);
|
||||
}
|
||||
|
||||
// Status icon rendering job
|
||||
|
|
|
@ -193,7 +193,8 @@ void FetchSpatialTree::run(const SceneContextPointer& sceneContext, const Render
|
|||
void CullSpatialSelection::configure(const Config& config) {
|
||||
}
|
||||
|
||||
void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection, ItemBounds& outItems) {
|
||||
void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext,
|
||||
const ItemSpatialTree::ItemSelection& inSelection, ItemBounds& outItems) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_viewFrustum);
|
||||
RenderArgs* args = renderContext->args;
|
||||
|
@ -236,7 +237,6 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
|||
Test test(_cullFunctor, args, details);
|
||||
|
||||
// Now we have a selection of items to render
|
||||
|
||||
outItems.clear();
|
||||
outItems.reserve(inSelection.numItems());
|
||||
|
||||
|
@ -293,3 +293,24 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
|||
|
||||
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
|
||||
}
|
||||
|
||||
void FilterItemSelection::configure(const Config& config) {
|
||||
}
|
||||
|
||||
void FilterItemSelection::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems) {
|
||||
assert(renderContext->args);
|
||||
assert(renderContext->args->_viewFrustum);
|
||||
RenderArgs* args = renderContext->args;
|
||||
auto& scene = sceneContext->_scene;
|
||||
|
||||
// Now we have a selection of items to render
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
|
||||
for (auto itemBound : inItems) {
|
||||
auto& item = scene->getItem(itemBound.id);
|
||||
if (_filter.test(item.getKey())) {
|
||||
outItems.emplace_back(itemBound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,30 @@ namespace render {
|
|||
ItemFilter _filter{ ItemFilter::Builder::opaqueShape().withoutLayered() };
|
||||
|
||||
void configure(const Config& config);
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& outSelection, ItemBounds& outItems);
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection, ItemBounds& outItems);
|
||||
};
|
||||
|
||||
class FilterItemSelectionConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int numItems READ getNumItems)
|
||||
public:
|
||||
int numItems{ 0 };
|
||||
int getNumItems() { return numItems; }
|
||||
};
|
||||
|
||||
class FilterItemSelection {
|
||||
public:
|
||||
using Config = FilterItemSelectionConfig;
|
||||
using JobModel = Job::ModelIO<FilterItemSelection, ItemBounds, ItemBounds, Config>;
|
||||
|
||||
FilterItemSelection() {}
|
||||
FilterItemSelection(const ItemFilter& filter) :
|
||||
_filter(filter) {}
|
||||
|
||||
ItemFilter _filter{ ItemFilter::Builder::opaqueShape().withoutLayered() };
|
||||
|
||||
void configure(const Config& config);
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems, ItemBounds& outItems);
|
||||
};
|
||||
|
||||
class DepthSortItems {
|
||||
|
|
Loading…
Reference in a new issue