Introducing the tag in lieu of the vsisiblity mask

This commit is contained in:
Sam Gateau 2018-01-26 02:59:43 -08:00
parent 23b99f04cd
commit 51dac04374
14 changed files with 102 additions and 114 deletions

View file

@ -2274,7 +2274,7 @@ void Application::initializeGL() {
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED); _renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraJob", cullFunctor, !DISABLE_DEFERRED);
#endif #endif
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::VISIBLE_MASK_0, render::ItemKey::VISIBLE_MASK_0); _renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, !DISABLE_DEFERRED, render::ItemKey::TAG_BITS_0, render::ItemKey::TAG_BITS_0);
_renderEngine->load(); _renderEngine->load();
_renderEngine->registerScene(_main3DScene); _renderEngine->registerScene(_main3DScene);

View file

@ -20,7 +20,7 @@ using RenderArgsPointer = std::shared_ptr<RenderArgs>;
void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor); task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor);
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::VISIBLE_MASK_1, render::ItemKey::VISIBLE_MASK_1); const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1);
assert(items.canCast<RenderFetchCullSortTask::Output>()); assert(items.canCast<RenderFetchCullSortTask::Output>());
if (!isDeferred) { if (!isDeferred) {
task.addJob<RenderForwardTask>("Forward", items); task.addJob<RenderForwardTask>("Forward", items);
@ -205,7 +205,7 @@ public:
void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) {
const auto cachedArg = task.addJob<SecondaryCameraJob>("SecondaryCamera"); const auto cachedArg = task.addJob<SecondaryCameraJob>("SecondaryCamera");
const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::VISIBLE_MASK_1, render::ItemKey::VISIBLE_MASK_1); const auto items = task.addJob<RenderFetchCullSortTask>("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1);
assert(items.canCast<RenderFetchCullSortTask::Output>()); assert(items.canCast<RenderFetchCullSortTask::Output>());
if (!isDeferred) { if (!isDeferred) {
task.addJob<RenderForwardTask>("Forward", items); task.addJob<RenderForwardTask>("Forward", items);

View file

@ -1078,7 +1078,7 @@ void MyAvatar::setEnableDebugDrawIKChains(bool isEnabled) {
} }
void MyAvatar::setEnableMeshVisible(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) { void MyAvatar::setEnableInverseKinematics(bool isEnabled) {
@ -1428,7 +1428,7 @@ void MyAvatar::clearJointsData() {
void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) { void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
Avatar::setSkeletonModelURL(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(); _headBoneSet.clear();
emit skeletonChanged(); 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) { void MyAvatar::setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visible) {
if (model->isActive() && model->isRenderable()) { 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("HeadTop_End", Qt::CaseInsensitive) == 0 ||
_attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) { _attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) {
_attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(), _attachmentModels[i]->setVisibleInScene(shouldDrawHead, qApp->getMain3DScene(),
render::ItemKey::VISIBLE_MASK_NONE); render::ItemKey::TAG_BITS_NONE);
} }
} }
} }

View file

@ -87,7 +87,7 @@ void ModelOverlay::update(float deltatime) {
if (_visibleDirty) { if (_visibleDirty) {
_visibleDirty = false; _visibleDirty = false;
// don't show overlays in mirrors // 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) { if (_drawInFrontDirty) {
_drawInFrontDirty = false; _drawInFrontDirty = false;

View file

@ -45,12 +45,12 @@ namespace render {
builder.withViewSpace(); builder.withViewSpace();
} }
if (overlay->getVisible()) { if (!overlay->getVisible()) {
builder.withVisibilityMask(render::ItemKey::VISIBLE_MASK_0); // don't draw overlays in mirror builder.withInvisible();
} else {
builder.withVisibilityMask(render::ItemKey::VISIBLE_MASK_NONE);
} }
builder.withTagBits(render::ItemKey::TAG_BITS_0); // Only draw overlays in main view
return builder.build(); return builder.build();
} }
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) { template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) {

View file

@ -1334,8 +1334,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
entity->stopModelOverrideIfNoParent(); entity->stopModelOverrideIfNoParent();
uint32_t viewVisiblityMask = _cauterized ? uint32_t viewVisiblityMask = _cauterized ?
render::ItemKey::VISIBLE_MASK_1 : // draw in every view except the main one (view zero) render::ItemKey::TAG_BITS_1 : // draw in every view except the main one (view zero)
render::ItemKey::VISIBLE_MASK_ALL; // draw in all views render::ItemKey::TAG_BITS_ALL; // draw in all views
if (model->isVisible() != _visible || model->getViewVisibilityMask() != viewVisiblityMask) { if (model->isVisible() != _visible || model->getViewVisibilityMask() != viewVisiblityMask) {
// FIXME: this seems like it could be optimized if we tracked our last known visible state in // FIXME: this seems like it could be optimized if we tracked our last known visible state in

View file

@ -247,7 +247,7 @@ void CauterizedModel::updateRenderItems() {
data.updateTransformForCauterizedMesh(renderTransform); data.updateTransformForCauterizedMesh(renderTransform);
data.setEnableCauterization(enableCauterization); 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.setLayer(isLayeredInFront, isLayeredInHUD);
data.setShapeKey(invalidatePayloadShapeKey, isWireframe); data.setShapeKey(invalidatePayloadShapeKey, isWireframe);
}); });

View file

@ -395,10 +395,10 @@ void ModelMeshPartPayload::setKey(bool isVisible, bool isLayered, uint8_t viewVi
if (!isVisible) { if (!isVisible) {
builder.withInvisible(); builder.withInvisible();
} else {
builder.withVisibilityMask(viewVisiblityMask);
} }
builder.withTagBits(render::ItemKey::TAG_BITS_ALL); // Draw models in all tags
if (isLayered) { if (isLayered) {
builder.withLayered(); builder.withLayered();
} }

View file

@ -389,7 +389,7 @@ protected:
QUrl _url; QUrl _url;
bool _isVisible; bool _isVisible;
uint8_t _viewVisibilityMask { render::ItemKey::VISIBLE_MASK_ALL }; uint8_t _viewVisibilityMask { render::ItemKey::TAG_BITS_ALL };
gpu::Buffers _blendedVertexBuffers; gpu::Buffers _blendedVertexBuffers;

View file

@ -264,7 +264,7 @@ void RenderShadowCascadeSetup::run(const render::RenderContextPointer& renderCon
const auto globalShadow = lightStage->getCurrentKeyShadow(); const auto globalShadow = lightStage->getCurrentKeyShadow();
if (globalShadow && _cascadeIndex<globalShadow->getCascadeCount()) { if (globalShadow && _cascadeIndex<globalShadow->getCascadeCount()) {
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); globalShadow->setKeylightCascadeFrustum(_cascadeIndex, args->getViewFrustum(), SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR);

View file

@ -34,13 +34,19 @@ const int Item::LAYER_3D = 1;
const int Item::LAYER_3D_FRONT = 2; const int Item::LAYER_3D_FRONT = 2;
const int Item::LAYER_3D_HUD = 3; const int Item::LAYER_3D_HUD = 3;
const uint8_t ItemKey::NUM_VISIBLE_MASK_INDICES { 4 }; const uint8_t ItemKey::TAG_BITS_ALL{ 0xFF };
const uint8_t ItemKey::VISIBLE_MASK_ALL { 0x0F }; const uint8_t ItemKey::TAG_BITS_NONE{ 0x00 };
const uint8_t ItemKey::VISIBLE_MASK_NONE { 0x00 }; const uint8_t ItemKey::TAG_BITS_0{ 0x01 };
const uint8_t ItemKey::VISIBLE_MASK_0 { 0x01 }; const uint8_t ItemKey::TAG_BITS_1{ 0x02 };
const uint8_t ItemKey::VISIBLE_MASK_1 { 0x02 }; const uint8_t ItemKey::TAG_BITS_2{ 0x04 };
const uint8_t ItemKey::VISIBLE_MASK_2 { 0x04 }; const uint8_t ItemKey::TAG_BITS_3{ 0x08 };
const uint8_t ItemKey::VISIBLE_MASK_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) { void Item::Status::Value::setScale(float scale) {

View file

@ -38,38 +38,61 @@ class Context;
// Key is the KEY to filter Items and create specialized lists // Key is the KEY to filter Items and create specialized lists
class ItemKey { class ItemKey {
public: 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_SHAPE = 0, // Item is a Shape
TYPE_LIGHT, // Item is a Light 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 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... TRANSLUCENT, // Transparent and not opaque, for some odd reason TRANSPARENCY doesn't work...
VIEW_SPACE, // Transformed in view space, and not in world space VIEW_SPACE, // Transformed in view space, and not in world space
DYNAMIC, // Dynamic and bound will change unlike static item DYNAMIC, // Dynamic and bound will change unlike static item
DEFORMED, // Deformed within bound, not solid DEFORMED, // Deformed within bound, not solid
INVISIBLE0, // Visible or not in this mask index? INVISIBLE, // Visible or not in the scene?
INVISIBLE1, // Visible or not in this mask index?
INVISIBLE2, // Visible or not in this mask index?
INVISIBLE3, // Visible or not in this mask index?
SHADOW_CASTER, // Item cast shadows SHADOW_CASTER, // Item cast shadows
PICKABLE, // Item can be picked/selected
LAYERED, // Item belongs to one of the layers different from the default layer 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 NUM_FLAGS, // Not a valid flag
}; };
typedef std::bitset<NUM_FLAGS> Flags; typedef std::bitset<NUM_FLAGS> Flags;
// VISIBLE MASK is defined from several bits in the Key. // All the bits touching tag bits sets to true
// An Item can be visible in some mask bits and not other allowing for per view rendering const static uint32_t KEY_TAG_BITS_MASK;
// Beware that the visibility mask is the oposite of what stored in the key vals. static uint32_t evalTagBitsWithKeyBits(uint8_t tagBits, const uint32_t keyBits) {
const static uint8_t NUM_VISIBLE_MASK_INDICES; return (keyBits & ~KEY_TAG_BITS_MASK) | (((uint32_t)tagBits) << FIRST_TAG_BIT);
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;
// The key is the Flags // The key is the Flags
Flags _flags; Flags _flags;
@ -96,44 +119,14 @@ public:
Builder& withViewSpace() { _flags.set(VIEW_SPACE); return (*this); } Builder& withViewSpace() { _flags.set(VIEW_SPACE); return (*this); }
Builder& withDynamic() { _flags.set(DYNAMIC); return (*this); } Builder& withDynamic() { _flags.set(DYNAMIC); return (*this); }
Builder& withDeformed() { _flags.set(DEFORMED); return (*this); } Builder& withDeformed() { _flags.set(DEFORMED); return (*this); }
Builder& withVisible(uint8_t maskIndex = NUM_VISIBLE_MASK_INDICES) { Builder& withInvisible() { _flags.set(INVISIBLE); return (*this); }
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& withShadowCaster() { _flags.set(SHADOW_CASTER); 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& 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 // Convenient standard keys that we will keep on using all over the place
static Builder opaqueShape() { return Builder().withTypeShape(); } static Builder opaqueShape() { return Builder().withTypeShape(); }
static Builder transparentShape() { return Builder().withTypeShape().withTransparent(); } static Builder transparentShape() { return Builder().withTypeShape().withTransparent(); }
@ -158,21 +151,20 @@ public:
bool isRigid() const { return !_flags[DEFORMED]; } bool isRigid() const { return !_flags[DEFORMED]; }
bool isDeformed() const { return _flags[DEFORMED]; } bool isDeformed() const { return _flags[DEFORMED]; }
bool isVisible(uint8_t maskIndex) const { return !_flags[INVISIBLE0 + maskIndex]; } bool isVisible() const { return !_flags[INVISIBLE]; }
bool isInvisible(uint8_t maskIndex) const { return _flags[INVISIBLE0 + maskIndex]; } bool isInvisible() const { return _flags[INVISIBLE]; }
uint8_t getVisibleMask() const { return (~(_flags.to_ulong() >> INVISIBLE0) & VISIBLE_MASK_ALL);}
bool isVisibleMask(uint8_t mask) const { return getVisibleMask() & mask; }
bool isShadowCaster() const { return _flags[SHADOW_CASTER]; } bool isShadowCaster() const { return _flags[SHADOW_CASTER]; }
bool isPickable() const { return _flags[PICKABLE]; }
bool isLayered() const { return _flags[LAYERED]; } bool isLayered() const { return _flags[LAYERED]; }
bool isSpatial() const { return !isLayered(); } 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 // Probably not public, flags used by the scene
bool isSmall() const { return _flags[SMALLER]; } bool isSmall() const { return _flags[__SMALLER]; }
void setSmaller(bool smaller) { (smaller ? _flags.set(SMALLER) : _flags.reset(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); }
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& withRigid() { _value.reset(ItemKey::DEFORMED); _mask.set(ItemKey::DEFORMED); return (*this); }
Builder& withDeformed() { _value.set(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& withVisible() { _value.reset(ItemKey::INVISIBLE); _mask.set(ItemKey::INVISIBLE); return (*this); }
Builder& withInvisible(uint8_t maskIndex) { _value.set(ItemKey::INVISIBLE0 + maskIndex); _mask.set(ItemKey::INVISIBLE0 + maskIndex); return (*this); } Builder& withInvisible() { _value.set(ItemKey::INVISIBLE); _mask.set(ItemKey::INVISIBLE); 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& withNoShadowCaster() { _value.reset(ItemKey::SHADOW_CASTER); _mask.set(ItemKey::SHADOW_CASTER); 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& 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& withoutLayered() { _value.reset(ItemKey::LAYERED); _mask.set(ItemKey::LAYERED); return (*this); }
Builder& withLayered() { _value.set(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); } Builder& withNothing() { _value.reset(); _mask.reset(); return (*this); }
// Convenient standard keys that we will keep on using all over the place // 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 opaqueShape() { return Builder().withTypeShape().withOpaque().withWorldSpace(); }
static Builder transparentShape() { return Builder().withTypeShape().withTransparent().withWorldSpace(); } static Builder transparentShape() { return Builder().withTypeShape().withTransparent().withWorldSpace(); }
static Builder light() { return Builder().withTypeLight(); } static Builder light() { return Builder().withTypeLight(); }

View file

@ -17,12 +17,12 @@
using namespace render; 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; }; cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; };
// CPU jobs: // CPU jobs:
// Fetch and cull the items from the scene // 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 spatialFilter = render::Varying(filter);
const auto spatialSelection = task.addJob<FetchSpatialTree>("FetchSceneSelection", spatialFilter); const auto spatialSelection = task.addJob<FetchSpatialTree>("FetchSceneSelection", spatialFilter);
const auto cullInputs = CullSpatialSelection::Inputs(spatialSelection, spatialFilter).asVarying(); 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 META_BUCKET = 3;
const int BACKGROUND_BUCKET = 2; const int BACKGROUND_BUCKET = 2;
MultiFilterItems<NUM_SPATIAL_FILTERS>::ItemFilterArray spatialFilters = { { MultiFilterItems<NUM_SPATIAL_FILTERS>::ItemFilterArray spatialFilters = { {
ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), ItemFilter::Builder::opaqueShape().withVisible().withTagBits(tagBits, tagMask),
ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), ItemFilter::Builder::transparentShape().withVisible().withTagBits(tagBits, tagMask),
ItemFilter::Builder::light().withVisibilityMask(visibilityMask, visibilityMaskTouched), ItemFilter::Builder::light().withVisible().withTagBits(tagBits, tagMask),
ItemFilter::Builder::meta().withVisibilityMask(visibilityMask, visibilityMaskTouched) ItemFilter::Builder::meta().withVisible().withTagBits(tagBits, tagMask)
} }; } };
MultiFilterItems<NUM_NON_SPATIAL_FILTERS>::ItemFilterArray nonspatialFilters = { { MultiFilterItems<NUM_NON_SPATIAL_FILTERS>::ItemFilterArray nonspatialFilters = { {
ItemFilter::Builder::opaqueShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), ItemFilter::Builder::opaqueShape().withVisible().withTagBits(tagBits, tagMask),
ItemFilter::Builder::transparentShape().withVisibilityMask(visibilityMask, visibilityMaskTouched), ItemFilter::Builder::transparentShape().withVisible().withTagBits(tagBits, tagMask),
ItemFilter::Builder::background().withVisibilityMask(visibilityMask, visibilityMaskTouched) ItemFilter::Builder::background().withVisible().withTagBits(tagBits, tagMask)
} }; } };
const auto filteredSpatialBuckets = const auto filteredSpatialBuckets =
task.addJob<MultiFilterItems<NUM_SPATIAL_FILTERS>>("FilterSceneSelection", culledSpatialSelection, spatialFilters) task.addJob<MultiFilterItems<NUM_SPATIAL_FILTERS>>("FilterSceneSelection", culledSpatialSelection, spatialFilters)

View file

@ -36,7 +36,7 @@ public:
RenderFetchCullSortTask() {} 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 #endif // hifi_RenderFetchCullSortTask_h