proper render bounds for models (need to pass RenderArgs to getBound everywhere)

This commit is contained in:
HifiExperiments 2021-01-17 22:08:06 -08:00
parent 1f71a23082
commit 92ea14a059
42 changed files with 108 additions and 102 deletions

View file

@ -16,7 +16,7 @@ render::ItemID WorldBoxRenderData::_item{ render::Item::INVALID_ITEM_ID };
namespace render { 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 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) { template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) {
if (Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) { if (Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) {
PerformanceTimer perfTimer("worldBox"); PerformanceTimer perfTimer("worldBox");

View file

@ -32,7 +32,7 @@ public:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff); 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); template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args);
} }

View file

@ -462,9 +462,9 @@ namespace render {
template <> const ItemKey payloadGetKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload) { template <> const ItemKey payloadGetKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload) {
return payload->getKey(); 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) { if (payload) {
return payload->getBound(); return payload->getBound(args);
} }
return Item::Bound(); return Item::Bound();
} }

View file

@ -31,7 +31,7 @@ public:
void render(RenderArgs* args); void render(RenderArgs* args);
render::Item::Bound& editBound() { return _bound; } 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; } render::ItemKey getKey() const { return _key; }
void setVisible(bool visible); void setVisible(bool visible);
@ -128,7 +128,7 @@ private:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload); 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 <> void payloadRender(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload, RenderArgs* args);
template <> const ShapeKey shapeGetShapeKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload); template <> const ShapeKey shapeGetShapeKey(const ParabolaPointer::RenderState::ParabolaRenderItem::Pointer& payload);
} }

View file

@ -66,7 +66,7 @@ private:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay); 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 <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args);
template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay); template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay);
template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems); template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems);

View file

@ -14,7 +14,7 @@ namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) { template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
return overlay->getKey(); 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(); return overlay->getBounds();
} }
template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) { template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) {

View file

@ -82,9 +82,9 @@ namespace render {
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) { template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) {
return payload->getKey(); 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) { if (payload) {
return payload->getBound(); return payload->getBound(args);
} }
return Item::Bound(); return Item::Bound();
} }

View file

@ -57,7 +57,7 @@ public:
void render(RenderArgs* args); void render(RenderArgs* args);
render::Item::Bound& editBound() { return _bound; } 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 setVisible(bool visible);
void showProxies(bool show); void showProxies(bool show);
@ -96,7 +96,7 @@ protected:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload); 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 <> void payloadRender(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args);
template <> const ShapeKey shapeGetShapeKey(const GameWorkloadRenderItem::Pointer& payload); template <> const ShapeKey shapeGetShapeKey(const GameWorkloadRenderItem::Pointer& payload);
} }

View file

@ -63,7 +63,7 @@ namespace render {
} }
return keyBuilder.build(); 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>(avatar); auto avatarPtr = static_pointer_cast<Avatar>(avatar);
if (avatarPtr) { if (avatarPtr) {
return avatarPtr->getRenderBounds(); return avatarPtr->getRenderBounds();

View file

@ -39,7 +39,7 @@
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar); 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 <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args);
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems); template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems);
} }

View file

@ -137,7 +137,7 @@ EntityRenderer::~EntityRenderer() {}
// Smart payload proxy members, implementing the payload interface // Smart payload proxy members, implementing the payload interface
// //
Item::Bound EntityRenderer::getBound() { Item::Bound EntityRenderer::getBound(RenderArgs* args) {
auto bound = _bound; auto bound = _bound;
if (_billboardMode != BillboardMode::NONE) { if (_billboardMode != BillboardMode::NONE) {
glm::vec3 dimensions = bound.getScale(); glm::vec3 dimensions = bound.getScale();

View file

@ -64,7 +64,7 @@ public:
static glm::vec3 calculatePulseColor(const glm::vec3& color, const PulsePropertyGroup& pulseProperties, quint64 start); static glm::vec3 calculatePulseColor(const glm::vec3& color, const PulsePropertyGroup& pulseProperties, quint64 start);
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const override; 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<QUuid>& containingZones) const override; bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const override;
protected: protected:

View file

@ -195,8 +195,8 @@ void GizmoEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
} }
} }
Item::Bound GizmoEntityRenderer::getBound() { Item::Bound GizmoEntityRenderer::getBound(RenderArgs* args) {
auto bound = Parent::getBound(); auto bound = Parent::getBound(args);
if (_ringProperties.getHasTickMarks()) { if (_ringProperties.getHasTickMarks()) {
glm::vec3 scale = bound.getScale(); glm::vec3 scale = bound.getScale();
for (int i = 0; i < 3; i += 2) { for (int i = 0; i < 3; i += 2) {

View file

@ -23,7 +23,7 @@ public:
~GizmoEntityRenderer(); ~GizmoEntityRenderer();
protected: protected:
Item::Bound getBound() override; Item::Bound getBound(RenderArgs* args) override;
ShapeKey getShapeKey() override; ShapeKey getShapeKey() override;
bool isTransparent() const override; bool isTransparent() const override;

View file

@ -49,13 +49,13 @@ void GridEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe
_minorGridEvery = entity->getMinorGridEvery(); _minorGridEvery = entity->getMinorGridEvery();
} }
Item::Bound GridEntityRenderer::getBound() { Item::Bound GridEntityRenderer::getBound(RenderArgs* args) {
if (_followCamera) { if (_followCamera) {
// This is a UI element that should always be in view, lie to the octree to avoid culling // 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); const AABox DOMAIN_BOX = AABox(glm::vec3(-TREE_SCALE / 2), TREE_SCALE);
return DOMAIN_BOX; return DOMAIN_BOX;
} }
return Parent::getBound(); return Parent::getBound(args);
} }
ShapeKey GridEntityRenderer::getShapeKey() { ShapeKey GridEntityRenderer::getShapeKey() {

View file

@ -23,7 +23,7 @@ public:
~GridEntityRenderer(); ~GridEntityRenderer();
protected: protected:
Item::Bound getBound() override; Item::Bound getBound(RenderArgs* args) override;
ShapeKey getShapeKey() override; ShapeKey getShapeKey() override;
bool isTransparent() const override; bool isTransparent() const override;

View file

@ -60,8 +60,8 @@ ItemKey LightEntityRenderer::getKey() {
return payloadGetKey(_lightPayload); return payloadGetKey(_lightPayload);
} }
Item::Bound LightEntityRenderer::getBound() { Item::Bound LightEntityRenderer::getBound(RenderArgs* args) {
return payloadGetBound(_lightPayload); return payloadGetBound(_lightPayload, args);
} }
void LightEntityRenderer::doRender(RenderArgs* args) { void LightEntityRenderer::doRender(RenderArgs* args) {

View file

@ -29,7 +29,7 @@ protected:
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual ItemKey getKey() override; virtual ItemKey getKey() override;
virtual Item::Bound getBound() override; virtual Item::Bound getBound(RenderArgs* args) override;
virtual void doRender(RenderArgs* args) override; virtual void doRender(RenderArgs* args) override;
private: private:

View file

@ -376,7 +376,7 @@ void MaterialEntityRenderer::applyMaterial(const TypedEntityPointer& entity) {
if (material->isProcedural()) { if (material->isProcedural()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(material); auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(material);
procedural->setBoundOperator([this] { return getBound(); }); procedural->setBoundOperator([this](RenderArgs* args) { return getBound(args); });
entity->setHasVertexShader(procedural->hasVertexShader()); entity->setHasVertexShader(procedural->hasVertexShader());
} }

View file

@ -161,7 +161,7 @@ ShapeKey ParticleEffectEntityRenderer::getShapeKey() {
return builder.build(); return builder.build();
} }
Item::Bound ParticleEffectEntityRenderer::getBound() { Item::Bound ParticleEffectEntityRenderer::getBound(RenderArgs* args) {
return _bound; return _bound;
} }

View file

@ -30,7 +30,7 @@ protected:
virtual ItemKey getKey() override; virtual ItemKey getKey() override;
virtual ShapeKey getShapeKey() override; virtual ShapeKey getShapeKey() override;
virtual Item::Bound getBound() override; virtual Item::Bound getBound(RenderArgs* args) override;
virtual void doRender(RenderArgs* args) override; virtual void doRender(RenderArgs* args) override;
private: private:

View file

@ -200,16 +200,16 @@ ShapeKey ShapeEntityRenderer::getShapeKey() {
return builder.build(); return builder.build();
} }
Item::Bound ShapeEntityRenderer::getBound() { Item::Bound ShapeEntityRenderer::getBound(RenderArgs* args) {
auto mat = _materials.find("0"); auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() && if (mat != _materials.end() && mat->second.top().material && mat->second.top().material->isProcedural() &&
mat->second.top().material->isReady()) { mat->second.top().material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material); auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(mat->second.top().material);
if (procedural->hasVertexShader() && procedural->hasBoundOperator()) { if (procedural->hasVertexShader() && procedural->hasBoundOperator()) {
return procedural->getBound(); return procedural->getBound(args);
} }
} }
return Parent::getBound(); return Parent::getBound(args);
} }
void ShapeEntityRenderer::doRender(RenderArgs* args) { void ShapeEntityRenderer::doRender(RenderArgs* args) {

View file

@ -26,7 +26,7 @@ public:
protected: protected:
ShapeKey getShapeKey() override; ShapeKey getShapeKey() override;
Item::Bound getBound() override; Item::Bound getBound(RenderArgs* args) override;
private: private:
virtual bool needsRenderUpdate() const override; virtual bool needsRenderUpdate() const override;

View file

@ -227,12 +227,12 @@ ItemKey entities::TextPayload::getKey() const {
return ItemKey::Builder::opaqueShape(); return ItemKey::Builder::opaqueShape();
} }
Item::Bound entities::TextPayload::getBound() const { Item::Bound entities::TextPayload::getBound(RenderArgs* args) const {
auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>(); auto entityTreeRenderer = DependencyManager::get<EntityTreeRenderer>();
if (entityTreeRenderer) { if (entityTreeRenderer) {
auto renderable = entityTreeRenderer->renderableForEntityId(_entityID); auto renderable = entityTreeRenderer->renderableForEntityId(_entityID);
if (renderable) { if (renderable) {
return std::static_pointer_cast<TextEntityRenderer>(renderable)->getBound(); return std::static_pointer_cast<TextEntityRenderer>(renderable)->getBound(args);
} }
} }
return Item::Bound(); return Item::Bound();
@ -335,9 +335,9 @@ template <> const ItemKey payloadGetKey(const TextPayload::Pointer& payload) {
return ItemKey::Builder::opaqueShape(); 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) { if (payload) {
return payload->getBound(); return payload->getBound(args);
} }
return Item::Bound(); return Item::Bound();
} }

View file

@ -88,7 +88,7 @@ public:
typedef Payload::DataPointer Pointer; typedef Payload::DataPointer Pointer;
ItemKey getKey() const; ItemKey getKey() const;
Item::Bound getBound() const; Item::Bound getBound(RenderArgs* args) const;
ShapeKey getShapeKey() const; ShapeKey getShapeKey() const;
void render(RenderArgs* args); void render(RenderArgs* args);
bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const; bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const;
@ -104,7 +104,7 @@ protected:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const entities::TextPayload::Pointer& payload); 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 <> const ShapeKey shapeGetShapeKey(const entities::TextPayload::Pointer& payload);
template <> void payloadRender(const entities::TextPayload::Pointer& payload, RenderArgs* args); template <> void payloadRender(const entities::TextPayload::Pointer& payload, RenderArgs* args);
template <> bool payloadPassesZoneOcclusionTest(const entities::TextPayload::Pointer& payload, const std::unordered_set<QUuid>& containingZones); template <> bool payloadPassesZoneOcclusionTest(const entities::TextPayload::Pointer& payload, const std::unordered_set<QUuid>& containingZones);

View file

@ -1,4 +1,4 @@
set(TARGET_NAME procedural) set(TARGET_NAME procedural)
setup_hifi_library() 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)

View file

@ -16,6 +16,7 @@
#include <QtCore/QJsonObject> #include <QtCore/QJsonObject>
#include <QtCore/QJsonArray> #include <QtCore/QJsonArray>
#include <render/Args.h>
#include <gpu/Shader.h> #include <gpu/Shader.h>
#include <gpu/Pipeline.h> #include <gpu/Pipeline.h>
#include <gpu/Batch.h> #include <gpu/Batch.h>
@ -113,9 +114,9 @@ public:
void setDoesFade(bool doesFade) { _doesFade = doesFade; } void setDoesFade(bool doesFade) { _doesFade = doesFade; }
bool hasVertexShader() const; bool hasVertexShader() const;
void setBoundOperator(const std::function<AABox()>& boundOperator) { _boundOperator = boundOperator; } void setBoundOperator(const std::function<AABox(RenderArgs*)>& boundOperator) { _boundOperator = boundOperator; }
bool hasBoundOperator() const { return (bool)_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 _vertexSource;
gpu::Shader::Source _vertexSourceSkinned; gpu::Shader::Source _vertexSourceSkinned;
@ -199,7 +200,7 @@ private:
bool _doesFade { true }; bool _doesFade { true };
ProceduralProgramKey _prevKey; ProceduralProgramKey _prevKey;
std::function<AABox()> _boundOperator { nullptr }; std::function<AABox(RenderArgs*)> _boundOperator { nullptr };
mutable std::mutex _mutex; mutable std::mutex _mutex;
}; };
@ -232,9 +233,9 @@ public:
void initializeProcedural(); void initializeProcedural();
void setBoundOperator(const std::function<AABox()>& boundOperator) { _procedural.setBoundOperator(boundOperator); } void setBoundOperator(const std::function<AABox(RenderArgs*)>& boundOperator) { _procedural.setBoundOperator(boundOperator); }
bool hasBoundOperator() const { return _procedural.hasBoundOperator(); } bool hasBoundOperator() const { return _procedural.hasBoundOperator(); }
AABox getBound() { return _procedural.getBound(); } AABox getBound(RenderArgs* args) { return _procedural.getBound(args); }
private: private:
QString _proceduralString; QString _proceduralString;

View file

@ -68,7 +68,7 @@ typedef render::Payload<AnimDebugDrawData> AnimDebugDrawPayload;
namespace render { 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 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) { template <> void payloadRender(const AnimDebugDrawData::Pointer& data, RenderArgs* args) {
data->render(args); data->render(args);
} }

View file

@ -575,7 +575,7 @@ void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Ou
auto& item = scene->getItem(state.itemId); auto& item = scene->getItem(state.itemId);
assert(item.getTransitionId() == transitionId); assert(item.getTransitionId() == transitionId);
#endif #endif
if (update(*jobConfig, scene, transaction, state, deltaTime)) { if (update(renderContext->args, *jobConfig, scene, transaction, state, deltaTime)) {
hasTransaction = true; hasTransaction = true;
} }
if (isFirstItem && (state.threshold != jobConfig->threshold)) { if (isFirstItem && (state.threshold != jobConfig->threshold)) {
@ -599,7 +599,7 @@ const FadeCategory FadeJob::transitionToCategory[render::Transition::TYPE_COUNT]
FADE_AVATAR_CHANGE 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]; const auto fadeCategory = transitionToCategory[transition.eventType];
auto& eventConfig = config.events[fadeCategory]; auto& eventConfig = config.events[fadeCategory];
auto item = scene->getItemSafe(transition.itemId); 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; const FadeConfig::Timing timing = (FadeConfig::Timing) eventConfig.timing;
if (item.exist()) { if (item.exist()) {
auto aabb = item.getBound(); auto aabb = item.getBound(args);
if (render::Item::isValidID(transition.boundItemId)) { if (render::Item::isValidID(transition.boundItemId)) {
auto boundItem = scene->getItemSafe(transition.boundItemId); auto boundItem = scene->getItemSafe(transition.boundItemId);
if (boundItem.exist()) { if (boundItem.exist()) {
aabb = boundItem.getBound(); aabb = boundItem.getBound(args);
} }
} }
auto& dimensions = aabb.getDimensions(); auto& dimensions = aabb.getDimensions();

View file

@ -223,7 +223,7 @@ private:
float _thresholdScale[FADE_CATEGORY_COUNT]; float _thresholdScale[FADE_CATEGORY_COUNT];
uint64_t _previousTime{ 0 }; 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); static float computeElementEnterRatio(double time, const double period, FadeConfig::Timing timing);
}; };

View file

@ -28,7 +28,7 @@ namespace render {
return builder.build(); 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) { if (payload) {
return payload->editBound(); return payload->editBound();
} }
@ -98,7 +98,7 @@ namespace render {
return builder.build(); 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) { if (payload) {
return payload->editBound(); return payload->editBound();
} }

View file

@ -43,7 +43,7 @@ protected:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const LightPayload::Pointer& payload); 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); template <> void payloadRender(const LightPayload::Pointer& payload, RenderArgs* args);
} }
@ -79,7 +79,7 @@ protected:
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const KeyLightPayload::Pointer& payload); 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); template <> void payloadRender(const KeyLightPayload::Pointer& payload, RenderArgs* args);
} }

View file

@ -177,8 +177,6 @@ void ModelMeshPartPayload::updateTransformForSkinnedMesh(const Transform& modelT
} }
_parentTransform = modelTransform; _parentTransform = modelTransform;
_worldBound = _adjustedLocalBound;
_worldBound.transform(_parentTransform);
} }
void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) { void ModelMeshPartPayload::bindMesh(gpu::Batch& batch) {
@ -289,15 +287,23 @@ ItemKey ModelMeshPartPayload::getKey() const {
return _itemKey; return _itemKey;
} }
Item::Bound ModelMeshPartPayload::getBound() const { Item::Bound ModelMeshPartPayload::getBound(RenderArgs* args) const {
graphics::MaterialPointer material = _drawMaterials.empty() ? nullptr : _drawMaterials.top().material; graphics::MaterialPointer material = _drawMaterials.empty() ? nullptr : _drawMaterials.top().material;
if (material && material->isProcedural() && material->isReady()) { if (material && material->isProcedural() && material->isReady()) {
auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(_drawMaterials.top().material); auto procedural = std::static_pointer_cast<graphics::ProceduralMaterial>(_drawMaterials.top().material);
if (procedural->hasVertexShader() && procedural->hasBoundOperator()) { 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 { 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 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) { if (payload) {
return payload->getBound(); return payload->getBound(args);
} }
return Item::Bound(); return Item::Bound();
} }

View file

@ -45,7 +45,7 @@ public:
// Render Item interface // Render Item interface
render::ItemKey getKey() const; render::ItemKey getKey() const;
render::Item::Bound getBound() const; render::Item::Bound getBound(RenderArgs* args) const;
render::ShapeKey getShapeKey() const; render::ShapeKey getShapeKey() const;
void render(RenderArgs* args); void render(RenderArgs* args);
@ -99,12 +99,11 @@ private:
Transform _parentTransform; Transform _parentTransform;
graphics::Box _localBound; graphics::Box _localBound;
graphics::Box _adjustedLocalBound; graphics::Box _adjustedLocalBound;
mutable graphics::Box _worldBound;
}; };
namespace render { namespace render {
template <> const ItemKey payloadGetKey(const ModelMeshPartPayload::Pointer& payload); 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 <> const ShapeKey shapeGetShapeKey(const ModelMeshPartPayload::Pointer& payload);
template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args); template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args);
template <> bool payloadPassesZoneOcclusionTest(const ModelMeshPartPayload::Pointer& payload, const std::unordered_set<QUuid>& containingZones); template <> bool payloadPassesZoneOcclusionTest(const ModelMeshPartPayload::Pointer& payload, const std::unordered_set<QUuid>& containingZones);

View file

@ -1527,7 +1527,7 @@ AABox Model::getRenderableMeshBound() const {
// Build a bound using the last known bound from all the renderItems. // Build a bound using the last known bound from all the renderItems.
AABox totalBound; AABox totalBound;
for (auto& renderItem : _modelMeshRenderItems) { for (auto& renderItem : _modelMeshRenderItems) {
totalBound += renderItem->getBound(); totalBound += renderItem->getBound(nullptr);
} }
return totalBound; return totalBound;
} }

View file

@ -83,7 +83,7 @@ void FetchNonspatialItems::run(const RenderContextPointer& renderContext, const
for (auto& id : items) { for (auto& id : items) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && item.passesZoneOcclusionTest(CullTest::_containingZones)) { 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) { for (auto id : inSelection.insideItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.insideSubcellItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.partialItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.partialSubcellItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.insideItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.insideSubcellItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
if (test.solidAngleTest(itemBound.bound)) { if (test.solidAngleTest(itemBound.bound)) {
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.partialItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) {
ItemBound itemBound(id, item.getBound()); ItemBound itemBound(id, item.getBound(args));
if (test.frustumTest(itemBound.bound)) { if (test.frustumTest(itemBound.bound)) {
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { 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) { for (auto id : inSelection.partialSubcellItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (filter.test(item.getKey()) && test.zoneOcclusionTest(item)) { 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)) { if (test.frustumTest(itemBound.bound) && test.solidAngleTest(itemBound.bound)) {
outItems.emplace_back(itemBound); outItems.emplace_back(itemBound);
if (item.getKey().isMetaCullGroup()) { if (item.getKey().isMetaCullGroup()) {
item.fetchMetaSubItemBounds(outItems, (*scene)); item.fetchMetaSubItemBounds(outItems, (*scene), args);
} }
} }
} }

View file

@ -194,7 +194,7 @@ void DrawItemSelection::run(const RenderContextPointer& renderContext, const Ite
render::ItemBounds itemBounds; render::ItemBounds itemBounds;
for (const auto& itemID : itemIDs) { for (const auto& itemID : itemIDs) {
auto& item = scene->getItem(itemID); auto& item = scene->getItem(itemID);
auto itemBound = item.getBound(); auto itemBound = item.getBound(args);
if (!itemBound.isInvalid()) { if (!itemBound.isInvalid()) {
itemBounds.emplace_back(itemID, itemBound); itemBounds.emplace_back(itemID, itemBound);
} }

View file

@ -139,7 +139,7 @@ void IDsToBounds::run(const RenderContextPointer& renderContext, const ItemIDs&
for (auto id : inItems) { for (auto id : inItems) {
auto& item = scene->getItem(id); auto& item = scene->getItem(id);
if (item.exist()) { if (item.exist()) {
outItems.emplace_back(ItemBound{ id, item.getBound() }); outItems.emplace_back(ItemBound{ id, item.getBound(renderContext->args) });
} }
} }
} else { } else {

View file

@ -97,7 +97,7 @@ const ShapeKey Item::getShapeKey() const {
return shapeKey; return shapeKey;
} }
uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene) const { uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene, RenderArgs* args) const {
ItemIDs subItems; ItemIDs subItems;
auto numSubs = fetchMetaSubItems(subItems); auto numSubs = fetchMetaSubItems(subItems);
@ -107,7 +107,7 @@ uint32_t Item::fetchMetaSubItemBounds(ItemBounds& subItemBounds, Scene& scene) c
if (scene.isAllocatedID(id)) { if (scene.isAllocatedID(id)) {
auto& item = scene.getItem(id); auto& item = scene.getItem(id);
if (item.exist()) { if (item.exist()) {
subItemBounds.emplace_back(id, item.getBound()); subItemBounds.emplace_back(id, item.getBound(args));
} else { } else {
numSubs--; numSubs--;
} }
@ -133,11 +133,11 @@ namespace render {
return payload->getShapeKey(); 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) { if (!payload) {
return render::Item::Bound(); return render::Item::Bound();
} }
return payload->getBound(); return payload->getBound(args);
} }
template <> void payloadRender(const PayloadProxyInterface::Pointer& payload, RenderArgs* args) { template <> void payloadRender(const PayloadProxyInterface::Pointer& payload, RenderArgs* args) {

View file

@ -431,7 +431,7 @@ public:
class PayloadInterface { class PayloadInterface {
public: public:
virtual const ItemKey getKey() const = 0; 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 void render(RenderArgs* args) = 0;
virtual const ShapeKey getShapeKey() const = 0; virtual const ShapeKey getShapeKey() const = 0;
@ -476,7 +476,7 @@ public:
// Payload Interface // Payload Interface
// Get the bound of the item expressed in world space (or eye space depending on the key.isWorldSpace()) // 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. // Get the layer where the item belongs, simply reflecting the key.
int getLayer() const { return _key.getLayer(); } int getLayer() const { return _key.getLayer(); }
@ -489,7 +489,7 @@ public:
// Meta Type Interface // Meta Type Interface
uint32_t fetchMetaSubItems(ItemIDs& subItems) const { return _payload->fetchMetaSubItems(subItems); } 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<QUuid>& containingZones) const { return _payload->passesZoneOcclusionTest(containingZones); } bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const { return _payload->passesZoneOcclusionTest(containingZones); }
@ -524,13 +524,13 @@ public:
inline QDebug operator<<(QDebug debug, const Item& item) { inline QDebug operator<<(QDebug debug, const Item& item) {
debug << "[Item: _key:" << item.getKey() << ", bounds:" << item.getBound() << "]"; debug << "[Item: _key:" << item.getKey() << "]";
return debug; return debug;
} }
// Item shared interface supported by the payload // Item shared interface supported by the payload
template <class T> const ItemKey payloadGetKey(const std::shared_ptr<T>& payloadData) { return ItemKey(); } template <class T> const ItemKey payloadGetKey(const std::shared_ptr<T>& payloadData) { return ItemKey(); }
template <class T> const Item::Bound payloadGetBound(const std::shared_ptr<T>& payloadData) { return Item::Bound(); } template <class T> const Item::Bound payloadGetBound(const std::shared_ptr<T>& payloadData, RenderArgs* args) { return Item::Bound(); }
template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { } template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { }
// Shape type interface // Shape type interface
@ -561,7 +561,7 @@ public:
// Payload general interface // Payload general interface
virtual const ItemKey getKey() const override { return payloadGetKey<T>(_data); } virtual const ItemKey getKey() const override { return payloadGetKey<T>(_data); }
virtual const Item::Bound getBound() const override { return payloadGetBound<T>(_data); } virtual const Item::Bound getBound(RenderArgs* args) const override { return payloadGetBound<T>(_data, args); }
virtual void render(RenderArgs* args) override { payloadRender<T>(_data, args); } virtual void render(RenderArgs* args) override { payloadRender<T>(_data, args); }
@ -607,9 +607,9 @@ template <> const ItemKey payloadGetKey(const FooPointer& foo) {
foo->makeMyKey(); foo->makeMyKey();
return foo->_myownKey; 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 // 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 // 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 ItemKey getKey() = 0;
virtual ShapeKey getShapeKey() = 0; virtual ShapeKey getShapeKey() = 0;
virtual Item::Bound getBound() = 0; virtual Item::Bound getBound(RenderArgs* args) = 0;
virtual void render(RenderArgs* args) = 0; virtual void render(RenderArgs* args) = 0;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const = 0; virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) const = 0;
virtual bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const = 0; virtual bool passesZoneOcclusionTest(const std::unordered_set<QUuid>& containingZones) const = 0;
@ -635,7 +635,7 @@ public:
}; };
template <> const ItemKey payloadGetKey(const PayloadProxyInterface::Pointer& payload); 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 <> void payloadRender(const PayloadProxyInterface::Pointer& payload, RenderArgs* args);
template <> uint32_t metaFetchMetaSubItems(const PayloadProxyInterface::Pointer& payload, ItemIDs& subItems); template <> uint32_t metaFetchMetaSubItems(const PayloadProxyInterface::Pointer& payload, ItemIDs& subItems);
template <> const ShapeKey shapeGetShapeKey(const PayloadProxyInterface::Pointer& payload); template <> const ShapeKey shapeGetShapeKey(const PayloadProxyInterface::Pointer& payload);

View file

@ -305,7 +305,7 @@ void Scene::resetItems(const Transaction::Resets& transactions) {
// Update the item's container // Update the item's container
assert((oldKey.isSpatial() == newKey.isSpatial()) || oldKey._flags.none()); assert((oldKey.isSpatial() == newKey.isSpatial()) || oldKey._flags.none());
if (newKey.isSpatial()) { 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()); item.resetCell(newCell, newKey.isSmall());
} else { } else {
_masterNonspatialSet.insert(itemId); _masterNonspatialSet.insert(itemId);
@ -361,14 +361,14 @@ void Scene::updateItems(const Transaction::Updates& transactions) {
// Update the item's container // Update the item's container
if (oldKey.isSpatial() == newKey.isSpatial()) { if (oldKey.isSpatial() == newKey.isSpatial()) {
if (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()); item.resetCell(newCell, newKey.isSmall());
} }
} else { } else {
if (newKey.isSpatial()) { if (newKey.isSpatial()) {
_masterNonspatialSet.erase(updateID); _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()); item.resetCell(newCell, newKey.isSmall());
} else { } else {
_masterSpatialTree.removeItem(oldCell, oldKey, updateID); _masterSpatialTree.removeItem(oldCell, oldKey, updateID);

View file

@ -60,7 +60,7 @@ void render::depthSortItems(const RenderContextPointer& renderContext, bool fron
for (auto itemDetails : inItems) { for (auto itemDetails : inItems) {
auto item = scene->getItem(itemDetails.id); 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()); float distanceSquared = args->getViewFrustum().distanceToCameraSquared(bound.calcCenter());
itemBoundSorts.emplace_back(ItemBoundSort(distanceSquared, distanceSquared, distanceSquared, itemDetails.id, bound)); itemBoundSorts.emplace_back(ItemBoundSort(distanceSquared, distanceSquared, distanceSquared, itemDetails.id, bound));