maybe i have solved the passing of the status

This commit is contained in:
samcake 2015-07-02 17:31:29 -07:00
parent dcd61fd417
commit 0c55130548
5 changed files with 46 additions and 43 deletions

View file

@ -10,7 +10,7 @@
Script.include("cookies.js");
var panel = new Panel(10, 800);
var panel = new Panel(10, 100);
panel.newSlider("Num Feed Opaques", 0, 1000,
function(value) { },

View file

@ -170,12 +170,13 @@ namespace render {
void makeEntityItemStatusGetters(RenderableModelEntityItem* entity, render::Item::Status::Getters& statusGetters) {
statusGetters.push_back([entity] () -> render::Item::Status::Value {
quint64 delta = usecTimestampNow() - entity->getLastEditedFromRemote();
return render::Item::Status::Value((delta / (0.01f * USECS_PER_SECOND)), 1.0f);
float ndelta = (delta / (0.2f * USECS_PER_SECOND));
return render::Item::Status::Value(1.0f - ndelta, (ndelta > 1.0f ? 0.01f : 0.5f));
});
statusGetters.push_back([entity] () -> render::Item::Status::Value {
quint64 delta = usecTimestampNow() - entity->getLastBroadcast();
// return render::Item::Status::Value((delta / (0.02f * USECS_PER_SECOND)), 0.5f);
return render::Item::Status::Value(1.0f, 0.5f);
float ndelta = (delta / (0.4f * USECS_PER_SECOND));
return render::Item::Status::Value(1.0f - ndelta, (ndelta > 1.0f ? 0.01f : 0.5f));
});
}

View file

@ -53,7 +53,7 @@ void ItemBucketMap::allocateStandardOpaqueTranparentBuckets() {
(*this)[ItemFilter::Builder::transparentShape().withLayered()];
}
const Item::Status::Value Item::Status::Value::INVALID{ std::numeric_limits<short>::min(), std::numeric_limits<short>::min() };
const Item::Status::Value Item::Status::Value::INVALID = Item::Status::Value();
void Item::Status::getCompressedValues(glm::ivec4& values) {
for (int i = 0; i < values.length(); i++) {

View file

@ -202,15 +202,15 @@ public:
class Status {
public:
class Value {
short _x = 0;
short _y = 0;
Value(short x, short y) : _x(x), _y(y) {}
unsigned short _x = 0xFFFF;
unsigned short _y = 0xFFFF;
Value() {}
public:
const static Value INVALID; // Invlaid value meanss the status won't show
Value(float x, float y = 1.0f) { setX(x); setY(y); }
void setX(float x) { _x = std::numeric_limits<short>::max() * std::max(std::min(x, 1.0f), -1.0f); }
void setY(float y) { _y = std::numeric_limits<short>::max() * std::max(std::min(y, 1.0f), -1.0f); }
void setX(float x) { _x = (std::numeric_limits<unsigned short>::max() -1) * 0.5f * (1.0f + std::max(std::min(x, 1.0f), -1.0f)); }
void setY(float y) { _y = (std::numeric_limits<unsigned short>::max() - 1) * 0.5f * (1.0f + std::max(std::min(y, 1.0f), -1.0f)); }
int getRaw() const { return *((const int*) this); }
};

View file

@ -1,27 +1,27 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// drawItemStatus.slv
// vertex shader
//
// Created by Sam Gateau on 6/30/2015.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
varying vec4 varColor;
uniform vec3 inBoundPos;
uniform vec3 inBoundDim;
uniform ivec4 inStatus;
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// drawItemStatus.slv
// vertex shader
//
// Created by Sam Gateau on 6/30/2015.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
varying vec4 varColor;
uniform vec3 inBoundPos;
uniform vec3 inBoundDim;
uniform ivec4 inStatus;
vec3 paintRainbow(float nv) {
float v = nv * 5.f;
if ( v < 0.f )
@ -38,14 +38,16 @@ vec3 paintRainbow(float nv) {
return vec3((v-4.f), 0.f, 1.f );
else
return vec3(1.f, 1.f, 1.f);
}
vec2 unpackStatus(int v) {
// return unpackSnorm2x16(uint(packed));
return vec2(clamp(float((v & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
clamp(float(((v >> 16) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0));
}
}
vec2 unpackStatus(int v) {
// return unpackSnorm2x16(uint(packed));
// return vec2(clamp(float((v & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
// clamp(float(((v >> 16) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0));
return vec2(clamp(float(int((v >> 0) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0),
clamp(float(int((v >> 16) & 0xFFFF) - 32727) / 32727.0, -1.0, 1.0));
}
void main(void) {
const vec2 ICON_PIXEL_SIZE = vec2(10, 10);
const vec2 MARGIN_PIXEL_SIZE = vec2(2, 2);
@ -69,7 +71,7 @@ void main(void) {
int iconNum = gl_VertexID / NUM_VERTICES;
// if invalid, just kill
if (inStatus[iconNum] == 0x80008000) {
if (inStatus[iconNum] == 0xFFFFFFFF) {
gl_Position = anchorPoint;
varColor = vec4(1.0);
return;