History

Remove Entities.currentAvatarEnergy and related from the API

David Rowe committed 8 years ago

Commit 3b900781 parent a76b4b12 files · +2 −75Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+2−57
@@ -258,12 +258,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 257 unmodified lines
258258 float volume = dimensions.x * dimensions.y * dimensions.z;
259259 auto density = propertiesWithSimID.getDensity();
260260 auto newVelocity = propertiesWithSimID.getVelocity().length();
261− float cost = calculateCost(density * volume, 0, newVelocity);
262− cost *= costMultiplier;
263−
264− if (cost > _currentAvatarEnergy) {
265− return QUuid();
266− }
267261
268262 EntityItemID id = EntityItemID(QUuid::createUuid());
269263
@@ -295,9 +289,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 25 unmodified lines
295289
296290 // queue the packet
297291 if (success) {
298− emit debitEnergySource(cost);
299292 queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID);
300−
301293 return id;
302294 } else {
303295 return QUuid();
@@ -387,18 +379,6 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 83 unmodified lines
387379 EntityItemID entityID(id);
388380 if (!_entityTree) {
389381 queueEntityMessage(PacketType::EntityEdit, entityID, properties);
390−
391− //if there is no local entity entity tree, no existing velocity, use 0.
392− float cost = calculateCost(density * volume, oldVelocity, newVelocity);
393− cost *= costMultiplier;
394−
395− if (cost > _currentAvatarEnergy) {
396− return QUuid();
397− } else {
398− //debit the avatar energy and continue
399− emit debitEnergySource(cost);
400− }
401−
402382 return id;
403383 }
404384 // If we have a local entity tree set, then also update it.
@@ -442,23 +422,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 37 unmodified lines
442422 properties.setClientOnly(entity->getClientOnly());
443423 properties.setOwningAvatarID(entity->getOwningAvatarID());
444424 properties = convertPropertiesFromScriptSemantics(properties, properties.getScalesWithParent());
445−
446− float cost = calculateCost(density * volume, oldVelocity, newVelocity);
447− cost *= costMultiplier;
448−
449− if (cost > _currentAvatarEnergy) {
450− updatedEntity = false;
451− } else {
452− //debit the avatar energy and continue
453− updatedEntity = _entityTree->updateEntity(entityID, properties);
454− if (updatedEntity) {
455− emit debitEnergySource(cost);
456− }
457− }
425+ updatedEntity = _entityTree->updateEntity(entityID, properties);
458426 });
459427
460428 // FIXME: We need to figure out a better way to handle this. Allowing these edits to go through potentially
461− // breaks avatar energy and entities that are parented.
429+ // breaks entities that are parented.
462430 //
463431 // To handle cases where a script needs to edit an entity with a _known_ entity id but doesn't exist
464432 // in the local entity tree, we need to allow those edits to go through to the server.
@@ -581,16 +549,6 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 116 unmodified lines
581549 float volume = dimensions.x * dimensions.y * dimensions.z;
582550 auto density = entity->getDensity();
583551 auto velocity = entity->getWorldVelocity().length();
584− float cost = calculateCost(density * volume, velocity, 0);
585− cost *= costMultiplier;
586−
587− if (cost > _currentAvatarEnergy) {
588− shouldDelete = false;
589− return;
590− } else {
591− //debit the avatar energy and continue
592− emit debitEnergySource(cost);
593− }
594552
595553 if (entity->getLocked()) {
596554 shouldDelete = false;
@@ -1816,19 +1774,6 @@ float EntityScriptingInterface::calculateCost(float mass, float oldVelocity, flo · 1219 unmodified lines
18161774 return std::abs(mass * (newVelocity - oldVelocity));
18171775 }
18181776
1819−void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) {
1820− // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy;
1821− _currentAvatarEnergy = energy;
1822−}
1823−
1824−float EntityScriptingInterface::getCostMultiplier() {
1825− return costMultiplier;
1826−}
1827−
1828−void EntityScriptingInterface::setCostMultiplier(float value) {
1829− costMultiplier = value;
1830−}
1831−
18321777 // TODO move this someplace that makes more sense...
18331778 bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, const glm::vec3& dimensions,
18341779 const glm::vec3& start, const glm::vec3& end, float radius) {