diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertSensors.cpp | 5 | ||||
-rw-r--r-- | source/gameengine/GameLogic/SCA_ISensor.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Camera.cpp | 16 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Camera.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_IpoActuator.cpp | 53 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 5 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_RayCast.cpp | 8 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 20 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.h | 14 |
12 files changed, 96 insertions, 39 deletions
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 40c15302553..d9c49217042 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -386,8 +386,9 @@ void BL_ConvertSensors(struct Object* blenderobject, bool bFindMaterial = false; PHY_IPhysicsController* physCtrl = kxscene->GetPhysicsEnvironment()->CreateSphereController(radius,pos); - if (isInActiveLayer) - kxscene->GetPhysicsEnvironment()->addSensor(physCtrl); + //will be done in KX_TouchEventManager::RegisterSensor() + //if (isInActiveLayer) + // kxscene->GetPhysicsEnvironment()->addSensor(physCtrl); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index cca303c6266..1a65f8311ed 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -343,6 +343,4 @@ PyObject* SCA_ISensor::PyEvaluate(PyObject* self, PyObject* args, PyObject* kwds { return BoolToPyArg(Evaluate(NULL)); } - - /* eof */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 86f114b2f51..51cfe30179c 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -142,7 +142,11 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event) result = (WasUp != m_IsUp); - // Return true if the message received state has changed. + // Return always true if a message was received otherwise we can loose messages + if (m_IsUp) + return true; + // Is it usefull to return also true when the first frame without a message?? + // This will cause a fast on/off cycle that seems useless! return result; } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 011443054a7..bb8ea7f23b3 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -32,7 +32,8 @@ */ #include "KX_Camera.h" - +#include "KX_Scene.h" +#include "KX_PythonInit.h" #include "KX_Python.h" #include "KX_PyMath.h" #ifdef HAVE_CONFIG_H @@ -391,6 +392,7 @@ PyMethodDef KX_Camera::Methods[] = { KX_PYMETHODTABLE(KX_Camera, setProjectionMatrix), KX_PYMETHODTABLE(KX_Camera, enableViewport), KX_PYMETHODTABLE(KX_Camera, setViewport), + KX_PYMETHODTABLE(KX_Camera, setOnTop), {NULL,NULL} //Sentinel }; @@ -759,3 +761,15 @@ KX_PYMETHODDEF_DOC(KX_Camera, setViewport, } Py_Return; } + +KX_PYMETHODDEF_DOC(KX_Camera, setOnTop, +"setOnTop()\n" +"Sets this camera's viewport on top\n") +{ + class KX_Scene* scene; + + scene = PHY_GetActiveScene(); + MT_assert(scene); + scene->SetCameraOnTop(this); + Py_Return; +} diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 60f0b107940..34a3d2f2653 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -251,6 +251,7 @@ public: KX_PYMETHOD_DOC(KX_Camera, enableViewport); KX_PYMETHOD_DOC(KX_Camera, setViewport); + KX_PYMETHOD_DOC(KX_Camera, setOnTop); virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */ virtual int _setattr(const STR_String& attr, PyObject *pyvalue); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index e7f1dea7bbf..287634fc7ec 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -211,12 +211,6 @@ bool KX_IpoActuator::Update(double curtime, bool frame) (*i)->Release(); } m_events.clear(); - - if (m_type != KX_ACT_IPO_PLAY) - { - if (bNegativeEvent) - RemoveAllEvents(); - } } double start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0); @@ -226,6 +220,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe)) { + // start for all Ipo, initial start for LOOP_STOP m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); m_bIpoPlaying = true; } @@ -238,17 +233,10 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { // Check if playing forwards. result = ! finished - if (!bNegativeEvent) - { - if (start_smaller_then_end > 0.0) - result = (m_localtime < m_endframe && !(m_localtime == m_startframe && bNegativeEvent)); - else - result = (m_localtime > m_endframe && !(m_localtime == m_startframe && bNegativeEvent)); - } + if (start_smaller_then_end > 0.0) + result = (m_localtime < m_endframe && m_bIpoPlaying); else - { - result = (m_bIpoPlaying && (m_localtime < m_endframe)); - } + result = (m_localtime > m_endframe && m_bIpoPlaying); if (result) { @@ -267,7 +255,6 @@ bool KX_IpoActuator::Update(double curtime, bool frame) } else { m_localtime=m_startframe; - SetStartTime(curtime); m_direction=1; } break; @@ -275,7 +262,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) case KX_ACT_IPO_PINGPONG: { result = true; - if (bNegativeEvent && ((m_localtime == m_startframe )|| (m_localtime == m_endframe))) + if (bNegativeEvent && !m_bIpoPlaying) result = false; else SetLocalTime(curtime); @@ -297,14 +284,18 @@ bool KX_IpoActuator::Update(double curtime, bool frame) } case KX_ACT_IPO_FLIPPER: { - result = !(bNegativeEvent && (m_localtime == m_startframe)); + if (bNegativeEvent && !m_bIpoPlaying) + result = false; if (numevents) { + float oldDirection = m_direction; if (bNegativeEvent) m_direction = -1; else m_direction = 1; - SetStartTime(curtime); + if (m_direction != oldDirection) + // changing direction, reset start time + SetStartTime(curtime); } SetLocalTime(curtime); @@ -332,18 +323,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame) m_bNegativeEvent = false; numevents = 0; } - SetStartTime(curtime); + if (!m_bIpoPlaying) + { + // Ipo was stopped, make sure we will restart from where it stopped + SetStartTime(curtime); + if (!bNegativeEvent) + // positive signal will restart the Ipo + m_bIpoPlaying = true; + } + } // fall through to loopend, and quit the ipo animation immediatly } case KX_ACT_IPO_LOOPEND: { if (numevents){ - if (bNegativeEvent){ + if (bNegativeEvent && m_bIpoPlaying){ m_bNegativeEvent = true; } } - if (bNegativeEvent && m_localtime == m_startframe){ + if (bNegativeEvent && !m_bIpoPlaying){ result = false; } else @@ -414,8 +413,12 @@ bool KX_IpoActuator::Update(double curtime, bool frame) result = false; } - if (!result && m_type != KX_ACT_IPO_LOOPSTOP) - m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0; + if (!result) + { + if (m_type != KX_ACT_IPO_LOOPSTOP) + m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0; + m_bIpoPlaying = false; + } return result; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index e0a826b8d5d..8febc0e10cd 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -631,10 +631,10 @@ void KX_KetsjiEngine::Render() RenderFrame(scene, cam); } - set<class KX_Camera*>* cameras = scene->GetCameras(); + list<class KX_Camera*>* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport - set<KX_Camera*>::iterator it = cameras->begin(); + list<KX_Camera*>::iterator it = cameras->begin(); while(it != cameras->end()) { if((*it)->GetViewport()) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 1a6aafafabf..58369ddcab6 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1159,3 +1159,8 @@ void PHY_SetActiveScene(class KX_Scene* scene) { gp_KetsjiScene = scene; } + +class KX_Scene* PHY_GetActiveScene() +{ + return gp_KetsjiScene; +} diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index a4c2d1453a6..edb7cfe4a3f 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -53,6 +53,7 @@ void exitGamePythonScripting(); void dictionaryClearByHand(PyObject *dict); void PHY_SetActiveScene(class KX_Scene* scene); +class KX_Scene* PHY_GetActiveScene(); #include "MT_Vector3.h" void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 7b13cb1fd7d..ea17e0b3dd6 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -77,6 +77,14 @@ bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsE if (callback.RayHit(info, result_point, result_normal)) return true; + // There is a bug in the code below: the delta is computed with the wrong + // sign on the face opposite to the center, resulting in infinite looping. + // In Blender 2.45 this code was never executed because callback.RayHit() always + // returned true, causing the ray sensor to stop on the first object. + // To avoid changing the behaviour will simply return false here. + // It should be discussed if we want the ray sensor to "see" through objects + // that don't have the required property/material (condition to get here) + return false; // skip past the object and keep tracing /* We add 0.01 of fudge, so that if the margin && radius == 0., we don't endless loop. */ diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1ed429ea490..f9c2f8e571b 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -263,7 +263,7 @@ SCA_TimeEventManager* KX_Scene::GetTimeEventManager() -set<class KX_Camera*>* KX_Scene::GetCameras() +list<class KX_Camera*>* KX_Scene::GetCameras() { return &m_cameras; } @@ -847,7 +847,7 @@ MT_CmMatrix4x4& KX_Scene::GetProjectionMatrix() KX_Camera* KX_Scene::FindCamera(KX_Camera* cam) { - set<KX_Camera*>::iterator it = m_cameras.begin(); + list<KX_Camera*>::iterator it = m_cameras.begin(); while ( (it != m_cameras.end()) && ((*it) != cam) ) { @@ -860,7 +860,7 @@ KX_Camera* KX_Scene::FindCamera(KX_Camera* cam) KX_Camera* KX_Scene::FindCamera(STR_String& name) { - set<KX_Camera*>::iterator it = m_cameras.begin(); + list<KX_Camera*>::iterator it = m_cameras.begin(); while ( (it != m_cameras.end()) && ((*it)->GetName() != name) ) { @@ -872,7 +872,8 @@ KX_Camera* KX_Scene::FindCamera(STR_String& name) void KX_Scene::AddCamera(KX_Camera* cam) { - m_cameras.insert(cam); + if (!FindCamera(cam)) + m_cameras.push_back(cam); } KX_Camera* KX_Scene::GetActiveCamera() @@ -893,6 +894,17 @@ void KX_Scene::SetActiveCamera(KX_Camera* cam) m_active_camera = cam; } +void KX_Scene::SetCameraOnTop(KX_Camera* cam) +{ + if (!FindCamera(cam)){ + // adding is always done at the back, so that's all that needs to be done + AddCamera(cam); + if (cam) std::cout << "Added cam " << cam->GetName() << std::endl; + } else { + m_cameras.remove(cam); + m_cameras.push_back(cam); + } +} void KX_Scene::UpdateMeshTransformations() diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index ba479c5e543..50fcf1a3c40 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -39,6 +39,7 @@ #include <vector> #include <set> +#include <list> #include "GEN_Map.h" #include "GEN_HashedPtr.h" @@ -119,7 +120,7 @@ protected: /** * The set of cameras for this scene */ - set<class KX_Camera*> m_cameras; + list<class KX_Camera*> m_cameras; /** * Various SCA managers used by the scene @@ -330,7 +331,7 @@ public: GetTimeEventManager( ); - set<class KX_Camera*>* + list<class KX_Camera*>* GetCameras( ); @@ -368,6 +369,15 @@ public: class KX_Camera* ); + /** + * Move this camera to the end of the list so that it is rendered last. + * If the camera is not on the list, it will be added + */ + void + SetCameraOnTop( + class KX_Camera* + ); + /** Return the viewmatrix as used by the last frame. */ MT_CmMatrix4x4& GetViewMatrix( |