diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 18028634f96b..e93706ffaa15 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -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)); @@ -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. @@ -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(); } } diff --git a/source/gameengine/Converter/BL_IpoConvert.cpp b/source/gameengine/Converter/BL_IpoConvert.cpp index 48d42b2815bf..097947352431 100644 --- a/source/gameengine/Converter/BL_IpoConvert.cpp +++ b/source/gameengine/Converter/BL_IpoConvert.cpp @@ -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" @@ -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++) { @@ -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); @@ -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))) { @@ -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))) { @@ -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++) { @@ -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; // -- diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 1d2224c96ab6..fd37ed78efcb 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -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 diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp index 250312bc4061..99a774d21597 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp @@ -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) @@ -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); @@ -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); - } - -} diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index 55d290ad7844..6e30cf017a07 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -35,7 +35,7 @@ #include "SG_Controller.h" #include "SG_Node.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" struct RAS_CameraData; @@ -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; @@ -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; } @@ -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__ */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index b1fb440e9c56..a85053fd0120 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -355,7 +355,7 @@ void KX_GameObject::SetParent(KX_GameObject* obj, bool addToCompound, bool ghost NodeSetLocalScale(scale1); NodeSetLocalPosition(mt::vec3(newpos[0],newpos[1],newpos[2])); NodeSetLocalOrientation(invori*NodeGetWorldOrientation()); - NodeUpdateGS(0.f); + NodeUpdateGS(); // object will now be a child, it must be removed from the parent list EXP_ListValue *rootlist = scene->GetRootParentList(); if (rootlist->RemoveValue(this)) @@ -393,7 +393,7 @@ void KX_GameObject::RemoveParent() // Remove us from our parent GetSGNode()->DisconnectFromParent(); - NodeUpdateGS(0.f); + NodeUpdateGS(); KX_Scene *scene = GetScene(); // the object is now a root object, add it to the parentlist @@ -675,7 +675,7 @@ void KX_GameObject::ApplyMovement(const mt::vec3& dloc,bool local) m_physicsController->RelativeTranslate(dloc,local); } GetSGNode()->RelativeTranslate(dloc,GetSGNode()->GetSGParent(),local); - NodeUpdateGS(0.0f); + NodeUpdateGS(); } void KX_GameObject::ApplyRotation(const mt::vec3& drot,bool local) @@ -687,7 +687,7 @@ void KX_GameObject::ApplyRotation(const mt::vec3& drot,bool local) if (m_physicsController) { // (IsDynamic()) m_physicsController->RelativeRotate(rotmat,local); } - NodeUpdateGS(0.0f); + NodeUpdateGS(); } void KX_GameObject::UpdateBlenderObjectMatrix(Object* blendobj) @@ -877,14 +877,11 @@ void KX_GameObject::InitIPO(bool ipo_as_force, bool ipo_add, bool ipo_local) { - SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin(); - - while (it != GetSGNode()->GetSGControllerList().end()) { - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true); - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force); - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, ipo_add); - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local); - it++; + for (SG_Controller *cont : m_sgNode->GetSGControllerList()) { + cont->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true); + cont->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force); + cont->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, ipo_add); + cont->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local); } } @@ -892,8 +889,8 @@ void KX_GameObject::UpdateIPO(float curframetime, bool recurse) { // just the 'normal' update procedure. - GetSGNode()->SetSimulatedTimeThread(curframetime,recurse); - GetSGNode()->UpdateWorldDataThread(curframetime); + GetSGNode()->SetSimulatedTimeThread(curframetime, recurse); + GetSGNode()->UpdateWorldDataThread(); } bool @@ -1337,10 +1334,9 @@ void KX_GameObject::NodeSetWorldPosition(const mt::vec3& trans) } } - -void KX_GameObject::NodeUpdateGS(double time) +void KX_GameObject::NodeUpdateGS() { - m_sgNode->UpdateWorldData(time); + m_sgNode->UpdateWorldData(); } const mt::mat3& KX_GameObject::NodeGetWorldOrientation() const @@ -1735,19 +1731,19 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeSetLocalPosition(mt::vec3(bmo->data)); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); break; case MATHUTILS_VEC_CB_POS_GLOBAL: self->NodeSetWorldPosition(mt::vec3(bmo->data)); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); break; case MATHUTILS_VEC_CB_SCALE_LOCAL: self->NodeSetLocalScale(mt::vec3(bmo->data)); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); break; case MATHUTILS_VEC_CB_SCALE_GLOBAL: self->NodeSetWorldScale(mt::vec3(bmo->data)); - self->NodeUpdateGS(0.0f); + self->NodeUpdateGS(); break; case MATHUTILS_VEC_CB_INERTIA_LOCAL: /* read only */ @@ -1839,12 +1835,12 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) case MATHUTILS_MAT_CB_ORI_LOCAL: mat3x3 = mt::mat3(bmo->data); self->NodeSetLocalOrientation(mat3x3); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); break; case MATHUTILS_MAT_CB_ORI_GLOBAL: mat3x3 = mt::mat3(bmo->data); self->NodeSetLocalOrientation(mat3x3); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); break; } @@ -2728,7 +2724,7 @@ int KX_GameObject::pyattr_set_worldPosition(EXP_PyObjectPlus *self_v, const EXP_ return PY_SET_ATTR_FAIL; self->NodeSetWorldPosition(pos); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -2752,7 +2748,7 @@ int KX_GameObject::pyattr_set_localPosition(EXP_PyObjectPlus *self_v, const EXP_ return PY_SET_ATTR_FAIL; self->NodeSetLocalPosition(pos); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -2793,7 +2789,7 @@ int KX_GameObject::pyattr_set_worldOrientation(EXP_PyObjectPlus *self_v, const E self->NodeSetGlobalOrientation(rot); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -2819,7 +2815,7 @@ int KX_GameObject::pyattr_set_localOrientation(EXP_PyObjectPlus *self_v, const E return PY_SET_ATTR_FAIL; self->NodeSetLocalOrientation(rot); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -2843,7 +2839,7 @@ int KX_GameObject::pyattr_set_worldScaling(EXP_PyObjectPlus *self_v, const EXP_P return PY_SET_ATTR_FAIL; self->NodeSetWorldScale(scale); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -2867,7 +2863,7 @@ int KX_GameObject::pyattr_set_localScaling(EXP_PyObjectPlus *self_v, const EXP_P return PY_SET_ATTR_FAIL; self->NodeSetLocalScale(scale); - self->NodeUpdateGS(0.f); + self->NodeUpdateGS(); return PY_SET_ATTR_SUCCESS; } @@ -3715,7 +3711,7 @@ PyObject *KX_GameObject::PyAlignAxisToVect(PyObject *args, PyObject *kwds) if (fac> 1.0f) fac = 1.0f; AlignAxisToVect(vect, axis, fac); - NodeUpdateGS(0.f); + NodeUpdateGS(); } Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 12949ae86d42..d533cbac4585 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -505,10 +505,7 @@ class KX_GameObject : public SCA_IObject, public mt::SimdClassAllocator // adapt local position so that world position is set to desired position void NodeSetWorldPosition(const mt::vec3& trans); - void - NodeUpdateGS( - double time - ); + void NodeUpdateGS(); const mt::mat3& NodeGetWorldOrientation( ) const; const mt::vec3& NodeGetWorldScaling( ) const; diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 7d02967ba7c2..89efe6dc6cb3 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -103,16 +103,12 @@ void KX_IpoSGController::SetGameObject(KX_GameObject *go) m_game_object = go; } -bool KX_IpoSGController::Update(double currentTime) +bool KX_IpoSGController::Update() { - if (!m_modified) { + if (!SG_Controller::Update()) { return false; } - for (KX_IInterpolator *interp : m_interpolators) { - interp->Execute(m_ipotime); - } - //initialization on the first frame of the IPO if (!m_ipo_start_initialized) { m_ipo_start_point = m_node->GetLocalPosition(); @@ -316,14 +312,7 @@ bool KX_IpoSGController::Update(double currentTime) m_game_object->NodeSetLocalScale(newScale); } - m_modified = false; - - return false; -} - -void KX_IpoSGController::AddInterpolator(KX_IInterpolator *interp) -{ - m_interpolators.push_back(interp); + return true; } SG_Controller *KX_IpoSGController::GetReplica(SG_Node *destnode) @@ -336,10 +325,10 @@ SG_Controller *KX_IpoSGController::GetReplica(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); @@ -356,11 +345,3 @@ SG_Controller *KX_IpoSGController::GetReplica(SG_Node *destnode) return iporeplica; } - -KX_IpoSGController::~KX_IpoSGController() -{ - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); i != m_interpolators.end(); ++i) { - delete (*i); - } -} diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index b39f2b00153a..9eff69d24bda 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -36,14 +36,13 @@ #include "SG_Node.h" #include "KX_IPOTransform.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #define KX_MAX_IPO_CHANNELS 19 //note- [0] is not used class KX_IpoSGController : public SG_Controller, public mt::SimdClassAllocator { KX_IPOTransform m_ipo_xform; - T_InterpolatorList m_interpolators; /** Flag for each IPO channel that can be applied to a game object */ bool m_ipo_channels_active[KX_MAX_IPO_CHANNELS]; @@ -80,7 +79,7 @@ class KX_IpoSGController : public SG_Controller, public mt::SimdClassAllocator public: KX_IpoSGController(); - virtual ~KX_IpoSGController(); + virtual ~KX_IpoSGController() = default; virtual SG_Controller *GetReplica(class SG_Node *destnode); @@ -99,8 +98,7 @@ class KX_IpoSGController : public SG_Controller, public mt::SimdClassAllocator return m_ipo_xform; } - void AddInterpolator(KX_IInterpolator *interp); - virtual bool Update(double time); + virtual bool Update(); }; #endif /* __KX_IPO_SGCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b6b2924799fc..a279b1341f00 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -433,7 +433,7 @@ bool KX_KetsjiEngine::NextFrame() // Scenegraph needs to be updated again, because Logic Controllers // can affect the local matrices. m_logger.StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds()); - scene->UpdateParents(m_frameTime); + scene->UpdateParents(); // Process actuators @@ -445,7 +445,7 @@ bool KX_KetsjiEngine::NextFrame() // Actuators can affect the scenegraph m_logger.StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds()); - scene->UpdateParents(m_frameTime); + scene->UpdateParents(); m_logger.StartLog(tc_physics, m_kxsystem->GetTimeInSeconds()); @@ -454,7 +454,7 @@ bool KX_KetsjiEngine::NextFrame() scene->GetPhysicsEnvironment()->ProceedDeltaTime(m_frameTime, timestep, framestep);//m_deltatimerealDeltaTime); m_logger.StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds()); - scene->UpdateParents(m_frameTime); + scene->UpdateParents(); } m_logger.StartLog(tc_services, m_kxsystem->GetTimeInSeconds()); @@ -504,7 +504,7 @@ KX_KetsjiEngine::CameraRenderData KX_KetsjiEngine::GetCameraRenderData(KX_Scene rendercam->NodeSetGlobalOrientation(camera->NodeGetWorldOrientation()); rendercam->NodeSetWorldPosition(camera->NodeGetWorldPosition()); rendercam->NodeSetWorldScale(camera->NodeGetWorldScaling()); - rendercam->NodeUpdateGS(0.0); + rendercam->NodeUpdateGS(); } // Else use the native camera. else { @@ -1113,14 +1113,14 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene *scene) activecam->NodeSetLocalPosition(camtrans.TranslationVector3D()); activecam->NodeSetLocalOrientation(camtrans.RotationMatrix()); - activecam->NodeUpdateGS(0.0f); } else { activecam->NodeSetLocalPosition(mt::zero3); activecam->NodeSetLocalOrientation(mt::mat3::Identity()); - activecam->NodeUpdateGS(0.0f); } + activecam->NodeUpdateGS(); + scene->GetCameraList()->Add(CM_AddRef(activecam)); scene->SetActiveCamera(activecam); scene->GetObjectList()->Add(CM_AddRef(activecam)); @@ -1129,7 +1129,7 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene *scene) activecam->Release(); } - scene->UpdateParents(0.0f); + scene->UpdateParents(); } void KX_KetsjiEngine::RenderDebugProperties() diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp index 731b7f6c5305..6c8d817665cb 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp @@ -41,45 +41,30 @@ typedef unsigned __int64 uint_ptr; typedef unsigned long uint_ptr; #endif -bool KX_LightIpoSGController::Update(double currentTime) +bool KX_LightIpoSGController::Update() { - if (m_modified) - { - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - (*i)->Execute(m_ipotime);//currentTime); - } - - RAS_ILightObject *lightobj; - - SG_Node* ob = (SG_Node*)m_node; - KX_LightObject* kxlight = (KX_LightObject*) ob->GetSGClientObject(); - lightobj = kxlight->GetLightData(); - //lightobj = (KX_Light*) - - if (m_modify_energy) { - lightobj->m_energy = m_energy; - } + if (!SG_Controller::Update()) { + return false; + } - if (m_modify_color) { - lightobj->m_color[0] = m_col_rgb[0]; - lightobj->m_color[1] = m_col_rgb[1]; - lightobj->m_color[2] = m_col_rgb[2]; - } + KX_LightObject *kxlight = (KX_LightObject *)m_node->GetSGClientObject(); + RAS_ILightObject *lightobj = kxlight->GetLightData(); - if (m_modify_dist) { - lightobj->m_distance = m_dist; - } + if (m_modify_energy) { + lightobj->m_energy = m_energy; + } - m_modified=false; + if (m_modify_color) { + lightobj->m_color[0] = m_col_rgb[0]; + lightobj->m_color[1] = m_col_rgb[1]; + lightobj->m_color[2] = m_col_rgb[2]; } - return false; -} + if (m_modify_dist) { + lightobj->m_distance = m_dist; + } -void KX_LightIpoSGController::AddInterpolator(KX_IInterpolator* interp) -{ - this->m_interpolators.push_back(interp); + return true; } SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode) @@ -91,10 +76,10 @@ SG_Controller* KX_LightIpoSGController::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); @@ -110,13 +95,3 @@ SG_Controller* KX_LightIpoSGController::GetReplica(class SG_Node* destnode) return iporeplica; } - -KX_LightIpoSGController::~KX_LightIpoSGController() -{ - - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - delete (*i); - } - -} diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index c75114b2cd14..7061de41d3cb 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -35,7 +35,7 @@ #include "SG_Controller.h" #include "SG_Node.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" class RAS_ILightObject; @@ -47,7 +47,6 @@ class KX_LightIpoSGController : public SG_Controller float m_dist; private: - T_InterpolatorList m_interpolators; unsigned short m_modify_energy : 1; unsigned short m_modify_color : 1; unsigned short m_modify_dist : 1; @@ -59,11 +58,11 @@ class KX_LightIpoSGController : public SG_Controller m_modify_dist(false) {} - virtual ~KX_LightIpoSGController(); + virtual ~KX_LightIpoSGController() = default; virtual SG_Controller* GetReplica(class SG_Node* destnode); - virtual bool Update(double time); + virtual bool Update(); void SetModifyEnergy(bool modify) { m_modify_energy = modify; @@ -76,8 +75,6 @@ class KX_LightIpoSGController : public SG_Controller void SetModifyDist(bool modify) { m_modify_dist = modify; } - - void AddInterpolator(KX_IInterpolator* interp); }; #endif /* __KX_LIGHTIPOSGCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp index 1358fcbdeef2..b3c9816697e0 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp @@ -30,36 +30,15 @@ #include "BLI_sys_types.h" // for intptr_t support -bool KX_MaterialIpoController::Update(double currentTime) +bool KX_MaterialIpoController::Update() { - if (m_modified) - { - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - (*i)->Execute(m_ipotime); - } - - m_material->UpdateIPO( - m_rgba, - m_specrgb, - m_hard, - m_spec, - m_ref, - m_emit, - m_ambient, - m_alpha, - m_specAlpha - ); - - m_modified=false; + if (!SG_Controller::Update()) { + return false; } - return false; -} + m_material->UpdateIPO(m_rgba, m_specrgb, m_hard, m_spec, m_ref, m_emit, m_ambient, m_alpha, m_specAlpha); -void KX_MaterialIpoController::AddInterpolator(KX_IInterpolator* interp) -{ - this->m_interpolators.push_back(interp); + return true; } SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode) @@ -71,10 +50,10 @@ SG_Controller* KX_MaterialIpoController::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); @@ -91,13 +70,3 @@ SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode) return iporeplica; } -KX_MaterialIpoController::~KX_MaterialIpoController() -{ - - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - delete (*i); - } - -} - diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index 25f70b250989..2f79e89d0cfc 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -10,7 +10,7 @@ #include "SG_Controller.h" #include "SG_Node.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #include "mathfu.h" class RAS_IPolyMaterial; @@ -29,19 +29,15 @@ class KX_MaterialIpoController : public SG_Controller, public mt::SimdClassAlloc float m_specAlpha; private: - T_InterpolatorList m_interpolators; - RAS_IPolyMaterial *m_material; public: KX_MaterialIpoController(RAS_IPolyMaterial *polymat) : m_material(polymat) {} - virtual ~KX_MaterialIpoController(); + virtual ~KX_MaterialIpoController() = default; virtual SG_Controller* GetReplica(class SG_Node* destnode); - virtual bool Update(double time); - - void AddInterpolator(KX_IInterpolator* interp); + virtual bool Update(); }; #endif /* __KX_MATERIALIPOCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp index b4051f623f54..e5fb90a1b7d2 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp @@ -41,33 +41,17 @@ typedef unsigned long uint_ptr; #endif -bool KX_ObColorIpoSGController::Update(double currentTime) +bool KX_ObColorIpoSGController::Update() { - if (m_modified) - { - SG_Node* ob = (SG_Node*)m_node; - KX_GameObject* kxgameobj= (KX_GameObject*) ob->GetSGClientObject(); - - m_rgba = kxgameobj->GetObjectColor(); - - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - (*i)->Execute(m_ipotime); - } - - - kxgameobj->SetObjectColor(m_rgba); - - - m_modified=false; + if (!SG_Controller::Update()) { + return false; } - return false; -} + KX_GameObject* kxgameobj= (KX_GameObject *)m_node->GetSGClientObject(); -void KX_ObColorIpoSGController::AddInterpolator(KX_IInterpolator* interp) -{ - this->m_interpolators.push_back(interp); + kxgameobj->SetObjectColor(m_rgba); // TODO test + + return true; } SG_Controller* KX_ObColorIpoSGController::GetReplica(class SG_Node* destnode) @@ -79,10 +63,10 @@ SG_Controller* KX_ObColorIpoSGController::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); @@ -99,12 +83,3 @@ SG_Controller* KX_ObColorIpoSGController::GetReplica(class SG_Node* destnode) return iporeplica; } -KX_ObColorIpoSGController::~KX_ObColorIpoSGController() -{ - - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - delete (*i); - } - -} diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index 37f4a2d9e27e..82d1f9891272 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -34,26 +34,19 @@ #include "SG_Controller.h" #include "SG_Node.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #include "mathfu.h" class KX_ObColorIpoSGController : public SG_Controller, public mt::SimdClassAllocator { public: mt::vec4 m_rgba; - - -private: - T_InterpolatorList m_interpolators; public: - KX_ObColorIpoSGController() - {} - virtual ~KX_ObColorIpoSGController(); + KX_ObColorIpoSGController() = default; + virtual ~KX_ObColorIpoSGController() = default; virtual SG_Controller* GetReplica(class SG_Node* destnode); - virtual bool Update(double time); - - void AddInterpolator(KX_IInterpolator* interp); + virtual bool Update(); }; #endif /* __KX_OBCOLORIPOSGCONTROLLER_H__ */ diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h index 44a3ab154129..74e72d1b647c 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.h @@ -32,12 +32,12 @@ #ifndef __KX_ORIENTATIONINTERPOLATOR_H__ #define __KX_ORIENTATIONINTERPOLATOR_H__ -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #include "mathfu.h" class KX_IScalarInterpolator; -class KX_OrientationInterpolator : public KX_IInterpolator { +class KX_OrientationInterpolator : public SG_IInterpolator { public: KX_OrientationInterpolator(mt::mat3& target, KX_IScalarInterpolator **ipos) diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h index 30f23af17cca..9c9d3d7db094 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.h +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.h @@ -32,12 +32,12 @@ #ifndef __KX_POSITIONINTERPOLATOR_H__ #define __KX_POSITIONINTERPOLATOR_H__ -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #include "mathfu.h" class KX_IScalarInterpolator; -class KX_PositionInterpolator : public KX_IInterpolator { +class KX_PositionInterpolator : public SG_IInterpolator { public: KX_PositionInterpolator(mt::vec3& target, KX_IScalarInterpolator *ipos[]) : diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h index 9f869b13b588..3b2c631bdf08 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.h @@ -32,11 +32,11 @@ #ifndef __KX_SCALARINTERPOLATOR_H__ #define __KX_SCALARINTERPOLATOR_H__ -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" class KX_IScalarInterpolator; -class KX_ScalarInterpolator : public KX_IInterpolator { +class KX_ScalarInterpolator : public SG_IInterpolator { public: KX_ScalarInterpolator(float* target, KX_IScalarInterpolator *ipo) : diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h index 344aeb1f6f8a..6f8ae064002f 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.h @@ -32,12 +32,12 @@ #ifndef __KX_SCALINGINTERPOLATOR_H__ #define __KX_SCALINGINTERPOLATOR_H__ -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" #include "mathfu.h" class KX_IScalarInterpolator; -class KX_ScalingInterpolator : public KX_IInterpolator { +class KX_ScalingInterpolator : public SG_IInterpolator { public: KX_ScalingInterpolator(mt::vec3& target, KX_IScalarInterpolator *ipos[]) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 4e0a0046961f..6639c8060e3e 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -774,7 +774,7 @@ void KX_Scene::DupliGroupRecurse(KX_GameObject *groupobj, int level) const mt::mat3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation(); replica->NodeSetLocalOrientation(newori); // Update scenegraph for entire tree of children. - replica->GetSGNode()->UpdateWorldData(0.0); + replica->GetSGNode()->UpdateWorldData(); // We can now add the graphic controller to the physic engine. replica->ActivateGraphicController(true); @@ -875,7 +875,7 @@ KX_GameObject *KX_Scene::AddReplicaObject(KX_GameObject *originalobj, KX_GameObj replica->NodeSetRelativeScale(newscale); } - replica->GetSGNode()->UpdateWorldData(0.0); + replica->GetSGNode()->UpdateWorldData(); // The size is correct, we can add the graphic controller to the physic engine. replica->ActivateGraphicController(true); @@ -1405,13 +1405,13 @@ void KX_Scene::LogicEndFrame() } } -void KX_Scene::UpdateParents(double curtime) +void KX_Scene::UpdateParents() { // We use the SG dynamic list SG_Node *node; while ((node = SG_Node::GetNextScheduled(m_sghead))) { - node->UpdateWorldData(curtime); + node->UpdateWorldData(); } // The list must be empty here diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 4978f838974f..999bf760de8f 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -275,7 +275,7 @@ class KX_Scene : public EXP_Value, public SCA_IScene static bool KX_ScenegraphUpdateFunc(SG_Node *node, void *gameobj, void *scene); static bool KX_ScenegraphRescheduleFunc(SG_Node *node, void *gameobj, void *scene); /// SceneGraph transformation update. - void UpdateParents(double curtime); + void UpdateParents(); void DupliGroupRecurse(KX_GameObject *groupobj, int level); bool IsObjectInGroup(KX_GameObject *gameobj) const; diff --git a/source/gameengine/Ketsji/KX_TextureRendererManager.cpp b/source/gameengine/Ketsji/KX_TextureRendererManager.cpp index e75b98f44e5b..4fed50671c24 100644 --- a/source/gameengine/Ketsji/KX_TextureRendererManager.cpp +++ b/source/gameengine/Ketsji/KX_TextureRendererManager.cpp @@ -149,7 +149,7 @@ bool KX_TextureRendererManager::RenderRenderer(RAS_Rasterizer *rasty, KX_Texture continue; } - m_camera->NodeUpdateGS(0.0f); + m_camera->NodeUpdateGS(); renderer->BindFace(i); diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.cpp b/source/gameengine/Ketsji/KX_WorldIpoController.cpp index f1178a416613..ce262f29fe07 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.cpp +++ b/source/gameengine/Ketsji/KX_WorldIpoController.cpp @@ -42,53 +42,42 @@ typedef unsigned __int64 uint_ptr; typedef unsigned long uint_ptr; #endif -bool KX_WorldIpoController::Update(double currentTime) +bool KX_WorldIpoController::Update() { - if (m_modified) { - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - (*i)->Execute(m_ipotime); - } - - KX_WorldInfo *world = KX_GetActiveScene()->GetWorldInfo(); - - if (m_modify_mist_start) { - world->setMistStart(m_mist_start); - } + if (!SG_Controller::Update()) { + return false; + } - if (m_modify_mist_dist) { - world->setMistDistance(m_mist_dist); - } + KX_WorldInfo *world = KX_GetActiveScene()->GetWorldInfo(); - if (m_modify_mist_intensity) { - world->setMistIntensity(m_mist_intensity); - } + if (m_modify_mist_start) { + world->setMistStart(m_mist_start); + } - if (m_modify_horizon_color) { - world->setHorizonColor(mt::vec4(m_hori_rgb[0], m_hori_rgb[1], m_hori_rgb[2], 1.0f)); - world->setMistColor(m_hori_rgb); - } + if (m_modify_mist_dist) { + world->setMistDistance(m_mist_dist); + } - if (m_modify_zenith_color) { - world->setZenithColor(mt::vec4(m_zeni_rgb[0], m_zeni_rgb[1], m_zeni_rgb[2], 1.0f)); - } + if (m_modify_mist_intensity) { + world->setMistIntensity(m_mist_intensity); + } - if (m_modify_ambient_color) { - world->setAmbientColor(m_ambi_rgb); - } + if (m_modify_horizon_color) { + world->setHorizonColor(mt::vec4(m_hori_rgb[0], m_hori_rgb[1], m_hori_rgb[2], 1.0f)); + world->setMistColor(m_hori_rgb); + } - m_modified = false; + if (m_modify_zenith_color) { + world->setZenithColor(mt::vec4(m_zeni_rgb[0], m_zeni_rgb[1], m_zeni_rgb[2], 1.0f)); } - return false; -} + if (m_modify_ambient_color) { + world->setAmbientColor(m_ambi_rgb); + } -void KX_WorldIpoController::AddInterpolator(KX_IInterpolator* interp) -{ - this->m_interpolators.push_back(interp); + return true; } - SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode) { KX_WorldIpoController* iporeplica = new KX_WorldIpoController(*this); @@ -98,10 +87,10 @@ SG_Controller* KX_WorldIpoController::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); @@ -118,12 +107,3 @@ SG_Controller* KX_WorldIpoController::GetReplica(class SG_Node* destnode) return iporeplica; } -KX_WorldIpoController::~KX_WorldIpoController() -{ - - T_InterpolatorList::iterator i; - for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) { - delete (*i); - } - -} diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index e1a5285b01dd..b033b3c4f070 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -34,7 +34,7 @@ #include "SG_Controller.h" #include "SG_Node.h" -#include "KX_IInterpolator.h" +#include "SG_IInterpolator.h" class KX_WorldIpoController : public SG_Controller, public mt::SimdClassAllocator { @@ -47,7 +47,6 @@ class KX_WorldIpoController : public SG_Controller, public mt::SimdClassAllocato mt::vec3 m_ambi_rgb; private: - T_InterpolatorList m_interpolators; unsigned short m_modify_mist_start : 1; unsigned short m_modify_mist_dist : 1; unsigned short m_modify_mist_intensity : 1; @@ -65,11 +64,11 @@ class KX_WorldIpoController : public SG_Controller, public mt::SimdClassAllocato m_modify_ambient_color(false) {} - virtual ~KX_WorldIpoController(); + virtual ~KX_WorldIpoController() = default; virtual SG_Controller* GetReplica(class SG_Node* destnode); - virtual bool Update(double time); + virtual bool Update(); void SetModifyMistStart(bool modify) { m_modify_mist_start = modify; @@ -94,8 +93,6 @@ class KX_WorldIpoController : public SG_Controller, public mt::SimdClassAllocato void SetModifyAmbientColor(bool modify) { m_modify_ambient_color = modify; } - - void AddInterpolator(KX_IInterpolator* interp); }; #endif /* __KX_WORLDIPOCONTROLLER_H__ */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp index d96b714c6afb..c9a9ab0a78f2 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp @@ -256,7 +256,7 @@ void RAS_OpenGLLight::BindShadowBuffer(RAS_ICanvas *canvas, KX_Camera *cam, mt:: cam->NodeSetLocalPosition(camtrans.TranslationVector3D()); cam->NodeSetLocalOrientation(camtrans.RotationMatrix()); - cam->NodeUpdateGS(0); + cam->NodeUpdateGS(); /* setup rasterizer transformations */ m_rasterizer->SetProjectionMatrix(projectionmat); diff --git a/source/gameengine/SceneGraph/CMakeLists.txt b/source/gameengine/SceneGraph/CMakeLists.txt index fee483588fb9..4847819ec59a 100644 --- a/source/gameengine/SceneGraph/CMakeLists.txt +++ b/source/gameengine/SceneGraph/CMakeLists.txt @@ -47,6 +47,7 @@ set(SRC SG_DList.h SG_Familly.h SG_Frustum.h + SG_IInterpolator.h SG_Node.h SG_ParentRelation.h SG_QList.h diff --git a/source/gameengine/SceneGraph/SG_Controller.cpp b/source/gameengine/SceneGraph/SG_Controller.cpp index 8b26789ac355..c05c6dc14f3b 100644 --- a/source/gameengine/SceneGraph/SG_Controller.cpp +++ b/source/gameengine/SceneGraph/SG_Controller.cpp @@ -32,12 +32,34 @@ #include "SG_Controller.h" SG_Controller::SG_Controller() - :m_node(nullptr), - m_modified(true), + :m_modified(true), + m_node(nullptr), m_ipotime(0.0) { } +SG_Controller::~SG_Controller() +{ + for (SG_IInterpolator *interp : m_interpolators) { + delete interp; + } +} + +bool SG_Controller::Update() +{ + if (!m_modified) { + return false; + } + + m_modified = false; + + for (SG_IInterpolator *interp : m_interpolators) { + interp->Execute(m_ipotime); + } + + return true; +} + void SG_Controller::SetNode(SG_Node *node) { m_node = node; @@ -57,3 +79,8 @@ void SG_Controller::SetSimulatedTime(double time) void SG_Controller::SetOption(SG_Controller::SG_ControllerOption option, bool value) { } + +void SG_Controller::AddInterpolator(SG_IInterpolator *interp) +{ + m_interpolators.push_back(interp); +} diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index 2f81f5f81470..337bdd0c39c9 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -35,7 +35,7 @@ #ifndef __SG_CONTROLLER_H__ #define __SG_CONTROLLER_H__ -#include +#include "SG_IInterpolator.h" class SG_Node; @@ -63,11 +63,12 @@ class SG_Controller }; SG_Controller(); - virtual ~SG_Controller() = default; + virtual ~SG_Controller(); - virtual bool Update(double time) = 0; + /// Perform an update, returns true when the update was performed. + virtual bool Update(); - virtual void SetNode(SG_Node *node); + void SetNode(SG_Node *node); void ClearNode(); @@ -86,10 +87,15 @@ class SG_Controller */ virtual void SetOption(SG_ControllerOption option, bool value); + void AddInterpolator(SG_IInterpolator *interp); + + protected: - SG_Node *m_node; + SG_IInterpolatorList m_interpolators; /// Were settings altered since the last update? bool m_modified; + + SG_Node *m_node; /// Local time of this ipo. double m_ipotime; diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/SceneGraph/SG_IInterpolator.h similarity index 77% rename from source/gameengine/Ketsji/KX_IInterpolator.h rename to source/gameengine/SceneGraph/SG_IInterpolator.h index 0abc368574b2..bacd15bc191c 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/SceneGraph/SG_IInterpolator.h @@ -25,23 +25,25 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file KX_IInterpolator.h - * \ingroup ketsji +/** \file SG_IInterpolator.h + * \ingroup scenegraph */ -#ifndef __KX_IINTERPOLATOR_H__ -#define __KX_IINTERPOLATOR_H__ +#ifndef __SG_IINTERPOLATOR_H__ +#define __SG_IINTERPOLATOR_H__ #include -class KX_IInterpolator { +class SG_IInterpolator +{ public: - virtual ~KX_IInterpolator() {} + SG_IInterpolator() = default; + virtual ~SG_IInterpolator() = default; virtual void Execute(float currentTime) const = 0; }; -typedef std::vector T_InterpolatorList; +using SG_IInterpolatorList = std::vector; -#endif +#endif // __SG_IINTERPOLATOR_H__ diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 34ced354e299..b9222ce426ba 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -222,38 +222,36 @@ void SG_Node::RemoveChild(SG_Node *child) CM_ListRemoveIfFound(m_children, child); } -void SG_Node::UpdateWorldData(double time, bool parentUpdated) +void SG_Node::UpdateWorldData(bool parentUpdated) { - if (UpdateSpatialData(GetSGParent(), time, parentUpdated)) { - // to update the - ActivateUpdateTransformCallback(); - } + UpdateSpatialData(m_SGparent, parentUpdated); + + ActivateUpdateTransformCallback(); // The node is updated, remove it from the update list Delink(); // update children's worlddata for (SG_Node *childnode : m_children) { - childnode->UpdateWorldData(time, parentUpdated); + childnode->UpdateWorldData(parentUpdated); } } -void SG_Node::UpdateWorldDataThread(double time, bool parentUpdated) +void SG_Node::UpdateWorldDataThread(bool parentUpdated) { CM_ThreadSpinLock& famillyMutex = m_familly->GetMutex(); famillyMutex.Lock(); - UpdateWorldDataThreadSchedule(time, parentUpdated); + UpdateWorldDataThreadSchedule(parentUpdated); famillyMutex.Unlock(); } -void SG_Node::UpdateWorldDataThreadSchedule(double time, bool parentUpdated) +void SG_Node::UpdateWorldDataThreadSchedule(bool parentUpdated) { - if (UpdateSpatialData(GetSGParent(), time, parentUpdated)) { - // to update the - ActivateUpdateTransformCallback(); - } + UpdateSpatialData(m_SGparent, parentUpdated); + + ActivateUpdateTransformCallback(); scheduleMutex.Lock(); // The node is updated, remove it from the update list @@ -262,7 +260,7 @@ void SG_Node::UpdateWorldDataThreadSchedule(double time, bool parentUpdated) // update children's worlddata for (SG_Node *childnode : m_children) { - childnode->UpdateWorldDataThreadSchedule(time, parentUpdated); + childnode->UpdateWorldDataThreadSchedule(parentUpdated); } } @@ -419,26 +417,15 @@ SG_ParentRelation *SG_Node::GetParentRelation() * Update Spatial Data. * Calculates WorldTransform., (either doing its self or using the linked SGControllers) */ -bool SG_Node::UpdateSpatialData(const SG_Node *parent, double time, bool& parentUpdated) +void SG_Node::UpdateSpatialData(const SG_Node *parent, bool& parentUpdated) { - bool bComputesWorldTransform = false; - // update spatial controllers for (SG_Controller *cont : m_SGcontrollers) { - if (cont->Update(time)) { - bComputesWorldTransform = true; - } - } - - // If none of the objects updated our values then we ask the - // parent_relation object owned by this class to update - // our world coordinates. - - if (!bComputesWorldTransform) { - bComputesWorldTransform = ComputeWorldTransforms(parent, parentUpdated); + cont->Update(); } - return bComputesWorldTransform; + // Ask the parent_relation object owned by this class to update our world coordinates. + ComputeWorldTransforms(parent, parentUpdated); } /** diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index d7522f9fd27d..c6e4b1cb356b 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -187,8 +187,8 @@ class SG_Node : public SG_QList, public mt::SimdClassAllocator * Update the spatial data of this node. Iterate through * the children of this node and update their world data. */ - void UpdateWorldData(double time, bool parentUpdated = false); - void UpdateWorldDataThread(double time, bool parentUpdated = false); + void UpdateWorldData(bool parentUpdated = false); + void UpdateWorldDataThread(bool parentUpdated = false); /** * Update the simulation time of this node. Iterate through @@ -363,10 +363,10 @@ class SG_Node : public SG_QList, public mt::SimdClassAllocator * Update the world coordinates of this spatial node. This also informs * any controllers to update this object. */ - bool UpdateSpatialData(const SG_Node *parent, double time, bool& parentUpdated); + void UpdateSpatialData(const SG_Node *parent, bool& parentUpdated); private: - void UpdateWorldDataThreadSchedule(double time, bool parentUpdated = false); + void UpdateWorldDataThreadSchedule(bool parentUpdated = false); void ProcessSGReplica(SG_Node **replica); diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 027654114b88..070ce3c28f57 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -265,7 +265,7 @@ bool ImageRender::Render() mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1], mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); - m_camera->GetSGNode()->UpdateWorldData(0.0); + m_camera->GetSGNode()->UpdateWorldData(); // compute camera frustum: // get position of mirror relative to camera: offset = mirrorPos-cameraPos mt::vec3 mirrorOffset = mirrorWorldPos - cameraWorldPos;