From 39654779fbfa9ca1015b65c3595623877f7921b4 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 24 May 2017 13:35:00 +1200 Subject: [PATCH 01/36] Position tablet relative to hand --- scripts/system/libraries/WebTablet.js | 33 ++++++++++++--------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 757743accc..88e6ec763b 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -41,7 +41,7 @@ var LOCAL_TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home- // returns object with two fields: // * position - position in front of the user // * rotation - rotation of entity so it faces the user. -function calcSpawnInfo(hand, height) { +function calcSpawnInfo(hand, tabletHeight) { var finalPosition; var headPos = (HMD.active && Camera.mode === "first person") ? HMD.position : Camera.position; @@ -52,29 +52,24 @@ function calcSpawnInfo(hand, height) { } if (HMD.active && hand !== NO_HANDS) { - var handController = getControllerWorldLocation(hand, true); + // Orient tablet per hand orientation. + // Angle it back similar to holding it like a book. + // Move tablet up so that hand is at bottom. + // Move tablet back so that hand is in front. - var TABLET_UP_OFFSET = 0.1; - var TABLET_FORWARD_OFFSET = 0.1; - var normal = Vec3.multiplyQbyV(handController.rotation, {x: 0, y: -1, z: 0}); - var pitch = Math.asin(normal.y); - var MAX_PITCH = Math.PI / 4; - if (pitch < -MAX_PITCH) { - pitch = -MAX_PITCH; - } else if (pitch > MAX_PITCH) { - pitch = MAX_PITCH; + var handController = getControllerWorldLocation(hand, true); + var position = handController.position; + var rotation = handController.rotation; + if (hand === Controller.Standard.LeftHand) { + rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, 90, 0)); + } else { + rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, -90, 0)); } - // rebuild normal from pitch and heading. - var heading = Math.atan2(normal.z, normal.x); - normal = {x: Math.cos(heading), y: Math.sin(pitch), z: Math.sin(heading)}; - - var position = Vec3.sum(handController.position, {x: 0, y: TABLET_UP_OFFSET, z: 0}); - var rotation = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Y_AXIS); - var offset = Vec3.multiplyQbyV(rotation, {x: 0, y: height / 2, z: TABLET_FORWARD_OFFSET}); + position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: tabletHeight * 0.4, z: tabletHeight * 0.05 })); return { - position: Vec3.sum(offset, position), + position: position, rotation: rotation }; } else { From 925cca97db51bbfabd30160d15259c0540208591 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 25 May 2017 09:16:17 +1200 Subject: [PATCH 02/36] Make the tablet horizontal --- scripts/system/libraries/WebTablet.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 88e6ec763b..a3090f05e7 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -54,17 +54,21 @@ function calcSpawnInfo(hand, tabletHeight) { if (HMD.active && hand !== NO_HANDS) { // Orient tablet per hand orientation. // Angle it back similar to holding it like a book. + // Make it horizontal. // Move tablet up so that hand is at bottom. // Move tablet back so that hand is in front. var handController = getControllerWorldLocation(hand, true); var position = handController.position; var rotation = handController.rotation; + if (hand === Controller.Standard.LeftHand) { rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, 90, 0)); } else { rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, -90, 0)); } + var eulers = Quat.safeEulerAngles(rotation); + rotation = Quat.fromPitchYawRollDegrees(eulers.x, eulers.y, 0); position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: tabletHeight * 0.4, z: tabletHeight * 0.05 })); From 6452e92ac9436b712a47c51aade2b656f5f4917e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 25 May 2017 11:28:26 +1200 Subject: [PATCH 03/36] Hand controller data may not be valid --- scripts/system/libraries/WebTablet.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index a3090f05e7..5168e2340d 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -51,14 +51,18 @@ function calcSpawnInfo(hand, tabletHeight) { hand = NO_HANDS; } + var handController = null; if (HMD.active && hand !== NO_HANDS) { + handController = getControllerWorldLocation(hand, true); + } + + if (handController && handController.valid) { // Orient tablet per hand orientation. // Angle it back similar to holding it like a book. // Make it horizontal. // Move tablet up so that hand is at bottom. // Move tablet back so that hand is in front. - var handController = getControllerWorldLocation(hand, true); var position = handController.position; var rotation = handController.rotation; From f1dca5019a6f79209b167102cd61cdfc12312855 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 25 May 2017 11:48:28 +1200 Subject: [PATCH 04/36] Fix making the tablet horizontal --- scripts/system/libraries/WebTablet.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 5168e2340d..c9918589f6 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -57,9 +57,8 @@ function calcSpawnInfo(hand, tabletHeight) { } if (handController && handController.valid) { - // Orient tablet per hand orientation. + // Orient tablet per hand pitch and yaw. // Angle it back similar to holding it like a book. - // Make it horizontal. // Move tablet up so that hand is at bottom. // Move tablet back so that hand is in front. @@ -67,12 +66,13 @@ function calcSpawnInfo(hand, tabletHeight) { var rotation = handController.rotation; if (hand === Controller.Standard.LeftHand) { - rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, 90, 0)); + rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, 90, 0)); } else { - rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(-60, -90, 0)); + rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)); } - var eulers = Quat.safeEulerAngles(rotation); - rotation = Quat.fromPitchYawRollDegrees(eulers.x, eulers.y, 0); + var normal = Vec3.multiplyQbyV(rotation, Vec3.UNIT_NEG_Y); + var lookAt = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Vec3.UNIT_Y); + rotation = Quat.multiply(lookAt, Quat.fromPitchYawRollDegrees(30, 0, 0)); position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: tabletHeight * 0.4, z: tabletHeight * 0.05 })); From 362e08a90d4f7861f08db2ef28444aecd3f9f064 Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 10:23:28 -0700 Subject: [PATCH 05/36] Add extrudePolygon for cylinder --- libraries/render-utils/src/GeometryCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index f1c995b943..f0e132ab7a 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -366,8 +366,6 @@ void GeometryCache::buildShapes() { shapeData.setupIndices(_shapeIndices, IndexVector(), wireIndices); } - // Not implememented yet: - //Triangle, extrudePolygon<3>(_shapes[Triangle], _shapeVertices, _shapeIndices); //Hexagon, @@ -375,11 +373,13 @@ void GeometryCache::buildShapes() { //Octagon, extrudePolygon<8>(_shapes[Octagon], _shapeVertices, _shapeIndices); + // Not implememented yet: //Quad, //Circle, //Torus, //Cone, - //Cylinder, + //Cylinder + extrudePolygon<48>(_shapes[Cylinder], _shapeVertices, _shapeIndices); } gpu::Stream::FormatPointer& getSolidStreamFormat() { From 417d9ec80b93766962dd44431cae9f2655bc731c Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 11:04:25 -0700 Subject: [PATCH 06/36] Surface cylinder option for primitive shape to html --- libraries/render-utils/src/GeometryCache.cpp | 5 +++-- libraries/render-utils/src/GeometryCache.h | 2 +- scripts/system/html/entityProperties.html | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index f0e132ab7a..41731a76df 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -372,14 +372,15 @@ void GeometryCache::buildShapes() { extrudePolygon<6>(_shapes[Hexagon], _shapeVertices, _shapeIndices); //Octagon, extrudePolygon<8>(_shapes[Octagon], _shapeVertices, _shapeIndices); + //Cylinder, + extrudePolygon<48>(_shapes[Cylinder], _shapeVertices, _shapeIndices); // Not implememented yet: //Quad, //Circle, //Torus, //Cone, - //Cylinder - extrudePolygon<48>(_shapes[Cylinder], _shapeVertices, _shapeIndices); + } gpu::Stream::FormatPointer& getSolidStreamFormat() { diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index e0a610a095..798c71317c 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -143,7 +143,7 @@ public: Icosahedron, Torus, // not yet implemented Cone, // not yet implemented - Cylinder, // not yet implemented + Cylinder, NUM_SHAPES, }; diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 35accdd0df..f15f7eed30 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -51,6 +51,7 @@ +
From d3e900e42f6e53b5adf169a98f1c33d5f07cdaca Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 12:54:49 -0700 Subject: [PATCH 07/36] Adding first pass on cone shape --- libraries/render-utils/src/GeometryCache.cpp | 82 +++++++++++++++++++- scripts/system/html/entityProperties.html | 1 + 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 41731a76df..58bae05ad4 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -324,6 +324,80 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); } +template +void extrudeConical(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { + using namespace geometry; + Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); + VertexVector vertices; + IndexVector solidIndices, wireIndices; + + std::vector base = polygon(); + + for (const vec3& v : base) { + vertices.push_back(vec3(0, 0.5f, 0)); + vertices.push_back(vec3(0, 1, 0)); + } + + for (const vec3& v : base) { + vertices.push_back(vec3(v.x, -0.5f, v.z)); + vertices.push_back(vec3(0, -1, 0)); + } + + + for (uint32_t i = 2; i < N; ++i) { + solidIndices.push_back(baseVertex + 0); + solidIndices.push_back(baseVertex + i); + solidIndices.push_back(baseVertex + i - 1); + solidIndices.push_back(baseVertex + N); + solidIndices.push_back(baseVertex + i + N - 1); + solidIndices.push_back(baseVertex + i + N); + } + for (uint32_t i = 1; i <= N; ++i) { + wireIndices.push_back(baseVertex + (i % N)); + wireIndices.push_back(baseVertex + i - 1); + wireIndices.push_back(baseVertex + (i % N) + N); + wireIndices.push_back(baseVertex + (i - 1) + N); + } + + // Now do the sides + baseVertex += 2 * N; + + for (uint32_t i = 0; i < N; ++i) { + vec3 left = base[i]; + vec3 right = base[(i + 1) % N]; + vec3 normal = glm::normalize(left + right); + vec3 topLeft = vec3(0.0, 0.5f, 0.0); + vec3 topRight = vec3(0.0, 0.5f, 0.0); + vec3 bottomLeft = vec3(left.x, -0.5f, left.z); + vec3 bottomRight = vec3(right.x, -0.5f, right.z); + + vertices.push_back(topLeft); + vertices.push_back(normal); + vertices.push_back(bottomLeft); + vertices.push_back(normal); + vertices.push_back(topRight); + vertices.push_back(normal); + vertices.push_back(bottomRight); + vertices.push_back(normal); + + solidIndices.push_back(baseVertex + 0); + solidIndices.push_back(baseVertex + 2); + solidIndices.push_back(baseVertex + 1); + solidIndices.push_back(baseVertex + 1); + solidIndices.push_back(baseVertex + 2); + solidIndices.push_back(baseVertex + 3); + wireIndices.push_back(baseVertex + 0); + wireIndices.push_back(baseVertex + 1); + wireIndices.push_back(baseVertex + 3); + wireIndices.push_back(baseVertex + 2); + baseVertex += 4; + } + + shapeData.setupVertices(vertexBuffer, vertices); + shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); + +} + // FIXME solids need per-face vertices, but smooth shaded // components do not. Find a way to support using draw elements // or draw arrays as appropriate @@ -373,13 +447,15 @@ void GeometryCache::buildShapes() { //Octagon, extrudePolygon<8>(_shapes[Octagon], _shapeVertices, _shapeIndices); //Cylinder, - extrudePolygon<48>(_shapes[Cylinder], _shapeVertices, _shapeIndices); - + extrudePolygon<64>(_shapes[Cylinder], _shapeVertices, _shapeIndices); + //Cone, + extrudeConical<64>(_shapes[Cone], _shapeVertices, _shapeIndices); + // Not implememented yet: //Quad, //Circle, //Torus, - //Cone, + } diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index f15f7eed30..a740306c92 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -52,6 +52,7 @@ +
From ffbe39df0a36b9c1032f76c0b3fb435a6294f4cd Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 13:06:24 -0700 Subject: [PATCH 08/36] Refactor to add optional conical parameter to existing extrude polygon function --- libraries/render-utils/src/GeometryCache.cpp | 98 ++++---------------- 1 file changed, 16 insertions(+), 82 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 58bae05ad4..11b330a9cf 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -255,17 +255,25 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid } template -void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { +void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool conical=false) { using namespace geometry; Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); VertexVector vertices; IndexVector solidIndices, wireIndices; - // Top and bottom faces + // Top (if not conical) and bottom faces std::vector shape = polygon(); - for (const vec3& v : shape) { - vertices.push_back(vec3(v.x, 0.5f, v.z)); - vertices.push_back(vec3(0, 1, 0)); + if (conical) { + for (const vec3& v : shape) { + vertices.push_back(vec3(0, 0.5f, 0)); + vertices.push_back(vec3(0, 1, 0)); + } + } + else { + for (const vec3& v : shape) { + vertices.push_back(vec3(v.x, 0.5f, v.z)); + vertices.push_back(vec3(0, 1, 0)); + } } for (const vec3& v : shape) { vertices.push_back(vec3(v.x, -0.5f, v.z)); @@ -293,8 +301,8 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver vec3 left = shape[i]; vec3 right = shape[(i + 1) % N]; vec3 normal = glm::normalize(left + right); - vec3 topLeft = vec3(left.x, 0.5f, left.z); - vec3 topRight = vec3(right.x, 0.5f, right.z); + vec3 topLeft = (conical ? vec3(0.0, 0.5f, 0.0) : vec3(left.x, 0.5f, left.z)); + vec3 topRight = (conical? vec3(0.0, 0.5f, 0.0) : vec3(right.x, 0.5f, right.z)); vec3 bottomLeft = vec3(left.x, -0.5f, left.z); vec3 bottomRight = vec3(right.x, -0.5f, right.z); @@ -324,80 +332,6 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); } -template -void extrudeConical(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { - using namespace geometry; - Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); - VertexVector vertices; - IndexVector solidIndices, wireIndices; - - std::vector base = polygon(); - - for (const vec3& v : base) { - vertices.push_back(vec3(0, 0.5f, 0)); - vertices.push_back(vec3(0, 1, 0)); - } - - for (const vec3& v : base) { - vertices.push_back(vec3(v.x, -0.5f, v.z)); - vertices.push_back(vec3(0, -1, 0)); - } - - - for (uint32_t i = 2; i < N; ++i) { - solidIndices.push_back(baseVertex + 0); - solidIndices.push_back(baseVertex + i); - solidIndices.push_back(baseVertex + i - 1); - solidIndices.push_back(baseVertex + N); - solidIndices.push_back(baseVertex + i + N - 1); - solidIndices.push_back(baseVertex + i + N); - } - for (uint32_t i = 1; i <= N; ++i) { - wireIndices.push_back(baseVertex + (i % N)); - wireIndices.push_back(baseVertex + i - 1); - wireIndices.push_back(baseVertex + (i % N) + N); - wireIndices.push_back(baseVertex + (i - 1) + N); - } - - // Now do the sides - baseVertex += 2 * N; - - for (uint32_t i = 0; i < N; ++i) { - vec3 left = base[i]; - vec3 right = base[(i + 1) % N]; - vec3 normal = glm::normalize(left + right); - vec3 topLeft = vec3(0.0, 0.5f, 0.0); - vec3 topRight = vec3(0.0, 0.5f, 0.0); - vec3 bottomLeft = vec3(left.x, -0.5f, left.z); - vec3 bottomRight = vec3(right.x, -0.5f, right.z); - - vertices.push_back(topLeft); - vertices.push_back(normal); - vertices.push_back(bottomLeft); - vertices.push_back(normal); - vertices.push_back(topRight); - vertices.push_back(normal); - vertices.push_back(bottomRight); - vertices.push_back(normal); - - solidIndices.push_back(baseVertex + 0); - solidIndices.push_back(baseVertex + 2); - solidIndices.push_back(baseVertex + 1); - solidIndices.push_back(baseVertex + 1); - solidIndices.push_back(baseVertex + 2); - solidIndices.push_back(baseVertex + 3); - wireIndices.push_back(baseVertex + 0); - wireIndices.push_back(baseVertex + 1); - wireIndices.push_back(baseVertex + 3); - wireIndices.push_back(baseVertex + 2); - baseVertex += 4; - } - - shapeData.setupVertices(vertexBuffer, vertices); - shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); - -} - // FIXME solids need per-face vertices, but smooth shaded // components do not. Find a way to support using draw elements // or draw arrays as appropriate @@ -449,7 +383,7 @@ void GeometryCache::buildShapes() { //Cylinder, extrudePolygon<64>(_shapes[Cylinder], _shapeVertices, _shapeIndices); //Cone, - extrudeConical<64>(_shapes[Cone], _shapeVertices, _shapeIndices); + extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true); // Not implememented yet: //Quad, From fee26c3976888d6f4b8e6423529d475831cffbee Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 13:12:08 -0700 Subject: [PATCH 09/36] Remove not yet implemented comment from Cone shape --- libraries/render-utils/src/GeometryCache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 798c71317c..9853269280 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -142,7 +142,7 @@ public: Dodecahedron, Icosahedron, Torus, // not yet implemented - Cone, // not yet implemented + Cone, Cylinder, NUM_SHAPES, }; From 10408a0fe4a62b9d91bb78f2c81a6e1f3359e279 Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 25 May 2017 15:32:49 -0700 Subject: [PATCH 10/36] basic circle function to be used as base for torus --- libraries/render-utils/src/GeometryCache.cpp | 40 ++++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 11b330a9cf..4f86f64c96 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -332,6 +332,39 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); } +void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { + // Draw a circle with radius 1/4th the size of the bounding box + using namespace geometry; + + Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); + VertexVector vertices; + IndexVector solidIndices, wireIndices; + + std::vector shape = polygon<64>(); + for (const vec3& v : shape) { + vertices.push_back(vec3(v.x, 0, v.z)); + vertices.push_back(vec3(0, 0, 0)); + } + + for (uint32_t i = 2; i < 64; ++i) { + solidIndices.push_back(baseVertex + 0); + solidIndices.push_back(baseVertex + i); + solidIndices.push_back(baseVertex + i - 1); + solidIndices.push_back(baseVertex + 64); + solidIndices.push_back(baseVertex + i + 64 - 1); + solidIndices.push_back(baseVertex + i + 64); + } + for (uint32_t i = 1; i <= 64; ++i) { + wireIndices.push_back(baseVertex + (i % 64)); + wireIndices.push_back(baseVertex + i - 1); + wireIndices.push_back(baseVertex + (i % 64) + 64); + wireIndices.push_back(baseVertex + (i - 1) + 64); + } + + shapeData.setupVertices(vertexBuffer, vertices); + shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); +} + // FIXME solids need per-face vertices, but smooth shaded // components do not. Find a way to support using draw elements // or draw arrays as appropriate @@ -384,13 +417,12 @@ void GeometryCache::buildShapes() { extrudePolygon<64>(_shapes[Cylinder], _shapeVertices, _shapeIndices); //Cone, extrudePolygon<64>(_shapes[Cone], _shapeVertices, _shapeIndices, true); - + //Circle + drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices); // Not implememented yet: //Quad, //Circle, - //Torus, - - + //Torus, } gpu::Stream::FormatPointer& getSolidStreamFormat() { From 2808ab4865611a1d01ca966f105c0939c5eb999b Mon Sep 17 00:00:00 2001 From: Liv Date: Fri, 26 May 2017 10:45:29 -0700 Subject: [PATCH 11/36] Sort of making progress on torus vertex buffer --- libraries/render-utils/src/GeometryCache.cpp | 49 +++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 4f86f64c96..e59046c14a 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -365,6 +365,52 @@ void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexB shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); } +template +void drawTorus(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { + using namespace geometry; + Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); + VertexVector vertices; + IndexVector solidIndices, wireIndices; + + float MAJOR_RADIUS = 0.75f; + float MINOR_RADIUS = 0.25f; + + // Minor segments + for (uint32_t j = 0; j < sMinor; j++) { + // Major segments + for (uint32_t i = 0; i < sMajor; i++) { + float_t u = float_t(i) / float_t(sMajor) * M_PI * 2; + float_t v = float_t(j + u) / float_t(sMinor) * M_PI * 2; + + vec3 vertex((MAJOR_RADIUS + MINOR_RADIUS * glm::cos(v)) * glm::cos(u), + (MAJOR_RADIUS + MINOR_RADIUS * glm::cos(v)) * glm::sin(u), + MINOR_RADIUS * glm::sin(v)); + + vertices.push_back(vertex); + } + } + + for (uint32_t x = 1; x <= sMinor; x++) { + for (uint32_t y = 1; y <= sMajor; y++) { + uint32_t a = (sMajor) * x + y - 1; + uint32_t b = (sMajor) * (x - 1) + y - 1; + uint32_t c = (sMajor) * (x - 1) + y; + uint32_t d = (sMajor) * x + y; + + solidIndices.push_back(a); + solidIndices.push_back(b); + solidIndices.push_back(d); + solidIndices.push_back(b); + solidIndices.push_back(c); + solidIndices.push_back(d); + + } + } + + shapeData.setupVertices(vertexBuffer, vertices); + shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); +} + // FIXME solids need per-face vertices, but smooth shaded // components do not. Find a way to support using draw elements // or draw arrays as appropriate @@ -422,7 +468,8 @@ void GeometryCache::buildShapes() { // Not implememented yet: //Quad, //Circle, - //Torus, + //Torus, + drawTorus<6, 4>(_shapes[Torus], _shapeVertices, _shapeIndices); } gpu::Stream::FormatPointer& getSolidStreamFormat() { From 367b3ec603c889021c23601db78e0fe11bfd4047 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 28 May 2017 09:59:32 +1200 Subject: [PATCH 12/36] Handle nonvertical avatar orientation --- scripts/system/libraries/WebTablet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index c9918589f6..9a000d551e 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -71,8 +71,8 @@ function calcSpawnInfo(hand, tabletHeight) { rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)); } var normal = Vec3.multiplyQbyV(rotation, Vec3.UNIT_NEG_Y); - var lookAt = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Vec3.UNIT_Y); - rotation = Quat.multiply(lookAt, Quat.fromPitchYawRollDegrees(30, 0, 0)); + var lookAt = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.UNIT_Y)); + rotation = Quat.multiply(Quat.angleAxis(30, Vec3.multiplyQbyV(lookAt, Vec3.UNIT_X)), lookAt); position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: tabletHeight * 0.4, z: tabletHeight * 0.05 })); From 8bcaacbe4079669a9b05337bc944fe398e215720 Mon Sep 17 00:00:00 2001 From: Liv Date: Wed, 31 May 2017 15:46:35 -0700 Subject: [PATCH 13/36] Removing incomplete torus function --- libraries/render-utils/src/GeometryCache.cpp | 48 +------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index e59046c14a..3fef5d15d1 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -365,52 +365,6 @@ void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexB shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); } -template -void drawTorus(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer) { - using namespace geometry; - Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); - VertexVector vertices; - IndexVector solidIndices, wireIndices; - - float MAJOR_RADIUS = 0.75f; - float MINOR_RADIUS = 0.25f; - - // Minor segments - for (uint32_t j = 0; j < sMinor; j++) { - // Major segments - for (uint32_t i = 0; i < sMajor; i++) { - float_t u = float_t(i) / float_t(sMajor) * M_PI * 2; - float_t v = float_t(j + u) / float_t(sMinor) * M_PI * 2; - - vec3 vertex((MAJOR_RADIUS + MINOR_RADIUS * glm::cos(v)) * glm::cos(u), - (MAJOR_RADIUS + MINOR_RADIUS * glm::cos(v)) * glm::sin(u), - MINOR_RADIUS * glm::sin(v)); - - vertices.push_back(vertex); - } - } - - for (uint32_t x = 1; x <= sMinor; x++) { - for (uint32_t y = 1; y <= sMajor; y++) { - uint32_t a = (sMajor) * x + y - 1; - uint32_t b = (sMajor) * (x - 1) + y - 1; - uint32_t c = (sMajor) * (x - 1) + y; - uint32_t d = (sMajor) * x + y; - - solidIndices.push_back(a); - solidIndices.push_back(b); - solidIndices.push_back(d); - solidIndices.push_back(b); - solidIndices.push_back(c); - solidIndices.push_back(d); - - } - } - - shapeData.setupVertices(vertexBuffer, vertices); - shapeData.setupIndices(indexBuffer, solidIndices, wireIndices); -} - // FIXME solids need per-face vertices, but smooth shaded // components do not. Find a way to support using draw elements // or draw arrays as appropriate @@ -469,7 +423,7 @@ void GeometryCache::buildShapes() { //Quad, //Circle, //Torus, - drawTorus<6, 4>(_shapes[Torus], _shapeVertices, _shapeIndices); + } gpu::Stream::FormatPointer& getSolidStreamFormat() { From 27d4edd2d0990a34ce7cf64272849a5545cfa838 Mon Sep 17 00:00:00 2001 From: Liv Date: Wed, 31 May 2017 16:25:11 -0700 Subject: [PATCH 14/36] Add circle and cone to entity shape list --- scripts/system/html/entityProperties.html | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index a740306c92..bf65bdad32 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -53,6 +53,7 @@ +
From 4dbe646c17000e1a58ca6c362f4f211a5b888c4a Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 3 Jun 2017 15:40:25 +0200 Subject: [PATCH 15/36] Set ective button property isActive before Home menu redraw. Makes sure redraw will read proper value of isActive property --- scripts/system/edit.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 3c687f2f29..ea2b108016 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -618,7 +618,6 @@ var toolBar = (function () { that.toggle = function () { that.setActive(!isActive); - activeButton.editProperties({isActive: isActive}); if (!isActive) { tablet.gotoHomeScreen(); } @@ -642,6 +641,8 @@ var toolBar = (function () { enabled: active })); isActive = active; + activeButton.editProperties({isActive: isActive}); + if (!isActive) { entityListTool.setVisible(false); gridTool.setVisible(false); From 9248715b2153dcef9029021f42d014a6265ddf1a Mon Sep 17 00:00:00 2001 From: Liv Date: Mon, 5 Jun 2017 17:37:32 -0700 Subject: [PATCH 16/36] Fixing z-index for Shape drop down --- scripts/system/html/css/edit-style.css | 3 ++- scripts/system/html/css/jsoneditor.css | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index fcb1815ca4..2d5a6e987f 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -657,7 +657,8 @@ hr { font-family: FiraSans-SemiBold; font-size: 15px; color: #404040; - background-color: #afafaf + background-color: #afafaf; + z-index: 999; } .dropdown li:hover { background-color: #00b4ef; diff --git a/scripts/system/html/css/jsoneditor.css b/scripts/system/html/css/jsoneditor.css index 4d63380a62..ce83b45ff3 100644 --- a/scripts/system/html/css/jsoneditor.css +++ b/scripts/system/html/css/jsoneditor.css @@ -503,7 +503,7 @@ div.jsoneditor-contextmenu-root { div.jsoneditor-contextmenu { position: absolute; box-sizing: content-box; - z-index: 99999; + z-index: 998; } div.jsoneditor-contextmenu ul, From 393aa84a554618be86c082259bc6e4c90d9d7425 Mon Sep 17 00:00:00 2001 From: Liv Date: Mon, 5 Jun 2017 17:45:52 -0700 Subject: [PATCH 17/36] Renaming conical to isConical --- libraries/render-utils/src/GeometryCache.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 53a10be218..2727b77846 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -256,7 +256,7 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid } template -void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool conical=false) { +void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool isConical=false) { using namespace geometry; Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); VertexVector vertices; @@ -264,7 +264,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver // Top (if not conical) and bottom faces std::vector shape = polygon(); - if (conical) { + if (isConical) { for (const vec3& v : shape) { vertices.push_back(vec3(0, 0.5f, 0)); vertices.push_back(vec3(0, 1, 0)); @@ -302,8 +302,8 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver vec3 left = shape[i]; vec3 right = shape[(i + 1) % N]; vec3 normal = glm::normalize(left + right); - vec3 topLeft = (conical ? vec3(0.0, 0.5f, 0.0) : vec3(left.x, 0.5f, left.z)); - vec3 topRight = (conical? vec3(0.0, 0.5f, 0.0) : vec3(right.x, 0.5f, right.z)); + vec3 topLeft = (isConical ? vec3(0.0, 0.5f, 0.0) : vec3(left.x, 0.5f, left.z)); + vec3 topRight = (isConical? vec3(0.0, 0.5f, 0.0) : vec3(right.x, 0.5f, right.z)); vec3 bottomLeft = vec3(left.x, -0.5f, left.z); vec3 bottomRight = vec3(right.x, -0.5f, right.z); From 42cb2332d587599e31cf30ad519ea07d56fbf432 Mon Sep 17 00:00:00 2001 From: Liv Date: Mon, 5 Jun 2017 17:46:13 -0700 Subject: [PATCH 18/36] Remove unimplemented comment on circle --- libraries/render-utils/src/GeometryCache.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 2727b77846..bfc85ab2bf 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -422,7 +422,6 @@ void GeometryCache::buildShapes() { drawCircle(_shapes[Circle], _shapeVertices, _shapeIndices); // Not implememented yet: //Quad, - //Circle, //Torus, } From 5579c409e77f4034e13cbb85c6d5083bc9dc97bf Mon Sep 17 00:00:00 2001 From: Liv Date: Mon, 5 Jun 2017 18:03:10 -0700 Subject: [PATCH 19/36] Style fix --- libraries/render-utils/src/GeometryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index bfc85ab2bf..32621e2606 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -256,7 +256,7 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid } template -void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool isConical=false) { +void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexBuffer, gpu::BufferPointer& indexBuffer, bool isConical = false) { using namespace geometry; Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); VertexVector vertices; From 6e5cb63d4f8c2daf18fc015608e5f643e4ea917a Mon Sep 17 00:00:00 2001 From: Liv Erickson Date: Tue, 6 Jun 2017 09:15:41 -0700 Subject: [PATCH 20/36] Add z-index fix for dropped down list --- scripts/system/html/css/edit-style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 2d5a6e987f..40f3d682cd 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -610,6 +610,7 @@ hr { .dropdown dl[dropped="true"] { color: #404040; background: linear-gradient(#afafaf, #afafaf); + z-index: 998; } .dropdown dt { From c3bf915fd4d289584130425a8b6543c345bd99fa Mon Sep 17 00:00:00 2001 From: Liv Date: Wed, 7 Jun 2017 15:04:39 -0700 Subject: [PATCH 21/36] Changing loop to avoid unused warnings --- libraries/render-utils/src/GeometryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 32621e2606..12de40dce8 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -265,7 +265,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver // Top (if not conical) and bottom faces std::vector shape = polygon(); if (isConical) { - for (const vec3& v : shape) { + for (uint32_t i = 0; i < N; i++) { vertices.push_back(vec3(0, 0.5f, 0)); vertices.push_back(vec3(0, 1, 0)); } From 1b45276de2686a083d263a67b014227a6c762346 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 7 Jun 2017 15:55:38 -0700 Subject: [PATCH 22/36] Adjust the preview to avoid seeing the masked pixels in HMD mode --- .../src/display-plugins/hmd/HmdDisplayPlugin.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index cab96c258b..08c8d4f754 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -221,6 +221,12 @@ void HmdDisplayPlugin::internalPresent() { float shiftLeftBy = getLeftCenterPixel() - (sourceSize.x / 2); float newWidth = sourceSize.x - shiftLeftBy; + // Experimentally adjusted the region presented in preview to avoid seeing the masked pixels and recenter the center... + static float SCALE_WIDTH = 0.9f; + static float SCALE_OFFSET = 2.0f; + newWidth *= SCALE_WIDTH; + shiftLeftBy *= SCALE_OFFSET; + const unsigned int RATIO_Y = 9; const unsigned int RATIO_X = 16; glm::uvec2 originalClippedSize { newWidth, newWidth * RATIO_Y / RATIO_X }; From 34bd2b8a2b93140b4b8f209eb081a6a4ebc67eb3 Mon Sep 17 00:00:00 2001 From: Liv Date: Thu, 8 Jun 2017 09:01:01 -0700 Subject: [PATCH 23/36] style fix --- libraries/render-utils/src/GeometryCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 12de40dce8..0c551feee7 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -265,7 +265,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver // Top (if not conical) and bottom faces std::vector shape = polygon(); if (isConical) { - for (uint32_t i = 0; i < N; i++) { + for (uint32_t i = 0; i < N; i++) { vertices.push_back(vec3(0, 0.5f, 0)); vertices.push_back(vec3(0, 1, 0)); } From 3b471425926daf1a7bd8cc201fe89b882aaa107b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 8 Jun 2017 10:28:38 -0700 Subject: [PATCH 24/36] fix bug that causes hmd avatar eyes to be all the way to the side when there's not another avatar to look at --- interface/src/Application.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 6 +++--- interface/src/avatar/MyAvatar.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ea5a9c0a89..44b0a36f7a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4163,7 +4163,7 @@ void Application::updateMyAvatarLookAtPosition() { lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE)); } else { lookAtSpot = myAvatar->getHead()->getEyePosition() + - (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, TREE_SCALE)); } } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index bc621543e3..dea2404cee 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -2664,8 +2664,8 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(const MyAvatar& myAvatar, co return (offset.y > CYLINDER_TOP) || (offset.y < CYLINDER_BOTTOM); } -void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) { - _desiredBodyMatrix = desiredBodyMatrix; +void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, + const glm::mat4& currentBodyMatrix, bool hasDriveInput) { if (myAvatar.getHMDLeanRecenterEnabled()) { if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) { @@ -2679,7 +2679,7 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat } } - glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix; + glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * desiredBodyMatrix; glm::mat4 currentWorldMatrix = myAvatar.getSensorToWorldMatrix() * currentBodyMatrix; AnimPose followWorldPose(currentWorldMatrix); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 3e2581382d..fb11705a9c 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -702,7 +702,6 @@ private: Vertical, NumFollowTypes }; - glm::mat4 _desiredBodyMatrix; float _timeRemaining[NumFollowTypes]; void deactivate(); From a4f4d49bec82425be82abca9b44e17528e0d445d Mon Sep 17 00:00:00 2001 From: seefo Date: Thu, 8 Jun 2017 11:50:23 -0700 Subject: [PATCH 25/36] Oven will now give proper return codes when used via CLI --- tools/oven/src/BakerCLI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/oven/src/BakerCLI.cpp b/tools/oven/src/BakerCLI.cpp index 7bdd221514..14eb9de150 100644 --- a/tools/oven/src/BakerCLI.cpp +++ b/tools/oven/src/BakerCLI.cpp @@ -48,7 +48,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) { _baker->moveToThread(qApp->getNextWorkerThread()); } else { qCDebug(model_baking) << "Failed to determine baker type for file" << inputUrl; - return; + QApplication::exit(1); } // invoke the bake method on the baker thread @@ -60,5 +60,5 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) { void BakerCLI::handleFinishedBaker() { qCDebug(model_baking) << "Finished baking file."; - QApplication::quit(); + QApplication::exit(_baker.get()->hasErrors()); } \ No newline at end of file From fce3badd1d985eddc0e5fa1ee2bee19169eff8ee Mon Sep 17 00:00:00 2001 From: seefo Date: Thu, 8 Jun 2017 10:48:38 -0700 Subject: [PATCH 26/36] Resolved FB#5005 --- libraries/networking/src/UserActivityLogger.cpp | 10 ++++++++++ libraries/networking/src/UserActivityLogger.h | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 28117c0933..51445dce2a 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -20,6 +20,10 @@ #include #include "AddressManager.h" +UserActivityLogger::UserActivityLogger() { + _timer.start(); +} + UserActivityLogger& UserActivityLogger::getInstance() { static UserActivityLogger sharedInstance; return sharedInstance; @@ -42,6 +46,12 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\""); actionPart.setBody(QByteArray().append(action)); multipart->append(actionPart); + + // Log the local-time that this event was logged + QHttpPart elapsedPart; + elapsedPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"elapsed_ms\""); + elapsedPart.setBody(QByteArray().append(_timer.elapsed())); + multipart->append(elapsedPart); // If there are action details, add them to the multipart if (!details.isEmpty()) { diff --git a/libraries/networking/src/UserActivityLogger.h b/libraries/networking/src/UserActivityLogger.h index 9fad498b86..179e8e6e66 100644 --- a/libraries/networking/src/UserActivityLogger.h +++ b/libraries/networking/src/UserActivityLogger.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "AddressManager.h" @@ -51,8 +52,10 @@ private slots: void requestError(QNetworkReply& errorReply); private: - UserActivityLogger() {}; + UserActivityLogger(); Setting::Handle _disabled { "UserActivityLoggerDisabled", false }; + + QElapsedTimer _timer; }; #endif // hifi_UserActivityLogger_h From ce4c3e1601278f2ac5159ea549173c12604f815f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 8 Jun 2017 13:55:30 -0700 Subject: [PATCH 27/36] fix bug that causes hmd avatar eyes to be all the way to the side when there's not another avatar to look at --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 44b0a36f7a..eec82d0537 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4160,7 +4160,7 @@ void Application::updateMyAvatarLookAtPosition() { if (isHMD) { glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHeadControllerPoseInSensorFrame().getMatrix(); - lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE)); + lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE)); } else { lookAtSpot = myAvatar->getHead()->getEyePosition() + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, TREE_SCALE)); From b7f8cc7f0b5a6a0b5f973035472789763e390649 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Thu, 8 Jun 2017 22:58:40 +0200 Subject: [PATCH 28/36] Fix intendantion --- scripts/system/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index eea35c5851..2c3cc496dc 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -641,9 +641,9 @@ var toolBar = (function () { enabled: active })); isActive = active; - activeButton.editProperties({isActive: isActive}); + activeButton.editProperties({isActive: isActive}); - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); if (!isActive) { entityListTool.setVisible(false); From dc02e3478298e9b92b55a4915881fd512f0daeef Mon Sep 17 00:00:00 2001 From: seefo Date: Thu, 8 Jun 2017 16:22:52 -0700 Subject: [PATCH 29/36] Resolved FB#5009 --- interface/src/AvatarBookmarks.cpp | 24 ++++++++++++++++++++++-- interface/src/AvatarBookmarks.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/interface/src/AvatarBookmarks.cpp b/interface/src/AvatarBookmarks.cpp index 5cdfc8213f..db2a240b92 100644 --- a/interface/src/AvatarBookmarks.cpp +++ b/interface/src/AvatarBookmarks.cpp @@ -21,15 +21,35 @@ #include "MainWindow.h" #include "Menu.h" - #include "AvatarBookmarks.h" +#include "InterfaceLogging.h" + #include AvatarBookmarks::AvatarBookmarks() { - _bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + AVATARBOOKMARKS_FILENAME; + _bookmarksFilename = PathUtils::getAppDataPath() + "/" + AVATARBOOKMARKS_FILENAME; readFromFile(); } +void AvatarBookmarks::readFromFile() { + // migrate old avatarbookmarks.json, used to be in 'local' folder on windows + QString oldConfigPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + AVATARBOOKMARKS_FILENAME; + QFile oldConfig(oldConfigPath); + + // I imagine that in a year from now, this code for migrating (as well as the two lines above) + // may be removed since all bookmarks should have been migrated by then + // - Robbie Uvanni (6.8.2017) + if (oldConfig.exists()) { + if (QDir().rename(oldConfigPath, _bookmarksFilename)) { + qCDebug(interfaceapp) << "Successfully migrated" << AVATARBOOKMARKS_FILENAME; + } else { + qCDebug(interfaceapp) << "Failed to migrate" << AVATARBOOKMARKS_FILENAME; + } + } + + Bookmarks::readFromFile(); +} + void AvatarBookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) { // Add menus/actions auto bookmarkAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::BookmarkAvatar); diff --git a/interface/src/AvatarBookmarks.h b/interface/src/AvatarBookmarks.h index 725af88b0d..dc5a0aee6e 100644 --- a/interface/src/AvatarBookmarks.h +++ b/interface/src/AvatarBookmarks.h @@ -29,6 +29,7 @@ public slots: protected: void addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) override; + void readFromFile(); private: const QString AVATARBOOKMARKS_FILENAME = "avatarbookmarks.json"; From 5b62c9e83b1261146bf3edc292c36ab41c61a358 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 9 Jun 2017 10:45:04 -0700 Subject: [PATCH 30/36] try again to get forward not-looking-at-anyone gaze to work right --- interface/src/Application.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4821b98e3f..890b5cb455 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4126,13 +4126,13 @@ void Application::updateMyAvatarLookAtPosition() { } } else { // I am not looking at anyone else, so just look forward - if (isHMD) { - glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * - myAvatar->getHeadControllerPoseInSensorFrame().getMatrix(); + auto headPose = myAvatar->getHeadControllerPoseInSensorFrame(); + if (headPose.isValid()) { + glm::mat4 worldHeadMat = myAvatar->getSensorToWorldMatrix() * headPose.getMatrix(); lookAtSpot = transformPoint(worldHeadMat, glm::vec3(0.0f, 0.0f, TREE_SCALE)); } else { lookAtSpot = myAvatar->getHead()->getEyePosition() + - (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, TREE_SCALE)); + (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); } } From 1808505d8b588912643ad3856a9c419ad6f9c47c Mon Sep 17 00:00:00 2001 From: Liv Date: Fri, 9 Jun 2017 10:54:57 -0700 Subject: [PATCH 31/36] Coding standard fixes --- libraries/render-utils/src/GeometryCache.cpp | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 0c551feee7..bab7b56686 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -266,7 +266,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver std::vector shape = polygon(); if (isConical) { for (uint32_t i = 0; i < N; i++) { - vertices.push_back(vec3(0, 0.5f, 0)); + vertices.push_back(vec3(0.0f, 0.5f, 0.0f)); vertices.push_back(vec3(0, 1, 0)); } } @@ -302,8 +302,8 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver vec3 left = shape[i]; vec3 right = shape[(i + 1) % N]; vec3 normal = glm::normalize(left + right); - vec3 topLeft = (isConical ? vec3(0.0, 0.5f, 0.0) : vec3(left.x, 0.5f, left.z)); - vec3 topRight = (isConical? vec3(0.0, 0.5f, 0.0) : vec3(right.x, 0.5f, right.z)); + vec3 topLeft = (isConical ? vec3(0.0f, 0.5f, 0.0f) : vec3(left.x, 0.5f, left.z)); + vec3 topRight = (isConical? vec3(0.0f, 0.5f, 0.0f) : vec3(right.x, 0.5f, right.z)); vec3 bottomLeft = vec3(left.x, -0.5f, left.z); vec3 bottomRight = vec3(right.x, -0.5f, right.z); @@ -340,26 +340,27 @@ void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexB Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); VertexVector vertices; IndexVector solidIndices, wireIndices; + const int numCircleVertices = 64; - std::vector shape = polygon<64>(); + std::vector shape = polygon(); for (const vec3& v : shape) { - vertices.push_back(vec3(v.x, 0, v.z)); + vertices.push_back(vec3(v.x, 0.0f, v.z)); vertices.push_back(vec3(0, 0, 0)); } - for (uint32_t i = 2; i < 64; ++i) { + for (uint32_t i = 2; i < numCircleVertices; ++i) { solidIndices.push_back(baseVertex + 0); solidIndices.push_back(baseVertex + i); solidIndices.push_back(baseVertex + i - 1); - solidIndices.push_back(baseVertex + 64); - solidIndices.push_back(baseVertex + i + 64 - 1); - solidIndices.push_back(baseVertex + i + 64); + solidIndices.push_back(baseVertex + numCircleVertices); + solidIndices.push_back(baseVertex + i + numCircleVertices - 1); + solidIndices.push_back(baseVertex + i + numCircleVertices); } - for (uint32_t i = 1; i <= 64; ++i) { - wireIndices.push_back(baseVertex + (i % 64)); + for (uint32_t i = 1; i <= numCircleVertices; ++i) { + wireIndices.push_back(baseVertex + (i % numCircleVertices)); wireIndices.push_back(baseVertex + i - 1); - wireIndices.push_back(baseVertex + (i % 64) + 64); - wireIndices.push_back(baseVertex + (i - 1) + 64); + wireIndices.push_back(baseVertex + (i % numCircleVertices) + numCircleVertices); + wireIndices.push_back(baseVertex + (i - 1) + numCircleVertices); } shapeData.setupVertices(vertexBuffer, vertices); From 06a5d0970c5916d7bcc78cc35a6e46cfed00f7c7 Mon Sep 17 00:00:00 2001 From: seefo Date: Fri, 9 Jun 2017 10:58:07 -0700 Subject: [PATCH 32/36] Fixed issue with invalid time being sent when logging --- libraries/networking/src/UserActivityLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 51445dce2a..0cfd1e09e7 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -50,7 +50,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall // Log the local-time that this event was logged QHttpPart elapsedPart; elapsedPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"elapsed_ms\""); - elapsedPart.setBody(QByteArray().append(_timer.elapsed())); + elapsedPart.setBody(QString::number(_timer.elapsed()).toLocal8Bit()); multipart->append(elapsedPart); // If there are action details, add them to the multipart From 8c488d95d1a097eb36359c667c821c376a63eabe Mon Sep 17 00:00:00 2001 From: Liv Date: Fri, 9 Jun 2017 11:46:38 -0700 Subject: [PATCH 33/36] Stylish updates --- libraries/render-utils/src/GeometryCache.cpp | 61 ++++++++++---------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index bab7b56686..0f50e3361d 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -69,7 +69,7 @@ std::vector polygon() { std::vector result; result.reserve(SIDES); double angleIncrement = 2.0 * M_PI / SIDES; - for (size_t i = 0; i < SIDES; ++i) { + for (size_t i = 0; i < SIDES; i++) { double angle = (double)i * angleIncrement; result.push_back(vec3{ cos(angle) * 0.5, 0.0, sin(angle) * 0.5 }); } @@ -172,20 +172,20 @@ void setupFlatShape(GeometryCache::ShapeData& shapeData, const geometry::Solid& face = shape.faces[f]; // Compute the face normal vec3 faceNormal = shape.getFaceNormal(f); // Create the vertices for the face - for (Index i = 0; i < N; ++i) { + for (Index i = 0; i < N; i++) { Index originalIndex = face[i]; vertices.push_back(shape.vertices[originalIndex]); vertices.push_back(faceNormal); } // Create the wire indices for unseen edges - for (Index i = 0; i < N; ++i) { + for (Index i = 0; i < N; i++) { Index a = i; Index b = (i + 1) % N; auto token = indexToken(face[a], face[b]); @@ -197,7 +197,7 @@ void setupFlatShape(GeometryCache::ShapeData& shapeData, const geometry::Solid& face = shape.faces[f]; // Create the wire indices for unseen edges - for (Index i = 0; i < N; ++i) { + for (Index i = 0; i < N; i++) { Index a = face[i]; Index b = face[(i + 1) % N]; auto token = indexToken(a, b); @@ -244,7 +244,7 @@ void setupSmoothShape(GeometryCache::ShapeData& shapeData, const geometry::Solid } // Create the solid face indices - for (Index i = 0; i < N - 2; ++i) { + for (Index i = 0; i < N - 2; i++) { solidIndices.push_back(face[i] + baseVertex); solidIndices.push_back(face[i + 1] + baseVertex); solidIndices.push_back(face[i + 2] + baseVertex); @@ -267,20 +267,20 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver if (isConical) { for (uint32_t i = 0; i < N; i++) { vertices.push_back(vec3(0.0f, 0.5f, 0.0f)); - vertices.push_back(vec3(0, 1, 0)); + vertices.push_back(vec3(0.0f, 1.0f, 0.0f)); } } else { for (const vec3& v : shape) { vertices.push_back(vec3(v.x, 0.5f, v.z)); - vertices.push_back(vec3(0, 1, 0)); + vertices.push_back(vec3(0.0f, 1.0f, 0.0f)); } } for (const vec3& v : shape) { vertices.push_back(vec3(v.x, -0.5f, v.z)); - vertices.push_back(vec3(0, -1, 0)); + vertices.push_back(vec3(0.0f, -1.0f, 0.0f)); } - for (uint32_t i = 2; i < N; ++i) { + for (uint32_t i = 2; i < N; i++) { solidIndices.push_back(baseVertex + 0); solidIndices.push_back(baseVertex + i); solidIndices.push_back(baseVertex + i - 1); @@ -288,7 +288,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver solidIndices.push_back(baseVertex + i + N - 1); solidIndices.push_back(baseVertex + i + N); } - for (uint32_t i = 1; i <= N; ++i) { + for (uint32_t i = 1; i <= N; i++) { wireIndices.push_back(baseVertex + (i % N)); wireIndices.push_back(baseVertex + i - 1); wireIndices.push_back(baseVertex + (i % N) + N); @@ -298,12 +298,12 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver // Now do the sides baseVertex += 2 * N; - for (uint32_t i = 0; i < N; ++i) { + for (uint32_t i = 0; i < N; i++) { vec3 left = shape[i]; vec3 right = shape[(i + 1) % N]; vec3 normal = glm::normalize(left + right); vec3 topLeft = (isConical ? vec3(0.0f, 0.5f, 0.0f) : vec3(left.x, 0.5f, left.z)); - vec3 topRight = (isConical? vec3(0.0f, 0.5f, 0.0f) : vec3(right.x, 0.5f, right.z)); + vec3 topRight = (isConical ? vec3(0.0f, 0.5f, 0.0f) : vec3(right.x, 0.5f, right.z)); vec3 bottomLeft = vec3(left.x, -0.5f, left.z); vec3 bottomRight = vec3(right.x, -0.5f, right.z); @@ -340,27 +340,28 @@ void drawCircle(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& vertexB Index baseVertex = (Index)(vertexBuffer->getSize() / SHAPE_VERTEX_STRIDE); VertexVector vertices; IndexVector solidIndices, wireIndices; - const int numCircleVertices = 64; + const int NUM_CIRCLE_VERTICES = 64; - std::vector shape = polygon(); + std::vector shape = polygon(); for (const vec3& v : shape) { vertices.push_back(vec3(v.x, 0.0f, v.z)); - vertices.push_back(vec3(0, 0, 0)); + vertices.push_back(vec3(0.0f, 0.0f, 0.0f)); } - for (uint32_t i = 2; i < numCircleVertices; ++i) { + for (uint32_t i = 2; i < NUM_CIRCLE_VERTICES; i++) { solidIndices.push_back(baseVertex + 0); solidIndices.push_back(baseVertex + i); solidIndices.push_back(baseVertex + i - 1); - solidIndices.push_back(baseVertex + numCircleVertices); - solidIndices.push_back(baseVertex + i + numCircleVertices - 1); - solidIndices.push_back(baseVertex + i + numCircleVertices); + solidIndices.push_back(baseVertex + NUM_CIRCLE_VERTICES); + solidIndices.push_back(baseVertex + i + NUM_CIRCLE_VERTICES - 1); + solidIndices.push_back(baseVertex + i + NUM_CIRCLE_VERTICES); } - for (uint32_t i = 1; i <= numCircleVertices; ++i) { - wireIndices.push_back(baseVertex + (i % numCircleVertices)); + + for (uint32_t i = 1; i <= NUM_CIRCLE_VERTICES; i++) { + wireIndices.push_back(baseVertex + (i % NUM_CIRCLE_VERTICES)); wireIndices.push_back(baseVertex + i - 1); - wireIndices.push_back(baseVertex + (i % numCircleVertices) + numCircleVertices); - wireIndices.push_back(baseVertex + (i - 1) + numCircleVertices); + wireIndices.push_back(baseVertex + (i % NUM_CIRCLE_VERTICES) + NUM_CIRCLE_VERTICES); + wireIndices.push_back(baseVertex + (i - 1) + NUM_CIRCLE_VERTICES); } shapeData.setupVertices(vertexBuffer, vertices); @@ -399,8 +400,8 @@ void GeometryCache::buildShapes() { Index baseVertex = (Index)(_shapeVertices->getSize() / SHAPE_VERTEX_STRIDE); ShapeData& shapeData = _shapes[Line]; shapeData.setupVertices(_shapeVertices, VertexVector { - vec3(-0.5, 0, 0), vec3(-0.5f, 0, 0), - vec3(0.5f, 0, 0), vec3(0.5f, 0, 0) + vec3(-0.5f, 0.0f, 0.0f), vec3(-0.5f, 0.0f, 0.0f), + vec3(0.5f, 0.0f, 0.0f), vec3(0.5f, 0.0f, 0.0f) }); IndexVector wireIndices; // Only two indices @@ -641,7 +642,7 @@ void GeometryCache::updateVertices(int id, const QVector& points, con auto pointCount = points.size(); auto colorCount = colors.size(); int compactColor = 0; - for (auto i = 0; i < pointCount; ++i) { + for (auto i = 0; i < pointCount; i++) { const auto& point = points[i]; *(vertex++) = point.x; *(vertex++) = point.y; @@ -718,7 +719,7 @@ void GeometryCache::updateVertices(int id, const QVector& points, con const glm::vec3 NORMAL(0.0f, 0.0f, 1.0f); auto pointCount = points.size(); auto colorCount = colors.size(); - for (auto i = 0; i < pointCount; ++i) { + for (auto i = 0; i < pointCount; i++) { const glm::vec3& point = points[i]; if (i < colorCount) { const glm::vec4& color = colors[i]; From 7785473ccbe3317adbf9e43516dde49b7bfc4a16 Mon Sep 17 00:00:00 2001 From: Liv Date: Fri, 9 Jun 2017 12:59:08 -0700 Subject: [PATCH 34/36] moving else --- libraries/render-utils/src/GeometryCache.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 0f50e3361d..dcf90012c1 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -269,8 +269,7 @@ void extrudePolygon(GeometryCache::ShapeData& shapeData, gpu::BufferPointer& ver vertices.push_back(vec3(0.0f, 0.5f, 0.0f)); vertices.push_back(vec3(0.0f, 1.0f, 0.0f)); } - } - else { + } else { for (const vec3& v : shape) { vertices.push_back(vec3(v.x, 0.5f, v.z)); vertices.push_back(vec3(0.0f, 1.0f, 0.0f)); From 6fe20f90a3a7181543eca834b746fb2c3b2ec48b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 8 Jun 2017 12:37:19 -0700 Subject: [PATCH 35/36] add better debugging for audio problems use OS default device if settings have no values --- interface/resources/qml/hifi/Audio.qml | 15 ++++++-- .../AudioDeviceScriptingInterface.cpp | 36 +++++++++++++++++-- libraries/audio-client/src/AudioClient.cpp | 25 ++++++++++--- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/interface/resources/qml/hifi/Audio.qml b/interface/resources/qml/hifi/Audio.qml index 66760ff290..46cec99e69 100644 --- a/interface/resources/qml/hifi/Audio.qml +++ b/interface/resources/qml/hifi/Audio.qml @@ -161,7 +161,12 @@ Rectangle { text.text: devicename onCheckBoxClicked: { if (checked) { - AudioDevice.setInputDeviceAsync(devicename) + if (devicename.length > 0) { + console.log("Audio.qml about to call AudioDevice.setInputDeviceAsync().devicename:" + devicename); + AudioDevice.setInputDeviceAsync(devicename); + } else { + console.log("Audio.qml attempted to set input device to empty device name."); + } } } } @@ -217,7 +222,13 @@ Rectangle { text.text: devicename onCheckBoxClicked: { if (checked) { - AudioDevice.setOutputDeviceAsync(devicename) + if (devicename.length > 0) { + console.log("Audio.qml about to call AudioDevice.setOutputDeviceAsync().devicename:" + devicename); + AudioDevice.setOutputDeviceAsync(devicename); + } else { + console.log("Audio.qml attempted to set output device to empty device name."); + } + } } } diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.cpp b/interface/src/scripting/AudioDeviceScriptingInterface.cpp index 05168b0d4c..d22f948344 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.cpp +++ b/interface/src/scripting/AudioDeviceScriptingInterface.cpp @@ -9,7 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "AudioClient.h" +#include +#include + #include "AudioDeviceScriptingInterface.h" #include "SettingsScriptingInterface.h" @@ -44,17 +46,23 @@ AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListMod onDeviceChanged(); //set up previously saved device SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance(); - const QString inDevice = settings->getValue("audio_input_device").toString(); + const QString inDevice = settings->getValue("audio_input_device", _currentInputDevice).toString(); if (inDevice != _currentInputDevice) { + qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << inDevice << "] _currentInputDevice:" << _currentInputDevice; setInputDeviceAsync(inDevice); } - const QString outDevice = settings->getValue("audio_output_device").toString(); + + // If the audio_output_device setting is not available, use the _currentOutputDevice + auto outDevice = settings->getValue("audio_output_device", _currentOutputDevice).toString(); if (outDevice != _currentOutputDevice) { + qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() outDevice: [" << outDevice << "] _currentOutputDevice:" << _currentOutputDevice; setOutputDeviceAsync(outDevice); } } bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; + bool result; QMetaObject::invokeMethod(DependencyManager::get().data(), "switchInputToAudioDevice", Qt::BlockingQueuedConnection, @@ -64,6 +72,9 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { } bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) { + + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; + bool result; QMetaObject::invokeMethod(DependencyManager::get().data(), "switchOutputToAudioDevice", Qt::BlockingQueuedConnection, @@ -86,8 +97,10 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN for (ScriptingAudioDeviceInfo di: _devices) { if (mode == di.mode && deviceMenuName.contains(di.name)) { if (mode == QAudio::AudioOutput) { + qCDebug(audioclient) << __FUNCTION__ << "about to call setOutputDeviceAsync() device: [" << di.name << "]"; setOutputDeviceAsync(di.name); } else { + qCDebug(audioclient) << __FUNCTION__ << "about to call setInputDeviceAsync() device: [" << di.name << "]"; setInputDeviceAsync(di.name); } return true; @@ -98,12 +111,26 @@ bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuN } void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) { + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; + + if (deviceName.isEmpty()) { + qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!"; + return; + } + QMetaObject::invokeMethod(DependencyManager::get().data(), "switchInputToAudioDevice", Qt::QueuedConnection, Q_ARG(const QString&, deviceName)); } void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) { + qCDebug(audioclient) << __FUNCTION__ << "deviceName:" << deviceName; + + if (deviceName.isEmpty()) { + qCDebug(audioclient) << __FUNCTION__ << "attempt to set empty deviceName:" << deviceName << "... ignoring!"; + return; + } + QMetaObject::invokeMethod(DependencyManager::get().data(), "switchOutputToAudioDevice", Qt::QueuedConnection, Q_ARG(const QString&, deviceName)); @@ -241,8 +268,11 @@ void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& n void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name) { currentDeviceUpdate(name, QAudio::AudioOutput); + + // FIXME - this is kinda janky to set the setting on the result of a signal //we got a signal that device changed. Save it now SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance(); + qCDebug(audioclient) << __FUNCTION__ << "about to call settings->setValue('audio_output_device', name); name:" << name; settings->setValue("audio_output_device", name); emit currentOutputDeviceChanged(name); } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index e03ca83131..f0363cd49c 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -216,7 +216,10 @@ AudioClient::AudioClient() : connect(&_receivedAudioStream, &MixedProcessedAudioStream::processSamples, this, &AudioClient::processReceivedSamples, Qt::DirectConnection); - connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); }); + connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { + qCDebug(audioclient) << "got AudioClient::changeDevice signal, about to call switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]"; + switchOutputToAudioDevice(outputDeviceInfo); + }); connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat); @@ -438,7 +441,8 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) { CoUninitialize(); } - qCDebug(audioclient) << "[" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]"; + qCDebug(audioclient) << "defaultAudioDeviceForMode mode: " << (mode == QAudio::AudioOutput ? "Output" : "Input") + << " [" << deviceName << "] [" << getNamedAudioDeviceForMode(mode, deviceName).deviceName() << "]"; return getNamedAudioDeviceForMode(mode, deviceName); #endif @@ -614,8 +618,12 @@ void AudioClient::start() { } void AudioClient::stop() { + // "switch" to invalid devices in order to shut down the state + qCDebug(audioclient) << "AudioClient::stop(), about to call switchInputToAudioDevice(null)"; switchInputToAudioDevice(QAudioDeviceInfo()); + + qCDebug(audioclient) << "AudioClient::stop(), about to call switchOutputToAudioDevice(null)"; switchOutputToAudioDevice(QAudioDeviceInfo()); } @@ -807,12 +815,12 @@ QVector AudioClient::getDeviceNames(QAudio::Mode mode) { } bool AudioClient::switchInputToAudioDevice(const QString& inputDeviceName) { - qCDebug(audioclient) << "[" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]"; + qCDebug(audioclient) << "switchInputToAudioDevice [" << inputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName).deviceName() << "]"; return switchInputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName)); } bool AudioClient::switchOutputToAudioDevice(const QString& outputDeviceName) { - qCDebug(audioclient) << "[" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]"; + qCDebug(audioclient) << "switchOutputToAudioDevice [" << outputDeviceName << "] [" << getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName).deviceName() << "]"; return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName)); } @@ -1357,6 +1365,7 @@ void AudioClient::setIsStereoInput(bool isStereoInput) { } // change in channel count for desired input format, restart the input device + qCDebug(audioclient) << __FUNCTION__ << "about to call switchInputToAudioDevice:" << _inputAudioDeviceName; switchInputToAudioDevice(_inputAudioDeviceName); } } @@ -1395,6 +1404,7 @@ void AudioClient::outputFormatChanged() { } bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) { + qCDebug(audioclient) << __FUNCTION__ << "inputDeviceInfo: [" << inputDeviceInfo.deviceName() << "]"; bool supportedFormat = false; // cleanup any previously initialized device @@ -1509,6 +1519,8 @@ void AudioClient::outputNotify() { } bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) { + qCDebug(audioclient) << "AudioClient::switchOutputToAudioDevice() outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]"; + bool supportedFormat = false; Lock localAudioLock(_localAudioMutex); @@ -1643,7 +1655,11 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice } int AudioClient::setOutputBufferSize(int numFrames, bool persist) { + qCDebug(audioclient) << __FUNCTION__ << "numFrames:" << numFrames << "persist:" << persist; + numFrames = std::min(std::max(numFrames, MIN_BUFFER_FRAMES), MAX_BUFFER_FRAMES); + qCDebug(audioclient) << __FUNCTION__ << "clamped numFrames:" << numFrames << "_sessionOutputBufferSizeFrames:" << _sessionOutputBufferSizeFrames; + if (numFrames != _sessionOutputBufferSizeFrames) { qCInfo(audioclient, "Audio output buffer set to %d frames", numFrames); _sessionOutputBufferSizeFrames = numFrames; @@ -1655,6 +1671,7 @@ int AudioClient::setOutputBufferSize(int numFrames, bool persist) { // The buffer size can't be adjusted after QAudioOutput::start() has been called, so // recreate the device by switching to the default. QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput); + qCDebug(audioclient) << __FUNCTION__ << "about to send changeDevice signal outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]"; emit changeDevice(outputDeviceInfo); // On correct thread, please, as setOutputBufferSize can be called from main thread. } } From fff8876b21154e7c260d4929e017099a88bec45c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 10 Jun 2017 09:33:45 +1200 Subject: [PATCH 36/36] Code review --- scripts/system/libraries/WebTablet.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 9a000d551e..f8f4e96f25 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -71,10 +71,12 @@ function calcSpawnInfo(hand, tabletHeight) { rotation = Quat.multiply(rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)); } var normal = Vec3.multiplyQbyV(rotation, Vec3.UNIT_NEG_Y); - var lookAt = Quat.lookAt({x: 0, y: 0, z: 0}, normal, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.UNIT_Y)); - rotation = Quat.multiply(Quat.angleAxis(30, Vec3.multiplyQbyV(lookAt, Vec3.UNIT_X)), lookAt); + var lookAt = Quat.lookAt(Vec3.ZERO, normal, Vec3.multiplyQbyV(MyAvatar.orientation, Vec3.UNIT_Y)); + var TABLET_RAKE_ANGLE = 30; + rotation = Quat.multiply(Quat.angleAxis(TABLET_RAKE_ANGLE, Vec3.multiplyQbyV(lookAt, Vec3.UNIT_X)), lookAt); - position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: tabletHeight * 0.4, z: tabletHeight * 0.05 })); + var RELATIVE_SPAWN_OFFSET = { x: 0, y: 0.4, z: 0.05 }; + position = Vec3.sum(position, Vec3.multiplyQbyV(rotation, Vec3.multiply(tabletHeight, RELATIVE_SPAWN_OFFSET))); return { position: position,