Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -123,10 +123,10 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 122 unmodified lines | |||
| 123 | propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged()); | 123 | propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged()); |
| 124 | 124 | ||
| 125 | auto dimensions = propertiesWithSimID.getDimensions(); | 125 | auto dimensions = propertiesWithSimID.getDimensions(); |
| 126 | float volume = dimensions.x*dimensions.y*dimensions.z; | 126 | float volume = dimensions.x * dimensions.y * dimensions.z; |
| 127 | auto density = propertiesWithSimID.getDensity(); | 127 | auto density = propertiesWithSimID.getDensity(); |
| 128 | auto newVelocity = propertiesWithSimID.getVelocity().length(); | 128 | auto newVelocity = propertiesWithSimID.getVelocity().length(); |
| 129 | double cost = calculateCost(density*volume, 0, newVelocity); | 129 | double cost = calculateCost(density * volume, 0, newVelocity); |
| 130 | cost *= costMultiplier; | 130 | cost *= costMultiplier; |
| 131 | 131 | ||
| 132 | if(cost > _currentAvatarEnergy) { | 132 | if(cost > _currentAvatarEnergy) { |
| @@ -231,10 +231,10 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 98 unmodified lines | |||
| 231 | EntityItemProperties properties = scriptSideProperties; | 231 | EntityItemProperties properties = scriptSideProperties; |
| 232 | 232 | ||
| 233 | auto dimensions = properties.getDimensions(); | 233 | auto dimensions = properties.getDimensions(); |
| 234 | float volume = dimensions.x*dimensions.y*dimensions.z; | 234 | float volume = dimensions.x * dimensions.y * dimensions.z; |
| 235 | auto density = properties.getDensity(); | 235 | auto density = properties.getDensity(); |
| 236 | auto newVelocity = properties.getVelocity().length(); | 236 | auto newVelocity = properties.getVelocity().length(); |
| 237 | double cost = calculateCost(density*volume, 0, newVelocity); | 237 | double cost = calculateCost(density * volume, 0, newVelocity); |
| 238 | cost *= costMultiplier; | 238 | cost *= costMultiplier; |
| 239 | 239 | ||
| 240 | if(cost > _currentAvatarEnergy) { | 240 | if(cost > _currentAvatarEnergy) { |
| @@ -351,10 +351,10 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 110 unmodified lines | |||
| 351 | if (entity) { | 351 | if (entity) { |
| 352 | 352 | ||
| 353 | auto dimensions = entity->getDimensions(); | 353 | auto dimensions = entity->getDimensions(); |
| 354 | float volume = dimensions.x*dimensions.y*dimensions.z; | 354 | float volume = dimensions.x * dimensions.y * dimensions.z; |
| 355 | auto density = entity->getDensity(); | 355 | auto density = entity->getDensity(); |
| 356 | auto velocity = entity->getVelocity().length(); | 356 | auto velocity = entity->getVelocity().length(); |
| 357 | double cost = calculateCost(density*volume, velocity, 0); | 357 | double cost = calculateCost(density * volume, velocity, 0); |
| 358 | cost *= costMultiplier; | 358 | cost *= costMultiplier; |
| 359 | 359 | ||
| 360 | if(cost > _currentAvatarEnergy) { | 360 | if(cost > _currentAvatarEnergy) { |
| @@ -1041,7 +1041,7 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { · 680 unmodified lines | |||
| 1041 | return result; | 1041 | return result; |
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | float EntityScriptingInterface::calculateCost(float mass, float oldVelocity,float newVelocity) { | 1044 | float EntityScriptingInterface::calculateCost(float mass, float oldVelocity, float newVelocity) { |
| 1045 | return std::abs(mass * (newVelocity - oldVelocity)); | 1045 | return std::abs(mass * (newVelocity - oldVelocity)); |
| 1046 | } | 1046 | } |
| 1047 | 1047 | ||