Merge pull request #8374 from ZappoMan/fadeFinalizeModels

implement support for updating the render items of models when they finish their fade
This commit is contained in:
Sam Gondelman 2016-08-05 10:34:48 -07:00 committed by GitHub
commit ffa540c0e5
5 changed files with 22 additions and 0 deletions

View file

@ -371,6 +371,12 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
PerformanceTimer perfTimer("RMEIrender");
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()) {
// Prepare the current frame
{

View file

@ -526,6 +526,13 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
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);
if (!getShapeKey().isValid()) {

View file

@ -12,6 +12,8 @@
#ifndef hifi_MeshPartPayload_h
#define hifi_MeshPartPayload_h
#include <Interpolate.h>
#include <gpu/Batch.h>
#include <render/Scene.h>
@ -85,6 +87,7 @@ public:
void startFade() { _fadeStartTime = usecTimestampNow(); }
bool hasStartedFade() { return _hasStartedFade; }
void setHasStartedFade(bool hasStartedFade) { _hasStartedFade = hasStartedFade; }
bool isStillFading() const { return Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f; }
// Render Item interface
render::ItemKey getKey() const override;
@ -108,6 +111,7 @@ public:
private:
quint64 _fadeStartTime { 0 };
bool _hasStartedFade { false };
mutable bool _wasFading { false };
};
namespace render {

View file

@ -174,6 +174,7 @@ void Model::setOffset(const glm::vec3& offset) {
void Model::updateRenderItems() {
_needsUpdateClusterMatrices = true;
_renderItemsNeedUpdate = false;
// 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.

View file

@ -103,6 +103,8 @@ public:
bool isVisible() const { return _isVisible; }
void updateRenderItems();
void setRenderItemsNeedUpdate() { _renderItemsNeedUpdate = true; }
bool getRenderItemsNeedUpdate() { return _renderItemsNeedUpdate; }
AABox getRenderableMeshBound() const;
bool maybeStartBlender();
@ -396,6 +398,8 @@ protected:
bool _geometryRequestFailed { false };
bool _renderItemsNeedUpdate { false };
private slots:
void handleGeometryResourceFailure() { _geometryRequestFailed = true; }
};