diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp
index 7e15e78624..2e9b386ba5 100644
--- a/libraries/entities/src/EntityScriptingInterface.cpp
+++ b/libraries/entities/src/EntityScriptingInterface.cpp
@@ -254,17 +254,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
propertiesWithSimID = convertPropertiesFromScriptSemantics(propertiesWithSimID, scalesWithParent);
propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged());
- auto dimensions = propertiesWithSimID.getDimensions();
- float volume = dimensions.x * dimensions.y * dimensions.z;
- auto density = propertiesWithSimID.getDensity();
- auto newVelocity = propertiesWithSimID.getVelocity().length();
- float cost = calculateCost(density * volume, 0, newVelocity);
- cost *= costMultiplier;
-
- if (cost > _currentAvatarEnergy) {
- return QUuid();
- }
-
EntityItemID id = EntityItemID(QUuid::createUuid());
// If we have a local entity tree set, then also update it.
@@ -295,9 +284,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
// queue the packet
if (success) {
- emit debitEnergySource(cost);
queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID);
-
return id;
} else {
return QUuid();
@@ -378,27 +365,9 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
EntityItemProperties properties = scriptSideProperties;
- auto dimensions = properties.getDimensions();
- float volume = dimensions.x * dimensions.y * dimensions.z;
- auto density = properties.getDensity();
- auto newVelocity = properties.getVelocity().length();
- float oldVelocity = { 0.0f };
-
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) {
- 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.
@@ -420,9 +389,6 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
// All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them.
// If any of these changed, pull any missing properties from the entity.
- //existing entity, retrieve old velocity for check down below
- oldVelocity = entity->getWorldVelocity().length();
-
if (!scriptSideProperties.parentIDChanged()) {
properties.setParentID(entity->getParentID());
}
@@ -442,23 +408,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
properties.setClientOnly(entity->getClientOnly());
properties.setOwningAvatarID(entity->getOwningAvatarID());
properties = convertPropertiesFromScriptSemantics(properties, properties.getScalesWithParent());
-
- float cost = calculateCost(density * volume, oldVelocity, newVelocity);
- cost *= costMultiplier;
-
- if (cost > _currentAvatarEnergy) {
- updatedEntity = false;
- } else {
- //debit the avatar energy and continue
- updatedEntity = _entityTree->updateEntity(entityID, properties);
- if (updatedEntity) {
- emit debitEnergySource(cost);
- }
- }
+ updatedEntity = _entityTree->updateEntity(entityID, properties);
});
// FIXME: We need to figure out a better way to handle this. Allowing these edits to go through potentially
- // breaks avatar energy and entities that are parented.
+ // breaks entities that are parented.
//
// To handle cases where a script needs to edit an entity with a _known_ entity id but doesn't exist
// in the local entity tree, we need to allow those edits to go through to the server.
@@ -577,21 +531,6 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
return;
}
- auto dimensions = entity->getScaledDimensions();
- float volume = dimensions.x * dimensions.y * dimensions.z;
- auto density = entity->getDensity();
- auto velocity = entity->getWorldVelocity().length();
- float cost = calculateCost(density * volume, velocity, 0);
- cost *= costMultiplier;
-
- if (cost > _currentAvatarEnergy) {
- shouldDelete = false;
- return;
- } else {
- //debit the avatar energy and continue
- emit debitEnergySource(cost);
- }
-
if (entity->getLocked()) {
shouldDelete = false;
} else {
@@ -1812,23 +1751,6 @@ void EntityScriptingInterface::emitScriptEvent(const EntityItemID& entityID, con
}
}
-float EntityScriptingInterface::calculateCost(float mass, float oldVelocity, float newVelocity) {
- return std::abs(mass * (newVelocity - oldVelocity));
-}
-
-void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) {
- // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy;
- _currentAvatarEnergy = energy;
-}
-
-float EntityScriptingInterface::getCostMultiplier() {
- return costMultiplier;
-}
-
-void EntityScriptingInterface::setCostMultiplier(float value) {
- costMultiplier = value;
-}
-
// TODO move this someplace that makes more sense...
bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, const glm::vec3& dimensions,
const glm::vec3& start, const glm::vec3& end, float radius) {
diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h
index 9613a7a310..4c2a2a47b4 100644
--- a/libraries/entities/src/EntityScriptingInterface.h
+++ b/libraries/entities/src/EntityScriptingInterface.h
@@ -94,8 +94,6 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
* Interface has displayed and so knows about.
*
* @namespace Entities
- * @property {number} currentAvatarEnergy - Deprecated
- * @property {number} costMultiplier - Deprecated
* @property {Uuid} keyboardFocusEntity - Get or set the {@link Entities.EntityType|Web} entity that has keyboard focus.
* If no entity has keyboard focus, get returns null
; set to null
or {@link Uuid|Uuid.NULL} to
* clear keyboard focus.
@@ -104,8 +102,6 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
class EntityScriptingInterface : public OctreeScriptingInterface, public Dependency {
Q_OBJECT
- Q_PROPERTY(float currentAvatarEnergy READ getCurrentAvatarEnergy WRITE setCurrentAvatarEnergy)
- Q_PROPERTY(float costMultiplier READ getCostMultiplier WRITE setCostMultiplier)
Q_PROPERTY(QUuid keyboardFocusEntity READ getKeyboardFocusEntity WRITE setKeyboardFocusEntity)
friend EntityPropertyMetadataRequest;
@@ -126,7 +122,6 @@ public:
void setEntityTree(EntityTreePointer modelTree);
EntityTreePointer getEntityTree() { return _entityTree; }
void setEntitiesScriptEngine(QSharedPointer engine);
- float calculateCost(float mass, float oldVelocity, float newVelocity);
void resetActivityTracking();
ActivityTracking getActivityTracking() const { return _activityTracking; }
@@ -1834,14 +1829,6 @@ signals:
*/
void clearingEntities();
- /**jsdoc
- * @function Entities.debitEnergySource
- * @param {number} value - The amount to debit.
- * @returns {Signal}
- * @deprecated This function is deprecated and will soon be removed.
- */
- void debitEnergySource(float value);
-
/**jsdoc
* Triggered in when a script in a {@link Entities.EntityType|Web} entity's Web page script sends an event over the
* script's EventBridge
.
@@ -1882,14 +1869,8 @@ private:
QSharedPointer _entitiesScriptEngine;
bool _bidOnSimulationOwnership { false };
- float _currentAvatarEnergy = { FLT_MAX };
- float getCurrentAvatarEnergy() { return _currentAvatarEnergy; }
- void setCurrentAvatarEnergy(float energy);
ActivityTracking _activityTracking;
- float costMultiplier = { 0.01f };
- float getCostMultiplier();
- void setCostMultiplier(float value);
};
#endif // hifi_EntityScriptingInterface_h