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; _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, void Gear::setGlobalGround(double *global_ground, float* global_vel,
double globalX, double globalY, double globalX, double globalY,
const simgear::BVHMaterial *material) 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) void Gear::getGlobalGround(double* global_ground)
{ {
int i; for(int i=0; i<4; i++) global_ground[i] = _global_ground[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;
} }
void Gear::getForce(float* force, float* contact) void Gear::getForce(float* force, float* contact)
@ -242,25 +102,6 @@ void Gear::getForce(float* force, float* contact)
Math::set3(_contact, 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() float Gear::getBumpAltitude()
{ {

View file

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