Promoted observer angular velocity to double precision.
parent
ed2b1319d8
commit
d4e6d97ede
|
@ -57,7 +57,7 @@ Observer::Observer() :
|
|||
position(0.0, 0.0, 0.0),
|
||||
orientation(1.0),
|
||||
velocity(0.0, 0.0, 0.0),
|
||||
angularVelocity(0.0f, 0.0f, 0.0f),
|
||||
angularVelocity(0.0, 0.0, 0.0),
|
||||
frame(NULL),
|
||||
realTime(0.0),
|
||||
targetSpeed(0.0),
|
||||
|
@ -231,13 +231,13 @@ void Observer::setVelocity(const Vec3d& v)
|
|||
}
|
||||
|
||||
|
||||
Vec3f Observer::getAngularVelocity() const
|
||||
Vec3d Observer::getAngularVelocity() const
|
||||
{
|
||||
return angularVelocity;
|
||||
}
|
||||
|
||||
|
||||
void Observer::setAngularVelocity(const Vec3f& v)
|
||||
void Observer::setAngularVelocity(const Vec3d& v)
|
||||
{
|
||||
angularVelocity = v;
|
||||
}
|
||||
|
@ -473,8 +473,7 @@ void Observer::update(double dt, double timeScale)
|
|||
if (observerMode == Free)
|
||||
{
|
||||
// Update the observer's orientation
|
||||
Vec3f fAV = getAngularVelocity();
|
||||
Vec3d AV(fAV.x, fAV.y, fAV.z);
|
||||
Vec3d AV = getAngularVelocity();
|
||||
Quatd dr = 0.5 * (AV * orientation);
|
||||
orientation += dt * dr;
|
||||
orientation.normalize();
|
||||
|
|
|
@ -117,8 +117,8 @@ public:
|
|||
|
||||
Vec3d getVelocity() const;
|
||||
void setVelocity(const Vec3d&);
|
||||
Vec3f getAngularVelocity() const;
|
||||
void setAngularVelocity(const Vec3f&);
|
||||
Vec3d getAngularVelocity() const;
|
||||
void setAngularVelocity(const Vec3d&);
|
||||
|
||||
float getFOV() const;
|
||||
void setFOV(float);
|
||||
|
@ -278,7 +278,7 @@ public:
|
|||
UniversalCoord position;
|
||||
Quatd orientation;
|
||||
Vec3d velocity;
|
||||
Vec3f angularVelocity;
|
||||
Vec3d angularVelocity;
|
||||
|
||||
// Position and orientation in universal coordinates, derived from the
|
||||
// equivalent quantities in the observer reference frame.
|
||||
|
|
|
@ -2262,9 +2262,9 @@ void CelestiaCore::tick()
|
|||
sim->changeOrbitDistance((float) (dt * 2));
|
||||
|
||||
// Keyboard rotate
|
||||
Vec3f av = sim->getObserver().getAngularVelocity();
|
||||
Vec3d av = sim->getObserver().getAngularVelocity();
|
||||
|
||||
av = av * (float) exp(-dt * RotationDecay);
|
||||
av = av * exp(-dt * RotationDecay);
|
||||
|
||||
float fov = sim->getActiveObserver()->getFOV() / stdFOV;
|
||||
Selection refObject = sim->getFrame()->getRefObject();
|
||||
|
@ -2276,26 +2276,23 @@ void CelestiaCore::tick()
|
|||
if (!altAzimuthMode)
|
||||
{
|
||||
if (keysPressed[Key_Left])
|
||||
av += Vec3f(0.0f, 0.0f, (float) (dt * -KeyRotationAccel));
|
||||
av += Vec3d(0.0, 0.0, dt * -KeyRotationAccel);
|
||||
if (keysPressed[Key_Right])
|
||||
av += Vec3f(0.0f, 0.0f, (float) (dt * KeyRotationAccel));
|
||||
av += Vec3d(0.0, 0.0, dt * KeyRotationAccel);
|
||||
if (keysPressed[Key_Down])
|
||||
av += Vec3f((float) (dt * fov * -KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * -KeyRotationAccel, 0.0, 0.0);
|
||||
if (keysPressed[Key_Up])
|
||||
av += Vec3f((float) (dt * fov * KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * KeyRotationAccel, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!refObject.empty())
|
||||
{
|
||||
Quatf orientation = sim->getObserver().getOrientationf();
|
||||
Vec3d upd = sim->getObserver().getPosition() -
|
||||
refObject.getPosition(sim->getTime());
|
||||
upd.normalize();
|
||||
Quatd orientation = sim->getObserver().getOrientation();
|
||||
Vec3d up = sim->getObserver().getPosition() - refObject.getPosition(sim->getTime());
|
||||
up.normalize();
|
||||
|
||||
Vec3f up((float) upd.x, (float) upd.y, (float) upd.z);
|
||||
|
||||
Vec3f v = up * (float) (KeyRotationAccel * dt);
|
||||
Vec3d v = up * (KeyRotationAccel * dt);
|
||||
v = v * (~orientation).toMatrix3();
|
||||
|
||||
if (keysPressed[Key_Left])
|
||||
|
@ -2303,25 +2300,25 @@ void CelestiaCore::tick()
|
|||
if (keysPressed[Key_Right])
|
||||
av += v;
|
||||
if (keysPressed[Key_Down])
|
||||
av += Vec3f((float) (dt * fov * -KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * -KeyRotationAccel, 0.0, 0.0);
|
||||
if (keysPressed[Key_Up])
|
||||
av += Vec3f((float) (dt * fov * KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * KeyRotationAccel, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keysPressed[Key_NumPad4])
|
||||
av += Vec3f(0.0f, (float) (dt * fov * -KeyRotationAccel), 0.0f);
|
||||
av += Vec3d(0.0, dt * fov * -KeyRotationAccel, 0.0);
|
||||
if (keysPressed[Key_NumPad6])
|
||||
av += Vec3f(0.0f, (float) (dt * fov * KeyRotationAccel), 0.0f);
|
||||
av += Vec3d(0.0, dt * fov * KeyRotationAccel, 0.0);
|
||||
if (keysPressed[Key_NumPad2])
|
||||
av += Vec3f((float) (dt * fov * -KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * -KeyRotationAccel, 0.0, 0.0);
|
||||
if (keysPressed[Key_NumPad8])
|
||||
av += Vec3f((float) (dt * fov * KeyRotationAccel), 0.0f, 0.0f);
|
||||
av += Vec3d(dt * fov * KeyRotationAccel, 0.0, 0.0);
|
||||
if (keysPressed[Key_NumPad7] || joyButtonsPressed[JoyButton7])
|
||||
av += Vec3f(0.0f, 0.0f, (float) (dt * -KeyRotationAccel));
|
||||
av += Vec3d(0.0, 0.0, dt * -KeyRotationAccel);
|
||||
if (keysPressed[Key_NumPad9] || joyButtonsPressed[JoyButton8])
|
||||
av += Vec3f(0.0f, 0.0f, (float) (dt * KeyRotationAccel));
|
||||
av += Vec3d(0.0, 0.0, dt * KeyRotationAccel);
|
||||
|
||||
//Use Boolean to indicate if sim->setTargetSpeed() is called
|
||||
bool bSetTargetSpeed = false;
|
||||
|
@ -2329,12 +2326,12 @@ void CelestiaCore::tick()
|
|||
{
|
||||
bSetTargetSpeed = true;
|
||||
|
||||
av += (float) (dt * KeyRotationAccel) * joystickRotation;
|
||||
av += (dt * KeyRotationAccel) * Vec3d(joystickRotation.x, joystickRotation.y, joystickRotation.z);
|
||||
sim->setTargetSpeed(sim->getTargetSpeed());
|
||||
}
|
||||
|
||||
if (keysPressed[Key_NumPad5])
|
||||
av = av * (float) exp(-dt * RotationBraking);
|
||||
av = av * exp(-dt * RotationBraking);
|
||||
|
||||
sim->getObserver().setAngularVelocity(av);
|
||||
|
||||
|
|
Loading…
Reference in New Issue