From 7a3443968d5547a0e69c9384c41373390344f845 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 16 Feb 2016 15:55:11 -0800 Subject: [PATCH 01/11] added collides with property --- examples/html/entityProperties.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 4b4c5a398e..1dfd5643bc 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -264,6 +264,7 @@ var elCollisionless = document.getElementById("property-collisionless"); var elDynamic = document.getElementById("property-dynamic" ); var elCollisionSoundURL = document.getElementById("property-collision-sound-url"); + var elCollidesWith = document.getElementById("property-collides-with"); var elLifetime = document.getElementById("property-lifetime"); var elScriptURL = document.getElementById("property-script-url"); var elScriptTimestamp = document.getElementById("property-script-timestamp"); @@ -482,6 +483,7 @@ elCollisionless.checked = properties.collisionless; elDynamic.checked = properties.dynamic; elCollisionSoundURL.value = properties.collisionSoundURL; + elCollidesWith.value = properties.collidesWith; elLifetime.value = properties.lifetime; elScriptURL.value = properties.script; elScriptTimestamp.value = properties.scriptTimestamp; @@ -703,6 +705,7 @@ elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); + elCollidesWith.addEventListener('change', createEmitTextPropertyUpdateFunction('collidesWith')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script')); @@ -1386,6 +1389,13 @@ +
+
collidesWith
+
+ +
+
+
Collision Sound URL
From 168fb67d675971e9133d76de8ba26db9b5f3fc77 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 16 Feb 2016 18:19:12 -0800 Subject: [PATCH 02/11] making collidesWith a checkbox --- examples/html/entityProperties.html | 49 ++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 1dfd5643bc..c4a46d2fa5 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -264,7 +264,6 @@ var elCollisionless = document.getElementById("property-collisionless"); var elDynamic = document.getElementById("property-dynamic" ); var elCollisionSoundURL = document.getElementById("property-collision-sound-url"); - var elCollidesWith = document.getElementById("property-collides-with"); var elLifetime = document.getElementById("property-lifetime"); var elScriptURL = document.getElementById("property-script-url"); var elScriptTimestamp = document.getElementById("property-script-timestamp"); @@ -483,7 +482,6 @@ elCollisionless.checked = properties.collisionless; elDynamic.checked = properties.dynamic; elCollisionSoundURL.value = properties.collisionSoundURL; - elCollidesWith.value = properties.collidesWith; elLifetime.value = properties.lifetime; elScriptURL.value = properties.script; elScriptTimestamp.value = properties.scriptTimestamp; @@ -705,7 +703,6 @@ elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); - elCollidesWith.addEventListener('change', createEmitTextPropertyUpdateFunction('collidesWith')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script')); @@ -1389,12 +1386,48 @@
-
-
collidesWith
-
- +
+
collidesWith
+ +
+ Static + + +
-
+ +
+ dynamic + + + +
+ +
+ kinematic + + + +
+ +
+ myAvatar + + + +
+ +
+ otherAvatar + + + +
+ + + + +
Collision Sound URL
From 0f8f67ef0b6a1be1b4c3f774958eb47b033ef559 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 16 Feb 2016 19:34:32 -0800 Subject: [PATCH 03/11] removing dynamic. need to add others --- examples/html/entityProperties.html | 49 ++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index c4a46d2fa5..f738925240 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -47,6 +47,17 @@ ); }; } + + function createEmitCheckedToStringPropertyUpdateFunction(checkboxElement, name, propertyName) { + var newString = ""; + if (checkboxElement.checked) { + newString += name + ""; + } else { + + } + + } + function createEmitGroupCheckedPropertyUpdateFunction(group, propertyName) { return function () { var properties = {}; @@ -263,6 +274,11 @@ var elDensity = document.getElementById("property-density"); var elCollisionless = document.getElementById("property-collisionless"); var elDynamic = document.getElementById("property-dynamic" ); + var elCollideStatic = document.getElementById("property-collide-static"); + var elCollideDynamic = document.getElementById("property-collide-dynamic"); + var elCollideKinematic = document.getElementById("property-collide-kinematic"); + var elCollideMyAvatar = document.getElementById("property-collide-myAvatar"); + var elCollideOtherAvatar = document.getElementById("property-collide-otherAvatar"); var elCollisionSoundURL = document.getElementById("property-collision-sound-url"); var elLifetime = document.getElementById("property-lifetime"); var elScriptURL = document.getElementById("property-script-url"); @@ -378,6 +394,7 @@ var elPreviewCameraButton = document.getElementById("preview-camera-button"); if (window.EventBridge !== undefined) { + var properties; EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "update") { @@ -419,7 +436,7 @@ var selected = false; } - var properties = data.selections[0].properties; + properties = data.selections[0].properties; elID.innerHTML = properties.id; @@ -433,6 +450,7 @@ } else { enableChildren(document.getElementById("properties-list"), 'input'); } + elName.value = properties.name; @@ -481,6 +499,16 @@ elDensity.value = properties.density.toFixed(4); elCollisionless.checked = properties.collisionless; elDynamic.checked = properties.dynamic; + + + + elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1; + elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1; + elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1; + elCollideMyAvatar.checked = properties.collidesWith.indexOf("myAvatar") > -1; + elCollideOtherAvatar.checked = properties.collidesWith.indexOf("otherAvatar") > -1; + + elCollisionSoundURL.value = properties.collisionSoundURL; elLifetime.value = properties.lifetime; elScriptURL.value = properties.script; @@ -702,6 +730,25 @@ elDensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('density')); elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); + + elCollideDynamic.addEventListener('change', function() { + if (elCollideDynamic.checked) { + if (properties.collidesWith.indexOf('dynamic') === -1) { + // We just added dynamic to list + properties.collidesWith += "dynamic," + console.log("Just added dynamic"); + } + } else { + // We've unchecked, so remove + properties.collidesWith = properties.collidesWith.replace("dynamic,", ""); + console.log("WE REMOVED SHIT"); + } + debugger + + + }); + + elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); From f85916e8083ba1425afae190dd93dd1c974378b2 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 17 Feb 2016 10:27:53 -0800 Subject: [PATCH 04/11] checkbox keeps getting checked... --- examples/edit.js | 1 + examples/html/entityProperties.html | 47 +++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index 6d170ab254..e89ad24a9c 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1542,6 +1542,7 @@ PropertiesTool = function(opts) { print(data.message); } } else if (data.type == "update") { + print("EBL WE GOT AN UPDATE! " + JSON.stringify(data)) selectionManager.saveProperties(); if (selectionManager.selections.length > 1) { properties = { diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index f738925240..0ae8e07807 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -731,21 +731,44 @@ elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); - elCollideDynamic.addEventListener('change', function() { - if (elCollideDynamic.checked) { - if (properties.collidesWith.indexOf('dynamic') === -1) { - // We just added dynamic to list - properties.collidesWith += "dynamic," - console.log("Just added dynamic"); + + function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) { + console.log("UPDATE CHECKED PROP") + if (subPropertyElement.checked) { + if (propertyValue.indexOf(subPropertyString)) { + propertyValue += subPropertyString + ','; } } else { - // We've unchecked, so remove - properties.collidesWith = properties.collidesWith.replace("dynamic,", ""); - console.log("WE REMOVED SHIT"); + // We've unchecked, so remove + propertyValue = propertyValue.replace(subPropertyString + ",", ""); } - debugger - - + + EventBridge.emitWebEvent( + JSON.stringify({ + type: "update", + properties: {propertyName: propertyValue} + }) + ); + + } + + + elCollideDynamic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic'); + }); + + elCollideKinematic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideKinematic, 'kinematic'); + }); + + elCollideStatic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideStatic, 'static'); + }); + elCollideMyAvatar.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideMyAvatar, 'myAvatar'); + }); + elCollideOtherAvatar.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideOtherAvatar, 'otherAvatar'); }); From 94fdf6b091efbc680f696454433a539d810414b3 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 17 Feb 2016 11:59:14 -0800 Subject: [PATCH 05/11] checkboxes working --- examples/html/entityProperties.html | 9 ++++++--- examples/libraries/entityList.js | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 0ae8e07807..502daa18fa 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -501,7 +501,7 @@ elDynamic.checked = properties.dynamic; - + console.log('STARTCHECK', properties.collidesWith) elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1; elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1; elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1; @@ -743,17 +743,20 @@ propertyValue = propertyValue.replace(subPropertyString + ",", ""); } + var _properties ={} + _properties[propertyName] = propertyValue; + EventBridge.emitWebEvent( JSON.stringify({ type: "update", - properties: {propertyName: propertyValue} + properties: _properties }) ); } - elCollideDynamic.addEventListener('change', function() { + console.log("CHANGE!") updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic'); }); diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index b37ba58737..6c6c0aaecb 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -8,12 +8,16 @@ EntityListTool = function(opts) { title: 'Entities', source: url, toolWindow: true }); + + var searchRadius = 100; var visible = false; webView.setVisible(visible); + that.webView = webView; + that.setVisible = function(newVisible) { visible = newVisible; webView.setVisible(visible); @@ -71,6 +75,7 @@ EntityListTool = function(opts) { webView.eventBridge.emitScriptEvent(JSON.stringify(data)); } + webView.eventBridge.webEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "selectionUpdate") { From 69caf1df4d5f3e9bff615e0a56d264c3f4aa955c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 17 Feb 2016 12:04:25 -0800 Subject: [PATCH 06/11] fix far-trigger --- examples/controllers/handControllerGrab.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 92dc86ee02..efb149b201 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -921,7 +921,8 @@ function MyController(hand) { continue; } - if (this.state == STATE_SEARCHING && !isPhysical && distance > NEAR_PICK_MAX_DISTANCE && !near) { + if (this.state == STATE_SEARCHING && + !isPhysical && distance > NEAR_PICK_MAX_DISTANCE && !near && !grabbableDataForCandidate.wantsTrigger) { // we can't distance-grab non-physical if (WANT_DEBUG_SEARCH_NAME && propsForCandidate.name == WANT_DEBUG_SEARCH_NAME) { print("grab is skipping '" + WANT_DEBUG_SEARCH_NAME + "': not physical and too far for near-grab"); @@ -1543,11 +1544,13 @@ function MyController(hand) { var now = Date.now(); if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) { var intersection = Entities.findRayIntersection(pickRay, true); - this.lastPickTime = now; - if (intersection.entityID != this.grabbedEntity) { - this.setState(STATE_RELEASE); - this.callEntityMethodOnGrabbed("stopFarTrigger"); - return; + if (intersection.accurate) { + this.lastPickTime = now; + if (intersection.entityID != this.grabbedEntity) { + this.setState(STATE_RELEASE); + this.callEntityMethodOnGrabbed("stopFarTrigger"); + return; + } } } From 64e50c532938b75980adc428be4b0e16482ba4ef Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 17 Feb 2016 12:35:23 -0800 Subject: [PATCH 07/11] keep search-line from freezing during a far-trigger --- examples/controllers/handControllerGrab.js | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index efb149b201..e53e2ad59c 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -478,6 +478,25 @@ function MyController(hand) { } }; + this.searchIndicatorOn = function(handPosition, distantPickRay) { + var SEARCH_SPHERE_SIZE = 0.011; + var SEARCH_SPHERE_FOLLOW_RATE = 0.50; + + if (this.intersectionDistance > 0) { + // If we hit something with our pick ray, move the search sphere toward that distance + this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE + + this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE); + } + + var searchSphereLocation = Vec3.sum(distantPickRay.origin, + Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); + this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, + (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); + if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { + this.overlayLineOn(handPosition, searchSphereLocation, + (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); + } + } this.handleDistantParticleBeam = function(handPosition, objectPosition, color) { @@ -1006,24 +1025,7 @@ function MyController(hand) { this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); } - var SEARCH_SPHERE_SIZE = 0.011; - var SEARCH_SPHERE_FOLLOW_RATE = 0.50; - - if (this.intersectionDistance > 0) { - // If we hit something with our pick ray, move the search sphere toward that distance - this.searchSphereDistance = this.searchSphereDistance * SEARCH_SPHERE_FOLLOW_RATE + - this.intersectionDistance * (1.0 - SEARCH_SPHERE_FOLLOW_RATE); - } - - var searchSphereLocation = Vec3.sum(distantPickRay.origin, - Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); - this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, - (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); - if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) { - this.overlayLineOn(handPosition, searchSphereLocation, - (this.triggerSmoothedGrab() || this.bumperSqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR); - } - + this.searchIndicatorOn(handPosition, distantPickRay); Controller.setReticleVisible(false); }; @@ -1551,12 +1553,13 @@ function MyController(hand) { this.callEntityMethodOnGrabbed("stopFarTrigger"); return; } + if (intersection.intersects) { + this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); + } + this.searchIndicatorOn(handPosition, pickRay); } } - if (USE_ENTITY_LINES_FOR_MOVING === true) { - this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); - } this.callEntityMethodOnGrabbed("continueFarTrigger"); }; From 19cd3ec15290ee39c003b1dfa15367e76330e0f1 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 17 Feb 2016 13:12:17 -0800 Subject: [PATCH 08/11] checkboxes working --- examples/edit.js | 1 - examples/html/entityProperties.html | 118 ++++++++++++++-------------- examples/html/style.css | 4 + 3 files changed, 62 insertions(+), 61 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index e89ad24a9c..6d170ab254 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1542,7 +1542,6 @@ PropertiesTool = function(opts) { print(data.message); } } else if (data.type == "update") { - print("EBL WE GOT AN UPDATE! " + JSON.stringify(data)) selectionManager.saveProperties(); if (selectionManager.selections.length > 1) { properties = { diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 502daa18fa..71c7aa0449 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -218,6 +218,28 @@ } }; + function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) { + if (subPropertyElement.checked) { + if (propertyValue.indexOf(subPropertyString)) { + propertyValue += subPropertyString + ','; + } + } else { + // We've unchecked, so remove + propertyValue = propertyValue.replace(subPropertyString + ",", ""); + } + + var _properties ={} + _properties[propertyName] = propertyValue; + + EventBridge.emitWebEvent( + JSON.stringify({ + type: "update", + properties: _properties + }) + ); + + } + function loaded() { openEventBridge(function() { var allSections = []; @@ -501,7 +523,6 @@ elDynamic.checked = properties.dynamic; - console.log('STARTCHECK', properties.collidesWith) elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1; elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1; elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1; @@ -732,31 +753,9 @@ elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); - function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) { - console.log("UPDATE CHECKED PROP") - if (subPropertyElement.checked) { - if (propertyValue.indexOf(subPropertyString)) { - propertyValue += subPropertyString + ','; - } - } else { - // We've unchecked, so remove - propertyValue = propertyValue.replace(subPropertyString + ",", ""); - } - var _properties ={} - _properties[propertyName] = propertyValue; - - EventBridge.emitWebEvent( - JSON.stringify({ - type: "update", - properties: _properties - }) - ); - - } elCollideDynamic.addEventListener('change', function() { - console.log("CHANGE!") updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic'); }); @@ -1459,46 +1458,45 @@
-
-
collidesWith
+ +
Collides With:
+
+
+ Static + + + +
-
- Static - - - +
+ dynamic + + + +
+ +
+ kinematic + + + +
+ +
+ myAvatar + + + +
+ +
+ otherAvatar + + + +
-
- dynamic - - - -
- -
- kinematic - - - -
- -
- myAvatar - - - -
- -
- otherAvatar - - - -
- - -
diff --git a/examples/html/style.css b/examples/html/style.css index 5b794cbfec..83982dab15 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -263,6 +263,10 @@ table#properties-list { border-bottom: 0.75pt solid #e5e5e5; } +.sub-props-checkbox-group { + margin-left: 20px; +} + #properties-list .label { font-weight: bold; overflow: hidden; From af1640ac4edab1ae387b21cb3b8156fb26b6313d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 17 Feb 2016 14:36:18 -0800 Subject: [PATCH 09/11] adjust avatar-energy code to avoid editing local tree and then not telling the entity-server about it --- .../entities/src/EntityScriptingInterface.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index f3a25b2c9c..d7a47136b5 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -133,11 +133,8 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties float cost = calculateCost(density * volume, 0, newVelocity); cost *= costMultiplier; - if(cost > _currentAvatarEnergy) { + if (cost > _currentAvatarEnergy) { return QUuid(); - } else { - //debit the avatar energy and continue - emit debitEnergySource(cost); } EntityItemID id = EntityItemID(QUuid::createUuid()); @@ -173,6 +170,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties // queue the packet if (success) { + emit debitEnergySource(cost); queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID); } @@ -232,7 +230,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& scriptSideProperties) { EntityItemProperties properties = scriptSideProperties; - + auto dimensions = properties.getDimensions(); float volume = dimensions.x * dimensions.y * dimensions.z; auto density = properties.getDensity(); @@ -242,18 +240,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& EntityItemID entityID(id); if (!_entityTree) { queueEntityMessage(PacketType::EntityEdit, entityID, properties); - + //if there is no local entity entity tree, no existing velocity, use 0. float cost = calculateCost(density * volume, oldVelocity, newVelocity); cost *= costMultiplier; - - if(cost > _currentAvatarEnergy) { + + if (cost > _currentAvatarEnergy) { return QUuid(); } else { //debit the avatar energy and continue emit debitEnergySource(cost); } - + return id; } // If we have a local entity tree set, then also update it. @@ -268,8 +266,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& return; } //existing entity, retrieve old velocity for check down below - oldVelocity = entity->getVelocity().length(); - + oldVelocity = entity->getVelocity().length(); + if (!scriptSideProperties.parentIDChanged()) { properties.setParentID(entity->getParentID()); } @@ -284,16 +282,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& } } properties = convertLocationFromScriptSemantics(properties); - updatedEntity = _entityTree->updateEntity(entityID, properties); float cost = calculateCost(density * volume, oldVelocity, newVelocity); cost *= costMultiplier; - - if(cost > _currentAvatarEnergy) { + + if (cost > _currentAvatarEnergy) { updatedEntity = false; } else { //debit the avatar energy and continue - emit debitEnergySource(cost); + updatedEntity = _entityTree->updateEntity(entityID, properties); + if (updatedEntity) { + emit debitEnergySource(cost); + } } }); @@ -370,15 +370,16 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { _entityTree->withWriteLock([&] { EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); if (entity) { - + auto dimensions = entity->getDimensions(); float volume = dimensions.x * dimensions.y * dimensions.z; auto density = entity->getDensity(); auto velocity = entity->getVelocity().length(); float cost = calculateCost(density * volume, velocity, 0); cost *= costMultiplier; - - if(cost > _currentAvatarEnergy) { + + if (cost > _currentAvatarEnergy) { + shouldDelete = false; return; } else { //debit the avatar energy and continue From 89039747a29cd3868e376b6244955ce1371aedfc Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 17 Feb 2016 16:22:14 -0800 Subject: [PATCH 10/11] Update entityProperties.html lowercase 'static' like other props --- examples/html/entityProperties.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 71c7aa0449..c5957fc27e 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -1462,7 +1462,7 @@
Collides With:
- Static + static @@ -1698,4 +1698,4 @@
- \ No newline at end of file + From 5f5af9c6a003ad9d9356e28a0371a4f6bbc8c642 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 17 Feb 2016 17:45:57 -0800 Subject: [PATCH 11/11] fixed edit bug --- examples/html/entityProperties.html | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 0c6e37b192..b7240d43f7 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -312,15 +312,7 @@ var elHyperlinkHref = document.getElementById("property-hyperlink-href"); var elHyperlinkDescription = document.getElementById("property-hyperlink-description"); var elHyperlinkSections = document.querySelectorAll(".hyperlink-section"); - - var elParticleSections = document.querySelectorAll(".particle-section"); - allSections.push(elParticleSections); - var elParticleIsEmitting = document.getElementById("property-particle-is-emitting"); - var elParticleMaxParticles = document.getElementById("property-particle-maxparticles"); - var elParticleLifeSpan = document.getElementById("property-particle-lifespan"); - var elParticleEmitRate = document.getElementById("property-particle-emit-rate"); - var elParticleRadius = document.getElementById("property-particle-radius"); - var elParticleTextures = document.getElementById("property-particle-textures"); + var elTextSections = document.querySelectorAll(".text-section"); allSections.push(elTextSections); @@ -602,18 +594,6 @@ elZoneSkyboxURL.value = properties.skybox.url; showElements(document.getElementsByClassName('skybox-section'), elZoneBackgroundMode.value == 'skybox'); - } else if (properties.type == "ParticleEffect") { - for (var i = 0; i < elParticleSections.length; i++) { - elParticleSections[i].style.display = 'block'; - } - - elParticleIsEmitting.checked = properties.isEmitting; - elParticleMaxParticles.value = properties.maxParticles; - elParticleLifeSpan.value = properties.lifespan.toFixed(2); - elParticleEmitRate.value = properties.emitRate.toFixed(1); - elParticleRadius.value = properties.particleRadius.toFixed(3); - elParticleTextures.value = properties.textures; - } else if (properties.type == "PolyVox") { for (var i = 0; i < elPolyVoxSections.length; i++) { elPolyVoxSections[i].style.display = 'block'; @@ -749,13 +729,6 @@ elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl')); - elParticleIsEmitting.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isEmitting')); - elParticleMaxParticles.addEventListener('change', createEmitNumberPropertyUpdateFunction('maxParticles')); - elParticleLifeSpan.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifespan')); - elParticleEmitRate.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitRate')); - elParticleRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('particleRadius')); - elParticleTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures')); - elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType')); elCompoundShapeURL.addEventListener('change', createEmitTextPropertyUpdateFunction('compoundShapeURL'));