Ticket #3814: cinematic_camera_cleanup_1.patch

File cinematic_camera_cleanup_1.patch, 7.2 KB (added by Vladislav Belov, 8 years ago)
  • source/graphics/CinemaPath.cpp

     
    194194#endif
    195195}
    196196
     197CVector3D CCinemaPath::GetNodePosition(const int index) const
     198{
     199    return Node[index].Position;
     200}
     201
     202fixed CCinemaPath::GetNodeDuration(const int index) const
     203{
     204    return Node[index].Distance;
     205}
     206
     207fixed CCinemaPath::GetDuration() const
     208{
     209    return MaxDistance;
     210}
     211
     212float CCinemaPath::GetNodeFraction() const
     213{
     214    return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance.ToFloat();
     215}
     216
     217float CCinemaPath::GetElapsedTime() const
     218{
     219    return m_TimeElapsed;
     220}
     221
     222CStrW CCinemaPath::GetName() const
     223{
     224    return m_Name;
     225}
     226
     227void CCinemaPath::SetTimescale(fixed scale)
     228{
     229    m_Timescale = scale;
     230}
     231
    197232void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation)
    198233{
    199234    CCamera *camera = g_Game->GetView()->GetCamera();
     
    288323    return t;
    289324}
    290325
     326const CCinemaData* CCinemaPath::GetData() const
     327{
     328    return CCinemaData::GetData();
     329}
     330
    291331bool CCinemaPath::Validate()
    292332{
    293333    if (m_TimeElapsed > GetDuration().ToFloat() || m_TimeElapsed < 0.0f)
     
    324364
    325365    MoveToPointAt(m_TimeElapsed / GetDuration().ToFloat(), GetNodeFraction(), m_PreviousRotation);
    326366    return true;
    327 }
    328  No newline at end of file
     367}
     368
     369bool CCinemaPath::Empty() const
     370{
     371    return Node.empty();
     372}
     373
     374fixed CCinemaPath::GetTimescale() const
     375{
     376    return m_Timescale;
     377}
     378
     379const TNSpline& CCinemaPath::getTargetSpline() const
     380{
     381    return m_TargetSpline;
     382}
  • source/graphics/CinemaPath.h

     
    5959public:
    6060    CCinemaPath() : m_TimeElapsed(0), m_PreviousNodeTime(0) {}
    6161    CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
    62     ~CCinemaPath() { DistStylePtr = NULL;  DistModePtr = NULL; }
    6362
    6463    // Sets camera position to calculated point on spline
    6564    void MoveToPointAt(float t, float nodet, const CVector3D&);
     
    8079    float (CCinemaPath::*DistStylePtr)(float ratio) const;
    8180    float (CCinemaPath::*DistModePtr)(float ratio) const;
    8281
    83     const CCinemaData* GetData() const { return CCinemaData::GetData(); }
     82    const CCinemaData* GetData() const;
    8483
    8584public:
    8685
     
    8887    void DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const;
    8988    void DrawNodes(const CVector4D& RGBA) const;
    9089
    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;
    9493
    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;
    9796
    98     CStrW GetName() const { return m_Name; }
     97    CStrW GetName() const;
    9998
    100     inline void SetTimescale(fixed scale) { m_Timescale = scale; }
     99    void SetTimescale(fixed scale);
    101100
    102101    float m_TimeElapsed;
    103102    float m_PreviousNodeTime; // How much time has passed before the current node
     
    122121    /**
    123122     * Returns true if path doesn't contain nodes
    124123     */
    125     bool Empty() { return Node.empty(); }
     124    bool Empty() const;
    126125
    127     fixed GetTimescale() const { return m_Timescale; }
     126    fixed GetTimescale() const;
    128127
    129     const TNSpline& getTargetSpline() const { return m_TargetSpline; }
     128    const TNSpline& getTargetSpline() const;
    130129
    131130private:
    132131
  • source/maths/NUSpline.cpp

     
    4444
    4545/*********************************** R N S **************************************************/
    4646
     47RNSpline::RNSpline()
     48    : NodeCount(0)
     49{
     50}
     51
    4752// adds node and updates segment length
    4853void RNSpline::AddNode(const CFixedVector3D& pos)
    4954{
     
    124129        Node[i+1].Position, endVel, t);
    125130}
    126131
     132const std::vector<SplineData>& RNSpline::GetAllNodes() const
     133{
     134    return Node;
     135}
     136
    127137// internal. Based on Equation 14
    128138CVector3D RNSpline::GetStartVelocity(int index)
    129139{
     
    144154
    145155/*********************************** S N S **************************************************/
    146156
     157void SNSpline::BuildSpline()
     158{
     159    RNSpline::BuildSpline();
     160    for (int i = 0; i < 3; ++i)
     161        Smooth();
     162}
     163
    147164// smoothing filter.
    148165void SNSpline::Smooth()
    149166{
     
    223240    Node.erase(Node.begin() + index, Node.begin() + index + 1);
    224241    --NodeCount;
    225242}
     243
    226244void TNSpline::UpdateNodeTime(const int index, fixed time)
    227245{
    228246    if (NodeCount == 0 || index > NodeCount - 1)
     
    230248
    231249    Node[index].Distance = time;
    232250}
     251
    233252void TNSpline::UpdateNodePos(const int index, const CFixedVector3D& pos)
    234253{
    235254    if (NodeCount == 0 || index > NodeCount - 1)
     
    238257    Node[index].Position = pos;
    239258}
    240259
     260void TNSpline::BuildSpline()
     261{
     262    RNSpline::BuildSpline();
     263    for (int i = 0; i < 3; ++i)
     264        Smooth();
     265}
     266
     267void TNSpline::Smooth()
     268{
     269    for (int i = 0; i < 3; ++i)
     270    {
     271        SNSpline::Smooth();
     272        Constrain();
     273    }
     274}
     275
    241276void TNSpline::Constrain()
    242277{
    243278    if (NodeCount < 3)
  • source/maths/NUSpline.h

     
    5151{
    5252public:
    5353
    54     RNSpline() { NodeCount = 0; }
    55     virtual ~RNSpline() {}
     54    RNSpline();
     55    virtual ~RNSpline() = default;
    5656
    5757    void AddNode(const CFixedVector3D& pos);
    5858    void BuildSpline();
    5959    CVector3D GetPosition(float time) const;
    6060    CVector3D GetRotation(float time) const;
    61     const std::vector<SplineData>& GetAllNodes() const { return Node; }
     61    const std::vector<SplineData>& GetAllNodes() const;
    6262
    6363    fixed MaxDistance;
    6464    int NodeCount;
     
    7878class SNSpline : public RNSpline
    7979{
    8080public:
    81     virtual ~SNSpline() {}
    82     void BuildSpline(){ RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }
     81    virtual ~SNSpline() = default;
     82
     83    void BuildSpline();
    8384    void Smooth();
    8485};
    8586
     
    9091class TNSpline : public SNSpline
    9192{
    9293public:
    93     virtual ~TNSpline() {}
     94    virtual ~TNSpline() = default;
    9495
    9596    void AddNode(const CFixedVector3D& pos, const CFixedVector3D& rotation, fixed timePeriod);
    96     void PushNode() { Node.push_back( SplineData() ); }
    9797    void InsertNode(const int index, const CFixedVector3D& pos, const CFixedVector3D& rotation, fixed timePeriod);
    9898    void RemoveNode(const int index);
     99    void UpdateNodePos(const int index, const CFixedVector3D& pos);
    99100    void UpdateNodeTime(const int index, fixed time);
    100     void UpdateNodePos(const int index, const CFixedVector3D& pos);
    101101
    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();
    104104    void Constrain();
    105105};
    106106