Ticket #3814: cinematic_camera_cleanup_1.patch
File cinematic_camera_cleanup_1.patch, 7.2 KB (added by , 8 years ago) |
---|
-
source/graphics/CinemaPath.cpp
194 194 #endif 195 195 } 196 196 197 CVector3D CCinemaPath::GetNodePosition(const int index) const 198 { 199 return Node[index].Position; 200 } 201 202 fixed CCinemaPath::GetNodeDuration(const int index) const 203 { 204 return Node[index].Distance; 205 } 206 207 fixed CCinemaPath::GetDuration() const 208 { 209 return MaxDistance; 210 } 211 212 float CCinemaPath::GetNodeFraction() const 213 { 214 return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance.ToFloat(); 215 } 216 217 float CCinemaPath::GetElapsedTime() const 218 { 219 return m_TimeElapsed; 220 } 221 222 CStrW CCinemaPath::GetName() const 223 { 224 return m_Name; 225 } 226 227 void CCinemaPath::SetTimescale(fixed scale) 228 { 229 m_Timescale = scale; 230 } 231 197 232 void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation) 198 233 { 199 234 CCamera *camera = g_Game->GetView()->GetCamera(); … … 288 323 return t; 289 324 } 290 325 326 const CCinemaData* CCinemaPath::GetData() const 327 { 328 return CCinemaData::GetData(); 329 } 330 291 331 bool CCinemaPath::Validate() 292 332 { 293 333 if (m_TimeElapsed > GetDuration().ToFloat() || m_TimeElapsed < 0.0f) … … 324 364 325 365 MoveToPointAt(m_TimeElapsed / GetDuration().ToFloat(), GetNodeFraction(), m_PreviousRotation); 326 366 return true; 327 } 328 No newline at end of file 367 } 368 369 bool CCinemaPath::Empty() const 370 { 371 return Node.empty(); 372 } 373 374 fixed CCinemaPath::GetTimescale() const 375 { 376 return m_Timescale; 377 } 378 379 const TNSpline& CCinemaPath::getTargetSpline() const 380 { 381 return m_TargetSpline; 382 } -
source/graphics/CinemaPath.h
59 59 public: 60 60 CCinemaPath() : m_TimeElapsed(0), m_PreviousNodeTime(0) {} 61 61 CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline); 62 ~CCinemaPath() { DistStylePtr = NULL; DistModePtr = NULL; }63 62 64 63 // Sets camera position to calculated point on spline 65 64 void MoveToPointAt(float t, float nodet, const CVector3D&); … … 80 79 float (CCinemaPath::*DistStylePtr)(float ratio) const; 81 80 float (CCinemaPath::*DistModePtr)(float ratio) const; 82 81 83 const CCinemaData* GetData() const { return CCinemaData::GetData(); }82 const CCinemaData* GetData() const; 84 83 85 84 public: 86 85 … … 88 87 void DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const; 89 88 void DrawNodes(const CVector4D& RGBA) const; 90 89 91 inline CVector3D GetNodePosition(const int index) const { return Node[index].Position; }92 inline fixed GetNodeDuration(const int index) const { return Node[index].Distance; }93 inline fixed GetDuration() const { return MaxDistance; }90 CVector3D GetNodePosition(const int index) const; 91 fixed GetNodeDuration(const int index) const; 92 fixed GetDuration() const; 94 93 95 inline float GetNodeFraction() const { return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance.ToFloat(); }96 inline float GetElapsedTime() const { return m_TimeElapsed; }94 float GetNodeFraction() const; 95 float GetElapsedTime() const; 97 96 98 CStrW GetName() const { return m_Name; }97 CStrW GetName() const; 99 98 100 inline void SetTimescale(fixed scale) { m_Timescale = scale; }99 void SetTimescale(fixed scale); 101 100 102 101 float m_TimeElapsed; 103 102 float m_PreviousNodeTime; // How much time has passed before the current node … … 122 121 /** 123 122 * Returns true if path doesn't contain nodes 124 123 */ 125 bool Empty() { return Node.empty(); }124 bool Empty() const; 126 125 127 fixed GetTimescale() const { return m_Timescale; }126 fixed GetTimescale() const; 128 127 129 const TNSpline& getTargetSpline() const { return m_TargetSpline; }128 const TNSpline& getTargetSpline() const; 130 129 131 130 private: 132 131 -
source/maths/NUSpline.cpp
44 44 45 45 /*********************************** R N S **************************************************/ 46 46 47 RNSpline::RNSpline() 48 : NodeCount(0) 49 { 50 } 51 47 52 // adds node and updates segment length 48 53 void RNSpline::AddNode(const CFixedVector3D& pos) 49 54 { … … 124 129 Node[i+1].Position, endVel, t); 125 130 } 126 131 132 const std::vector<SplineData>& RNSpline::GetAllNodes() const 133 { 134 return Node; 135 } 136 127 137 // internal. Based on Equation 14 128 138 CVector3D RNSpline::GetStartVelocity(int index) 129 139 { … … 144 154 145 155 /*********************************** S N S **************************************************/ 146 156 157 void SNSpline::BuildSpline() 158 { 159 RNSpline::BuildSpline(); 160 for (int i = 0; i < 3; ++i) 161 Smooth(); 162 } 163 147 164 // smoothing filter. 148 165 void SNSpline::Smooth() 149 166 { … … 223 240 Node.erase(Node.begin() + index, Node.begin() + index + 1); 224 241 --NodeCount; 225 242 } 243 226 244 void TNSpline::UpdateNodeTime(const int index, fixed time) 227 245 { 228 246 if (NodeCount == 0 || index > NodeCount - 1) … … 230 248 231 249 Node[index].Distance = time; 232 250 } 251 233 252 void TNSpline::UpdateNodePos(const int index, const CFixedVector3D& pos) 234 253 { 235 254 if (NodeCount == 0 || index > NodeCount - 1) … … 238 257 Node[index].Position = pos; 239 258 } 240 259 260 void TNSpline::BuildSpline() 261 { 262 RNSpline::BuildSpline(); 263 for (int i = 0; i < 3; ++i) 264 Smooth(); 265 } 266 267 void TNSpline::Smooth() 268 { 269 for (int i = 0; i < 3; ++i) 270 { 271 SNSpline::Smooth(); 272 Constrain(); 273 } 274 } 275 241 276 void TNSpline::Constrain() 242 277 { 243 278 if (NodeCount < 3) -
source/maths/NUSpline.h
51 51 { 52 52 public: 53 53 54 RNSpline() { NodeCount = 0; }55 virtual ~RNSpline() {}54 RNSpline(); 55 virtual ~RNSpline() = default; 56 56 57 57 void AddNode(const CFixedVector3D& pos); 58 58 void BuildSpline(); 59 59 CVector3D GetPosition(float time) const; 60 60 CVector3D GetRotation(float time) const; 61 const std::vector<SplineData>& GetAllNodes() const { return Node; }61 const std::vector<SplineData>& GetAllNodes() const; 62 62 63 63 fixed MaxDistance; 64 64 int NodeCount; … … 78 78 class SNSpline : public RNSpline 79 79 { 80 80 public: 81 virtual ~SNSpline() {} 82 void BuildSpline(){ RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); } 81 virtual ~SNSpline() = default; 82 83 void BuildSpline(); 83 84 void Smooth(); 84 85 }; 85 86 … … 90 91 class TNSpline : public SNSpline 91 92 { 92 93 public: 93 virtual ~TNSpline() {}94 virtual ~TNSpline() = default; 94 95 95 96 void AddNode(const CFixedVector3D& pos, const CFixedVector3D& rotation, fixed timePeriod); 96 void PushNode() { Node.push_back( SplineData() ); }97 97 void InsertNode(const int index, const CFixedVector3D& pos, const CFixedVector3D& rotation, fixed timePeriod); 98 98 void RemoveNode(const int index); 99 void UpdateNodePos(const int index, const CFixedVector3D& pos); 99 100 void UpdateNodeTime(const int index, fixed time); 100 void UpdateNodePos(const int index, const CFixedVector3D& pos);101 101 102 void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }103 void Smooth() { for (int x = 0; x < 3; ++x) { SNSpline::Smooth(); Constrain(); } }102 void BuildSpline(); 103 void Smooth(); 104 104 void Constrain(); 105 105 }; 106 106