diff --git a/interface/src/graphics/WorldBox.cpp b/interface/src/graphics/WorldBox.cpp index 0e15d9da86..a627cf75e4 100644 --- a/interface/src/graphics/WorldBox.cpp +++ b/interface/src/graphics/WorldBox.cpp @@ -16,7 +16,7 @@ render::ItemID WorldBoxRenderData::_item{ render::Item::INVALID_ITEM_ID }; namespace render { template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff) { return ItemKey::Builder::opaqueShape().withTagBits(ItemKey::TAG_BITS_0 | ItemKey::TAG_BITS_1); } - template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff) { return Item::Bound(); } + template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) { return Item::Bound(); } template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) { if (Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) { PerformanceTimer perfTimer("worldBox"); diff --git a/interface/src/graphics/WorldBox.h b/interface/src/graphics/WorldBox.h index 4d53652c0e..0d697eb133 100644 --- a/interface/src/graphics/WorldBox.h +++ b/interface/src/graphics/WorldBox.h @@ -32,7 +32,7 @@ public: namespace render { template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff); - template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff); + template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args); template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args); } diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 216248f8b5..67f0772228 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -462,9 +462,9 @@ namespace render { template <> const ItemKey payloadGetKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload) { return payload->getKey(); } - template <> const Item::Bound payloadGetBound(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload) { + template <> const Item::Bound payloadGetBound(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args) { if (payload) { - return payload->getBound(); + return payload->getBound(args); } return Item::Bound(); } diff --git a/interface/src/raypick/ParabolaPointer.h b/interface/src/raypick/ParabolaPointer.h index 85d09adbdb..1701e4dcfa 100644 --- a/interface/src/raypick/ParabolaPointer.h +++ b/interface/src/raypick/ParabolaPointer.h @@ -31,7 +31,7 @@ public: void render(RenderArgs* args); render::Item::Bound& editBound() { return _bound; } - const render::Item::Bound& getBound() { return _bound; } + const render::Item::Bound& getBound(RenderArgs* args) { return _bound; } render::ItemKey getKey() const { return _key; } void setVisible(bool visible); @@ -128,7 +128,7 @@ private: namespace render { template <> const ItemKey payloadGetKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload); - template <> const Item::Bound payloadGetBound(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload); + template <> const Item::Bound payloadGetBound(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args); template <> void payloadRender(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload); } diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index 72373d2d20..5c92cfce00 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -66,7 +66,7 @@ private: namespace render { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay); - template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay); + template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay, RenderArgs* args); template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay); template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems); diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index 0d1bcdd071..fdcd4f7205 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -14,7 +14,7 @@ namespace render { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) { return overlay->getKey(); } - template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) { + template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay, RenderArgs* args) { return overlay->getBounds(); } template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) { diff --git a/interface/src/workload/GameWorkloadRenderer.cpp b/interface/src/workload/GameWorkloadRenderer.cpp index f65bf88754..1310baf4b3 100644 --- a/interface/src/workload/GameWorkloadRenderer.cpp +++ b/interface/src/workload/GameWorkloadRenderer.cpp @@ -82,9 +82,9 @@ namespace render { template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) { return payload->getKey(); } - template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload) { + template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args) { if (payload) { - return payload->getBound(); + return payload->getBound(args); } return Item::Bound(); } diff --git a/interface/src/workload/GameWorkloadRenderer.h b/interface/src/workload/GameWorkloadRenderer.h index a25598821e..ad33425774 100644 --- a/interface/src/workload/GameWorkloadRenderer.h +++ b/interface/src/workload/GameWorkloadRenderer.h @@ -57,7 +57,7 @@ public: void render(RenderArgs* args); render::Item::Bound& editBound() { return _bound; } - const render::Item::Bound& getBound() { return _bound; } + const render::Item::Bound& getBound(RenderArgs* args) { return _bound; } void setVisible(bool visible); void showProxies(bool show); @@ -96,7 +96,7 @@ protected: namespace render { template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload); - template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload); + template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args); template <> void payloadRender(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const GameWorkloadRenderItem::Pointer& payload); } diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index d859454a99..f361e15999 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -63,7 +63,7 @@ namespace render { } return keyBuilder.build(); } - template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar) { + template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar, RenderArgs* args) { auto avatarPtr = static_pointer_cast(avatar); if (avatarPtr) { return avatarPtr->getRenderBounds(); diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 25dd347484..4fc9c25595 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -39,7 +39,7 @@ namespace render { template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); - template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar); + template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar, RenderArgs* args); template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args); template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); } diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index fdb971e7a3..b2670e3bce 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -137,7 +137,7 @@ EntityRenderer::~EntityRenderer() {} // Smart payload proxy members, implementing the payload interface // -Item::Bound EntityRenderer::getBound() { +Item::Bound EntityRenderer::getBound(RenderArgs* args) { auto bound = _bound; if (_billboardMode != BillboardMode::NONE) { glm::vec3 dimensions = bound.getScale(); diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index 4afcd6e231..7f0e1e16ee 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -64,7 +64,7 @@ public: static glm::vec3 calculatePulseColor(const glm::vec3& color, const PulsePropertyGroup& pulseProperties, quint64 start); virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override; - virtual Item::Bound getBound() override; + virtual Item::Bound getBound(RenderArgs* args) override; bool passesZoneOcclusionTest(const std::unordered_set& containingZones) const override; protected: diff --git a/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp b/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp index 3abd120bf9..bf005ae2e5 100644 --- a/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGizmoEntityItem.cpp @@ -195,8 +195,8 @@ void GizmoEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint } } -Item::Bound GizmoEntityRenderer::getBound() { - auto bound = Parent::getBound(); +Item::Bound GizmoEntityRenderer::getBound(RenderArgs* args) { + auto bound = Parent::getBound(args); if (_ringProperties.getHasTickMarks()) { glm::vec3 scale = bound.getScale(); for (int i = 0; i < 3; i += 2) { diff --git a/libraries/entities-renderer/src/RenderableGizmoEntityItem.h b/libraries/entities-renderer/src/RenderableGizmoEntityItem.h index 8593348bde..6a09d1a047 100644 --- a/libraries/entities-renderer/src/RenderableGizmoEntityItem.h +++ b/libraries/entities-renderer/src/RenderableGizmoEntityItem.h @@ -23,7 +23,7 @@ public: ~GizmoEntityRenderer(); protected: - Item::Bound getBound() override; + Item::Bound getBound(RenderArgs* args) override; ShapeKey getShapeKey() override; bool isTransparent() const override; diff --git a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp index a5ae4acbf5..e374fe29c0 100644 --- a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp @@ -49,13 +49,13 @@ void GridEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe _minorGridEvery = entity->getMinorGridEvery(); } -Item::Bound GridEntityRenderer::getBound() { +Item::Bound GridEntityRenderer::getBound(RenderArgs* args) { if (_followCamera) { // This is a UI element that should always be in view, lie to the octree to avoid culling const AABox DOMAIN_BOX = AABox(glm::vec3(-TREE_SCALE / 2), TREE_SCALE); return DOMAIN_BOX; } - return Parent::getBound(); + return Parent::getBound(args); } ShapeKey GridEntityRenderer::getShapeKey() { diff --git a/libraries/entities-renderer/src/RenderableGridEntityItem.h b/libraries/entities-renderer/src/RenderableGridEntityItem.h index 1958d17136..fd5b397424 100644 --- a/libraries/entities-renderer/src/RenderableGridEntityItem.h +++ b/libraries/entities-renderer/src/RenderableGridEntityItem.h @@ -23,7 +23,7 @@ public: ~GridEntityRenderer(); protected: - Item::Bound getBound() override; + Item::Bound getBound(RenderArgs* args) override; ShapeKey getShapeKey() override; bool isTransparent() const override; diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp index 9eb2e8428d..2ab2051fcf 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp @@ -60,8 +60,8 @@ ItemKey LightEntityRenderer::getKey() { return payloadGetKey(_lightPayload); } -Item::Bound LightEntityRenderer::getBound() { - return payloadGetBound(_lightPayload); +Item::Bound LightEntityRenderer::getBound(RenderArgs* args) { + return payloadGetBound(_lightPayload, args); } void LightEntityRenderer::doRender(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.h b/libraries/entities-renderer/src/RenderableLightEntityItem.h index 323f280795..bbb5ec346a 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.h +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.h @@ -29,7 +29,7 @@ protected: virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; virtual ItemKey getKey() override; - virtual Item::Bound getBound() override; + virtual Item::Bound getBound(RenderArgs* args) override; virtual void doRender(RenderArgs* args) override; private: diff --git a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp index 74b479affe..714defe817 100644 --- a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp @@ -376,7 +376,7 @@ void MaterialEntityRenderer::applyMaterial(const TypedEntityPointer& entity) { if (material->isProcedural()) { auto procedural = std::static_pointer_cast(material); - procedural->setBoundOperator([this] { return getBound(); }); + procedural->setBoundOperator([this](RenderArgs* args) { return getBound(args); }); entity->setHasVertexShader(procedural->hasVertexShader()); } diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index 4fe6bc8f93..e2a57840d9 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -161,7 +161,7 @@ ShapeKey ParticleEffectEntityRenderer::getShapeKey() { return builder.build(); } -Item::Bound ParticleEffectEntityRenderer::getBound() { +Item::Bound ParticleEffectEntityRenderer::getBound(RenderArgs* args) { return _bound; } diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index ca6bc859fb..547d654486 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -30,7 +30,7 @@ protected: virtual ItemKey getKey() override; virtual ShapeKey getShapeKey() override; - virtual Item::Bound getBound() override; + virtual Item::Bound getBound(RenderArgs* args) override; virtual void doRender(RenderArgs* args) override; private: diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index 9cc18a8df5..674d7c297d 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -200,16 +200,16 @@ ShapeKey ShapeEntityRenderer::getShapeKey() { return builder.build(); } -Item::Bound ShapeEntityRenderer::getBound() { +Item::Bound ShapeEntityRenderer::getBound(RenderArgs* args) { auto mat = _materials.find("0"); if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && mat->second.top().material->isReady()) { auto procedural = std::static_pointer_cast(mat->second.top().material); if (procedural->hasVertexShader() && procedural->hasBoundOperator()) { - return procedural->getBound(); + return procedural->getBound(args); } } - return Parent::getBound(); + return Parent::getBound(args); } void ShapeEntityRenderer::doRender(RenderArgs* args) { diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.h b/libraries/entities-renderer/src/RenderableShapeEntityItem.h index 9fb2fa8f23..fe62ad48b9 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.h +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.h @@ -26,7 +26,7 @@ public: protected: ShapeKey getShapeKey() override; - Item::Bound getBound() override; + Item::Bound getBound(RenderArgs* args) override; private: virtual bool needsRenderUpdate() const override; diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 1724cf69d5..16d9afb913 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -227,12 +227,12 @@ ItemKey entities::TextPayload::getKey() const { return ItemKey::Builder::opaqueShape(); } -Item::Bound entities::TextPayload::getBound() const { +Item::Bound entities::TextPayload::getBound(RenderArgs* args) const { auto entityTreeRenderer = DependencyManager::get(); if (entityTreeRenderer) { auto renderable = entityTreeRenderer->renderableForEntityId(_entityID); if (renderable) { - return std::static_pointer_cast(renderable)->getBound(); + return std::static_pointer_cast(renderable)->getBound(args); } } return Item::Bound(); @@ -335,9 +335,9 @@ template <> const ItemKey payloadGetKey(const TextPayload::Pointer& payload) { return ItemKey::Builder::opaqueShape(); } -template <> const Item::Bound payloadGetBound(const TextPayload::Pointer& payload) { +template <> const Item::Bound payloadGetBound(const TextPayload::Pointer& payload, RenderArgs* args) { if (payload) { - return payload->getBound(); + return payload->getBound(args); } return Item::Bound(); } diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.h b/libraries/entities-renderer/src/RenderableTextEntityItem.h index 1564c98644..0f736d1229 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.h +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.h @@ -88,7 +88,7 @@ public: typedef Payload::DataPointer Pointer; ItemKey getKey() const; - Item::Bound getBound() const; + Item::Bound getBound(RenderArgs* args) const; ShapeKey getShapeKey() const; void render(RenderArgs* args); bool passesZoneOcclusionTest(const std::unordered_set& containingZones) const; @@ -104,7 +104,7 @@ protected: namespace render { template <> const ItemKey payloadGetKey(const entities::TextPayload::Pointer& payload); - template <> const Item::Bound payloadGetBound(const entities::TextPayload::Pointer& payload); + template <> const Item::Bound payloadGetBound(const entities::TextPayload::Pointer& payload, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const entities::TextPayload::Pointer& payload); template <> void payloadRender(const entities::TextPayload::Pointer& payload, RenderArgs* args); template <> bool payloadPassesZoneOcclusionTest(const entities::TextPayload::Pointer& payload, const std::unordered_set& containingZones); diff --git a/libraries/procedural/CMakeLists.txt b/libraries/procedural/CMakeLists.txt index d737d34e95..a7394a3670 100644 --- a/libraries/procedural/CMakeLists.txt +++ b/libraries/procedural/CMakeLists.txt @@ -1,4 +1,4 @@ set(TARGET_NAME procedural) setup_hifi_library() -link_hifi_libraries(shared gpu shaders networking graphics material-networking ktx image hfm) +link_hifi_libraries(shared gpu shaders networking render graphics material-networking ktx image hfm) diff --git a/libraries/procedural/src/procedural/Procedural.h b/libraries/procedural/src/procedural/Procedural.h index 9b3d0a9bd4..7d655b5ef4 100644 --- a/libraries/procedural/src/procedural/Procedural.h +++ b/libraries/procedural/src/procedural/Procedural.h @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -113,9 +114,9 @@ public: void setDoesFade(bool doesFade) { _doesFade = doesFade; } bool hasVertexShader() const; - void setBoundOperator(const std::function& boundOperator) { _boundOperator = boundOperator; } + void setBoundOperator(const std::function& boundOperator) { _boundOperator = boundOperator; } bool hasBoundOperator() const { return (bool)_boundOperator; } - AABox getBound() { return _boundOperator(); } + AABox getBound(RenderArgs* args) { return _boundOperator(args); } gpu::Shader::Source _vertexSource; gpu::Shader::Source _vertexSourceSkinned; @@ -199,7 +200,7 @@ private: bool _doesFade { true }; ProceduralProgramKey _prevKey; - std::function _boundOperator { nullptr }; + std::function _boundOperator { nullptr }; mutable std::mutex _mutex; }; @@ -232,9 +233,9 @@ public: void initializeProcedural(); - void setBoundOperator(const std::function& boundOperator) { _procedural.setBoundOperator(boundOperator); } + void setBoundOperator(const std::function& boundOperator) { _procedural.setBoundOperator(boundOperator); } bool hasBoundOperator() const { return _procedural.hasBoundOperator(); } - AABox getBound() { return _procedural.getBound(); } + AABox getBound(RenderArgs* args) { return _procedural.getBound(args); } private: QString _proceduralString; diff --git a/libraries/render-utils/src/AnimDebugDraw.cpp b/libraries/render-utils/src/AnimDebugDraw.cpp index c4020cb4c4..770ac0b7dd 100644 --- a/libraries/render-utils/src/AnimDebugDraw.cpp +++ b/libraries/render-utils/src/AnimDebugDraw.cpp @@ -68,7 +68,7 @@ typedef render::Payload AnimDebugDrawPayload; namespace render { template <> const ItemKey payloadGetKey(const AnimDebugDrawData::Pointer& data) { return (data->_isVisible ? ItemKey::Builder::transparentShape() : ItemKey::Builder::transparentShape().withInvisible()).withTagBits(ItemKey::TAG_BITS_ALL); } - template <> const Item::Bound payloadGetBound(const AnimDebugDrawData::Pointer& data) { return data->_bound; } + template <> const Item::Bound payloadGetBound(const AnimDebugDrawData::Pointer& data, RenderArgs* args) { return data->_bound; } template <> void payloadRender(const AnimDebugDrawData::Pointer& data, RenderArgs* args) { data->render(args); } diff --git a/libraries/render-utils/src/FadeEffectJobs.cpp b/libraries/render-utils/src/FadeEffectJobs.cpp index 43206e77fa..6f6205060a 100644 --- a/libraries/render-utils/src/FadeEffectJobs.cpp +++ b/libraries/render-utils/src/FadeEffectJobs.cpp @@ -575,7 +575,7 @@ void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Ou auto& item = scene->getItem(state.itemId); assert(item.getTransitionId() == transitionId); #endif - if (update(*jobConfig, scene, transaction, state, deltaTime)) { + if (update(renderContext->args, *jobConfig, scene, transaction, state, deltaTime)) { hasTransaction = true; } if (isFirstItem && (state.threshold != jobConfig->threshold)) { @@ -599,7 +599,7 @@ const FadeCategory FadeJob::transitionToCategory[render::Transition::TYPE_COUNT] FADE_AVATAR_CHANGE }; -bool FadeJob::update(const Config& config, const render::ScenePointer& scene, render::Transaction& transaction, render::Transition& transition, const double deltaTime) const { +bool FadeJob::update(RenderArgs* args, const Config& config, const render::ScenePointer& scene, render::Transaction& transaction, render::Transition& transition, const double deltaTime) const { const auto fadeCategory = transitionToCategory[transition.eventType]; auto& eventConfig = config.events[fadeCategory]; auto item = scene->getItemSafe(transition.itemId); @@ -607,11 +607,11 @@ bool FadeJob::update(const Config& config, const render::ScenePointer& scene, re const FadeConfig::Timing timing = (FadeConfig::Timing) eventConfig.timing; if (item.exist()) { - auto aabb = item.getBound(); + auto aabb = item.getBound(args); if (render::Item::isValidID(transition.boundItemId)) { auto boundItem = scene->getItemSafe(transition.boundItemId); if (boundItem.exist()) { - aabb = boundItem.getBound(); + aabb = boundItem.getBound(args); } } auto& dimensions = aabb.getDimensions(); diff --git a/libraries/render-utils/src/FadeEffectJobs.h b/libraries/render-utils/src/FadeEffectJobs.h index 449995dba5..08b49c8d2d 100644 --- a/libraries/render-utils/src/FadeEffectJobs.h +++ b/libraries/render-utils/src/FadeEffectJobs.h @@ -223,7 +223,7 @@ private: float _thresholdScale[FADE_CATEGORY_COUNT]; uint64_t _previousTime{ 0 }; - bool update(const Config& config, const render::ScenePointer& scene, render::Transaction& transaction, render::Transition& transition, const double deltaTime) const; + bool update(RenderArgs* args, const Config& config, const render::ScenePointer& scene, render::Transaction& transaction, render::Transition& transition, const double deltaTime) const; static float computeElementEnterRatio(double time, const double period, FadeConfig::Timing timing); }; diff --git a/libraries/render-utils/src/LightPayload.cpp b/libraries/render-utils/src/LightPayload.cpp index 79e0c1d94d..d1018982d0 100644 --- a/libraries/render-utils/src/LightPayload.cpp +++ b/libraries/render-utils/src/LightPayload.cpp @@ -28,7 +28,7 @@ namespace render { return builder.build(); } - template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload) { + template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload, RenderArgs* args) { if (payload) { return payload->editBound(); } @@ -98,7 +98,7 @@ namespace render { return builder.build(); } - template <> const Item::Bound payloadGetBound(const KeyLightPayload::Pointer& payload) { + template <> const Item::Bound payloadGetBound(const KeyLightPayload::Pointer& payload, RenderArgs* args) { if (payload) { return payload->editBound(); } diff --git a/libraries/render-utils/src/LightPayload.h b/libraries/render-utils/src/LightPayload.h index 44b79ce10c..4c6695ec58 100644 --- a/libraries/render-utils/src/LightPayload.h +++ b/libraries/render-utils/src/LightPayload.h @@ -43,7 +43,7 @@ protected: namespace render { template <> const ItemKey payloadGetKey(const LightPayload::Pointer& payload); - template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload); + template <> const Item::Bound payloadGetBound(const LightPayload::Pointer& payload, RenderArgs* args); template <> void payloadRender(const LightPayload::Pointer& payload, RenderArgs* args); } @@ -79,7 +79,7 @@ protected: namespace render { template <> const ItemKey payloadGetKey(const KeyLightPayload::Pointer& payload); - template <> const Item::Bound payloadGetBound(const KeyLightPayload::Pointer& payload); + template <> const Item::Bound payloadGetBound(const KeyLightPayload::Pointer& payload, RenderArgs* args); template <> void payloadRender(const KeyLightPayload::Pointer& payload, RenderArgs* args); } diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index 0e0af6fc71..2d07fec8bf 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -177,8 +177,6 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& modelT } _parentTransform = modelTransform; - _worldBound = _adjustedLocalBound; - _worldBound.transform(_parentTransform); } void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) { @@ -289,15 +287,23 @@ ItemKey ModelMeshPartPayload::getKey() const { return _itemKey; } -Item::Bound ModelMeshPartPayload::getBound() const { +Item::Bound ModelMeshPartPayload::getBound(RenderArgs* args) const { graphics::MaterialPointer material = _drawMaterials.empty() ? nullptr : _drawMaterials.top().material; if (material && material->isProcedural() && material->isReady()) { auto procedural = std::static_pointer_cast(_drawMaterials.top().material); if (procedural->hasVertexShader() && procedural->hasBoundOperator()) { - return procedural->getBound(); + return procedural->getBound(args); } } - return _worldBound; + + auto worldBound = _adjustedLocalBound; + auto parentTransform = _parentTransform; + if (args) { + parentTransform.setRotation(BillboardModeHelpers::getBillboardRotation(parentTransform.getTranslation(), parentTransform.getRotation(), _billboardMode, + args->_renderMode == RenderArgs::RenderMode::SHADOW_RENDER_MODE ? BillboardModeHelpers::getPrimaryViewFrustumPosition() : args->getViewFrustum().getPosition())); + } + worldBound.transform(parentTransform); + return worldBound; } ShapeKey ModelMeshPartPayload::getShapeKey() const { @@ -396,9 +402,9 @@ template <> const ItemKey payloadGetKey(const ModelMeshPartPayload::Pointer& pay return ItemKey::Builder::opaqueShape(); // for lack of a better idea } -template <> const Item::Bound payloadGetBound(const ModelMeshPartPayload::Pointer& payload) { +template <> const Item::Bound payloadGetBound(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args) { if (payload) { - return payload->getBound(); + return payload->getBound(args); } return Item::Bound(); } diff --git a/libraries/render-utils/src/MeshPartPayload.h b/libraries/render-utils/src/MeshPartPayload.h index 63ccb85470..b5cff41bf8 100644 --- a/libraries/render-utils/src/MeshPartPayload.h +++ b/libraries/render-utils/src/MeshPartPayload.h @@ -45,7 +45,7 @@ public: // Render Item interface render::ItemKey getKey() const; - render::Item::Bound getBound() const; + render::Item::Bound getBound(RenderArgs* args) const; render::ShapeKey getShapeKey() const; void render(RenderArgs* args); @@ -99,12 +99,11 @@ private: Transform _parentTransform; graphics::Box _localBound; graphics::Box _adjustedLocalBound; - mutable graphics::Box _worldBound; }; namespace render { template <> const ItemKey payloadGetKey(const ModelMeshPartPayload::Pointer& payload); - template <> const Item::Bound payloadGetBound(const ModelMeshPartPayload::Pointer& payload); + template <> const Item::Bound payloadGetBound(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const ModelMeshPartPayload::Pointer& payload); template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args); template <> bool payloadPassesZoneOcclusionTest(const ModelMeshPartPayload::Pointer& payload, const std::unordered_set& containingZones); diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index dad2f95420..f4267fdf39 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1527,7 +1527,7 @@ AABox Model::getRenderableMeshBound() const { // Build a bound using the last known bound from all the renderItems. AABox totalBound; for (auto& renderItem : _modelMeshRenderItems) { - totalBound += renderItem->getBound(); + totalBound += renderItem->getBound(nullptr); } return totalBound; } diff --git a/libraries/render/src/render/CullTask.cpp b/libraries/render/src/render/CullTask.cpp index 164d8e9f21..68bb467f66 100644 --- a/libraries/render/src/render/CullTask.cpp +++ b/libraries/render/src/render/CullTask.cpp @@ -83,7 +83,7 @@ void FetchNonspatialItems::run(const RenderContextPointer& renderContext, const for (auto& id : items) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && item.passesZoneOcclusionTest(CullTest::_containingZones)) { - outItems.emplace_back(ItemBound(id, item.getBound())); + outItems.emplace_back(ItemBound(id, item.getBound(renderContext->args))); } } } @@ -188,10 +188,10 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.insideItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -203,10 +203,10 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.insideSubcellItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -218,10 +218,10 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.partialItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -233,10 +233,10 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.partialSubcellItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -250,10 +250,10 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.insideItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -265,11 +265,11 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.insideSubcellItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); if (test.solidAngleTest(itemBound.bound)) { outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -282,11 +282,11 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.partialItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); if (test.frustumTest(itemBound.bound)) { outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } @@ -299,11 +299,11 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext, for (auto id : inSelection.partialSubcellItems) { auto& item = scene->getItem(id); if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { - ItemBound itemBound(id, item.getBound()); + ItemBound itemBound(id, item.getBound(args)); if (test.frustumTest(itemBound.bound) && test.solidAngleTest(itemBound.bound)) { outItems.emplace_back(itemBound); if (item.getKey().isMetaCullGroup()) { - item.fetchMetaSubItemBounds(outItems, (*scene)); + item.fetchMetaSubItemBounds(outItems, (*scene), args); } } } diff --git a/libraries/render/src/render/DrawSceneOctree.cpp b/libraries/render/src/render/DrawSceneOctree.cpp index 493ed01c3f..44d54c3c28 100644 --- a/libraries/render/src/render/DrawSceneOctree.cpp +++ b/libraries/render/src/render/DrawSceneOctree.cpp @@ -194,7 +194,7 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite render::ItemBounds itemBounds; for (const auto& itemID : itemIDs) { auto& item = scene->getItem(itemID); - auto itemBound = item.getBound(); + auto itemBound = item.getBound(args); if (!itemBound.isInvalid()) { itemBounds.emplace_back(itemID, itemBound); } diff --git a/libraries/render/src/render/FilterTask.cpp b/libraries/render/src/render/FilterTask.cpp index 20d29f3e5d..b269f44b41 100644 --- a/libraries/render/src/render/FilterTask.cpp +++ b/libraries/render/src/render/FilterTask.cpp @@ -139,7 +139,7 @@ void IDsToBounds::run(const RenderContextPointer& renderContext, const ItemIDs& for (auto id : inItems) { auto& item = scene->getItem(id); if (item.exist()) { - outItems.emplace_back(ItemBound{ id, item.getBound() }); + outItems.emplace_back(ItemBound{ id, item.getBound(renderContext->args) }); } } } else { diff --git a/libraries/render/src/render/Item.cpp b/libraries/render/src/render/Item.cpp index f21df58368..369f227566 100644 --- a/libraries/render/src/render/Item.cpp +++ b/libraries/render/src/render/Item.cpp @@ -97,7 +97,7 @@ const ShapeKey Item::getShapeKey() const { return shapeKey; } -uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene) const { +uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene, RenderArgs* args) const { ItemIDs subItems; auto numSubs = fetchMetaSubItems(subItems); @@ -107,7 +107,7 @@ uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene) c if (scene.isAllocatedID(id)) { auto& item = scene.getItem(id); if (item.exist()) { - subItemBounds.emplace_back(id, item.getBound()); + subItemBounds.emplace_back(id, item.getBound(args)); } else { numSubs--; } @@ -133,11 +133,11 @@ namespace render { return payload->getShapeKey(); } - template <> const Item::Bound payloadGetBound(const PayloadProxyInterface::Pointer& payload) { + template <> const Item::Bound payloadGetBound(const PayloadProxyInterface::Pointer& payload, RenderArgs* args) { if (!payload) { return render::Item::Bound(); } - return payload->getBound(); + return payload->getBound(args); } template <> void payloadRender(const PayloadProxyInterface::Pointer& payload, RenderArgs* args) { diff --git a/libraries/render/src/render/Item.h b/libraries/render/src/render/Item.h index 8a67108d0e..5952be8a84 100644 --- a/libraries/render/src/render/Item.h +++ b/libraries/render/src/render/Item.h @@ -431,7 +431,7 @@ public: class PayloadInterface { public: virtual const ItemKey getKey() const = 0; - virtual const Bound getBound() const = 0; + virtual const Bound getBound(RenderArgs* args) const = 0; virtual void render(RenderArgs* args) = 0; virtual const ShapeKey getShapeKey() const = 0; @@ -476,7 +476,7 @@ public: // Payload Interface // Get the bound of the item expressed in world space (or eye space depending on the key.isWorldSpace()) - const Bound getBound() const { return _payload->getBound(); } + const Bound getBound(RenderArgs* args) const { return _payload->getBound(args); } // Get the layer where the item belongs, simply reflecting the key. int getLayer() const { return _key.getLayer(); } @@ -489,7 +489,7 @@ public: // Meta Type Interface uint32_t fetchMetaSubItems(ItemIDs& subItems) const { return _payload->fetchMetaSubItems(subItems); } - uint32_t fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene) const; + uint32_t fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene, RenderArgs* args) const; bool passesZoneOcclusionTest(const std::unordered_set& containingZones) const { return _payload->passesZoneOcclusionTest(containingZones); } @@ -524,13 +524,13 @@ public: inline QDebug operator<<(QDebug debug, const Item& item) { - debug << "[Item: _key:" << item.getKey() << ", bounds:" << item.getBound() << "]"; + debug << "[Item: _key:" << item.getKey() << "]"; return debug; } // Item shared interface supported by the payload template const ItemKey payloadGetKey(const std::shared_ptr& payloadData) { return ItemKey(); } -template const Item::Bound payloadGetBound(const std::shared_ptr& payloadData) { return Item::Bound(); } +template const Item::Bound payloadGetBound(const std::shared_ptr& payloadData, RenderArgs* args) { return Item::Bound(); } template void payloadRender(const std::shared_ptr& payloadData, RenderArgs* args) { } // Shape type interface @@ -561,7 +561,7 @@ public: // Payload general interface virtual const ItemKey getKey() const override { return payloadGetKey(_data); } - virtual const Item::Bound getBound() const override { return payloadGetBound(_data); } + virtual const Item::Bound getBound(RenderArgs* args) const override { return payloadGetBound(_data, args); } virtual void render(RenderArgs* args) override { payloadRender(_data, args); } @@ -607,9 +607,9 @@ template <> const ItemKey payloadGetKey(const FooPointer& foo) { foo->makeMyKey(); return foo->_myownKey; } -template <> const Item::Bound payloadGetBound(const FooPointer& foo) { +template <> const Item::Bound payloadGetBound(const FooPointer& foo, RenderArgs* args) { // evaluate Foo's own bound - return foo->evaluateMyBound(); + return foo->evaluateMyBound(args); } // In this example, do not specialize the payloadRender call which means the compiler will use the default version which does nothing @@ -624,7 +624,7 @@ public: virtual ItemKey getKey() = 0; virtual ShapeKey getShapeKey() = 0; - virtual Item::Bound getBound() = 0; + virtual Item::Bound getBound(RenderArgs* args) = 0; virtual void render(RenderArgs* args) = 0; virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const = 0; virtual bool passesZoneOcclusionTest(const std::unordered_set& containingZones) const = 0; @@ -635,7 +635,7 @@ public: }; template <> const ItemKey payloadGetKey(const PayloadProxyInterface::Pointer& payload); -template <> const Item::Bound payloadGetBound(const PayloadProxyInterface::Pointer& payload); +template <> const Item::Bound payloadGetBound(const PayloadProxyInterface::Pointer& payload, RenderArgs* args); template <> void payloadRender(const PayloadProxyInterface::Pointer& payload, RenderArgs* args); template <> uint32_t metaFetchMetaSubItems(const PayloadProxyInterface::Pointer& payload, ItemIDs& subItems); template <> const ShapeKey shapeGetShapeKey(const PayloadProxyInterface::Pointer& payload); diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index bea111edb5..5500183196 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -305,7 +305,7 @@ void Scene::resetItems(const Transaction::Resets& transactions) { // Update the item's container assert((oldKey.isSpatial() == newKey.isSpatial()) || oldKey._flags.none()); if (newKey.isSpatial()) { - auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(), itemId, newKey); + auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(nullptr), itemId, newKey); item.resetCell(newCell, newKey.isSmall()); } else { _masterNonspatialSet.insert(itemId); @@ -361,14 +361,14 @@ void Scene::updateItems(const Transaction::Updates& transactions) { // Update the item's container if (oldKey.isSpatial() == newKey.isSpatial()) { if (newKey.isSpatial()) { - auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(), updateID, newKey); + auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(nullptr), updateID, newKey); item.resetCell(newCell, newKey.isSmall()); } } else { if (newKey.isSpatial()) { _masterNonspatialSet.erase(updateID); - auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(), updateID, newKey); + auto newCell = _masterSpatialTree.resetItem(oldCell, oldKey, item.getBound(nullptr), updateID, newKey); item.resetCell(newCell, newKey.isSmall()); } else { _masterSpatialTree.removeItem(oldCell, oldKey, updateID); diff --git a/libraries/render/src/render/SortTask.cpp b/libraries/render/src/render/SortTask.cpp index 5b4061a10f..266c5be41d 100644 --- a/libraries/render/src/render/SortTask.cpp +++ b/libraries/render/src/render/SortTask.cpp @@ -60,7 +60,7 @@ void render::depthSortItems(const RenderContextPointer& renderContext, bool fron for (auto itemDetails : inItems) { auto item = scene->getItem(itemDetails.id); - auto bound = itemDetails.bound; // item.getBound(); + auto bound = itemDetails.bound; // item.getBound(args); float distanceSquared = args->getViewFrustum().distanceToCameraSquared(bound.calcCenter()); itemBoundSorts.emplace_back(ItemBoundSort(distanceSquared, distanceSquared, distanceSquared, itemDetails.id, bound));