Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -126,7 +126,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 125 unmodified lines | ||
| 126 | 126 | auto density = propertiesWithSimID.getDensity(); |
| 127 | 127 | auto newVelocity = propertiesWithSimID.getVelocity().length(); |
| 128 | 128 | double cost = calculateCost(density*volume, 0, newVelocity); |
| 129 | − cost *= ENTITY_MANIPULATION_MULTIPLIER; //try this as a constant for now | |
| 129 | + cost *= costMultiplier; | |
| 130 | 130 | |
| 131 | 131 | if(cost > _currentAvatarEnergy) { |
| 132 | 132 | return QUuid(); |
| @@ -231,7 +231,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 98 unmodified lines | ||
| 231 | 231 | auto density = properties.getDensity(); |
| 232 | 232 | auto newVelocity = properties.getVelocity().length(); |
| 233 | 233 | double cost = calculateCost(density*volume, 0, newVelocity); |
| 234 | − cost *= ENTITY_MANIPULATION_MULTIPLIER; | |
| 234 | + cost *= costMultiplier; | |
| 235 | 235 | |
| 236 | 236 | if(cost > _currentAvatarEnergy) { |
| 237 | 237 | return QUuid(); |
| @@ -351,7 +351,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 113 unmodified lines | ||
| 351 | 351 | auto density = entity->getDensity(); |
| 352 | 352 | auto velocity = entity->getVelocity().length(); |
| 353 | 353 | double cost = calculateCost(density*volume, velocity, 0); |
| 354 | − cost *= ENTITY_MANIPULATION_MULTIPLIER; | |
| 354 | + cost *= costMultiplier; | |
| 355 | 355 | |
| 356 | 356 | if(cost > _currentAvatarEnergy) { |
| 357 | 357 | return; |
| @@ -1037,11 +1037,7 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { · 679 unmodified lines | ||
| 1037 | 1037 | return result; |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | −void EntityScriptingInterface::addCostFunction(QScriptValue costFunction) { | |
| 1041 | − _costFunction = &costFunction; | |
| 1042 | −} | |
| 1043 | − | |
| 1044 | −double EntityScriptingInterface::calculateCost(float mass, float oldVelocity,float newVelocity) { | |
| 1040 | +float EntityScriptingInterface::calculateCost(float mass, float oldVelocity,float newVelocity) { | |
| 1045 | 1041 | return std::abs(mass * (newVelocity - oldVelocity)); |
| 1046 | 1042 | } |
| 1047 | 1043 | |
| @@ -1049,3 +1045,11 @@ void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) { · 1 unmodified line | ||
| 1049 | 1045 | // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy; |
| 1050 | 1046 | _currentAvatarEnergy = energy; |
| 1051 | 1047 | } |
| 1048 | + | |
| 1049 | +float EntityScriptingInterface::getCostMultiplier() { | |
| 1050 | + return costMultiplier; | |
| 1051 | +} | |
| 1052 | + | |
| 1053 | +void EntityScriptingInterface::setCostMultiplier(float value) { | |
| 1054 | + costMultiplier = value; | |
| 1055 | +} | |