mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 09:25:31 +02:00
Added fade state in render::Item
This commit is contained in:
parent
e178e36963
commit
69a7ec42fd
7 changed files with 50 additions and 37 deletions
|
@ -888,13 +888,6 @@ namespace render {
|
|||
payload->_owner->getRenderableInterface()->render(args);
|
||||
}
|
||||
}
|
||||
|
||||
template <> bool payloadMustFade(const PolyVoxPayload::Pointer& payload) {
|
||||
if (payload && payload->_owner) {
|
||||
return payload->_owner->mustFade();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace render {
|
|||
template <> const ItemKey payloadGetKey(const PolyVoxPayload::Pointer& payload);
|
||||
template <> const Item::Bound payloadGetBound(const PolyVoxPayload::Pointer& payload);
|
||||
template <> void payloadRender(const PolyVoxPayload::Pointer& payload, RenderArgs* args);
|
||||
template <> bool payloadMustFade(const PolyVoxPayload::Pointer& payload);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -455,7 +455,6 @@ public:
|
|||
|
||||
bool isFading() const { return _isFading; }
|
||||
float getFadingRatio() const { return (isFading() ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f); }
|
||||
bool mustFade() const { return _isFading; }
|
||||
|
||||
virtual void emitScriptEvent(const QVariant& message) {}
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ void FadeSwitchJob::distribute(const render::RenderContextPointer& renderContext
|
|||
for (const auto& itemBound : inputItems) {
|
||||
auto& item = scene->getItem(itemBound.id);
|
||||
|
||||
if (!item.mustFade() && &item!=editedItem) {
|
||||
// if (!item.mustFade() && &item!=editedItem) {
|
||||
// No need to fade
|
||||
normalOutput.edit<render::ItemBounds>().emplace_back(itemBound);
|
||||
}
|
||||
/* }
|
||||
else {
|
||||
fadeOutput.edit<render::ItemBounds>().emplace_back(itemBound);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,8 +320,12 @@ template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, Ren
|
|||
return payload->render(args);
|
||||
}
|
||||
|
||||
template <> bool payloadMustFade(const ModelMeshPartPayload::Pointer& payload) {
|
||||
return payload->mustFade();
|
||||
template <> const Item::FadeState* payloadGetFadeState(const ModelMeshPartPayload::Pointer& payload) {
|
||||
return &payload->getFadeState();
|
||||
}
|
||||
|
||||
template <> Item::FadeState* const payloadEditFadeState(ModelMeshPartPayload::Pointer& payload) {
|
||||
return &payload->editFadeState();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -489,9 +493,9 @@ ShapeKey ModelMeshPartPayload::getShapeKey() const {
|
|||
if (wireframe) {
|
||||
builder.withWireframe();
|
||||
}
|
||||
if (_fadeState != STATE_COMPLETE) {
|
||||
/* if (_fadeState != STATE_COMPLETE) {
|
||||
builder.withFade();
|
||||
}
|
||||
}*/
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -530,10 +534,6 @@ void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline:
|
|||
batch.setModelTransform(_transform);
|
||||
}
|
||||
|
||||
bool ModelMeshPartPayload::mustFade() const {
|
||||
return _fadeState != STATE_COMPLETE;
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::render(RenderArgs* args) {
|
||||
PerformanceTimer perfTimer("ModelMeshPartPayload::render");
|
||||
|
||||
|
@ -542,15 +542,16 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
return; // bail asap
|
||||
}
|
||||
|
||||
if (_fadeState == STATE_WAITING_TO_START) {
|
||||
if (_state == WAITING_TO_START) {
|
||||
if (model->isLoaded()) {
|
||||
// FIXME as far as I can tell this is the ONLY reason render-util depends on entities.
|
||||
/* // FIXME as far as I can tell this is the ONLY reason render-util depends on entities.
|
||||
if (EntityItem::getEntitiesShouldFadeFunction()()) {
|
||||
_fadeStartTime = usecTimestampNow();
|
||||
_fadeState = STATE_IN_PROGRESS;
|
||||
} else {
|
||||
_fadeState = STATE_COMPLETE;
|
||||
}
|
||||
}*/
|
||||
_state = STARTED;
|
||||
model->setRenderItemsNeedUpdate();
|
||||
} else {
|
||||
return;
|
||||
|
@ -581,12 +582,12 @@ void ModelMeshPartPayload::render(RenderArgs* args) {
|
|||
// apply material properties
|
||||
bindMaterial(batch, locations, args->_enableTexturing);
|
||||
|
||||
if (args->_enableFade) {
|
||||
/* if (args->_enableFade) {
|
||||
// Apply fade effect
|
||||
if (!FadeRenderJob::bindPerItem(batch, args, _transform.getTranslation(), _fadeStartTime)) {
|
||||
_fadeState = STATE_COMPLETE;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/* else {
|
||||
// TODO : very ugly way to update the fade state. Need to improve this with global fade manager.
|
||||
_fadeState = STATE_COMPLETE;
|
||||
|
|
|
@ -97,7 +97,9 @@ public:
|
|||
int getLayer() const;
|
||||
render::ShapeKey getShapeKey() const override; // shape interface
|
||||
void render(RenderArgs* args) override;
|
||||
bool mustFade() const;
|
||||
|
||||
const render::Item::FadeState& getFadeState() const { return _fadeState; }
|
||||
render::Item::FadeState& editFadeState() { return _fadeState; }
|
||||
|
||||
// ModelMeshPartPayload functions to perform render
|
||||
void bindMesh(gpu::Batch& batch) override;
|
||||
|
@ -120,14 +122,13 @@ public:
|
|||
private:
|
||||
|
||||
enum State : uint8_t {
|
||||
STATE_WAITING_TO_START = 0,
|
||||
STATE_IN_PROGRESS = 1,
|
||||
STATE_COMPLETE = 2,
|
||||
WAITING_TO_START = 0,
|
||||
STARTED = 1,
|
||||
};
|
||||
|
||||
mutable quint64 _fadeStartTime { 0 };
|
||||
mutable State _fadeState { STATE_WAITING_TO_START } ;
|
||||
mutable State _state { WAITING_TO_START } ;
|
||||
|
||||
render::Item::FadeState _fadeState;
|
||||
};
|
||||
|
||||
namespace render {
|
||||
|
@ -136,7 +137,8 @@ namespace render {
|
|||
template <> int payloadGetLayer(const ModelMeshPartPayload::Pointer& payload);
|
||||
template <> const ShapeKey shapeGetShapeKey(const ModelMeshPartPayload::Pointer& payload);
|
||||
template <> void payloadRender(const ModelMeshPartPayload::Pointer& payload, RenderArgs* args);
|
||||
template <> bool payloadMustFade(const ModelMeshPartPayload::Pointer& payload);
|
||||
template <> const Item::FadeState* payloadGetFadeState(const ModelMeshPartPayload::Pointer& payload);
|
||||
template <> Item::FadeState* const payloadEditFadeState(ModelMeshPartPayload::Pointer& payload);
|
||||
}
|
||||
|
||||
#endif // hifi_MeshPartPayload_h
|
||||
|
|
|
@ -310,19 +310,34 @@ public:
|
|||
};
|
||||
typedef std::shared_ptr<UpdateFunctorInterface> UpdateFunctorPointer;
|
||||
|
||||
// This holds the current state for all fade event types applied to this item
|
||||
class FadeState {
|
||||
public:
|
||||
|
||||
uint64_t startTime{ 0 };
|
||||
glm::vec3 noiseOffset{ 0.f, 0.f, 0.f };
|
||||
glm::vec3 baseOffset{ 0.f, 0.f, 0.f };
|
||||
glm::vec3 baseSize{ 1.f, 1.f, 1.f };
|
||||
float threshold{ 0.f };
|
||||
uint8_t eventType{ (uint8_t)-1 };
|
||||
|
||||
};
|
||||
|
||||
// Payload is whatever is in this Item and implement the Payload Interface
|
||||
class PayloadInterface {
|
||||
public:
|
||||
virtual const ItemKey getKey() const = 0;
|
||||
virtual const Bound getBound() const = 0;
|
||||
virtual int getLayer() const = 0;
|
||||
virtual bool mustFade() const = 0;
|
||||
virtual void render(RenderArgs* args) = 0;
|
||||
|
||||
virtual const ShapeKey getShapeKey() const = 0;
|
||||
|
||||
virtual uint32_t fetchMetaSubItems(ItemIDs& subItems) const = 0;
|
||||
|
||||
virtual const FadeState* getFadeState() const = 0;
|
||||
virtual FadeState* const editFadeState() = 0;
|
||||
|
||||
~PayloadInterface() {}
|
||||
|
||||
// Status interface is local to the base class
|
||||
|
@ -364,8 +379,6 @@ public:
|
|||
// Get the layer where the item belongs. 0 by default meaning NOT LAYERED
|
||||
int getLayer() const { return _payload->getLayer(); }
|
||||
|
||||
bool mustFade() const { return _payload->mustFade(); }
|
||||
|
||||
// Render call for the item
|
||||
void render(RenderArgs* args) const { _payload->render(args); }
|
||||
|
||||
|
@ -378,6 +391,9 @@ public:
|
|||
// Access the status
|
||||
const StatusPointer& getStatus() const { return _payload->getStatus(); }
|
||||
|
||||
const FadeState* getFadeState() const { return _payload->getFadeState(); }
|
||||
FadeState* const editFadeState() { return _payload->editFadeState(); }
|
||||
|
||||
protected:
|
||||
PayloadPointer _payload;
|
||||
ItemKey _key;
|
||||
|
@ -411,7 +427,8 @@ template <class T> const ItemKey payloadGetKey(const std::shared_ptr<T>& payload
|
|||
template <class T> const Item::Bound payloadGetBound(const std::shared_ptr<T>& payloadData) { return Item::Bound(); }
|
||||
template <class T> int payloadGetLayer(const std::shared_ptr<T>& payloadData) { return 0; }
|
||||
template <class T> void payloadRender(const std::shared_ptr<T>& payloadData, RenderArgs* args) { }
|
||||
template <class T> bool payloadMustFade(const std::shared_ptr<T>& payloadData) { return false; }
|
||||
template <class T> const Item::FadeState* payloadGetFadeState(const std::shared_ptr<T>& payloadData) { return nullptr; }
|
||||
template <class T> Item::FadeState* const payloadEditFadeState(std::shared_ptr<T>& payloadData) { return nullptr; }
|
||||
|
||||
// Shape type interface
|
||||
// This allows shapes to characterize their pipeline via a ShapeKey, to be picked with a subclass of Shape.
|
||||
|
@ -438,7 +455,9 @@ public:
|
|||
virtual const ItemKey getKey() const override { return payloadGetKey<T>(_data); }
|
||||
virtual const Item::Bound getBound() const override { return payloadGetBound<T>(_data); }
|
||||
virtual int getLayer() const override { return payloadGetLayer<T>(_data); }
|
||||
virtual bool mustFade() const override { return payloadMustFade<T>(_data); }
|
||||
|
||||
virtual const Item::FadeState* getFadeState() const { return payloadGetFadeState<T>(_data); }
|
||||
virtual Item::FadeState* const editFadeState() { return payloadEditFadeState<T>(_data); }
|
||||
|
||||
virtual void render(RenderArgs* args) override { payloadRender<T>(_data, args); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue