12 #ifndef hifi_render_CullTask_h
13 #define hifi_render_CullTask_h
16 #include "ViewFrustum.h"
20 using CullFunctor = std::function<bool(
const RenderArgs*,
const AABox&)>;
26 RenderDetails::Item& _renderDetails;
27 ViewFrustumPointer _antiFrustum;
29 float _squareTanAlpha;
31 CullTest(CullFunctor& functor, RenderArgs* pargs, RenderDetails::Item& renderDetails, ViewFrustumPointer antiFrustum =
nullptr);
33 bool frustumTest(
const AABox& bound);
34 bool antiFrustumTest(
const AABox& bound);
35 bool solidAngleTest(
const AABox& bound);
36 bool zoneOcclusionTest(
const render::Item& item);
38 static std::unordered_set<QUuid> _containingZones;
39 static std::unordered_set<QUuid> _prevContainingZones;
42 class FetchNonspatialItems {
44 using JobModel = Job::ModelIO<FetchNonspatialItems, ItemFilter, ItemBounds>;
45 void run(
const RenderContextPointer& renderContext,
const ItemFilter& filter, ItemBounds& outItems);
48 class FetchSpatialTreeConfig :
public Job::Config {
50 Q_PROPERTY(
int numItems READ getNumItems)
51 Q_PROPERTY(
bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
55 int getNumItems() {
return numItems; }
57 bool freezeFrustum{
false };
60 void setFreezeFrustum(
bool enabled) { freezeFrustum = enabled; emit dirty(); }
66 class FetchSpatialTree {
67 bool _freezeFrustum{
false };
68 bool _justFrozeFrustum{
false };
69 ViewFrustum _frozenFrustum;
72 using Config = FetchSpatialTreeConfig;
73 using Inputs = render::VaryingSet2<ItemFilter, glm::ivec2>;
74 using JobModel = Job::ModelIO<FetchSpatialTree, Inputs, ItemSpatialTree::ItemSelection, Config>;
78 void configure(
const Config& config);
79 void run(
const RenderContextPointer& renderContext,
const Inputs& inputs, ItemSpatialTree::ItemSelection& outSelection);
82 class CullSpatialSelectionConfig :
public Job::Config {
84 Q_PROPERTY(
int numItems READ getNumItems)
85 Q_PROPERTY(
bool freezeFrustum MEMBER freezeFrustum WRITE setFreezeFrustum)
86 Q_PROPERTY(
bool skipCulling MEMBER skipCulling WRITE setSkipCulling)
89 int getNumItems() {
return numItems; }
91 bool freezeFrustum{
false };
92 bool skipCulling{
false };
94 void setFreezeFrustum(
bool enabled) { freezeFrustum = enabled; emit dirty(); }
95 void setSkipCulling(
bool enabled) { skipCulling = enabled; emit dirty(); }
100 class CullSpatialSelection {
102 using Config = CullSpatialSelectionConfig;
103 using Inputs = render::VaryingSet2<ItemSpatialTree::ItemSelection, ItemFilter>;
104 using JobModel = Job::ModelIO<CullSpatialSelection, Inputs, ItemBounds, Config>;
106 CullSpatialSelection(CullFunctor cullFunctor,
bool skipCulling, RenderDetails::Type type) :
107 _cullFunctor(cullFunctor),
108 _skipCulling(skipCulling),
111 CullFunctor _cullFunctor;
112 bool _skipCulling {
false };
113 RenderDetails::Type _detailType{ RenderDetails::OTHER };
115 bool _freezeFrustum {
false };
116 bool _justFrozeFrustum {
false };
117 bool _overrideSkipCulling {
false };
118 ViewFrustum _frozenFrustum;
120 void configure(
const Config& config);
121 void run(
const RenderContextPointer& renderContext,
const Inputs& inputs, ItemBounds& outItems);
124 class CullShapeBounds {
126 using Inputs = render::VaryingSet4<ShapeBounds, ItemFilter, ItemFilter, ViewFrustumPointer>;
127 using Outputs = render::VaryingSet2<ShapeBounds, AABox>;
128 using JobModel = Job::ModelIO<CullShapeBounds, Inputs, Outputs>;
130 CullShapeBounds(CullFunctor cullFunctor, RenderDetails::Type type) :
131 _cullFunctor{ cullFunctor },
134 CullShapeBounds(CullFunctor cullFunctor) :
135 _cullFunctor{ cullFunctor } {
138 void run(
const RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
142 CullFunctor _cullFunctor;
143 RenderDetails::Type _detailType{ RenderDetails::OTHER };
147 class ApplyCullFunctorOnItemBounds {
149 using Inputs = render::VaryingSet2<ItemBounds, ViewFrustumPointer>;
150 using Outputs = ItemBounds;
151 using JobModel = Job::ModelIO<ApplyCullFunctorOnItemBounds, Inputs, Outputs>;
153 ApplyCullFunctorOnItemBounds(render::CullFunctor cullFunctor) : _cullFunctor(cullFunctor) {}
154 void run(
const RenderContextPointer& renderContext,
const Inputs& inputs, Outputs& outputs);
158 render::CullFunctor _cullFunctor;
161 class ClearContainingZones {
163 using JobModel = Job::Model<ClearContainingZones>;
164 void run(
const RenderContextPointer& renderContext);