Skip to content

Commit

Permalink
UPBGE: Move interpolator into SG_Controller.
Browse files Browse the repository at this point in the history
Interpolator list was a common attribut of all the classes derived from
SG_Controller, in consideration this attribut is moved into SG_Controller
and the function Update iterate over all the interpolators and call for
update.

In the same time the function UpdateSpatialData always call for parent
relation update as before all the controller subclasses were returning
false in function Update.
  • Loading branch information
panzergame committed Dec 29, 2017
1 parent ad70ea4 commit 7dfc5e2
Show file tree
Hide file tree
Showing 33 changed files with 236 additions and 388 deletions.
6 changes: 3 additions & 3 deletions source/gameengine/Converter/BL_BlenderDataConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ static void bl_ConvertBlenderObject_Single(BL_SceneConverter& converter,
gameobj->NodeSetLocalPosition(pos);
gameobj->NodeSetLocalOrientation(rotation);
gameobj->NodeSetLocalScale(scale);
gameobj->NodeUpdateGS(0);
gameobj->NodeUpdateGS();

sumolist->Add(CM_AddRef(gameobj));

Expand Down Expand Up @@ -1156,7 +1156,7 @@ static void bl_ConvertBlenderObject_Single(BL_SceneConverter& converter,
if (isInActiveLayer) {
objectlist->Add(CM_AddRef(gameobj));

gameobj->NodeUpdateGS(0);
gameobj->NodeUpdateGS();
}
else {
// We must store this object otherwise it will be deleted at the end of this function if it is not a root object.
Expand Down Expand Up @@ -1469,7 +1469,7 @@ void BL_ConvertBlenderObjects(struct Main *maggie,
for (KX_GameObject *gameobj : sumolist) {
if (!gameobj->GetSGNode()->GetSGParent()) {
parentlist->Add(CM_AddRef(gameobj));
gameobj->NodeUpdateGS(0.0);
gameobj->NodeUpdateGS();
}
}

Expand Down
14 changes: 7 additions & 7 deletions source/gameengine/Converter/BL_IpoConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

#include "KX_GameObject.h"
#include "BL_IpoConvert.h"
#include "KX_IInterpolator.h"
#include "SG_IInterpolator.h"
#include "KX_ScalarInterpolator.h"

#include "BL_ScalarInterpolator.h"
Expand Down Expand Up @@ -112,7 +112,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_S
// For each active channel in the adtList add an
// interpolator to the game object.

KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *interp;

for (int i=0; i<3; i++) {
Expand Down Expand Up @@ -166,7 +166,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_S
SG_Controller *BL_CreateObColorIPO(struct bAction *action, KX_GameObject* gameobj, KX_Scene *scene)
{
KX_ObColorIpoSGController* ipocontr_obcol=nullptr;
KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *interp;
BL_InterpolatorList *adtList= GetAdtList(action, scene);

Expand Down Expand Up @@ -200,7 +200,7 @@ SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj
// For each active channel in the adtList add an
// interpolator to the game object.

KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *interp;

if ((interp= adtList->GetScalarInterpolator("energy", 0))) {
Expand Down Expand Up @@ -241,7 +241,7 @@ SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* camera
// For each active channel in the adtList add an
// interpolator to the game object.

KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *interp;

if ((interp = adtList->GetScalarInterpolator("lens", 0))) {
Expand Down Expand Up @@ -274,7 +274,7 @@ SG_Controller * BL_CreateWorldIPO( bAction *action, struct World *blenderworld,
BL_InterpolatorList *adtList = GetAdtList(action, scene);

// For each active channel in the adtList add an interpolator to the game object.
KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *interp;

for (int i=0; i<3; i++) {
Expand Down Expand Up @@ -362,7 +362,7 @@ SG_Controller *BL_CreateMaterialIpo(
KX_MaterialIpoController* ipocontr = nullptr;

BL_InterpolatorList *adtList= GetAdtList(action, scene);
KX_IInterpolator *interpolator;
SG_IInterpolator *interpolator;
BL_ScalarInterpolator *sinterp;

// --
Expand Down
1 change: 0 additions & 1 deletion source/gameengine/Ketsji/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ set(SRC
KX_GameActuator.h
KX_GameObject.h
KX_Globals.h
KX_IInterpolator.h
KX_IPOTransform.h
KX_IPO_SGController.h
KX_IScalarInterpolator.h
Expand Down
62 changes: 20 additions & 42 deletions source/gameengine/Ketsji/KX_CameraIpoSGController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,28 @@ typedef unsigned __int64 uint_ptr;
typedef unsigned long uint_ptr;
#endif

bool KX_CameraIpoSGController::Update(double currentTime)
bool KX_CameraIpoSGController::Update()
{
if (m_modified)
{
T_InterpolatorList::iterator i;
for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
(*i)->Execute(m_ipotime);
}

SG_Node* ob = (SG_Node*)m_node;
KX_Camera* kxcamera = (KX_Camera*) ob->GetSGClientObject();
RAS_CameraData* camdata = kxcamera->GetCameraData();

if (m_modify_lens)
camdata->m_lens = m_lens;

if (m_modify_clipstart )
camdata->m_clipstart = m_clipstart;

if (m_modify_clipend)
camdata->m_clipend = m_clipend;

if (m_modify_lens || m_modify_clipstart || m_modify_clipend)
kxcamera->InvalidateProjectionMatrix();

m_modified=false;
if (!SG_Controller::Update()) {
return false;
}
return false;
}

KX_Camera* kxcamera = (KX_Camera *)m_node->GetSGClientObject();
RAS_CameraData* camdata = kxcamera->GetCameraData();

void KX_CameraIpoSGController::AddInterpolator(KX_IInterpolator* interp)
{
this->m_interpolators.push_back(interp);
if (m_modify_lens)
camdata->m_lens = m_lens;

if (m_modify_clipstart )
camdata->m_clipstart = m_clipstart;

if (m_modify_clipend)
camdata->m_clipend = m_clipend;

if (m_modify_lens || m_modify_clipstart || m_modify_clipend)
kxcamera->InvalidateProjectionMatrix();

return true;
}

SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode)
Expand All @@ -86,10 +74,10 @@ SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode)
// dirty hack, ask Gino for a better solution in the ipo implementation
// hacken en zagen, in what we call datahiding, not written for replication :(

T_InterpolatorList oldlist = m_interpolators;
SG_IInterpolatorList oldlist = m_interpolators;
iporeplica->m_interpolators.clear();

T_InterpolatorList::iterator i;
SG_IInterpolatorList::iterator i;
for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
iporeplica->AddInterpolator(copyipo);
Expand All @@ -105,13 +93,3 @@ SG_Controller* KX_CameraIpoSGController::GetReplica(class SG_Node* destnode)

return iporeplica;
}

KX_CameraIpoSGController::~KX_CameraIpoSGController()
{

T_InterpolatorList::iterator i;
for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
delete (*i);
}

}
12 changes: 3 additions & 9 deletions source/gameengine/Ketsji/KX_CameraIpoSGController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "SG_Controller.h"
#include "SG_Node.h"

#include "KX_IInterpolator.h"
#include "SG_IInterpolator.h"

struct RAS_CameraData;

Expand All @@ -47,7 +47,6 @@ class KX_CameraIpoSGController : public SG_Controller
float m_clipend;

private:
T_InterpolatorList m_interpolators;
unsigned short m_modify_lens : 1;
unsigned short m_modify_clipstart : 1;
unsigned short m_modify_clipend : 1;
Expand All @@ -59,14 +58,10 @@ class KX_CameraIpoSGController : public SG_Controller
m_modify_clipend(false)
{}

~KX_CameraIpoSGController();
virtual ~KX_CameraIpoSGController() = default;
SG_Controller* GetReplica(class SG_Node* destnode);
bool Update(double time);
virtual bool Update();

void SetSimulatedTime(double time) {
m_ipotime = time;
m_modified = true;
}
void SetModifyLens(bool modify) {
m_modify_lens = modify;
}
Expand All @@ -76,7 +71,6 @@ class KX_CameraIpoSGController : public SG_Controller
void SetModifyClipStart(bool modify) {
m_modify_clipstart = modify;
}
void AddInterpolator(KX_IInterpolator* interp);
};

#endif /* __KX_CAMERAIPOSGCONTROLLER_H__ */
Loading

0 comments on commit 7dfc5e2

Please sign in to comment.