Remove unnecessary move and add a bit documentation
This commit is contained in:
parent
2272002d5c
commit
cb797c3145
@ -518,14 +518,14 @@ float AbstractCharacteristics::getStabilitySmoothFlyingImpulse() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterpolationArray&& AbstractCharacteristics::getTurnRadius() const
|
InterpolationArray AbstractCharacteristics::getTurnRadius() const
|
||||||
{
|
{
|
||||||
InterpolationArray result;
|
InterpolationArray result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(TURN_RADIUS, &result, &is_set);
|
process(TURN_RADIUS, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_RADIUS).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_RADIUS).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractCharacteristics::getTurnTimeResetSteer() const
|
float AbstractCharacteristics::getTurnTimeResetSteer() const
|
||||||
@ -538,14 +538,14 @@ float AbstractCharacteristics::getTurnTimeResetSteer() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterpolationArray&& AbstractCharacteristics::getTurnTimeFullSteer() const
|
InterpolationArray AbstractCharacteristics::getTurnTimeFullSteer() const
|
||||||
{
|
{
|
||||||
InterpolationArray result;
|
InterpolationArray result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(TURN_TIME_FULL_STEER, &result, &is_set);
|
process(TURN_TIME_FULL_STEER, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_FULL_STEER).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(TURN_TIME_FULL_STEER).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractCharacteristics::getEnginePower() const
|
float AbstractCharacteristics::getEnginePower() const
|
||||||
@ -598,24 +598,24 @@ float AbstractCharacteristics::getEngineMaxSpeedReverseRatio() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float>&& AbstractCharacteristics::getGearSwitchRatio() const
|
std::vector<float> AbstractCharacteristics::getGearSwitchRatio() const
|
||||||
{
|
{
|
||||||
std::vector<float> result;
|
std::vector<float> result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(GEAR_SWITCH_RATIO, &result, &is_set);
|
process(GEAR_SWITCH_RATIO, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_SWITCH_RATIO).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_SWITCH_RATIO).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float>&& AbstractCharacteristics::getGearPowerIncrease() const
|
std::vector<float> AbstractCharacteristics::getGearPowerIncrease() const
|
||||||
{
|
{
|
||||||
std::vector<float> result;
|
std::vector<float> result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(GEAR_POWER_INCREASE, &result, &is_set);
|
process(GEAR_POWER_INCREASE, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_POWER_INCREASE).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(GEAR_POWER_INCREASE).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractCharacteristics::getMass() const
|
float AbstractCharacteristics::getMass() const
|
||||||
@ -658,14 +658,14 @@ float AbstractCharacteristics::getWheelsRadius() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float>&& AbstractCharacteristics::getWheelsPosition() const
|
std::vector<float> AbstractCharacteristics::getWheelsPosition() const
|
||||||
{
|
{
|
||||||
std::vector<float> result;
|
std::vector<float> result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(WHEELS_POSITION, &result, &is_set);
|
process(WHEELS_POSITION, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_POSITION).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(WHEELS_POSITION).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractCharacteristics::getCameraDistance() const
|
float AbstractCharacteristics::getCameraDistance() const
|
||||||
@ -1018,24 +1018,24 @@ float AbstractCharacteristics::getPlungerInFaceTime() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float>&& AbstractCharacteristics::getStartupTime() const
|
std::vector<float> AbstractCharacteristics::getStartupTime() const
|
||||||
{
|
{
|
||||||
std::vector<float> result;
|
std::vector<float> result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(STARTUP_TIME, &result, &is_set);
|
process(STARTUP_TIME, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_TIME).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_TIME).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<float>&& AbstractCharacteristics::getStartupBoost() const
|
std::vector<float> AbstractCharacteristics::getStartupBoost() const
|
||||||
{
|
{
|
||||||
std::vector<float> result;
|
std::vector<float> result;
|
||||||
bool is_set = false;
|
bool is_set = false;
|
||||||
process(STARTUP_BOOST, &result, &is_set);
|
process(STARTUP_BOOST, &result, &is_set);
|
||||||
if (!is_set)
|
if (!is_set)
|
||||||
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_BOOST).c_str());
|
Log::fatal("AbstractCharacteristics", "Can't get characteristic %s", getName(STARTUP_BOOST).c_str());
|
||||||
return std::move(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AbstractCharacteristics::getRescueDuration() const
|
float AbstractCharacteristics::getRescueDuration() const
|
||||||
|
@ -205,12 +205,16 @@ public:
|
|||||||
virtual const SkiddingProperties* getSkiddingProperties() const;
|
virtual const SkiddingProperties* getSkiddingProperties() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* The process function is the core of this characteristics system.
|
||||||
|
* Any computation of the properties should happen here and modify the
|
||||||
|
* values of the value-pointer (be sure to use the right type!) and the
|
||||||
|
* is_set parameter when the value was set by the call (and wasn't set
|
||||||
|
* before).
|
||||||
*
|
*
|
||||||
* \param type The characteristic that should be modified.
|
* \param type The characteristic that should be modified.
|
||||||
* \param value The current value and result at the same time.
|
* \param value The current value and result at the same time.
|
||||||
* \param is_set If the current value was already set (so it can be used
|
* \param is_set If the current value was already set (so it can be used
|
||||||
* for computations.
|
* for computations).
|
||||||
*/
|
*/
|
||||||
virtual void process(CharacteristicType type, Value value, bool *is_set) const;
|
virtual void process(CharacteristicType type, Value value, bool *is_set) const;
|
||||||
|
|
||||||
@ -231,9 +235,9 @@ public:
|
|||||||
float getStabilityTrackConnectionAccel() const;
|
float getStabilityTrackConnectionAccel() const;
|
||||||
float getStabilitySmoothFlyingImpulse() const;
|
float getStabilitySmoothFlyingImpulse() const;
|
||||||
|
|
||||||
InterpolationArray&& getTurnRadius() const;
|
InterpolationArray getTurnRadius() const;
|
||||||
float getTurnTimeResetSteer() const;
|
float getTurnTimeResetSteer() const;
|
||||||
InterpolationArray&& getTurnTimeFullSteer() const;
|
InterpolationArray getTurnTimeFullSteer() const;
|
||||||
|
|
||||||
float getEnginePower() const;
|
float getEnginePower() const;
|
||||||
float getEngineMaxSpeed() const;
|
float getEngineMaxSpeed() const;
|
||||||
@ -241,15 +245,15 @@ public:
|
|||||||
float getEngineBrakeTimeIncrease() const;
|
float getEngineBrakeTimeIncrease() const;
|
||||||
float getEngineMaxSpeedReverseRatio() const;
|
float getEngineMaxSpeedReverseRatio() const;
|
||||||
|
|
||||||
std::vector<float>&& getGearSwitchRatio() const;
|
std::vector<float> getGearSwitchRatio() const;
|
||||||
std::vector<float>&& getGearPowerIncrease() const;
|
std::vector<float> getGearPowerIncrease() const;
|
||||||
|
|
||||||
float getMass() const;
|
float getMass() const;
|
||||||
|
|
||||||
float getWheelsDampingRelaxation() const;
|
float getWheelsDampingRelaxation() const;
|
||||||
float getWheelsDampingCompression() const;
|
float getWheelsDampingCompression() const;
|
||||||
float getWheelsRadius() const;
|
float getWheelsRadius() const;
|
||||||
std::vector<float>&& getWheelsPosition() const;
|
std::vector<float> getWheelsPosition() const;
|
||||||
|
|
||||||
float getCameraDistance() const;
|
float getCameraDistance() const;
|
||||||
float getCameraForwardUpAngle() const;
|
float getCameraForwardUpAngle() const;
|
||||||
@ -295,8 +299,8 @@ public:
|
|||||||
float getPlungerFadeOutTime() const;
|
float getPlungerFadeOutTime() const;
|
||||||
float getPlungerInFaceTime() const;
|
float getPlungerInFaceTime() const;
|
||||||
|
|
||||||
std::vector<float>&& getStartupTime() const;
|
std::vector<float> getStartupTime() const;
|
||||||
std::vector<float>&& getStartupBoost() const;
|
std::vector<float> getStartupBoost() const;
|
||||||
|
|
||||||
float getRescueDuration() const;
|
float getRescueDuration() const;
|
||||||
float getRescueVertOffset() const;
|
float getRescueVertOffset() const;
|
||||||
|
@ -101,8 +101,8 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_
|
|||||||
for (std::vector<std::string>::const_iterator it = processors.begin();
|
for (std::vector<std::string>::const_iterator it = processors.begin();
|
||||||
it != processors.end(); it++)
|
it != processors.end(); it++)
|
||||||
{
|
{
|
||||||
std::vector<std::string> pair = StringUtils::split(*it,':');
|
std::vector<std::string> pair = StringUtils::split(*it, ':');
|
||||||
if (!pair.size() == 2)
|
if (pair.size() != 2)
|
||||||
Log::error("XmlCharacteristics::process",
|
Log::error("XmlCharacteristics::process",
|
||||||
"Can't process %s: Wrong format", getName(type).c_str());
|
"Can't process %s: Wrong format", getName(type).c_str());
|
||||||
else
|
else
|
||||||
@ -140,7 +140,7 @@ void XmlCharacteristics::process(CharacteristicType type, Value value, bool *is_
|
|||||||
it != processors.end(); it++)
|
it != processors.end(); it++)
|
||||||
{
|
{
|
||||||
std::vector<std::string> pair = StringUtils::split(*it,':');
|
std::vector<std::string> pair = StringUtils::split(*it,':');
|
||||||
if (!pair.size() == 2)
|
if (pair.size() != 2)
|
||||||
Log::error("XmlCharacteristics::process",
|
Log::error("XmlCharacteristics::process",
|
||||||
"Can't process %s: Wrong format", getName(type).c_str());
|
"Can't process %s: Wrong format", getName(type).c_str());
|
||||||
else
|
else
|
||||||
@ -229,6 +229,9 @@ void XmlCharacteristics::processFloat(const std::string &processor, float *value
|
|||||||
*value += val;
|
*value += val;
|
||||||
else if (operations[index - 1] == "-")
|
else if (operations[index - 1] == "-")
|
||||||
*value -= val;
|
*value -= val;
|
||||||
|
else
|
||||||
|
Log::fatal("XmlCharacteristics::processFloat",
|
||||||
|
"Unknown operator (%s)", operations[index - 1].c_str());
|
||||||
}
|
}
|
||||||
*is_set = true;
|
*is_set = true;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Input data
|
# Input data
|
||||||
#FIXME is wheelPosition needed??
|
#FIXME is wheelPosition needed?
|
||||||
characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce
|
characteristics = """Suspension: stiffness, rest, travelCm, expSpringResponse, maxForce
|
||||||
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse
|
Stability: rollInfluence, chassisLinearDamping, chassisAngularDamping, downwardImpulseFactor, trackConnectionAccel, smoothFlyingImpulse
|
||||||
Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray)
|
Turn: radius(InterpolationArray), timeResetSteer, timeFullSteer(InterpolationArray)
|
||||||
@ -54,9 +54,6 @@ class GroupMember:
|
|||||||
self.typeC = typeC
|
self.typeC = typeC
|
||||||
self.typeStr = typeStr
|
self.typeStr = typeStr
|
||||||
|
|
||||||
def shouldMove(self):
|
|
||||||
return self.typeC != "float"
|
|
||||||
|
|
||||||
"""E.g. power(std::vector<float>/floatVector)
|
"""E.g. power(std::vector<float>/floatVector)
|
||||||
or speed(InterpolationArray)
|
or speed(InterpolationArray)
|
||||||
The default type is float"""
|
The default type is float"""
|
||||||
@ -163,9 +160,6 @@ def main():
|
|||||||
for m in g.members:
|
for m in g.members:
|
||||||
nameTitle = joinSubName(g, m, True)
|
nameTitle = joinSubName(g, m, True)
|
||||||
nameUnderscore = joinSubName(g, m, False)
|
nameUnderscore = joinSubName(g, m, False)
|
||||||
if m.shouldMove():
|
|
||||||
typeC = m.typeC + "&&"
|
|
||||||
else:
|
|
||||||
typeC = m.typeC
|
typeC = m.typeC
|
||||||
|
|
||||||
print(" {0} get{1}() const;".
|
print(" {0} get{1}() const;".
|
||||||
@ -175,10 +169,6 @@ def main():
|
|||||||
for m in g.members:
|
for m in g.members:
|
||||||
nameTitle = joinSubName(g, m, True)
|
nameTitle = joinSubName(g, m, True)
|
||||||
nameUnderscore = joinSubName(g, m, False)
|
nameUnderscore = joinSubName(g, m, False)
|
||||||
if m.shouldMove():
|
|
||||||
typeC = m.typeC + "&&"
|
|
||||||
result = "std::move(result)"
|
|
||||||
else:
|
|
||||||
typeC = m.typeC
|
typeC = m.typeC
|
||||||
result = "result"
|
result = "result"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user