From a972f04fbf66590c922346491b813f074acf4d9b Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Wed, 27 Dec 2017 18:49:51 +0100 Subject: [PATCH] UPBGE: Cleanup BL_ScalarInterpolator.[h/cpp]. This cleanup includes: - uncrustify pass - remove extra class/struct keyword - move function definition to .cpp. --- .../Converter/BL_ScalarInterpolator.cpp | 35 +++++++++++-------- .../Converter/BL_ScalarInterpolator.h | 30 +++++++--------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/source/gameengine/Converter/BL_ScalarInterpolator.cpp b/source/gameengine/Converter/BL_ScalarInterpolator.cpp index eb7dd8b607e8..42dba918c244 100644 --- a/source/gameengine/Converter/BL_ScalarInterpolator.cpp +++ b/source/gameengine/Converter/BL_ScalarInterpolator.cpp @@ -29,33 +29,39 @@ * \ingroup bgeconv */ - #include "BL_ScalarInterpolator.h" -#include - extern "C" { -#include "DNA_action_types.h" -#include "DNA_anim_types.h" -#include "BKE_fcurve.h" +# include "DNA_action_types.h" +# include "DNA_anim_types.h" +# include "BKE_fcurve.h" +} + +BL_ScalarInterpolator::BL_ScalarInterpolator(FCurve *fcu) + :m_fcu(fcu) +{ } float BL_ScalarInterpolator::GetValue(float currentTime) const { - // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime); return evaluate_fcurve(m_fcu, currentTime); } +FCurve *BL_ScalarInterpolator::GetFCurve() const +{ + return m_fcu; +} + BL_InterpolatorList::BL_InterpolatorList(bAction *action) :m_action(action) { - if (action==nullptr) + if (!action) { return; - + } + for (FCurve *fcu = (FCurve *)action->curves.first; fcu; fcu = fcu->next) { if (fcu->rna_path) { - BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); - //assert(new_ipo); + BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); m_interpolators.push_back(new_ipo); } } @@ -73,12 +79,13 @@ bAction *BL_InterpolatorList::GetAction() const return m_action; } -BL_ScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) +BL_ScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const std::string& rna_path, int array_index) { for (BL_ScalarInterpolator *interp : m_interpolators) { - FCurve *fcu= interp->GetFCurve(); - if (array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0) + FCurve *fcu = interp->GetFCurve(); + if (array_index == fcu->array_index && rna_path == fcu->rna_path) { return interp; + } } return nullptr; } diff --git a/source/gameengine/Converter/BL_ScalarInterpolator.h b/source/gameengine/Converter/BL_ScalarInterpolator.h index 60a5d0182ca3..f4c95de3eb82 100644 --- a/source/gameengine/Converter/BL_ScalarInterpolator.h +++ b/source/gameengine/Converter/BL_ScalarInterpolator.h @@ -32,31 +32,27 @@ #ifndef __KX_BLENDERSCALARINTERPOLATOR_H__ #define __KX_BLENDERSCALARINTERPOLATOR_H__ -#include - #include "KX_IScalarInterpolator.h" +#include +#include + struct bAction; +struct FCurve; -typedef unsigned short BL_IpoChannel; +class BL_ScalarInterpolator : public KX_IScalarInterpolator +{ +private: + FCurve *m_fcu; -class BL_ScalarInterpolator : public KX_IScalarInterpolator { public: - BL_ScalarInterpolator() {} // required for use in STL list - BL_ScalarInterpolator(struct FCurve* fcu) : - m_fcu(fcu) - {} + BL_ScalarInterpolator(FCurve *fcu); + virtual ~BL_ScalarInterpolator() = default; - virtual ~BL_ScalarInterpolator() {} - virtual float GetValue(float currentTime) const; - struct FCurve *GetFCurve() { return m_fcu; } - -private: - struct FCurve *m_fcu; + FCurve *GetFCurve() const; }; - class BL_InterpolatorList { private: @@ -64,12 +60,12 @@ class BL_InterpolatorList std::vector m_interpolators; public: - BL_InterpolatorList(struct bAction *action); + BL_InterpolatorList(bAction *action); ~BL_InterpolatorList(); bAction *GetAction() const; - BL_ScalarInterpolator *GetScalarInterpolator(const char *rna_path, int array_index); + BL_ScalarInterpolator *GetScalarInterpolator(const std::string& rna_path, int array_index); }; #endif /* __KX_BLENDERSCALARINTERPOLATOR_H__ */