History

Merge branch 'WorkingEnergy'

Babiuch, Ryan Nicholas committed 10 years ago

Commit 786400e2 parents d7951f4 3cb2f9c3 files · +21 −19Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+12−8
@@ -126,7 +126,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 125 unmodified lines
126126 auto density = propertiesWithSimID.getDensity();
127127 auto newVelocity = propertiesWithSimID.getVelocity().length();
128128 double cost = calculateCost(density*volume, 0, newVelocity);
129− cost *= ENTITY_MANIPULATION_MULTIPLIER; //try this as a constant for now
129+ cost *= costMultiplier;
130130
131131 if(cost > _currentAvatarEnergy) {
132132 return QUuid();
@@ -231,7 +231,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 98 unmodified lines
231231 auto density = properties.getDensity();
232232 auto newVelocity = properties.getVelocity().length();
233233 double cost = calculateCost(density*volume, 0, newVelocity);
234− cost *= ENTITY_MANIPULATION_MULTIPLIER;
234+ cost *= costMultiplier;
235235
236236 if(cost > _currentAvatarEnergy) {
237237 return QUuid();
@@ -351,7 +351,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) { · 113 unmodified lines
351351 auto density = entity->getDensity();
352352 auto velocity = entity->getVelocity().length();
353353 double cost = calculateCost(density*volume, velocity, 0);
354− cost *= ENTITY_MANIPULATION_MULTIPLIER;
354+ cost *= costMultiplier;
355355
356356 if(cost > _currentAvatarEnergy) {
357357 return;
@@ -1037,11 +1037,7 @@ QStringList EntityScriptingInterface::getJointNames(const QUuid& entityID) { · 679 unmodified lines
10371037 return result;
10381038 }
10391039
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) {
10451041 return std::abs(mass * (newVelocity - oldVelocity));
10461042 }
10471043
@@ -1049,3 +1045,11 @@ void EntityScriptingInterface::setCurrentAvatarEnergy(float energy) { · 1 unmodified line
10491045 // qCDebug(entities) << "NEW AVATAR ENERGY IN ENTITY SCRIPTING INTERFACE: " << energy;
10501046 _currentAvatarEnergy = energy;
10511047 }
1048+
1049+float EntityScriptingInterface::getCostMultiplier() {
1050+ return costMultiplier;
1051+}
1052+
1053+void EntityScriptingInterface::setCostMultiplier(float value) {
1054+ costMultiplier = value;
1055+}