From c0ac9333e90314d3ab45cbe5ed31e1547d8586a8 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 4 Feb 2015 23:04:06 -0800 Subject: [PATCH 1/7] Don't hide mouse events from C++ GUI --- examples/lookWithMouse.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 2fe12cce24..70a98c0733 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -80,14 +80,6 @@ Controller.mousePressEvent.connect(mousePressEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); Controller.mouseReleaseEvent.connect(mouseReleaseEvent); -// disable the standard application for mouse events -Controller.captureMouseEvents(); - -function scriptEnding() { - // re-enabled the standard application for mouse events - Controller.releaseMouseEvents(); -} - MyAvatar.bodyYaw = 0; MyAvatar.bodyPitch = 0; MyAvatar.bodyRoll = 0; From b4da2ddd52b67a18997e123af7eaaab6b228ea48 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 5 Feb 2015 09:13:32 -0800 Subject: [PATCH 2/7] fix physics crash on disconnect from domainserver --- libraries/physics/src/PhysicsEngine.cpp | 15 ++++++++++----- libraries/physics/src/PhysicsEngine.h | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 7e40d13cad..461d15114c 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -86,7 +86,7 @@ void PhysicsEngine::removeEntityInternal(EntityItem* entity) { if (physicsInfo) { EntityMotionState* motionState = static_cast(physicsInfo); if (motionState->getRigidBody()) { - removeObject(motionState); + removeObjectFromBullet(motionState); } else { // only need to hunt in this list when there is no RigidBody _nonPhysicalKinematicObjects.remove(motionState); @@ -130,7 +130,7 @@ void PhysicsEngine::clearEntitiesInternal() { // For now we assume this would only be called on shutdown in which case we can just let the memory get lost. QSet::const_iterator stateItr = _entityMotionStates.begin(); for (stateItr = _entityMotionStates.begin(); stateItr != _entityMotionStates.end(); ++stateItr) { - removeObject(*stateItr); + removeObjectFromBullet(*stateItr); delete (*stateItr); } _entityMotionStates.clear(); @@ -211,6 +211,9 @@ void PhysicsEngine::relayIncomingChangesToSimulation() { if (removeMotionState) { // if we get here then there is no need to keep this motionState around (no physics or kinematics) _outgoingPackets.remove(motionState); + if (motionState->getType() == MOTION_STATE_TYPE_ENTITY) { + _entityMotionStates.remove(static_cast(motionState)); + } // NOTE: motionState will clean up its own backpointers in the Object delete motionState; continue; @@ -455,7 +458,7 @@ void PhysicsEngine::addObject(const ShapeInfo& shapeInfo, btCollisionShape* shap _dynamicsWorld->addRigidBody(body); } -void PhysicsEngine::removeObject(ObjectMotionState* motionState) { +void PhysicsEngine::removeObjectFromBullet(ObjectMotionState* motionState) { assert(motionState); btRigidBody* body = motionState->getRigidBody(); if (body) { @@ -464,8 +467,9 @@ void PhysicsEngine::removeObject(ObjectMotionState* motionState) { ShapeInfoUtil::collectInfoFromShape(shape, shapeInfo); _dynamicsWorld->removeRigidBody(body); _shapeManager.releaseShape(shapeInfo); - delete body; + // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. motionState->setRigidBody(NULL); + delete body; motionState->setKinematic(false, _numSubsteps); removeContacts(motionState); @@ -492,8 +496,9 @@ bool PhysicsEngine::updateObjectHard(btRigidBody* body, ObjectMotionState* motio // FAIL! we are unable to support these changes! _shapeManager.releaseShape(oldShape); - delete body; + // NOTE: setRigidBody() modifies body->m_userPointer so we should clear the MotionState's body BEFORE deleting it. motionState->setRigidBody(NULL); + delete body; motionState->setKinematic(false, _numSubsteps); removeContacts(motionState); return false; diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index 993b4aeade..2a7baa3ec6 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -79,13 +79,13 @@ public: /// \return true if Object added void addObject(const ShapeInfo& shapeInfo, btCollisionShape* shape, ObjectMotionState* motionState); - /// \param motionState pointer to Object's MotionState - void removeObject(ObjectMotionState* motionState); - /// process queue of changed from external sources void relayIncomingChangesToSimulation(); private: + /// \param motionState pointer to Object's MotionState + void removeObjectFromBullet(ObjectMotionState* motionState); + void removeContacts(ObjectMotionState* motionState); // return 'true' of update was successful From 41720dbc4b0ca9f29fe1d8ef8702a1f5f00523cd Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Feb 2015 10:07:31 -0800 Subject: [PATCH 3/7] Add drag-drop functionality for placing entities --- examples/editEntities.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index 220f10dffa..de8b0a29f5 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -94,6 +94,7 @@ var modelURLs = [ var mode = 0; var isActive = false; +var placingEntityID = null; var toolBar = (function () { var that = {}, @@ -363,7 +364,7 @@ var toolBar = (function () { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE)); if (position.x > 0 && position.y > 0 && position.z > 0) { - Entities.addEntity({ + placingEntityID = Entities.addEntity({ type: "Box", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), dimensions: DEFAULT_DIMENSIONS, @@ -380,7 +381,7 @@ var toolBar = (function () { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE)); if (position.x > 0 && position.y > 0 && position.z > 0) { - Entities.addEntity({ + placingEntityID = Entities.addEntity({ type: "Sphere", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), dimensions: DEFAULT_DIMENSIONS, @@ -396,7 +397,7 @@ var toolBar = (function () { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE)); if (position.x > 0 && position.y > 0 && position.z > 0) { - Entities.addEntity({ + placingEntityID = Entities.addEntity({ type: "Light", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), dimensions: DEFAULT_DIMENSIONS, @@ -421,7 +422,7 @@ var toolBar = (function () { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE)); if (position.x > 0 && position.y > 0 && position.z > 0) { - Entities.addEntity({ + placingEntityID = Entities.addEntity({ type: "Text", position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS), dimensions: { x: 0.5, y: 0.3, z: 0.01 }, @@ -535,6 +536,18 @@ var idleMouseTimerId = null; var IDLE_MOUSE_TIMEOUT = 200; function mouseMoveEvent(event) { + if (placingEntityID) { + if (!placingEntityID.isKnownID) { + placingEntityID = Entities.identifyEntity(placingEntityID); + } + var pickRay = Camera.computePickRay(event.x, event.y); + var offset = Vec3.multiply(cameraManager.zoomDistance, pickRay.direction); + var position = Vec3.sum(Camera.position, offset); + Entities.editEntity(placingEntityID, { + position: position, + }); + return; + } if (!isActive) { return; } @@ -590,6 +603,10 @@ function highlightEntityUnderCursor(position, accurateRay) { function mouseReleaseEvent(event) { + if (placingEntityID) { + selectionManager.setSelections([placingEntityID]); + placingEntityID = null; + } if (isActive && selectionManager.hasSelection()) { tooltip.show(false); } From 2343da0a8ac15e9d1f7a79147f461b4d525369f6 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Feb 2015 10:16:51 -0800 Subject: [PATCH 4/7] Update drag/drop distance while in non-independent mode --- examples/editEntities.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index de8b0a29f5..ac6fce205a 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -534,6 +534,7 @@ var mouseCapturedByTool = false; var lastMousePosition = null; var idleMouseTimerId = null; var IDLE_MOUSE_TIMEOUT = 200; +var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0; function mouseMoveEvent(event) { if (placingEntityID) { @@ -541,7 +542,8 @@ function mouseMoveEvent(event) { placingEntityID = Entities.identifyEntity(placingEntityID); } var pickRay = Camera.computePickRay(event.x, event.y); - var offset = Vec3.multiply(cameraManager.zoomDistance, pickRay.direction); + var distance = Camera.mode == "independent" ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE; + var offset = Vec3.multiply(distance, pickRay.direction); var position = Vec3.sum(Camera.position, offset); Entities.editEntity(placingEntityID, { position: position, From 1e11e658a809aa755ba2d5543ae2e70914ac0801 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Feb 2015 10:18:34 -0800 Subject: [PATCH 5/7] Update drag/drop distance to be based on cameraManager.enabled rather than camera mode --- examples/editEntities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/editEntities.js b/examples/editEntities.js index ac6fce205a..d73c6fa6e7 100644 --- a/examples/editEntities.js +++ b/examples/editEntities.js @@ -542,7 +542,7 @@ function mouseMoveEvent(event) { placingEntityID = Entities.identifyEntity(placingEntityID); } var pickRay = Camera.computePickRay(event.x, event.y); - var distance = Camera.mode == "independent" ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE; + var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE; var offset = Vec3.multiply(distance, pickRay.direction); var position = Vec3.sum(Camera.position, offset); Entities.editEntity(placingEntityID, { From 850de6e67ecb008c1070819057c810501d188b89 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Feb 2015 11:19:01 -0800 Subject: [PATCH 6/7] Add User Data to entity properties panel --- examples/html/entityProperties.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index a671325e39..cee7f578e5 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -119,6 +119,7 @@ var elCollisionsWillMove = document.getElementById("property-collisions-will-move"); var elLifetime = document.getElementById("property-lifetime"); var elScriptURL = document.getElementById("property-script-url"); + var elUserData = document.getElementById("property-user-data"); var elBoxSections = document.querySelectorAll(".box-section"); var elBoxColorRed = document.getElementById("property-box-red"); @@ -224,6 +225,7 @@ elCollisionsWillMove.checked = properties.collisionsWillMove; elLifetime.value = properties.lifetime; elScriptURL.value = properties.script; + elUserData.value = properties.userData; if (properties.type != "Box") { for (var i = 0; i < elBoxSections.length; i++) { @@ -361,6 +363,7 @@ elCollisionsWillMove.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionsWillMove')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script')); + elUserData.addEventListener('change', createEmitTextPropertyUpdateFunction('userData')); var boxColorChangeFunction = createEmitColorPropertyUpdateFunction( 'color', elBoxColorRed, elBoxColorGreen, elBoxColorBlue); @@ -593,6 +596,13 @@ +
+
User Data
+
+ +
+
+
Color
From 6863895533c987ff5f487dc3d89dbdeedf23e7f7 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 5 Feb 2015 11:19:18 -0800 Subject: [PATCH 7/7] Remove value from animation settings textarea --- 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 cee7f578e5..08fbb1cea8 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -648,7 +648,7 @@
Animation Settings
- +