mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 06:24:41 +02:00
use makeEntityItemStatusGetters from more entity types
This commit is contained in:
parent
7b4dd9a908
commit
4cf84a4e5b
2 changed files with 36 additions and 36 deletions
|
@ -40,3 +40,39 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeEntityItemStatusGetters(EntityItem* entity, render::Item::Status::Getters& statusGetters) {
|
||||||
|
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||||
|
quint64 delta = usecTimestampNow() - entity->getLastEditedFromRemote();
|
||||||
|
const float WAIT_THRESHOLD_INV = 1.0f / (0.2f * USECS_PER_SECOND);
|
||||||
|
float normalizedDelta = delta * WAIT_THRESHOLD_INV;
|
||||||
|
// Status icon will scale from 1.0f down to 0.0f after WAIT_THRESHOLD
|
||||||
|
// Color is red if last update is after WAIT_THRESHOLD, green otherwise (120 deg is green)
|
||||||
|
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
||||||
|
render::Item::Status::Value::GREEN :
|
||||||
|
render::Item::Status::Value::RED),
|
||||||
|
(unsigned char) RenderItemStatusIcon::PACKET_RECEIVED);
|
||||||
|
});
|
||||||
|
|
||||||
|
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||||
|
quint64 delta = usecTimestampNow() - entity->getLastBroadcast();
|
||||||
|
const float WAIT_THRESHOLD_INV = 1.0f / (0.4f * USECS_PER_SECOND);
|
||||||
|
float normalizedDelta = delta * WAIT_THRESHOLD_INV;
|
||||||
|
// Status icon will scale from 1.0f down to 0.0f after WAIT_THRESHOLD
|
||||||
|
// Color is Magenta if last update is after WAIT_THRESHOLD, cyan otherwise (180 deg is green)
|
||||||
|
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
||||||
|
render::Item::Status::Value::MAGENTA :
|
||||||
|
render::Item::Status::Value::CYAN),
|
||||||
|
(unsigned char)RenderItemStatusIcon::PACKET_SENT);
|
||||||
|
});
|
||||||
|
|
||||||
|
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||||
|
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
||||||
|
if (motionState && motionState->isActive()) {
|
||||||
|
return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE,
|
||||||
|
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
||||||
|
}
|
||||||
|
return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE,
|
||||||
|
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -181,42 +181,6 @@ namespace render {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeEntityItemStatusGetters(EntityItem* entity, render::Item::Status::Getters& statusGetters) {
|
|
||||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
|
||||||
quint64 delta = usecTimestampNow() - entity->getLastEditedFromRemote();
|
|
||||||
const float WAIT_THRESHOLD_INV = 1.0f / (0.2f * USECS_PER_SECOND);
|
|
||||||
float normalizedDelta = delta * WAIT_THRESHOLD_INV;
|
|
||||||
// Status icon will scale from 1.0f down to 0.0f after WAIT_THRESHOLD
|
|
||||||
// Color is red if last update is after WAIT_THRESHOLD, green otherwise (120 deg is green)
|
|
||||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
|
||||||
render::Item::Status::Value::GREEN :
|
|
||||||
render::Item::Status::Value::RED),
|
|
||||||
(unsigned char) RenderItemStatusIcon::PACKET_RECEIVED);
|
|
||||||
});
|
|
||||||
|
|
||||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
|
||||||
quint64 delta = usecTimestampNow() - entity->getLastBroadcast();
|
|
||||||
const float WAIT_THRESHOLD_INV = 1.0f / (0.4f * USECS_PER_SECOND);
|
|
||||||
float normalizedDelta = delta * WAIT_THRESHOLD_INV;
|
|
||||||
// Status icon will scale from 1.0f down to 0.0f after WAIT_THRESHOLD
|
|
||||||
// Color is Magenta if last update is after WAIT_THRESHOLD, cyan otherwise (180 deg is green)
|
|
||||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ?
|
|
||||||
render::Item::Status::Value::MAGENTA :
|
|
||||||
render::Item::Status::Value::CYAN),
|
|
||||||
(unsigned char)RenderItemStatusIcon::PACKET_SENT);
|
|
||||||
});
|
|
||||||
|
|
||||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
|
||||||
ObjectMotionState* motionState = static_cast<ObjectMotionState*>(entity->getPhysicsInfo());
|
|
||||||
if (motionState && motionState->isActive()) {
|
|
||||||
return render::Item::Status::Value(1.0f, render::Item::Status::Value::BLUE,
|
|
||||||
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
|
||||||
}
|
|
||||||
return render::Item::Status::Value(0.0f, render::Item::Status::Value::BLUE,
|
|
||||||
(unsigned char)RenderItemStatusIcon::ACTIVE_IN_BULLET);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||||
render::PendingChanges& pendingChanges) {
|
render::PendingChanges& pendingChanges) {
|
||||||
_myMetaItem = scene->allocateID();
|
_myMetaItem = scene->allocateID();
|
||||||
|
|
Loading…
Reference in a new issue