1
0
Fork 0

YASim Gear: move one-liners to header

This commit is contained in:
Henning Stahlke 2017-03-11 21:06:16 +01:00
parent 06ba4fe351
commit 60f5c97272
2 changed files with 36 additions and 193 deletions

View file

@ -53,98 +53,6 @@ Gear::Gear()
_global_ground[3] = -1e3;
}
void Gear::setPosition(float* position)
{
int i;
for(i=0; i<3; i++) _pos[i] = position[i];
}
void Gear::setCompression(float* compression)
{
int i;
for(i=0; i<3; i++) _cmpr[i] = compression[i];
}
void Gear::setSpring(float spring)
{
_spring = spring;
}
void Gear::setDamping(float damping)
{
_damp = damping;
}
void Gear::setStaticFriction(float sfric)
{
_sfric = sfric;
}
void Gear::setDynamicFriction(float dfric)
{
_dfric = dfric;
}
void Gear::setBrake(float brake)
{
_brake = Math::clamp(brake, 0, 1);
}
void Gear::setRotation(float rotation)
{
_rot = rotation;
}
void Gear::setExtension(float extension)
{
_extension = Math::clamp(extension, 0, 1);
}
void Gear::setCastering(bool c)
{
_castering = c;
}
void Gear::setContactPoint(bool c)
{
_isContactPoint=c;
}
void Gear::setOnWater(bool c)
{
_onWater = c;
}
void Gear::setOnSolid(bool c)
{
_onSolid = c;
}
void Gear::setIgnoreWhileSolving(bool c)
{
_ignoreWhileSolving = c;
}
void Gear::setSpringFactorNotPlaning(float f)
{
_spring_factor_not_planing = f;
}
void Gear::setSpeedPlaning(float s)
{
_speed_planing = s;
}
void Gear::setReduceFrictionByExtension(float s)
{
_reduceFrictionByExtension = s;
}
void Gear::setInitialLoad(float l)
{
_initialLoad = l;
}
void Gear::setGlobalGround(double *global_ground, float* global_vel,
double globalX, double globalY,
const simgear::BVHMaterial *material)
@ -183,57 +91,9 @@ void Gear::setGlobalGround(double *global_ground, float* global_vel,
}
void Gear::getPosition(float* out)
{
int i;
for(i=0; i<3; i++) out[i] = _pos[i];
}
void Gear::getCompression(float* out)
{
int i;
for(i=0; i<3; i++) out[i] = _cmpr[i];
}
void Gear::getGlobalGround(double* global_ground)
{
int i;
for(i=0; i<4; i++) global_ground[i] = _global_ground[i];
}
float Gear::getSpring()
{
return _spring;
}
float Gear::getDamping()
{
return _damp;
}
float Gear::getStaticFriction()
{
return _sfric;
}
float Gear::getDynamicFriction()
{
return _dfric;
}
float Gear::getBrake()
{
return _brake;
}
float Gear::getRotation()
{
return _rot;
}
float Gear::getExtension()
{
return _extension;
for(int i=0; i<4; i++) global_ground[i] = _global_ground[i];
}
void Gear::getForce(float* force, float* contact)
@ -242,25 +102,6 @@ void Gear::getForce(float* force, float* contact)
Math::set3(_contact, contact);
}
float Gear::getWoW()
{
return _wow;
}
float Gear::getCompressFraction()
{
return _frac;
}
bool Gear::getCastering()
{
return _castering;
}
bool Gear::getGroundIsSolid()
{
return _ground_isSolid;
}
float Gear::getBumpAltitude()
{

View file

@ -1,5 +1,6 @@
#ifndef _GEAR_HPP
#define _GEAR_HPP
#include "Math.hpp"
namespace simgear {
class BVHMaterial;
@ -33,42 +34,43 @@ public:
Gear();
// Externally set values
void setPosition(float* position);
void setCompression(float* compression);
void setSpring(float spring);
void setDamping(float damping);
void setStaticFriction(float sfric);
void setDynamicFriction(float dfric);
void setBrake(float brake);
void setRotation(float rotation);
void setExtension(float extension);
void setCastering(bool castering);
void setOnWater(bool c);
void setOnSolid(bool c);
void setSpringFactorNotPlaning(float f);
void setSpeedPlaning(float s);
void setReduceFrictionByExtension(float s);
void setInitialLoad(float l);
void setIgnoreWhileSolving(bool c);
void setPosition(float* position) { Math::set3(position, _pos); }
void getPosition(float* out) { Math::set3(_pos, out); }
void setCompression(float* compression) { Math::set3(compression, _cmpr); }
void getCompression(float* out) { Math::set3(_cmpr, out); }
void setSpring(float spring) { _spring = spring; }
float getSpring() { return _spring; }
void setDamping(float damping) { _damp = damping; }
float getDamping() {return _damp; }
void setStaticFriction(float sfric) { _sfric = sfric; }
float getStaticFriction() { return _sfric; }
void setDynamicFriction(float dfric) { _dfric = dfric; }
float getDynamicFriction() { return _dfric; }
void setBrake(float brake) { _brake = Math::clamp(brake, 0, 1); }
float getBrake() { return _brake; }
void setRotation(float rotation) { _rot = rotation; }
float getRotation() { return _rot; }
void setExtension(float extension) { _extension = Math::clamp(extension, 0, 1); }
float getExtension() { return _extension; }
void setCastering(bool c) { _castering = c; }
bool getCastering() { return _castering; }
void setOnWater(bool c) { _onWater = c; }
void setOnSolid(bool c) { _onSolid = c; }
void setSpringFactorNotPlaning(float f) { _spring_factor_not_planing = f; }
void setSpeedPlaning(float s) { _speed_planing = s; }
void setReduceFrictionByExtension(float s) { _reduceFrictionByExtension = s; }
void setInitialLoad(float l) { _initialLoad = l; }
float getInitialLoad() {return _initialLoad; }
void setIgnoreWhileSolving(bool c) { _ignoreWhileSolving = c; }
void setGlobalGround(double* global_ground, float* global_vel,
double globalX, double globalY,
const simgear::BVHMaterial *material);
void getPosition(float* out);
void getCompression(float* out);
const simgear::BVHMaterial *material);
void getGlobalGround(double* global_ground);
float getSpring();
float getDamping();
float getStaticFriction();
float getDynamicFriction();
float getBrake();
float getRotation();
float getExtension();
float getInitialLoad() {return _initialLoad; }
bool getCastering();
float getCasterAngle() { return _casterAngle; }
float getRollSpeed() { return _rollSpeed; }
float getBumpAltitude();
bool getGroundIsSolid();
bool getGroundIsSolid() { return _ground_isSolid; }
float getGroundFrictionFactor() { return (float)_ground_frictionFactor; }
void integrate(float dt);
@ -81,12 +83,12 @@ public:
// Computed values: total force, weight-on-wheels (force normal to
// ground) and compression fraction.
void getForce(float* force, float* contact);
float getWoW();
float getCompressFraction();
float getWoW() { return _wow; }
float getCompressFraction() { return _frac; }
float getCompressDist() { return _compressDist; }
bool getSubmergable() {return (!_ground_isSolid)&&(!_isContactPoint); }
bool getIgnoreWhileSolving() {return _ignoreWhileSolving; }
void setContactPoint(bool c);
void setContactPoint(bool c) { _isContactPoint=c; }
private:
float calcFriction(float wgt, float v);