Merge pull request #8429 from SamGondelman/loadingFade2

Don't do fade effect once physics kick in
This commit is contained in:
Brad Hefta-Gaub 2016-08-18 12:46:24 -07:00 committed by GitHub
commit 1cec7b2db0
5 changed files with 26 additions and 10 deletions

View file

@ -1237,6 +1237,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
_defaultSkybox->setCubemap(_defaultSkyboxTexture); _defaultSkybox->setCubemap(_defaultSkyboxTexture);
_defaultSkybox->setColor({ 1.0, 1.0, 1.0 }); _defaultSkybox->setColor({ 1.0, 1.0, 1.0 });
EntityItem::setEntitiesShouldFadeFunction([this]() {
SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer);
return entityServerNode && !isPhysicsEnabled();
});
// After all of the constructor is completed, then set firstRun to false. // After all of the constructor is completed, then set firstRun to false.
Setting::Handle<bool> firstRun{ Settings::firstRun, true }; Setting::Handle<bool> firstRun{ Settings::firstRun, true };
firstRun.set(false); firstRun.set(false);

View file

@ -35,6 +35,7 @@
int EntityItem::_maxActionsDataSize = 800; int EntityItem::_maxActionsDataSize = 800;
quint64 EntityItem::_rememberDeletedActionTime = 20 * USECS_PER_SECOND; quint64 EntityItem::_rememberDeletedActionTime = 20 * USECS_PER_SECOND;
std::function<bool()> EntityItem::_entitiesShouldFadeFunction = [](){ return true; };
EntityItem::EntityItem(const EntityItemID& entityItemID) : EntityItem::EntityItem(const EntityItemID& entityItemID) :
SpatiallyNestable(NestableType::Entity, entityItemID), SpatiallyNestable(NestableType::Entity, entityItemID),

View file

@ -432,6 +432,8 @@ public:
QUuid getOwningAvatarID() const { return _owningAvatarID; } QUuid getOwningAvatarID() const { return _owningAvatarID; }
void setOwningAvatarID(const QUuid& owningAvatarID) { _owningAvatarID = owningAvatarID; } void setOwningAvatarID(const QUuid& owningAvatarID) { _owningAvatarID = owningAvatarID; }
static void setEntitiesShouldFadeFunction(std::function<bool()> func) { _entitiesShouldFadeFunction = func; }
static std::function<bool()> getEntitiesShouldFadeFunction() { return _entitiesShouldFadeFunction; }
virtual bool isTransparent() { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; } virtual bool isTransparent() { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
protected: protected:
@ -564,7 +566,8 @@ protected:
quint64 _lastUpdatedAccelerationTimestamp { 0 }; quint64 _lastUpdatedAccelerationTimestamp { 0 };
quint64 _fadeStartTime { usecTimestampNow() }; quint64 _fadeStartTime { usecTimestampNow() };
bool _isFading { true }; static std::function<bool()> _entitiesShouldFadeFunction;
bool _isFading { _entitiesShouldFadeFunction() };
}; };
#endif // hifi_EntityItem_h #endif // hifi_EntityItem_h

View file

@ -15,6 +15,7 @@
#include "DeferredLightingEffect.h" #include "DeferredLightingEffect.h"
#include "Model.h" #include "Model.h"
#include "EntityItem.h"
using namespace render; using namespace render;
@ -517,10 +518,16 @@ void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline:
} }
void ModelMeshPartPayload::startFade() { void ModelMeshPartPayload::startFade() {
_fadeStartTime = usecTimestampNow(); bool shouldFade = EntityItem::getEntitiesShouldFadeFunction()();
_hasStartedFade = true; if (shouldFade) {
_prevHasStartedFade = false; _fadeStartTime = usecTimestampNow();
_hasFinishedFade = false; _hasStartedFade = true;
_hasFinishedFade = false;
} else {
_isFading = true;
_hasStartedFade = true;
_hasFinishedFade = true;
}
} }
void ModelMeshPartPayload::render(RenderArgs* args) const { void ModelMeshPartPayload::render(RenderArgs* args) const {
@ -533,10 +540,11 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
// When an individual mesh parts like this finishes its fade, we will mark the Model as // When an individual mesh parts like this finishes its fade, we will mark the Model as
// having render items that need updating // having render items that need updating
bool nextIsFading = _isFading ? isStillFading() : false; bool nextIsFading = _isFading ? isStillFading() : false;
if (_isFading != nextIsFading || _prevHasStartedFade != _hasStartedFade) { bool startFading = !_isFading && !_hasFinishedFade && _hasStartedFade;
_isFading = nextIsFading || _prevHasStartedFade != _hasStartedFade; bool endFading = _isFading && !nextIsFading;
_hasFinishedFade = _prevHasStartedFade == _hasStartedFade && !_isFading; if (startFading || endFading) {
_prevHasStartedFade = _hasStartedFade; _isFading = startFading;
_hasFinishedFade = endFading;
_model->setRenderItemsNeedUpdate(); _model->setRenderItemsNeedUpdate();
} }

View file

@ -110,7 +110,6 @@ public:
private: private:
quint64 _fadeStartTime { 0 }; quint64 _fadeStartTime { 0 };
bool _hasStartedFade { false }; bool _hasStartedFade { false };
mutable bool _prevHasStartedFade{ false };
mutable bool _hasFinishedFade { false }; mutable bool _hasFinishedFade { false };
mutable bool _isFading { false }; mutable bool _isFading { false };
}; };