Skip to content

Commit

Permalink
UPBGE: Cleanup BL_ScalarInterpolator.[h/cpp].
Browse files Browse the repository at this point in the history
This cleanup includes:
- uncrustify pass
- remove extra class/struct keyword
- move function definition to .cpp.
  • Loading branch information
panzergame committed Dec 27, 2017
1 parent 95774a1 commit a972f04
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
35 changes: 21 additions & 14 deletions source/gameengine/Converter/BL_ScalarInterpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,39 @@
* \ingroup bgeconv
*/


#include "BL_ScalarInterpolator.h"

#include <cstring>

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);
}
}
Expand All @@ -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;
}
Expand Down
30 changes: 13 additions & 17 deletions source/gameengine/Converter/BL_ScalarInterpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,40 @@
#ifndef __KX_BLENDERSCALARINTERPOLATOR_H__
#define __KX_BLENDERSCALARINTERPOLATOR_H__

#include <vector>

#include "KX_IScalarInterpolator.h"

#include <vector>
#include <string>

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:
bAction *m_action;
std::vector<BL_ScalarInterpolator *> 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__ */

0 comments on commit a972f04

Please sign in to comment.