mirror of
https://github.com/overte-org/overte.git
synced 2025-08-12 16:14:34 +02:00
For a fistfull of magic numbers
This commit is contained in:
parent
95f5b14d45
commit
4d48b98364
3 changed files with 18 additions and 3 deletions
|
@ -174,7 +174,7 @@ void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item
|
|||
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 ? 0.0f : 120.0f));
|
||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ? render::Item::Status::Value::GREEN : render::Item::Status::Value::RED));
|
||||
});
|
||||
statusGetters.push_back([entity] () -> render::Item::Status::Value {
|
||||
quint64 delta = usecTimestampNow() - entity->getLastBroadcast();
|
||||
|
@ -182,7 +182,7 @@ void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item
|
|||
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 ? 300.0f : 180.0f));
|
||||
return render::Item::Status::Value(1.0f - normalizedDelta, (normalizedDelta > 1.0f ? render::Item::Status::Value::MAGENTA : render::Item::Status::Value::CYAN));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,12 @@ void ItemBucketMap::allocateStandardOpaqueTranparentBuckets() {
|
|||
|
||||
const Item::Status::Value Item::Status::Value::INVALID = Item::Status::Value();
|
||||
|
||||
const float Item::Status::Value::RED = 0.0f;
|
||||
const float Item::Status::Value::YELLOW = 60.0f;
|
||||
const float Item::Status::Value::GREEN = 120.0f;
|
||||
const float Item::Status::Value::CYAN = 180.0f;
|
||||
const float Item::Status::Value::BLUE = 240.0f;
|
||||
const float Item::Status::Value::MAGENTA = 300.0f;
|
||||
|
||||
void Item::Status::Value::setScale(float scale) {
|
||||
_scale = (std::numeric_limits<unsigned short>::max() -1) * 0.5f * (1.0f + std::max(std::min(scale, 1.0f), 0.0f));
|
||||
|
@ -64,7 +70,8 @@ void Item::Status::Value::setScale(float scale) {
|
|||
|
||||
void Item::Status::Value::setColor(float hue) {
|
||||
// Convert the HUe from range [0, 360] to signed normalized value
|
||||
_color = (std::numeric_limits<unsigned short>::max() - 1) * 0.5f * (1.0f + std::max(std::min(hue, 360.0f), 0.0f));
|
||||
const float HUE_MAX = 360.0f;
|
||||
_color = (std::numeric_limits<unsigned short>::max() - 1) * 0.5f * (1.0f + std::max(std::min(hue, HUE_MAX), 0.0f) / HUE_MAX);
|
||||
}
|
||||
|
||||
void Item::Status::getPackedValues(glm::ivec4& values) const {
|
||||
|
|
|
@ -218,6 +218,14 @@ public:
|
|||
// the color hue in the range [0, 360] representing the color wheel hue
|
||||
void setColor(float hue);
|
||||
|
||||
// Standard color Hue
|
||||
static const float RED; // 0.0f;
|
||||
static const float YELLOW; // 60.0f;
|
||||
static const float GREEN; // 120.0f;
|
||||
static const float CYAN; // 180.0f;
|
||||
static const float BLUE; // 240.0f;
|
||||
static const float MAGENTA; // 300.0f;
|
||||
|
||||
// Retreive the Value data tightely packed as an int
|
||||
int getPackedData() const { return *((const int*) this); }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue