mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 17:58:45 +02:00
implement support for updating the render items of models when they finish their fade
This commit is contained in:
parent
67cf105720
commit
83280aa3f2
5 changed files with 22 additions and 0 deletions
|
@ -371,6 +371,12 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RMEIrender");
|
PerformanceTimer perfTimer("RMEIrender");
|
||||||
assert(getType() == EntityTypes::Model);
|
assert(getType() == EntityTypes::Model);
|
||||||
|
|
||||||
|
// When the individual mesh parts of a model finish fading, they will mark their Model as needing updating
|
||||||
|
// we will watch for that and ask the model to update it's render items
|
||||||
|
if (_model && _model->getRenderItemsNeedUpdate()) {
|
||||||
|
_model->updateRenderItems();
|
||||||
|
}
|
||||||
|
|
||||||
if (hasModel()) {
|
if (hasModel()) {
|
||||||
// Prepare the current frame
|
// Prepare the current frame
|
||||||
{
|
{
|
||||||
|
|
|
@ -526,6 +526,13 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
|
||||||
return; // bail asap
|
return; // bail asap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When an individual mesh parts like this finishes its fade, we will mark the Model as
|
||||||
|
// having render items that need updating
|
||||||
|
if (_wasFading && !isStillFading()) {
|
||||||
|
_model->setRenderItemsNeedUpdate();
|
||||||
|
}
|
||||||
|
_wasFading = isStillFading();
|
||||||
|
|
||||||
gpu::Batch& batch = *(args->_batch);
|
gpu::Batch& batch = *(args->_batch);
|
||||||
|
|
||||||
if (!getShapeKey().isValid()) {
|
if (!getShapeKey().isValid()) {
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_MeshPartPayload_h
|
#ifndef hifi_MeshPartPayload_h
|
||||||
#define hifi_MeshPartPayload_h
|
#define hifi_MeshPartPayload_h
|
||||||
|
|
||||||
|
#include <Interpolate.h>
|
||||||
|
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
#include <render/Scene.h>
|
#include <render/Scene.h>
|
||||||
|
@ -85,6 +87,7 @@ public:
|
||||||
void startFade() { _fadeStartTime = usecTimestampNow(); }
|
void startFade() { _fadeStartTime = usecTimestampNow(); }
|
||||||
bool hasStartedFade() { return _hasStartedFade; }
|
bool hasStartedFade() { return _hasStartedFade; }
|
||||||
void setHasStartedFade(bool hasStartedFade) { _hasStartedFade = hasStartedFade; }
|
void setHasStartedFade(bool hasStartedFade) { _hasStartedFade = hasStartedFade; }
|
||||||
|
bool isStillFading() const { return Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f; }
|
||||||
|
|
||||||
// Render Item interface
|
// Render Item interface
|
||||||
render::ItemKey getKey() const override;
|
render::ItemKey getKey() const override;
|
||||||
|
@ -108,6 +111,7 @@ public:
|
||||||
private:
|
private:
|
||||||
quint64 _fadeStartTime { 0 };
|
quint64 _fadeStartTime { 0 };
|
||||||
bool _hasStartedFade { false };
|
bool _hasStartedFade { false };
|
||||||
|
mutable bool _wasFading { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
|
@ -174,6 +174,7 @@ void Model::setOffset(const glm::vec3& offset) {
|
||||||
void Model::updateRenderItems() {
|
void Model::updateRenderItems() {
|
||||||
|
|
||||||
_needsUpdateClusterMatrices = true;
|
_needsUpdateClusterMatrices = true;
|
||||||
|
_renderItemsNeedUpdate = false;
|
||||||
|
|
||||||
// queue up this work for later processing, at the end of update and just before rendering.
|
// queue up this work for later processing, at the end of update and just before rendering.
|
||||||
// the application will ensure only the last lambda is actually invoked.
|
// the application will ensure only the last lambda is actually invoked.
|
||||||
|
|
|
@ -103,6 +103,8 @@ public:
|
||||||
bool isVisible() const { return _isVisible; }
|
bool isVisible() const { return _isVisible; }
|
||||||
|
|
||||||
void updateRenderItems();
|
void updateRenderItems();
|
||||||
|
void setRenderItemsNeedUpdate() { _renderItemsNeedUpdate = true; }
|
||||||
|
bool getRenderItemsNeedUpdate() { return _renderItemsNeedUpdate; }
|
||||||
AABox getRenderableMeshBound() const;
|
AABox getRenderableMeshBound() const;
|
||||||
|
|
||||||
bool maybeStartBlender();
|
bool maybeStartBlender();
|
||||||
|
@ -396,6 +398,8 @@ protected:
|
||||||
|
|
||||||
bool _geometryRequestFailed { false };
|
bool _geometryRequestFailed { false };
|
||||||
|
|
||||||
|
bool _renderItemsNeedUpdate { false };
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
|
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue