quiet ubuntu warnings, particle properties show radians

This commit is contained in:
SamGondelman 2018-06-18 13:16:33 -07:00
parent 0d34689320
commit 12a5d8b550
6 changed files with 33 additions and 12 deletions

View file

@ -134,8 +134,8 @@ public:
DEFINE_PROPERTY_REF(PROP_SCRIPT, Script, script, QString, ENTITY_ITEM_DEFAULT_SCRIPT);
DEFINE_PROPERTY(PROP_SCRIPT_TIMESTAMP, ScriptTimestamp, scriptTimestamp, quint64, ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP);
DEFINE_PROPERTY_REF(PROP_COLLISION_SOUND_URL, CollisionSoundURL, collisionSoundURL, QString, ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL);
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, particle::DEFAULT_XCOLOR);
DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, particle::DEFAULT_XCOLOR_SPREAD);
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, ParticleEffectEntityItem::DEFAULT_XCOLOR);
DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, ParticleEffectEntityItem::DEFAULT_XCOLOR_SPREAD);
DEFINE_PROPERTY_REF(PROP_COLOR_START, ColorStart, colorStart, vec3, particle::DEFAULT_COLOR_UNINITIALIZED);
DEFINE_PROPERTY_REF(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3, particle::DEFAULT_COLOR_UNINITIALIZED);
DEFINE_PROPERTY(PROP_ALPHA, Alpha, alpha, float, particle::DEFAULT_ALPHA);

View file

@ -145,6 +145,8 @@ uint64_t Properties::emitIntervalUsecs() const {
return 0;
}
const xColor ParticleEffectEntityItem::DEFAULT_XCOLOR = xColor(static_cast<unsigned char>(DEFAULT_COLOR.r), static_cast<unsigned char>(DEFAULT_COLOR.g), static_cast<unsigned char>(DEFAULT_COLOR.b));
const xColor ParticleEffectEntityItem::DEFAULT_XCOLOR_SPREAD = xColor(static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.r), static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.g), static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.b));
EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
EntityItemPointer entity(new ParticleEffectEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); });
@ -342,7 +344,7 @@ void ParticleEffectEntityItem::computeAndUpdateDimensions() {
glm::vec3 velocity = particleProperties.emission.speed.target * direction;
glm::vec3 velocitySpread = particleProperties.emission.speed.spread * direction;
glm::vec3 maxVelocity = glm::abs(velocity) + velocitySpread;
glm::vec3 maxAccleration = particleProperties.emission.acceleration.target + particleProperties.emission.acceleration.spread;
glm::vec3 maxAccleration = glm::abs(particleProperties.emission.acceleration.target) + particleProperties.emission.acceleration.spread;
float maxRadius = particleProperties.radius.gradient.target;
if (!glm::isnan(particleProperties.radius.range.start)) {
maxRadius = glm::max(maxRadius, particleProperties.radius.range.start);

View file

@ -21,10 +21,8 @@ namespace particle {
static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work
static const float UNINITIALIZED = NAN;
static const vec3 DEFAULT_COLOR = { 255, 255, 255 };
static const xColor DEFAULT_XCOLOR = { static_cast<unsigned char>(DEFAULT_COLOR.r), static_cast<unsigned char>(DEFAULT_COLOR.g), static_cast<unsigned char>(DEFAULT_COLOR.b) };
static const vec3 DEFAULT_COLOR_UNINITIALIZED = { UNINITIALIZED, UNINITIALIZED, UNINITIALIZED };
static const vec3 DEFAULT_COLOR_SPREAD = { 0, 0, 0 };
static const xColor DEFAULT_XCOLOR_SPREAD = { static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.r), static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.g), static_cast<unsigned char>(DEFAULT_COLOR_SPREAD.b) };
static const float DEFAULT_ALPHA = 1.0f;
static const float DEFAULT_ALPHA_SPREAD = 0.0f;
static const float DEFAULT_ALPHA_START = UNINITIALIZED;
@ -320,6 +318,9 @@ public:
particle::Properties getParticleProperties() const;
static const xColor DEFAULT_XCOLOR;
static const xColor DEFAULT_XCOLOR_SPREAD;
protected:
particle::Properties _particleProperties;
bool _isEmitting { true };

View file

@ -127,13 +127,28 @@ QScriptValue vec3toScriptValue(QScriptEngine* engine, const glm::vec3 &vec3) {
obj.setProperty("x", vec3.x);
obj.setProperty("y", vec3.y);
obj.setProperty("z", vec3.z);
obj.setProperty("red", vec3.x);
obj.setProperty("green", vec3.y);
obj.setProperty("blue", vec3.z);
return obj;
}
void vec3FromScriptValue(const QScriptValue &object, glm::vec3 &vec3) {
vec3.x = object.property("x").toVariant().toFloat();
vec3.y = object.property("y").toVariant().toFloat();
vec3.z = object.property("z").toVariant().toFloat();
auto x = object.property("x").toVariant();
if (!x.isValid()) {
x = object.property("red").toVariant();
}
auto y = object.property("y").toVariant();
if (!y.isValid()) {
y = object.property("green").toVariant();
}
auto z = object.property("z").toVariant();
if (!z.isValid()) {
z = object.property("blue").toVariant();
}
vec3.x = x.toFloat();
vec3.y = y.toFloat();
vec3.z = z.toFloat();
}
QVariant vec3toVariant(const glm::vec3& vec3) {

View file

@ -92,6 +92,8 @@ inline QDebug& operator<<(QDebug& dbg, const rgbColor& c) {
}
struct xColor {
xColor() {}
xColor(unsigned char r, unsigned char g, unsigned char b) : red(r), green(g), blue(b) {}
unsigned char red;
unsigned char green;
unsigned char blue;

View file

@ -144,9 +144,10 @@ HifiEntityUI.prototype = {
vector.z = z.value;
}
json[key] = vector;
} else if (el.className.indexOf("radian") !== -1) {
json[key] = document.getElementById(key).value * RADIANS_PER_DEGREE;
} else if (el.className.length > 0) {
json[key] = document.getElementById(key)
.value;
json[key] = document.getElementById(key).value;
}
}
@ -543,12 +544,11 @@ HifiEntityUI.prototype = {
slider.setAttribute("step", 1);
inputField.oninput = function (event) {
// TODO: Remove this functionality? Alan finds it confusing
if (parseInt(event.target.value) > parseInt(slider.getAttribute("max")) && group.max !== 1) {
slider.setAttribute("max", event.target.value);
}
slider.value = event.target.value;
self.webBridgeSync(group.id, slider.value);
};
inputField.onchange = inputField.oninput;
@ -599,6 +599,7 @@ HifiEntityUI.prototype = {
slider.setAttribute("step", 0.01);
inputField.oninput = function (event) {
// TODO: Remove this functionality? Alan finds it confusing
if (parseFloat(event.target.value) > parseFloat(slider.getAttribute("max")) && group.max !== 1) {
slider.setAttribute("max", event.target.value);
}