format code for ForceFeedbackManager::lowSpeedConstantForceEffect
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7809 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 1ab8c7367b2c2cb50e4dde53784b3d765e2c870d Former-commit-id: 78b3eb29823238fc70422916ff2327830a64c16e
This commit is contained in:
parent
ff468c66b6
commit
c0bdbeee12
1 changed files with 11 additions and 39 deletions
|
@ -32,7 +32,6 @@ clock_t effectStart = std::clock();
|
||||||
clock_t effectCurTime = std::clock();
|
clock_t effectCurTime = std::clock();
|
||||||
|
|
||||||
float prevSteerCmd;
|
float prevSteerCmd;
|
||||||
float prevSteerCmdDiff;
|
|
||||||
int prevDirection = 1;
|
int prevDirection = 1;
|
||||||
|
|
||||||
int filterPositiveNumbers (int number){
|
int filterPositiveNumbers (int number){
|
||||||
|
@ -442,68 +441,41 @@ int ForceFeedbackManager::engineRevvingEffect(tCarElt* car, tSituation *s)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ForceFeedbackManager::lowSpeedConstantForceEffect(tCarElt* car, tSituation *s){
|
int ForceFeedbackManager::lowSpeedConstantForceEffect(tCarElt *car, tSituation *s)
|
||||||
|
{
|
||||||
int effectForce;
|
|
||||||
int sign;
|
|
||||||
|
|
||||||
//we need to store the sign of the force
|
//we need to store the sign of the force
|
||||||
sign = ((car->_steerTqCenter - prevSteerCmd) > 0) - ((car->_steerTqCenter - prevSteerCmd) < 0);
|
int sign = ((car->_steerTqCenter - prevSteerCmd) > 0) - ((car->_steerTqCenter - prevSteerCmd) < 0);
|
||||||
|
|
||||||
GfLogDebug("test: (%f)\n", car->_steerTqCenter);
|
GfLogDebug("steerTqCenter: (%f)\n", car->_steerTqCenter);
|
||||||
GfLogDebug("test: (%f)\n", prevSteerCmd );
|
GfLogDebug("prevSteerCmd: (%f)\n", prevSteerCmd);
|
||||||
|
|
||||||
int prevDirectionSign = (prevDirection > 0) - (prevDirection < 0);
|
int prevDirectionSign = (prevDirection > 0) - (prevDirection < 0);
|
||||||
|
|
||||||
GfLogDebug("Sign: (%d)\n", sign);
|
GfLogDebug("Sign: (%d)\n", sign);
|
||||||
GfLogDebug("Direction sign: (%d)\n", prevDirectionSign);
|
GfLogDebug("Direction sign: (%d)\n", prevDirectionSign);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(prevDirectionSign == sign || sign == 0){
|
|
||||||
|
|
||||||
prevDirection = prevDirection + sign;
|
prevDirection = prevDirection + sign;
|
||||||
|
if (prevDirection > 7) prevDirection = 7;
|
||||||
}else{
|
if (prevDirection < -7) prevDirection = -7;
|
||||||
|
|
||||||
prevDirection = sign;
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
prevDirection = prevDirection + sign;
|
|
||||||
if (prevDirection > 7) prevDirection =7;
|
|
||||||
if (prevDirection < -7) prevDirection =-7;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GfLogDebug("Direction score: (%d)\n", prevDirection);
|
GfLogDebug("Direction score: (%d)\n", prevDirection);
|
||||||
|
|
||||||
|
int effectForce = 0;
|
||||||
|
|
||||||
//force calculation
|
//force calculation
|
||||||
if (car->_speed_xy < this->effectsConfig["lowSpeedConstantForceEffect"]["maxSpeedAtWhichForceIsApplied"]
|
if (car->_speed_xy < this->effectsConfig["lowSpeedConstantForceEffect"]["maxSpeedAtWhichForceIsApplied"])
|
||||||
// && abs(prevDirection) > 8
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
effectForce = this->effectsConfig["lowSpeedConstantForceEffect"]["maxForce"] / 8 * abs(prevDirection) /
|
effectForce = this->effectsConfig["lowSpeedConstantForceEffect"]["maxForce"] / 8 * abs(prevDirection) /
|
||||||
//(car->_speed_xy + 1) *
|
(pow(car->_speed_xy, 0.5f) + 1) * prevDirectionSign;
|
||||||
(pow(car->_speed_xy, (float) 1/2) + 1) * prevDirectionSign;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
effectForce = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prevSteerCmdDiff = car->_steerTqCenter - prevSteerCmd;
|
|
||||||
prevSteerCmd = car->_steerTqCenter;
|
prevSteerCmd = car->_steerTqCenter;
|
||||||
|
|
||||||
GfLogDebug("SPEED: (%i)\n", (int)car->_speed_xy);
|
GfLogDebug("SPEED: (%i)\n", (int)car->_speed_xy);
|
||||||
GfLogDebug("Efect: (%i)\n", effectForce);
|
GfLogDebug("Efect: (%i)\n", effectForce);
|
||||||
|
|
||||||
return effectForce;
|
return effectForce;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//initialize the force feedback
|
//initialize the force feedback
|
||||||
TGFCLIENT_API ForceFeedbackManager forceFeedback;
|
TGFCLIENT_API ForceFeedbackManager forceFeedback;
|
||||||
|
|
Loading…
Reference in a new issue