From 9788aa307e593ff36514fa68bab740bf290346e9 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 10 Oct 2018 12:38:07 -0700 Subject: [PATCH] remove width/height/depth --- libraries/shared/src/RegisteredMetaTypes.cpp | 67 +++----------------- libraries/shared/src/RegisteredMetaTypes.h | 64 +++++++++---------- 2 files changed, 39 insertions(+), 92 deletions(-) diff --git a/libraries/shared/src/RegisteredMetaTypes.cpp b/libraries/shared/src/RegisteredMetaTypes.cpp index 56ca5c8d39..507eccdf37 100644 --- a/libraries/shared/src/RegisteredMetaTypes.cpp +++ b/libraries/shared/src/RegisteredMetaTypes.cpp @@ -74,9 +74,7 @@ QScriptValue vec2ToScriptValue(QScriptEngine* engine, const glm::vec2& vec2) { "0: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," "1: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," "u: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," - "v: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," - "width: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," - "height: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }" + "v: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }" "})" ); } @@ -101,17 +99,11 @@ void vec2FromScriptValue(const QScriptValue& object, glm::vec2& vec2) { if (!x.isValid()) { x = object.property("u"); } - if (!x.isValid()) { - x = object.property("width"); - } QScriptValue y = object.property("y"); if (!y.isValid()) { y = object.property("v"); } - if (!y.isValid()) { - y = object.property("height"); - } vec2.x = x.toVariant().toFloat(); vec2.y = y.toVariant().toFloat(); @@ -146,16 +138,12 @@ glm::vec2 vec2FromVariant(const QVariant &object, bool& isValid) { if (!x.isValid()) { x = map["u"]; } - if (!x.isValid()) { - x = map["width"]; - } + auto y = map["y"]; if (!y.isValid()) { y = map["v"]; } - if (!y.isValid()) { - y = map["height"]; - } + if (x.isValid() && y.isValid()) { result.x = x.toFloat(&isValid); if (isValid) { @@ -185,10 +173,7 @@ QScriptValue vec3ToScriptValue(QScriptEngine* engine, const glm::vec3& vec3) { "b: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }," "red: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," "green: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," - "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }," - "width: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," - "height: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," - "depth: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" + "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" "})" ); } @@ -214,10 +199,7 @@ QScriptValue vec3ColorToScriptValue(QScriptEngine* engine, const glm::vec3& vec3 "b: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }," "x: { set: function(nv) { return this.red = nv; }, get: function() { return this.red; } }," "y: { set: function(nv) { return this.green = nv; }, get: function() { return this.green; } }," - "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }," - "width: { set: function(nv) { return this.red = nv; }, get: function() { return this.red; } }," - "height: { set: function(nv) { return this.green = nv; }, get: function() { return this.green; } }," - "depth: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" + "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" "})" ); } @@ -254,9 +236,6 @@ void vec3FromScriptValue(const QScriptValue& object, glm::vec3& vec3) { if (!x.isValid()) { x = object.property("red"); } - if (!x.isValid()) { - x = object.property("width"); - } QScriptValue y = object.property("y"); if (!y.isValid()) { @@ -265,9 +244,6 @@ void vec3FromScriptValue(const QScriptValue& object, glm::vec3& vec3) { if (!y.isValid()) { y = object.property("green"); } - if (!y.isValid()) { - y = object.property("height"); - } QScriptValue z = object.property("z"); if (!z.isValid()) { @@ -276,9 +252,6 @@ void vec3FromScriptValue(const QScriptValue& object, glm::vec3& vec3) { if (!z.isValid()) { z = object.property("blue"); } - if (!z.isValid()) { - z = object.property("depth"); - } vec3.x = x.toVariant().toFloat(); vec3.y = y.toVariant().toFloat(); @@ -300,10 +273,7 @@ QScriptValue u8vec3ToScriptValue(QScriptEngine* engine, const glm::u8vec3& vec3) "b: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }," "red: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," "green: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," - "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }," - "width: { set: function(nv) { return this.x = nv; }, get: function() { return this.x; } }," - "height: { set: function(nv) { return this.y = nv; }, get: function() { return this.y; } }," - "depth: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" + "blue: { set: function(nv) { return this.z = nv; }, get: function() { return this.z; } }" "})" ); } @@ -329,10 +299,7 @@ QScriptValue u8vec3ColorToScriptValue(QScriptEngine* engine, const glm::u8vec3& "b: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }," "x: { set: function(nv) { return this.red = nv; }, get: function() { return this.red; } }," "y: { set: function(nv) { return this.green = nv; }, get: function() { return this.green; } }," - "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }," - "width: { set: function(nv) { return this.red = nv; }, get: function() { return this.red; } }," - "height: { set: function(nv) { return this.green = nv; }, get: function() { return this.green; } }," - "depth: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" + "z: { set: function(nv) { return this.blue = nv; }, get: function() { return this.blue; } }" "})" ); } @@ -369,9 +336,6 @@ void u8vec3FromScriptValue(const QScriptValue& object, glm::u8vec3& vec3) { if (!x.isValid()) { x = object.property("red"); } - if (!x.isValid()) { - x = object.property("width"); - } QScriptValue y = object.property("y"); if (!y.isValid()) { @@ -380,9 +344,6 @@ void u8vec3FromScriptValue(const QScriptValue& object, glm::u8vec3& vec3) { if (!y.isValid()) { y = object.property("green"); } - if (!y.isValid()) { - y = object.property("height"); - } QScriptValue z = object.property("z"); if (!z.isValid()) { @@ -391,9 +352,6 @@ void u8vec3FromScriptValue(const QScriptValue& object, glm::u8vec3& vec3) { if (!z.isValid()) { z = object.property("blue"); } - if (!z.isValid()) { - z = object.property("depth"); - } vec3.x = x.toVariant().toUInt(); vec3.y = y.toVariant().toUInt(); @@ -452,9 +410,7 @@ glm::vec3 vec3FromVariant(const QVariant& object, bool& valid) { if (!x.isValid()) { x = map["red"]; } - if (!x.isValid()) { - x = map["width"]; - } + auto y = map["y"]; if (!y.isValid()) { y = map["g"]; @@ -462,9 +418,7 @@ glm::vec3 vec3FromVariant(const QVariant& object, bool& valid) { if (!y.isValid()) { y = map["green"]; } - if (!y.isValid()) { - y = map["height"]; - } + auto z = map["z"]; if (!z.isValid()) { z = map["b"]; @@ -472,9 +426,6 @@ glm::vec3 vec3FromVariant(const QVariant& object, bool& valid) { if (!z.isValid()) { z = map["blue"]; } - if (!z.isValid()) { - z = map["depth"]; - } if (x.canConvert() && y.canConvert() && z.canConvert()) { v.x = x.toFloat(); diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index da88c524f3..095ecdf18d 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -50,16 +50,15 @@ void mat4FromScriptValue(const QScriptValue& object, glm::mat4& mat4); * A 2-dimensional vector. * * @typedef {object} Vec2 -* @property {number} x - X-coordinate of the vector. Synonyms: u and width. -* @property {number} y - Y-coordinate of the vector. Synonyms: v and height. +* @property {number} x - X-coordinate of the vector. Synonyms: u. +* @property {number} y - Y-coordinate of the vector. Synonyms: v. * @example Vec2s can be set in multiple ways and modified with their aliases, but still stringify in the same way * Entities.editEntity(, { materialMappingPos: { x: 0.1, y: 0.2 }}); // { x: 0.1, y: 0.2 } * Entities.editEntity(, { materialMappingPos: { u: 0.3, v: 0.4 }}); // { x: 0.3, y: 0.4 } -* Entities.editEntity(, { materialMappingPos: { width: 0.5, height: 0.6 }}); // { x: 0.5, y: 0.6 } -* Entities.editEntity(, { materialMappingPos: [0.7, 0.8]}); // { x: 0.7, y: 0.8 } -* Entities.editEntity(, { materialMappingPos: 0.9}); // { x: 0.9, y: 0.9 } -* var color = Entities.getEntityProperties().materialMappingPos; // { x: 0.9, y: 0.9 } -* color.v = 1.0; // { x: 0.9, y: 1.0 } +* Entities.editEntity(, { materialMappingPos: [0.5, 0.6] }); // { x: 0.5, y: 0.6 } +* Entities.editEntity(, { materialMappingPos: 0.7 }); // { x: 0.7, y: 0.7 } +* var color = Entities.getEntityProperties().materialMappingPos; // { x: 0.7, y: 0.7 } +* color.v = 0.8; // { x: 0.7, y: 0.8 } */ QScriptValue vec2ToScriptValue(QScriptEngine* engine, const glm::vec2& vec2); void vec2FromScriptValue(const QScriptValue& object, glm::vec2& vec2); @@ -72,19 +71,18 @@ glm::vec2 vec2FromVariant(const QVariant& object); * A 3-dimensional vector. See also the {@link Vec3(0)|Vec3} object. * * @typedef {object} Vec3 -* @property {number} x - X-coordinate of the vector. Synonyms: r, red, and width. -* @property {number} y - Y-coordinate of the vector. Synonyms: g, green, and height. -* @property {number} z - Z-coordinate of the vector. Synonyms: b, blue, and depth. +* @property {number} x - X-coordinate of the vector. Synonyms: r, red. +* @property {number} y - Y-coordinate of the vector. Synonyms: g, green. +* @property {number} z - Z-coordinate of the vector. Synonyms: b, blue. * @example Vec3s can be set in multiple ways and modified with their aliases, but still stringify in the same way * Entities.editEntity(, { position: { x: 1, y: 2, z: 3 }}); // { x: 1, y: 2, z: 3 } * Entities.editEntity(, { position: { r: 4, g: 5, b: 6 }}); // { x: 4, y: 5, z: 6 } * Entities.editEntity(, { position: { red: 7, green: 8, blue: 9 }}); // { x: 7, y: 8, z: 9 } -* Entities.editEntity(, { position: { width: 10, height: 11, depth: 12 }}); // { x: 10, y: 11, z: 12 } -* Entities.editEntity(, { position: [13, 14, 15]}); // { x: 13, y: 14, z: 15 } -* Entities.editEntity(, { position: 16}); // { x: 16, y: 16, z: 16 } -* var position = Entities.getEntityProperties().position; // { x: 16, y: 16, z: 16 } -* position.g = 17; // { x: 16, y: 17, z: 16 } -* position.blue = 18; // { x: 16, y: 17, z: 18 } +* Entities.editEntity(, { position: [10, 11, 12] }); // { x: 10, y: 11, z: 12 } +* Entities.editEntity(, { position: 13 }); // { x: 13, y: 13, z: 13 } +* var position = Entities.getEntityProperties().position; // { x: 13, y: 13, z: 13 } +* position.g = 14; // { x: 13, y: 14, z: 13 } +* position.blue = 15; // { x: 13, y: 14, z: 15 } * Entities.editEntity(, { position: "red"}); // { x: 255, y: 0, z: 0 } * Entities.editEntity(, { position: "#00FF00"}); // { x: 0, y: 255, z: 0 } */ @@ -96,19 +94,18 @@ void vec3FromScriptValue(const QScriptValue& object, glm::vec3& vec3); * A color vector. See also the {@link Vec3(0)|Vec3} object. * * @typedef {object} Color -* @property {number} red - Red component value. Integer in the range 0 - 255. Synonyms: r, x, and width. -* @property {number} green - Green component value. Integer in the range 0 - 255. Synonyms: g, y, and height. -* @property {number} blue - Blue component value. Integer in the range 0 - 255. Synonyms: b, z, and depth. +* @property {number} red - Red component value. Integer in the range 0 - 255. Synonyms: r, x. +* @property {number} green - Green component value. Integer in the range 0 - 255. Synonyms: g, y. +* @property {number} blue - Blue component value. Integer in the range 0 - 255. Synonyms: b, z. * @example Colors can be set in multiple ways and modified with their aliases, but still stringify in the same way * Entities.editEntity(, { color: { x: 1, y: 2, z: 3 }}); // { red: 1, green: 2, blue: 3 } * Entities.editEntity(, { color: { r: 4, g: 5, b: 6 }}); // { red: 4, green: 5, blue: 6 } * Entities.editEntity(, { color: { red: 7, green: 8, blue: 9 }}); // { red: 7, green: 8, blue: 9 } -* Entities.editEntity(, { color: { width: 10, height: 11, depth: 12 }}); // { red: 10, green: 11, blue: 12 } -* Entities.editEntity(, { color: [13, 14, 15]}); // { red: 13, green: 14, blue: 15 } -* Entities.editEntity(, { color: 16}); // { red: 16, green: 16, blue: 16 } -* var color = Entities.getEntityProperties().color; // { red: 16, green: 16, blue: 16 } -* color.g = 17; // { red: 16, green: 17, blue: 16 } -* color.blue = 18; // { red: 16, green: 17, blue: 18 } +* Entities.editEntity(, { color: [10, 11, 12] }); // { red: 10, green: 11, blue: 12 } +* Entities.editEntity(, { color: 13 }); // { red: 13, green: 13, blue: 13 } +* var color = Entities.getEntityProperties().color; // { red: 13, green: 13, blue: 13 } +* color.g = 14; // { red: 13, green: 14, blue: 13 } +* color.blue = 15; // { red: 13, green: 14, blue: 15 } * Entities.editEntity(, { color: "red"}); // { red: 255, green: 0, blue: 0 } * Entities.editEntity(, { color: "#00FF00"}); // { red: 0, green: 255, blue: 0 } */ @@ -116,19 +113,18 @@ void vec3FromScriptValue(const QScriptValue& object, glm::vec3& vec3); * A color vector. See also the {@link Vec3(0)|Vec3} object. * * @typedef {object} ColorFloat -* @property {number} red - Red component value. Real in the range 0 - 255. Synonyms: r, x, and width. -* @property {number} green - Green component value. Real in the range 0 - 255. Synonyms: g, y, and height. -* @property {number} blue - Blue component value. Real in the range 0 - 255. Synonyms: b, z, and depth. +* @property {number} red - Red component value. Real in the range 0 - 255. Synonyms: r, x. +* @property {number} green - Green component value. Real in the range 0 - 255. Synonyms: g, y. +* @property {number} blue - Blue component value. Real in the range 0 - 255. Synonyms: b, z. * @example ColorFloats can be set in multiple ways and modified with their aliases, but still stringify in the same way * Entities.editEntity(, { color: { x: 1, y: 2, z: 3 }}); // { red: 1, green: 2, blue: 3 } * Entities.editEntity(, { color: { r: 4, g: 5, b: 6 }}); // { red: 4, green: 5, blue: 6 } * Entities.editEntity(, { color: { red: 7, green: 8, blue: 9 }}); // { red: 7, green: 8, blue: 9 } -* Entities.editEntity(, { color: { width: 10, height: 11, depth: 12 }}); // { red: 10, green: 11, blue: 12 } -* Entities.editEntity(, { color: [13, 14, 15]}); // { red: 13, green: 14, blue: 15 } -* Entities.editEntity(, { color: 16}); // { red: 16, green: 16, blue: 16 } -* var color = Entities.getEntityProperties().color; // { red: 16, green: 16, blue: 16 } -* color.g = 17; // { red: 16, green: 17, blue: 16 } -* color.blue = 18; // { red: 16, green: 17, blue: 18 } +* Entities.editEntity(, { color: [10, 11, 12] }); // { red: 10, green: 11, blue: 12 } +* Entities.editEntity(, { color: 13 }); // { red: 13, green: 13, blue: 13 } +* var color = Entities.getEntityProperties().color; // { red: 13, green: 13, blue: 13 } +* color.g = 14; // { red: 13, green: 14, blue: 13 } +* color.blue = 15; // { red: 13, green: 14, blue: 15 } * Entities.editEntity(, { color: "red"}); // { red: 255, green: 0, blue: 0 } * Entities.editEntity(, { color: "#00FF00"}); // { red: 0, green: 255, blue: 0 } */