From 51dac0437422f119d4457ca24c93b9db9e07fb55 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 26 Jan 2018 02:59:43 -0800 Subject: [PATCH] Introducing the tag in lieu of the vsisiblity mask --- interface/src/Application.cpp | 2 +- interface/src/SecondaryCamera.cpp | 4 +- interface/src/avatar/MyAvatar.cpp | 8 +- interface/src/ui/overlays/ModelOverlay.cpp | 2 +- interface/src/ui/overlays/OverlaysPayload.cpp | 8 +- .../src/RenderableModelEntityItem.cpp | 4 +- .../render-utils/src/CauterizedModel.cpp | 2 +- .../render-utils/src/MeshPartPayload.cpp | 4 +- libraries/render-utils/src/Model.h | 2 +- .../render-utils/src/RenderShadowTask.cpp | 2 +- libraries/render/src/render/Item.cpp | 20 ++- libraries/render/src/render/Item.h | 138 ++++++++---------- .../src/render/RenderFetchCullSortTask.cpp | 18 +-- .../src/render/RenderFetchCullSortTask.h | 2 +- 14 files changed, 102 insertions(+), 114 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3284ed902e..bdb97bcdd8 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2274,7 +2274,7 @@ void Application::initializeGL() { #ifndef Q_OS_ANDROID _renderEngine->addJob("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED); #endif - _renderEngine->addJob("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::VISIBLE_MASK_0, render::ItemKey::VISIBLE_MASK_0); + _renderEngine->addJob("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::TAG_BITS_0, render::ItemKey::TAG_BITS_0); _renderEngine->load(); _renderEngine->registerScene(_main3DScene); diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index 9d5b6a44a5..1ae1cc3559 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -20,7 +20,7 @@ using RenderArgsPointer = std::shared_ptr; void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { task.addJob("RenderShadowTask", cullFunctor); - const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::VISIBLE_MASK_1, render::ItemKey::VISIBLE_MASK_1); + const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); assert(items.canCast()); if (!isDeferred) { task.addJob("Forward", items); @@ -205,7 +205,7 @@ public: void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { const auto cachedArg = task.addJob("SecondaryCamera"); - const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::VISIBLE_MASK_1, render::ItemKey::VISIBLE_MASK_1); + const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); assert(items.canCast()); if (!isDeferred) { task.addJob("Forward", items); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index dd51de2079..a63af4435b 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1078,7 +1078,7 @@ void MyAvatar::setEnableDebugDrawIKChains(bool isEnabled) { } void MyAvatar::setEnableMeshVisible(bool isEnabled) { - _skeletonModel->setVisibleInScene(isEnabled, qApp->getMain3DScene(), render::ItemKey::VISIBLE_MASK_NONE); + _skeletonModel->setVisibleInScene(isEnabled, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE); } void MyAvatar::setEnableInverseKinematics(bool isEnabled) { @@ -1428,7 +1428,7 @@ void MyAvatar::clearJointsData() { void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { Avatar::setSkeletonModelURL(skeletonModelURL); - _skeletonModel->setVisibleInScene(true, qApp->getMain3DScene(), render::ItemKey::VISIBLE_MASK_NONE); + _skeletonModel->setVisibleInScene(true, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE); _headBoneSet.clear(); emit skeletonChanged(); @@ -1742,7 +1742,7 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName, void MyAvatar::setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visible) { if (model->isActive() && model->isRenderable()) { - model->setVisibleInScene(visible, scene, render::ItemKey::VISIBLE_MASK_NONE); + model->setVisibleInScene(visible, scene, render::ItemKey::TAG_BITS_NONE); } } @@ -1938,7 +1938,7 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) { _attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 || _attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) { _attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(), - render::ItemKey::VISIBLE_MASK_NONE); + render::ItemKey::TAG_BITS_NONE); } } } diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index 59d4521307..015a1a4a3b 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -87,7 +87,7 @@ void ModelOverlay::update(float deltatime) { if (_visibleDirty) { _visibleDirty = false; // don't show overlays in mirrors - _model->setVisibleInScene(getVisible(), scene, render::ItemKey::VISIBLE_MASK_0); + _model->setVisibleInScene(getVisible(), scene, render::ItemKey::TAG_BITS_0); } if (_drawInFrontDirty) { _drawInFrontDirty = false; diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index 937de1a236..f99ced0021 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -45,12 +45,12 @@ namespace render { builder.withViewSpace(); } - if (overlay->getVisible()) { - builder.withVisibilityMask(render::ItemKey::VISIBLE_MASK_0); // don't draw overlays in mirror - } else { - builder.withVisibilityMask(render::ItemKey::VISIBLE_MASK_NONE); + if (!overlay->getVisible()) { + builder.withInvisible(); } + builder.withTagBits(render::ItemKey::TAG_BITS_0); // Only draw overlays in main view + return builder.build(); } template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index ee3557346d..190864cecf 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -1334,8 +1334,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce entity->stopModelOverrideIfNoParent(); uint32_t viewVisiblityMask = _cauterized ? - render::ItemKey::VISIBLE_MASK_1 : // draw in every view except the main one (view zero) - render::ItemKey::VISIBLE_MASK_ALL; // draw in all views + render::ItemKey::TAG_BITS_1 : // draw in every view except the main one (view zero) + render::ItemKey::TAG_BITS_ALL; // draw in all views if (model->isVisible() != _visible || model->getViewVisibilityMask() != viewVisiblityMask) { // FIXME: this seems like it could be optimized if we tracked our last known visible state in diff --git a/libraries/render-utils/src/CauterizedModel.cpp b/libraries/render-utils/src/CauterizedModel.cpp index 809be09436..574d3d741c 100644 --- a/libraries/render-utils/src/CauterizedModel.cpp +++ b/libraries/render-utils/src/CauterizedModel.cpp @@ -247,7 +247,7 @@ void CauterizedModel::updateRenderItems() { data.updateTransformForCauterizedMesh(renderTransform); data.setEnableCauterization(enableCauterization); - data.setKey(isVisible, isLayeredInFront || isLayeredInHUD, render::ItemKey::VISIBLE_MASK_ALL); + data.setKey(isVisible, isLayeredInFront || isLayeredInHUD, render::ItemKey::TAG_BITS_ALL); data.setLayer(isLayeredInFront, isLayeredInHUD); data.setShapeKey(invalidatePayloadShapeKey, isWireframe); }); diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 451b168465..aaec28e210 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -395,10 +395,10 @@ void ModelMeshPartPayload::setKey(bool isVisible, bool isLayered, uint8_t viewVi if (!isVisible) { builder.withInvisible(); - } else { - builder.withVisibilityMask(viewVisiblityMask); } + builder.withTagBits(render::ItemKey::TAG_BITS_ALL); // Draw models in all tags + if (isLayered) { builder.withLayered(); } diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index d9845de9ed..1fa14f92d6 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -389,7 +389,7 @@ protected: QUrl _url; bool _isVisible; - uint8_t _viewVisibilityMask { render::ItemKey::VISIBLE_MASK_ALL }; + uint8_t _viewVisibilityMask { render::ItemKey::TAG_BITS_ALL }; gpu::Buffers _blendedVertexBuffers; diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index 7a7714e1e0..d83dfd73a5 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -264,7 +264,7 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon const auto globalShadow = lightStage->getCurrentKeyShadow(); if (globalShadow && _cascadeIndexgetCascadeCount()) { - output.edit1() = ItemFilter::Builder::visibleWorldItems(0x00, 0x00).withTypeShape().withOpaque().withoutLayered(); + output.edit1() = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered(); globalShadow->setKeylightCascadeFrustum(_cascadeIndex, args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); diff --git a/libraries/render/src/render/Item.cpp b/libraries/render/src/render/Item.cpp index 0e4502a47c..1bf20ab510 100644 --- a/libraries/render/src/render/Item.cpp +++ b/libraries/render/src/render/Item.cpp @@ -34,13 +34,19 @@ const int Item::LAYER_3D = 1; const int Item::LAYER_3D_FRONT = 2; const int Item::LAYER_3D_HUD = 3; -const uint8_t ItemKey::NUM_VISIBLE_MASK_INDICES { 4 }; -const uint8_t ItemKey::VISIBLE_MASK_ALL { 0x0F }; -const uint8_t ItemKey::VISIBLE_MASK_NONE { 0x00 }; -const uint8_t ItemKey::VISIBLE_MASK_0 { 0x01 }; -const uint8_t ItemKey::VISIBLE_MASK_1 { 0x02 }; -const uint8_t ItemKey::VISIBLE_MASK_2 { 0x04 }; -const uint8_t ItemKey::VISIBLE_MASK_3 { 0x08 }; +const uint8_t ItemKey::TAG_BITS_ALL{ 0xFF }; +const uint8_t ItemKey::TAG_BITS_NONE{ 0x00 }; +const uint8_t ItemKey::TAG_BITS_0{ 0x01 }; +const uint8_t ItemKey::TAG_BITS_1{ 0x02 }; +const uint8_t ItemKey::TAG_BITS_2{ 0x04 }; +const uint8_t ItemKey::TAG_BITS_3{ 0x08 }; +const uint8_t ItemKey::TAG_BITS_4 { 0x10 }; +const uint8_t ItemKey::TAG_BITS_5{ 0x20 }; +const uint8_t ItemKey::TAG_BITS_6{ 0x40 }; +const uint8_t ItemKey::TAG_BITS_7 { 0x80 }; + +const uint32_t ItemKey::KEY_TAG_BITS_MASK = ((uint32_t) ItemKey::TAG_BITS_ALL) << FIRST_TAG_BIT; + void Item::Status::Value::setScale(float scale) { diff --git a/libraries/render/src/render/Item.h b/libraries/render/src/render/Item.h index 97eaefcb53..4833bd2f42 100644 --- a/libraries/render/src/render/Item.h +++ b/libraries/render/src/render/Item.h @@ -38,38 +38,61 @@ class Context; // Key is the KEY to filter Items and create specialized lists class ItemKey { public: - enum FlagBit { + // 8 tags are available to organize the items and filter them against as fields of the ItemKey. + // TAG & TAG_BITS are defined from several bits in the Key. + // An Item can be tagged and filtering can rely on the tags to keep or exclude items + // ItemKey are not taged by default + enum Tag : uint8_t { + TAG_0 = 0, // 8 Tags + TAG_1, + TAG_2, + TAG_3, + TAG_4, + TAG_5, + TAG_6, + TAG_7, + + NUM_TAGS, + }; + // Tag bits are derived from the Tag enum + const static uint8_t TAG_BITS_ALL; + const static uint8_t TAG_BITS_NONE; + const static uint8_t TAG_BITS_0; + const static uint8_t TAG_BITS_1; + const static uint8_t TAG_BITS_2; + const static uint8_t TAG_BITS_3; + const static uint8_t TAG_BITS_4; + const static uint8_t TAG_BITS_5; + const static uint8_t TAG_BITS_6; + const static uint8_t TAG_BITS_7; + + enum FlagBit : uint32_t { TYPE_SHAPE = 0, // Item is a Shape TYPE_LIGHT, // Item is a Light TYPE_META, // Item is a Meta: meanning it s used to represent a higher level object, potentially represented by other render items + TRANSLUCENT, // Transparent and not opaque, for some odd reason TRANSPARENCY doesn't work... VIEW_SPACE, // Transformed in view space, and not in world space DYNAMIC, // Dynamic and bound will change unlike static item DEFORMED, // Deformed within bound, not solid - INVISIBLE0, // Visible or not in this mask index? - INVISIBLE1, // Visible or not in this mask index? - INVISIBLE2, // Visible or not in this mask index? - INVISIBLE3, // Visible or not in this mask index? + INVISIBLE, // Visible or not in the scene? SHADOW_CASTER, // Item cast shadows - PICKABLE, // Item can be picked/selected LAYERED, // Item belongs to one of the layers different from the default layer - SMALLER, + FIRST_TAG_BIT, // 8 Tags available to organize the items and filter them against + LAST_TAG_BIT = FIRST_TAG_BIT + NUM_TAGS, + + __SMALLER, // Reserved bit for spatialized item to indicate that it is smaller than expected in the cell in which it belongs (probably because it overlaps over several smaller cells) NUM_FLAGS, // Not a valid flag }; typedef std::bitset Flags; - // VISIBLE MASK is defined from several bits in the Key. - // An Item can be visible in some mask bits and not other allowing for per view rendering - // Beware that the visibility mask is the oposite of what stored in the key vals. - const static uint8_t NUM_VISIBLE_MASK_INDICES; - const static uint8_t VISIBLE_MASK_ALL; - const static uint8_t VISIBLE_MASK_NONE; - const static uint8_t VISIBLE_MASK_0; - const static uint8_t VISIBLE_MASK_1; - const static uint8_t VISIBLE_MASK_2; - const static uint8_t VISIBLE_MASK_3; + // All the bits touching tag bits sets to true + const static uint32_t KEY_TAG_BITS_MASK; + static uint32_t evalTagBitsWithKeyBits(uint8_t tagBits, const uint32_t keyBits) { + return (keyBits & ~KEY_TAG_BITS_MASK) | (((uint32_t)tagBits) << FIRST_TAG_BIT); + } // The key is the Flags Flags _flags; @@ -96,44 +119,14 @@ public: Builder& withViewSpace() { _flags.set(VIEW_SPACE); return (*this); } Builder& withDynamic() { _flags.set(DYNAMIC); return (*this); } Builder& withDeformed() { _flags.set(DEFORMED); return (*this); } - Builder& withVisible(uint8_t maskIndex = NUM_VISIBLE_MASK_INDICES) { - if (maskIndex == NUM_VISIBLE_MASK_INDICES) { - _flags.reset(INVISIBLE0); - _flags.reset(INVISIBLE1); - _flags.reset(INVISIBLE2); - _flags.reset(INVISIBLE3); - } - else { - _flags.reset(INVISIBLE0 + maskIndex); - } - return (*this); - } - Builder& withInvisible(uint8_t maskIndex = NUM_VISIBLE_MASK_INDICES) { - if (maskIndex == NUM_VISIBLE_MASK_INDICES) { - _flags.set(INVISIBLE0); - _flags.set(INVISIBLE1); - _flags.set(INVISIBLE2); - _flags.set(INVISIBLE3); - } else { - _flags.set(INVISIBLE0 + maskIndex); - } - return (*this); - } - Builder& withVisibilityMask(uint8_t mask) { - for (int i = 0; i < ItemKey::NUM_VISIBLE_MASK_INDICES; i++) { - if ((1 << i) & mask) { - withVisible(i); - } - else { - withInvisible(i); - } - } - return (*this); - } + Builder& withInvisible() { _flags.set(INVISIBLE); return (*this); } Builder& withShadowCaster() { _flags.set(SHADOW_CASTER); return (*this); } - Builder& withPickable() { _flags.set(PICKABLE); return (*this); } Builder& withLayered() { _flags.set(LAYERED); return (*this); } + Builder& withTag(Tag tag) { _flags.set(FIRST_TAG_BIT + tag); return (*this); } + // Set ALL the tags in one call using the Tag bits + Builder& withTagBits(uint8_t tagBits) { _flags = evalTagBitsWithKeyBits(tagBits, _flags.to_ulong()); return (*this); } + // Convenient standard keys that we will keep on using all over the place static Builder opaqueShape() { return Builder().withTypeShape(); } static Builder transparentShape() { return Builder().withTypeShape().withTransparent(); } @@ -158,21 +151,20 @@ public: bool isRigid() const { return !_flags[DEFORMED]; } bool isDeformed() const { return _flags[DEFORMED]; } - bool isVisible(uint8_t maskIndex) const { return !_flags[INVISIBLE0 + maskIndex]; } - bool isInvisible(uint8_t maskIndex) const { return _flags[INVISIBLE0 + maskIndex]; } - uint8_t getVisibleMask() const { return (~(_flags.to_ulong() >> INVISIBLE0) & VISIBLE_MASK_ALL);} - bool isVisibleMask(uint8_t mask) const { return getVisibleMask() & mask; } + bool isVisible() const { return !_flags[INVISIBLE]; } + bool isInvisible() const { return _flags[INVISIBLE]; } bool isShadowCaster() const { return _flags[SHADOW_CASTER]; } - bool isPickable() const { return _flags[PICKABLE]; } - bool isLayered() const { return _flags[LAYERED]; } bool isSpatial() const { return !isLayered(); } + bool isTag(Tag tag) const { return _flags[FIRST_TAG_BIT + tag]; } + uint8_t getTagBits() const { return ((_flags.to_ulong() & KEY_TAG_BITS_MASK) >> FIRST_TAG_BIT); } + // Probably not public, flags used by the scene - bool isSmall() const { return _flags[SMALLER]; } - void setSmaller(bool smaller) { (smaller ? _flags.set(SMALLER) : _flags.reset(SMALLER)); } + bool isSmall() const { return _flags[__SMALLER]; } + void setSmaller(bool smaller) { (smaller ? _flags.set(__SMALLER) : _flags.reset(__SMALLER)); } bool operator==(const ItemKey& key) { return (_flags == key._flags); } bool operator!=(const ItemKey& key) { return (_flags != key._flags); } @@ -220,34 +212,24 @@ public: Builder& withRigid() { _value.reset(ItemKey::DEFORMED); _mask.set(ItemKey::DEFORMED); return (*this); } Builder& withDeformed() { _value.set(ItemKey::DEFORMED); _mask.set(ItemKey::DEFORMED); return (*this); } - Builder& withVisible(uint8_t maskIndex) { _value.reset(ItemKey::INVISIBLE0 + maskIndex); _mask.set(ItemKey::INVISIBLE0 + maskIndex); return (*this); } - Builder& withInvisible(uint8_t maskIndex) { _value.set(ItemKey::INVISIBLE0 + maskIndex); _mask.set(ItemKey::INVISIBLE0 + maskIndex); return (*this); } - Builder& withVisibilityMask(uint8_t mask, uint8_t touchBits) { - for (int i = 0; i < ItemKey::NUM_VISIBLE_MASK_INDICES; i++) { - if ((1 << i) & touchBits) { - if ((1 << i) & mask) { - withVisible(i); - } - else { - withInvisible(i); - } - } - } - return (*this); - } + Builder& withVisible() { _value.reset(ItemKey::INVISIBLE); _mask.set(ItemKey::INVISIBLE); return (*this); } + Builder& withInvisible() { _value.set(ItemKey::INVISIBLE); _mask.set(ItemKey::INVISIBLE); return (*this); } Builder& withNoShadowCaster() { _value.reset(ItemKey::SHADOW_CASTER); _mask.set(ItemKey::SHADOW_CASTER); return (*this); } Builder& withShadowCaster() { _value.set(ItemKey::SHADOW_CASTER); _mask.set(ItemKey::SHADOW_CASTER); return (*this); } - Builder& withPickable() { _value.set(ItemKey::PICKABLE); _mask.set(ItemKey::PICKABLE); return (*this); } - Builder& withoutLayered() { _value.reset(ItemKey::LAYERED); _mask.set(ItemKey::LAYERED); return (*this); } Builder& withLayered() { _value.set(ItemKey::LAYERED); _mask.set(ItemKey::LAYERED); return (*this); } + Builder& withoutTag(ItemKey::Tag tagIndex) { _value.reset(ItemKey::FIRST_TAG_BIT + tagIndex); _mask.set(ItemKey::FIRST_TAG_BIT + tagIndex); return (*this); } + Builder& withTag(ItemKey::Tag tagIndex) { _value.set(ItemKey::FIRST_TAG_BIT + tagIndex); _mask.set(ItemKey::FIRST_TAG_BIT + tagIndex); return (*this); } + // Set ALL the tags in one call using the Tag bits and the Tag bits touched + Builder& withTagBits(uint8_t tagBits, uint8_t tagMask) { _value = ItemKey::evalTagBitsWithKeyBits(tagBits, _value.to_ulong()); _mask = ItemKey::evalTagBitsWithKeyBits(tagMask, _mask.to_ulong()); return (*this); } + Builder& withNothing() { _value.reset(); _mask.reset(); return (*this); } // Convenient standard keys that we will keep on using all over the place - static Builder visibleWorldItems(uint8_t visibilityMask, uint8_t visibilityMaskTouched) { return Builder().withVisibilityMask(visibilityMask, visibilityMaskTouched).withWorldSpace(); } + static Builder visibleWorldItems() { return Builder().withVisible().withWorldSpace(); } static Builder opaqueShape() { return Builder().withTypeShape().withOpaque().withWorldSpace(); } static Builder transparentShape() { return Builder().withTypeShape().withTransparent().withWorldSpace(); } static Builder light() { return Builder().withTypeLight(); } diff --git a/libraries/render/src/render/RenderFetchCullSortTask.cpp b/libraries/render/src/render/RenderFetchCullSortTask.cpp index b4e1a618dc..a402c3bc9d 100644 --- a/libraries/render/src/render/RenderFetchCullSortTask.cpp +++ b/libraries/render/src/render/RenderFetchCullSortTask.cpp @@ -17,12 +17,12 @@ using namespace render; -void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varying& output, CullFunctor cullFunctor, uint8_t visibilityMask, uint8_t visibilityMaskTouched) { +void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varying& output, CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) { cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; }; // CPU jobs: // Fetch and cull the items from the scene - const ItemFilter filter = ItemFilter::Builder::visibleWorldItems(visibilityMask, visibilityMaskTouched).withoutLayered(); + const ItemFilter filter = ItemFilter::Builder::visibleWorldItems().withoutLayered().withTagBits(tagBits, tagMask); const auto spatialFilter = render::Varying(filter); const auto spatialSelection = task.addJob("FetchSceneSelection", spatialFilter); const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying(); @@ -40,15 +40,15 @@ void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varyin const int META_BUCKET = 3; const int BACKGROUND_BUCKET = 2; MultiFilterItems::ItemFilterArray spatialFilters = { { - ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), - ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), - ItemFilter::Builder::light().withVisibilityMask(visibilityMask, visibilityMaskTouched), - ItemFilter::Builder::meta().withVisibilityMask(visibilityMask, visibilityMaskTouched) + ItemFilter::Builder::opaqueShape().withVisible().withTagBits(tagBits, tagMask), + ItemFilter::Builder::transparentShape().withVisible().withTagBits(tagBits, tagMask), + ItemFilter::Builder::light().withVisible().withTagBits(tagBits, tagMask), + ItemFilter::Builder::meta().withVisible().withTagBits(tagBits, tagMask) } }; MultiFilterItems::ItemFilterArray nonspatialFilters = { { - ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), - ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), - ItemFilter::Builder::background().withVisibilityMask(visibilityMask, visibilityMaskTouched) + ItemFilter::Builder::opaqueShape().withVisible().withTagBits(tagBits, tagMask), + ItemFilter::Builder::transparentShape().withVisible().withTagBits(tagBits, tagMask), + ItemFilter::Builder::background().withVisible().withTagBits(tagBits, tagMask) } }; const auto filteredSpatialBuckets = task.addJob>("FilterSceneSelection", culledSpatialSelection, spatialFilters) diff --git a/libraries/render/src/render/RenderFetchCullSortTask.h b/libraries/render/src/render/RenderFetchCullSortTask.h index 9aa235b3fb..8c9f2e7304 100644 --- a/libraries/render/src/render/RenderFetchCullSortTask.h +++ b/libraries/render/src/render/RenderFetchCullSortTask.h @@ -36,7 +36,7 @@ public: RenderFetchCullSortTask() {} - void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, uint8_t visibilityMask = 0xFF, uint8_t visibilityMaskTouched = 0x00); + void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, uint8_t tagBits = 0x00, uint8_t tagMask = 0x00); }; #endif // hifi_RenderFetchCullSortTask_h