From c1c5991ac50032a2429f57488bbe09b0c445d4ce Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 12 Dec 2014 12:07:48 -0800 Subject: [PATCH 01/11] Fix for distorted replaced textures. --- interface/src/MetavoxelSystem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 87060d7dfa..002acec9ed 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -2188,13 +2188,15 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g bufferPair.second.release(); } if (_heightTextureID == 0) { + // we use non-aligned data for the various layers + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &_heightTextureID); glBindTexture(GL_TEXTURE_2D, _heightTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); const QVector& heightContents = node->getHeight()->getContents(); glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, width, height, 0, GL_RED, GL_UNSIGNED_SHORT, heightContents.constData()); @@ -2241,6 +2243,9 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, &ZERO_VALUE); } glBindTexture(GL_TEXTURE_2D, 0); + + // restore the default alignment; it's what Qt uses for image storage + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } if (cursor) { From b8737ad5257058b6edea3f1fa17514b6a0bec2a4 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:26:07 -0800 Subject: [PATCH 02/11] Update 'f' focus to only work when something is selected --- examples/editEntities.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index e9f42bf74c..fc48cf22b5 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -839,9 +839,11 @@ Controller.keyReleaseEvent.connect(function (event) { selectionDisplay.toggleSpaceMode(); } else if (event.text == "f") { if (isActive) { - cameraManager.focus(selectionManager.worldPosition, - selectionManager.worldDimensions, - Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + if (selectionManager.hasSelection()) { + cameraManager.focus(selectionManager.worldPosition, + selectionManager.worldDimensions, + Menu.isOptionChecked(MENU_EASE_ON_FOCUS)); + } } } else if (event.text == '[') { if (isActive) { From d1f5bf2e3cdf9c68229dded470df12adc90140e9 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:27:30 -0800 Subject: [PATCH 03/11] Add rotation to properties window --- examples/editEntities.js | 5 +++++ examples/html/entityProperties.html | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index fc48cf22b5..980f38f2cc 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1004,6 +1004,7 @@ PropertiesTool = function(opts) { }; if (selectionManager.hasSelection()) { data.properties = Entities.getEntityProperties(selectionManager.selections[0]); + data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation); } webView.eventBridge.emitScriptEvent(JSON.stringify(data)); }); @@ -1012,6 +1013,10 @@ PropertiesTool = function(opts) { print(data); data = JSON.parse(data); if (data.type == "update") { + if (data.properties.rotation !== undefined) { + var rotation = data.properties.rotation; + data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z); + } Entities.editEntity(selectionManager.selections[0], data.properties); selectionManager._update(); } diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 17eb0ad88f..d30aac72ee 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -85,6 +85,10 @@ var elRegistrationY = document.getElementById("property-reg-y"); var elRegistrationZ = document.getElementById("property-reg-z"); + var elRotationX = document.getElementById("property-rot-x"); + var elRotationY = document.getElementById("property-rot-y"); + var elRotationZ = document.getElementById("property-rot-z"); + var elLinearVelocityX = document.getElementById("property-lvel-x"); var elLinearVelocityY = document.getElementById("property-lvel-y"); var elLinearVelocityZ = document.getElementById("property-lvel-z"); @@ -181,6 +185,10 @@ elRegistrationY.value = properties.registrationPoint.y.toFixed(2); elRegistrationZ.value = properties.registrationPoint.z.toFixed(2); + elRotationX.value = properties.rotation.x.toFixed(2); + elRotationY.value = properties.rotation.y.toFixed(2); + elRotationZ.value = properties.rotation.z.toFixed(2); + elLinearVelocityX.value = properties.velocity.x.toFixed(2); elLinearVelocityY.value = properties.velocity.y.toFixed(2); elLinearVelocityZ.value = properties.velocity.z.toFixed(2); @@ -302,6 +310,12 @@ elRegistrationY.addEventListener('change', registrationChangeFunction); elRegistrationZ.addEventListener('change', registrationChangeFunction); + var rotationChangeFunction = createEmitVec3PropertyUpdateFunction( + 'rotation', elRotationX, elRotationY, elRotationZ); + elRotationX.addEventListener('change', rotationChangeFunction); + elRotationY.addEventListener('change', rotationChangeFunction); + elRotationZ.addEventListener('change', rotationChangeFunction); + var velocityChangeFunction = createEmitVec3PropertyUpdateFunction( 'velocity', elLinearVelocityX, elLinearVelocityY, elLinearVelocityZ); elLinearVelocityX.addEventListener('change', velocityChangeFunction); @@ -486,6 +500,15 @@ + + Rotation + +
Pitch
+
Yaw
+
Roll
+ + + Linear Velocity From 1a90a810379dd1ad196af9aeafa3792b89fa5d91 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:27:56 -0800 Subject: [PATCH 04/11] Add id to properties window --- examples/editEntities.js | 1 + examples/html/entityProperties.html | 11 +++++++++++ examples/html/style.css | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index 980f38f2cc..ea6496d4f5 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1003,6 +1003,7 @@ PropertiesTool = function(opts) { type: 'update', }; if (selectionManager.hasSelection()) { + data.id = selectionManager.selections[0].id; data.properties = Entities.getEntityProperties(selectionManager.selections[0]); data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation); } diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index d30aac72ee..a34f7ce13f 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -70,6 +70,7 @@ }; function loaded() { + var elID = document.getElementById("property-id"); var elType = document.getElementById("property-type"); var elLocked = document.getElementById("property-locked"); var elVisible = document.getElementById("property-visible"); @@ -160,6 +161,8 @@ } else { var properties = data.properties; + elID.innerHTML = data.id; + elType.innerHTML = properties.type; elLocked.checked = properties.locked; @@ -451,6 +454,14 @@ + + + ID + + + + + Type diff --git a/examples/html/style.css b/examples/html/style.css index 424933e14e..aa23cf97ab 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -17,6 +17,17 @@ body { user-select: none; } +.selectable { + -webkit-touch-callout: text; + -webkit-user-select: text; + -khtml-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; + + cursor: text; +} + .color-box { display: inline-block; width: 20px; From a5cbc9b3e2fa3aa8e3544d30dc66529c4cc785f3 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:28:22 -0800 Subject: [PATCH 05/11] Fix properties window to work with undo/redo --- examples/editEntities.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index ea6496d4f5..b671e45d7c 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1014,11 +1014,13 @@ PropertiesTool = function(opts) { print(data); data = JSON.parse(data); if (data.type == "update") { + selectionManager.saveProperties(); if (data.properties.rotation !== undefined) { var rotation = data.properties.rotation; data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z); } Entities.editEntity(selectionManager.selections[0], data.properties); + pushCommandForSelections(); selectionManager._update(); } }); From 33b4c614eae17ad3ef7c54a821e929f2ffb0ee52 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:28:57 -0800 Subject: [PATCH 06/11] Add buttons for moving selection to grid and resetting to natural dimensions --- examples/editEntities.js | 48 +++++++++++++++++++++++++++++ examples/html/entityProperties.html | 29 +++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/examples/editEntities.js b/examples/editEntities.js index b671e45d7c..3f133ac0b2 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1022,6 +1022,54 @@ PropertiesTool = function(opts) { Entities.editEntity(selectionManager.selections[0], data.properties); pushCommandForSelections(); selectionManager._update(); + } else if (data.type == "action") { + if (data.action == "moveSelectionToGrid") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), + var diff = { x: 0, y: dY, z: 0 }; + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(SelectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } else if (data.action == "moveAllToGrid") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; + var dY = grid.getOrigin().y - bottomY; + var diff = { x: 0, y: dY, z: 0 }; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(SelectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } else if (data.action == "resetToNaturalDimensions") { + if (!selectionManager.hasSelection()) { + return; + } + selectionManager.saveProperties(); + for (var i = 0; i < SelectionManager.selections.length; i++) { + var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + Entities.editEntity(SelectionManager.selections[i], { + dimensions: properties.naturalDimensions, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } } }); diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index a34f7ce13f..48804d475a 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -77,10 +77,13 @@ var elPositionX = document.getElementById("property-pos-x"); var elPositionY = document.getElementById("property-pos-y"); var elPositionZ = document.getElementById("property-pos-z"); + var elMoveSelectionToGrid = document.getElementById("move-selection-to-grid"); + var elMoveAllToGrid = document.getElementById("move-all-to-grid"); var elDimensionsX = document.getElementById("property-dim-x"); var elDimensionsY = document.getElementById("property-dim-y"); var elDimensionsZ = document.getElementById("property-dim-z"); + var elResetToNaturalDimensions = document.getElementById("reset-to-natural-dimensions"); var elRegistrationX = document.getElementById("property-reg-x"); var elRegistrationY = document.getElementById("property-reg-y"); @@ -398,6 +401,25 @@ elTextBackgroundColorGreen.addEventListener('change', textBackgroundColorChangeFunction); elTextBackgroundColorBlue.addEventListener('change', textBackgroundColorChangeFunction); + elMoveSelectionToGrid.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "moveSelectionToGrid", + })); + }); + elMoveAllToGrid.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "moveAllToGrid", + })); + }); + elResetToNaturalDimensions.addEventListener("click", function() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "action", + action: "resetToNaturalDimensions", + })); + }); + var resizing = false; var startX = 0; @@ -490,6 +512,10 @@
X
Y
Z
+
+ + +
@@ -508,6 +534,9 @@
X
Y
Z
+
+ +
From dde9b92dbd4a02d630f171a7f1d72dea36236a88 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:31:54 -0800 Subject: [PATCH 07/11] Update SelectionManager -> selectionManager --- examples/editEntities.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 3f133ac0b2..c2f2ad4086 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1030,10 +1030,10 @@ PropertiesTool = function(opts) { selectionManager.saveProperties(); var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), var diff = { x: 0, y: dY, z: 0 }; - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(SelectionManager.selections[i], { + Entities.editEntity(selectionManager.selections[i], { position: newPosition, }); } @@ -1044,13 +1044,13 @@ PropertiesTool = function(opts) { return; } selectionManager.saveProperties(); - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; var dY = grid.getOrigin().y - bottomY; var diff = { x: 0, y: dY, z: 0 }; var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(SelectionManager.selections[i], { + Entities.editEntity(selectionManager.selections[i], { position: newPosition, }); } @@ -1061,9 +1061,9 @@ PropertiesTool = function(opts) { return; } selectionManager.saveProperties(); - for (var i = 0; i < SelectionManager.selections.length; i++) { - var properties = SelectionManager.savedProperties[SelectionManager.selections[i].id]; - Entities.editEntity(SelectionManager.selections[i], { + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + Entities.editEntity(selectionManager.selections[i], { dimensions: properties.naturalDimensions, }); } From 2fab404f7fee8c04a0fe3ce2e8a117cb00a57b37 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:35:39 -0800 Subject: [PATCH 08/11] Reorganize selectionManager selection checking --- examples/editEntities.js | 79 +++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index c2f2ad4086..0b5c089c07 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -1024,51 +1024,48 @@ PropertiesTool = function(opts) { selectionManager._update(); } else if (data.type == "action") { if (data.action == "moveSelectionToGrid") { - if (!selectionManager.hasSelection()) { - return; - } - selectionManager.saveProperties(); - var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), - var diff = { x: 0, y: dY, z: 0 }; - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(selectionManager.selections[i], { - position: newPosition, - }); - } - pushCommandForSelections(); - selectionManager._update(); - } else if (data.action == "moveAllToGrid") { - if (!selectionManager.hasSelection()) { - return; - } - selectionManager.saveProperties(); - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; - var dY = grid.getOrigin().y - bottomY; + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2), var diff = { x: 0, y: dY, z: 0 }; - var newPosition = Vec3.sum(properties.position, diff); - Entities.editEntity(selectionManager.selections[i], { - position: newPosition, - }); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(selectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); + } + } else if (data.action == "moveAllToGrid") { + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2; + var dY = grid.getOrigin().y - bottomY; + var diff = { x: 0, y: dY, z: 0 }; + var newPosition = Vec3.sum(properties.position, diff); + Entities.editEntity(selectionManager.selections[i], { + position: newPosition, + }); + } + pushCommandForSelections(); + selectionManager._update(); } - pushCommandForSelections(); - selectionManager._update(); } else if (data.action == "resetToNaturalDimensions") { - if (!selectionManager.hasSelection()) { - return; + if (selectionManager.hasSelection()) { + selectionManager.saveProperties(); + for (var i = 0; i < selectionManager.selections.length; i++) { + var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; + Entities.editEntity(selectionManager.selections[i], { + dimensions: properties.naturalDimensions, + }); + } + pushCommandForSelections(); + selectionManager._update(); } - selectionManager.saveProperties(); - for (var i = 0; i < selectionManager.selections.length; i++) { - var properties = selectionManager.savedProperties[selectionManager.selections[i].id]; - Entities.editEntity(selectionManager.selections[i], { - dimensions: properties.naturalDimensions, - }); - } - pushCommandForSelections(); - selectionManager._update(); } } }); From a9223f58879f2afbb3cef72ffc4181b24a61dbb2 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 12 Dec 2014 15:45:31 -0800 Subject: [PATCH 09/11] Remove text from label --- examples/html/entityProperties.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 48804d475a..4e22637ad6 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -481,7 +481,7 @@ ID - + From d28e274876491a7e0f5f4c05254294e9179c5cf7 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Dec 2014 07:43:40 -0800 Subject: [PATCH 10/11] fix warning --- interface/src/Application.h | 2 ++ interface/src/voxels/VoxelSystem.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index f82b14b47e..1b51b99e77 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -12,6 +12,8 @@ #ifndef hifi_Application_h #define hifi_Application_h +// testing + #include #include diff --git a/interface/src/voxels/VoxelSystem.cpp b/interface/src/voxels/VoxelSystem.cpp index 2f4fd3f0fa..67f3d585ea 100644 --- a/interface/src/voxels/VoxelSystem.cpp +++ b/interface/src/voxels/VoxelSystem.cpp @@ -874,7 +874,6 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo if (node->getShouldRender()) { glm::vec3 startVertex = node->getCorner(); float voxelScale = node->getScale(); - nodeColor const & color = node->getColor(); glBufferIndex nodeIndex = GLBUFFER_INDEX_UNKNOWN; if (reuseIndex && node->isKnownBufferIndex()) { From 31db2188cb0f77060b070c0a485b05887dc84101 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Dec 2014 07:58:13 -0800 Subject: [PATCH 11/11] remove test comment --- interface/src/Application.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 1b51b99e77..f82b14b47e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -12,8 +12,6 @@ #ifndef hifi_Application_h #define hifi_Application_h -// testing - #include #include