mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
proper render bounds for models (need to pass RenderArgs to getBound everywhere)
This commit is contained in:
parent
1f71a23082
commit
92ea14a059
42 changed files with 108 additions and 102 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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>(avatar);
|
||||
if (avatarPtr) {
|
||||
return avatarPtr->getRenderBounds();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<QUuid>& containingZones) const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
~GizmoEntityRenderer();
|
||||
|
||||
protected:
|
||||
Item::Bound getBound() override;
|
||||
Item::Bound getBound(RenderArgs* args) override;
|
||||
ShapeKey getShapeKey() override;
|
||||
|
||||
bool isTransparent() const override;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
~GridEntityRenderer();
|
||||
|
||||
protected:
|
||||
Item::Bound getBound() override;
|
||||
Item::Bound getBound(RenderArgs* args) override;
|
||||
ShapeKey getShapeKey() override;
|
||||
|
||||
bool isTransparent() const override;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -376,7 +376,7 @@ void MaterialEntityRenderer::applyMaterial(const TypedEntityPointer& entity) {
|
|||
|
||||
if (material->isProcedural()) {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ ShapeKey ParticleEffectEntityRenderer::getShapeKey() {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Item::Bound ParticleEffectEntityRenderer::getBound() {
|
||||
Item::Bound ParticleEffectEntityRenderer::getBound(RenderArgs* args) {
|
||||
return _bound;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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<graphics::ProceduralMaterial>(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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<EntityTreeRenderer>();
|
||||
if (entityTreeRenderer) {
|
||||
auto renderable = entityTreeRenderer->renderableForEntityId(_entityID);
|
||||
if (renderable) {
|
||||
return std::static_pointer_cast<TextEntityRenderer>(renderable)->getBound();
|
||||
return std::static_pointer_cast<TextEntityRenderer>(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();
|
||||
}
|
||||
|
|
|
@ -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<QUuid>& 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<QUuid>& containingZones);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
#include <render/Args.h>
|
||||
#include <gpu/Shader.h>
|
||||
#include <gpu/Pipeline.h>
|
||||
#include <gpu/Batch.h>
|
||||
|
@ -113,9 +114,9 @@ public:
|
|||
void setDoesFade(bool doesFade) { _doesFade = doesFade; }
|
||||
|
||||
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; }
|
||||
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<AABox()> _boundOperator { nullptr };
|
||||
std::function<AABox(RenderArgs*)> _boundOperator { nullptr };
|
||||
|
||||
mutable std::mutex _mutex;
|
||||
};
|
||||
|
@ -232,9 +233,9 @@ public:
|
|||
|
||||
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(); }
|
||||
AABox getBound() { return _procedural.getBound(); }
|
||||
AABox getBound(RenderArgs* args) { return _procedural.getBound(args); }
|
||||
|
||||
private:
|
||||
QString _proceduralString;
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef render::Payload<AnimDebugDrawData> 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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<graphics::ProceduralMaterial>(_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();
|
||||
}
|
||||
|
|
|
@ -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<QUuid>& containingZones);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<QUuid>& 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 <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) { }
|
||||
|
||||
// Shape type interface
|
||||
|
@ -561,7 +561,7 @@ public:
|
|||
|
||||
// Payload general interface
|
||||
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); }
|
||||
|
||||
|
@ -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<QUuid>& 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue