Ticket #3814: cinematic_camera_spline_clear.patch

File cinematic_camera_spline_clear.patch, 3.0 KB (added by Vladislav Belov, 8 years ago)

Adds spline description, fix target spline building

  • source/graphics/CinemaPath.cpp

     
    4343    : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f)
    4444{
    4545    m_TimeElapsed = 0;
     46
     47    // Calculate curves by nodes
    4648    BuildSpline();
     49    m_TargetSpline.BuildSpline();
    4750
    4851    if (m_Orientation == L"target")
    4952    {
  • source/maths/NUSpline.h

     
    1515 * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
    1616 */
    1717
    18 //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
     18// 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
    2121
    2222#ifndef INCLUDED_NUSPLINE
    2323#define INCLUDED_NUSPLINE
    2424
    25 #define MAX_SPLINE_NODES 40
    26 #include <stdlib.h>
     25#define MAX_SPLINE_NODES 128
     26#include <cstdlib>
    2727
    2828#include "FixedVector3D.h"
    2929#include "Vector3D.h"
    3030
     31/**
     32 * Struct for an Spline Node data
     33 */
    3134struct SplineData
    3235{
    3336    // Should be fixed, because used in the simulation
     
    3538    CVector3D Velocity;
    3639    // TODO: make rotation as other spline
    3740    CFixedVector3D Rotation;
    38     fixed Distance/*, DistanceOffset*/; //DistanceOffset is to keep track of how far into the spline this node is
     41    fixed Distance; // Time interval to previous node, should be 0 for first node
    3942};
    4043
     44
     45/**
     46 * Rounded Nonuniform Spline for describing spatial curves or paths with constant speed
     47 */
    4148class RNSpline
    4249{
    4350public:
     
    6168    CVector3D GetEndVelocity(int index);
    6269};
    6370
     71
     72/**
     73 * Smooth Nonuniform Spline for describing paths with smooth acceleration and deceleration,
     74 * but without turning
     75 */
    6476class SNSpline : public RNSpline
    6577{
    6678public:
    6779    virtual ~SNSpline() {}
    68     void BuildSpline(){ RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }
     80    void BuildSpline() { RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }
    6981    void Smooth();
    7082};
    7183
     84
     85/**
     86 * Timed Nonuniform Spline for paths with different time intervals between nodes
     87 */
    7288class TNSpline : public SNSpline
    7389{
    7490public:
     
    8197    void UpdateNodeTime(const int index, fixed time);
    8298    void UpdateNodePos(const int index, const CFixedVector3D& pos);
    8399
    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(); } }
    86102    void Constrain();
    87103};
    88104