Ticket #3814: cinematic_camera_spline_clear.patch
File cinematic_camera_spline_clear.patch, 3.0 KB (added by , 8 years ago) |
---|
-
source/graphics/CinemaPath.cpp
43 43 : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f) 44 44 { 45 45 m_TimeElapsed = 0; 46 47 // Calculate curves by nodes 46 48 BuildSpline(); 49 m_TargetSpline.BuildSpline(); 47 50 48 51 if (m_Orientation == L"target") 49 52 { -
source/maths/NUSpline.h
15 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 17 18 // Desc: Contains classes for smooth splines19 // Borrowed from Game Programming Gems4. (Slightly changed to better suit our purposes20 // (and compatability). Any references to external material can be found there18 // Desc: Contains classes for smooth splines 19 // Borrowed from Game Programming Gems4. (Slightly changed to better suit our purposes 20 // (and compatability). Any references to external material can be found there 21 21 22 22 #ifndef INCLUDED_NUSPLINE 23 23 #define INCLUDED_NUSPLINE 24 24 25 #define MAX_SPLINE_NODES 4026 #include < stdlib.h>25 #define MAX_SPLINE_NODES 128 26 #include <cstdlib> 27 27 28 28 #include "FixedVector3D.h" 29 29 #include "Vector3D.h" 30 30 31 /** 32 * Struct for an Spline Node data 33 */ 31 34 struct SplineData 32 35 { 33 36 // Should be fixed, because used in the simulation … … 35 38 CVector3D Velocity; 36 39 // TODO: make rotation as other spline 37 40 CFixedVector3D Rotation; 38 fixed Distance /*, DistanceOffset*/; //DistanceOffset is to keep track of how far into the spline this node is41 fixed Distance; // Time interval to previous node, should be 0 for first node 39 42 }; 40 43 44 45 /** 46 * Rounded Nonuniform Spline for describing spatial curves or paths with constant speed 47 */ 41 48 class RNSpline 42 49 { 43 50 public: … … 61 68 CVector3D GetEndVelocity(int index); 62 69 }; 63 70 71 72 /** 73 * Smooth Nonuniform Spline for describing paths with smooth acceleration and deceleration, 74 * but without turning 75 */ 64 76 class SNSpline : public RNSpline 65 77 { 66 78 public: 67 79 virtual ~SNSpline() {} 68 void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }80 void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); } 69 81 void Smooth(); 70 82 }; 71 83 84 85 /** 86 * Timed Nonuniform Spline for paths with different time intervals between nodes 87 */ 72 88 class TNSpline : public SNSpline 73 89 { 74 90 public: … … 81 97 void UpdateNodeTime(const int index, fixed time); 82 98 void UpdateNodePos(const int index, const CFixedVector3D& pos); 83 99 84 void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }85 void Smooth() { for (int x = 0; x < 3; ++x) { SNSpline::Smooth(); Constrain(); } }100 void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); } 101 void Smooth() { for (int x = 0; x < 3; ++x) { SNSpline::Smooth(); Constrain(); } } 86 102 void Constrain(); 87 103 }; 88 104