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 | auto density = propertiesWithSimID.getDensity(); | 126 | auto density = propertiesWithSimID.getDensity(); |
| 127 | auto newVelocity = propertiesWithSimID.getVelocity().length(); | 127 | auto newVelocity = propertiesWithSimID.getVelocity().length(); |
| 128 | double cost = calculateCost(density*volume, 0, newVelocity); | 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 | if(cost > _currentAvatarEnergy) { | 131 | if(cost > _currentAvatarEnergy) { |
| 132 | return QUuid(); | 132 | return QUuid(); |
| @@ -231,7 +231,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 98 unmodified lines | |||
| 231 | auto density = properties.getDensity(); | 231 | auto density = properties.getDensity(); |
| 232 | auto newVelocity = properties.getVelocity().length(); | 232 | auto newVelocity = properties.getVelocity().length(); |
| 233 | double cost = calculateCost(density*volume, 0, newVelocity); | 233 | double cost = calculateCost(density*volume, 0, newVelocity); |
| 234 | cost *= ENTITY_MANIPULATION_MULTIPLIER; | 234 | cost *= costMultiplier; |
| 235 | 235 | ||
| 236 | if(cost > _currentAvatarEnergy) { | 236 | if(cost > _currentAvatarEnergy) { |
| 237 | return QUuid(); | 237 | return QUuid(); |
| @@ -351,7 +351,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 113 unmodified lines | |||
| 351 | auto density = entity->getDensity(); | 351 | auto density = entity->getDensity(); |
| 352 | auto velocity = entity->getVelocity().length(); | 352 | auto velocity = entity->getVelocity().length(); |
| 353 | double cost = calculateCost(density*volume, velocity, 0); | 353 | double cost = calculateCost(density*volume, velocity, 0); |
| 354 | cost *= ENTITY_MANIPULATION_MULTIPLIER; | 354 | cost *= costMultiplier; |
| 355 | 355 | ||
| 356 | if(cost > _currentAvatarEnergy) { | 356 | if(cost > _currentAvatarEnergy) { |
| 357 | return; | 357 | return; |
| @@ -1037,11 +1037,7 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { · 679 unmodified lines | |||
| 1037 | return result; | 1037 | return result; |
| 1038 | } | 1038 | } |
| 1039 | 1039 | ||
| 1040 | void EntityScriptingInterface::addCostFunction(QScriptValue costFunction) { | 1040 | float EntityScriptingInterface::calculateCost(float mass, float oldVelocity,float newVelocity) { |
| 1041 | _costFunction = &costFunction; | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | double EntityScriptingInterface::calculateCost(float mass, float oldVelocity,float newVelocity) { | ||
| 1045 | return std::abs(mass * (newVelocity - oldVelocity)); | 1041 | return std::abs(mass * (newVelocity - oldVelocity)); |
| 1046 | } | 1042 | } |
| 1047 | 1043 | ||
| @@ -1049,3 +1045,11 @@ void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) { · 1 unmodified line | |||
| 1049 | // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy; | 1045 | // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy; |
| 1050 | _currentAvatarEnergy = energy; | 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 | } | ||