From: <sv...@ww...> - 2005-08-28 22:54:11
|
Author: mkrose Date: 2005-08-28 15:54:01 -0700 (Sun, 28 Aug 2005) New Revision: 1620 Modified: trunk/CSP/CSPSim/Include/Views/CameraKinematics.h trunk/CSP/CSPSim/Source/Views/CameraAgent.cpp trunk/CSP/CSPSim/Source/Views/CameraKinematics.cpp trunk/CSP/CSPSim/Source/Views/ExternalViews.cpp Log: Use double instead of float in the various view classes. Eliminates various warnings in MSVC while simplifying the code. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1620 Modified: trunk/CSP/CSPSim/Include/Views/CameraKinematics.h =================================================================== --- trunk/CSP/CSPSim/Include/Views/CameraKinematics.h 2005-08-28 22:46:03 UTC (rev 1619) +++ trunk/CSP/CSPSim/Include/Views/CameraKinematics.h 2005-08-28 22:54:01 UTC (rev 1620) @@ -31,24 +31,24 @@ class CameraKinematics: public simdata::Referenced { // XXX: serialize - const float m_BaseRate, m_DisplacementCoefficient; - const float m_MinimumDistanceOffset, m_AbsoluteMaximumDistance; + const double m_BaseRate, m_DisplacementCoefficient; + const double m_MinimumDistanceOffset, m_AbsoluteMaximumDistance; double m_Phi, m_Theta; - float m_FOVScale; - float m_PanRatePhi, m_PanRateTheta, m_ZoomRate; + double m_FOVScale; + double m_PanRatePhi, m_PanRateTheta, m_ZoomRate; double m_DistanceToObject, m_MinimumDistance; double m_Accel; bool m_ExternalPan; void rotateTheta(double dt) { m_Theta += m_Accel * m_PanRateTheta * dt * m_FOVScale; } void rotatePhi(double dt) { m_Phi += m_Accel * m_PanRatePhi * dt * m_FOVScale; } void scale(double dt); - float smooth(double value, float min_value,float max_value) const; + double smooth(double value, double min_value,double max_value) const; public: CameraKinematics(); virtual ~CameraKinematics() {} - void clampPhi(float min_phi,float max_phi, bool smooth_on = true); - void clampTheta(float min_theta,float max_theta, bool smooth_on = true); + void clampPhi(double min_phi,double max_phi, bool smooth_on = true); + void clampTheta(double min_theta,double max_theta, bool smooth_on = true); void reset(); void resetDistance(); void update(double dt); @@ -72,7 +72,7 @@ inline double getPhi() const { return m_Phi; } inline void setTheta(double theta) { m_Theta = theta; } inline double getTheta() const { return m_Theta; } - inline void setDistance(float d) { m_DistanceToObject = d; } + inline void setDistance(double d) { m_DistanceToObject = d; } inline double getDistance() const { return m_DistanceToObject; } void accept(CameraCommand* cc); bool externalPan() const { return m_ExternalPan; } Modified: trunk/CSP/CSPSim/Source/Views/CameraAgent.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Views/CameraAgent.cpp 2005-08-28 22:46:03 UTC (rev 1619) +++ trunk/CSP/CSPSim/Source/Views/CameraAgent.cpp 2005-08-28 22:54:01 UTC (rev 1620) @@ -55,7 +55,7 @@ const simdata::Ref<TerrainObject> terrain = scene->getTerrain(); TerrainObject::IntersectionHint camera_hint = 0; double const SAFETY = 3.0; - float h = SAFETY + terrain->getGroundElevation(m_EyePoint.x(), m_EyePoint.y(), camera_hint); + double h = SAFETY + terrain->getGroundElevation(m_EyePoint.x(), m_EyePoint.y(), camera_hint); // if the eyepoint is near the ground, check more carefully that the terrain isn't // clipped by the near-clipping plane. if (m_EyePoint.z() < h) { Modified: trunk/CSP/CSPSim/Source/Views/CameraKinematics.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Views/CameraKinematics.cpp 2005-08-28 22:46:03 UTC (rev 1619) +++ trunk/CSP/CSPSim/Source/Views/CameraKinematics.cpp 2005-08-28 22:54:01 UTC (rev 1620) @@ -34,7 +34,7 @@ void CameraKinematics::scale(double dt) { - float scale_factor = 1.0 + m_ZoomRate * dt; + double scale_factor = 1.0 + m_ZoomRate * dt; if ((m_DistanceToObject > m_MinimumDistance && scale_factor < 1.0) || (m_DistanceToObject < m_AbsoluteMaximumDistance && scale_factor > 1.0) ) { m_DistanceToObject *= scale_factor; @@ -53,9 +53,9 @@ m_Accel = 1.0 + (m_Accel - 1.0) * std::max(0.0, 1.0 - dt); } -float CameraKinematics::smooth(double value, float min_value, float max_value) const { - float epsilon = 0.1f * fabs(max_value - min_value); - float damping = std::min(value - min_value, max_value - value)/epsilon; +double CameraKinematics::smooth(double value, double min_value, double max_value) const { + double epsilon = 0.1f * fabs(max_value - min_value); + double damping = std::min(value - min_value, max_value - value)/epsilon; if (damping > 0.0 && damping < 1.0) { return damping; } else { @@ -74,14 +74,14 @@ m_ExternalPan(false) { reset(); } -void CameraKinematics::clampPhi(float min_phi, float max_phi, bool smooth_on) { +void CameraKinematics::clampPhi(double min_phi, double max_phi, bool smooth_on) { if (smooth_on && m_PanRatePhi != 0.0) { m_PanRatePhi = simdata::sign(m_PanRatePhi) * smooth(m_Phi, min_phi, max_phi) * m_BaseRate; } m_Phi = simdata::clampTo<double>(m_Phi, min_phi, max_phi); } -void CameraKinematics::clampTheta(float min_theta, float max_theta, bool smooth_on) { +void CameraKinematics::clampTheta(double min_theta, double max_theta, bool smooth_on) { if (smooth_on && m_PanRateTheta != 0.0) { m_PanRateTheta = simdata::sign(m_PanRateTheta)*smooth(m_Theta, min_theta, max_theta)*m_BaseRate; } Modified: trunk/CSP/CSPSim/Source/Views/ExternalViews.cpp =================================================================== --- trunk/CSP/CSPSim/Source/Views/ExternalViews.cpp 2005-08-28 22:46:03 UTC (rev 1619) +++ trunk/CSP/CSPSim/Source/Views/ExternalViews.cpp 2005-08-28 22:54:01 UTC (rev 1620) @@ -126,10 +126,10 @@ void FlybyView::recalculate(simdata::Vector3& ep, simdata::Vector3& /*lp*/, simdata::Vector3& /*up*/, double /*dt*/) { TerrainObject* terrain = CSPSim::theSim->getTerrain(); if (terrain) { - const float SAFETY = 2.0f; + const double SAFETY = 2.0f; TerrainObject::IntersectionHint camera_hint = 0; - float h = SAFETY + terrain->getGroundElevation(ep.x(), ep.y(), camera_hint); - float d = static_cast<float>(ep.z() - h); + double h = SAFETY + terrain->getGroundElevation(ep.x(), ep.y(), camera_hint); + double d = ep.z() - h; if (d<0) ep.z() -= d; } } |