no need to store the physics env in each KX_GameObject
authorCampbell Barton <ideasman42@gmail.com>
Tue, 4 Aug 2009 05:14:10 +0000 (05:14 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 4 Aug 2009 05:14:10 +0000 (05:14 +0000)
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/KX_ConstraintActuator.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Rasterizer/RAS_BucketManager.cpp

index 7a902a727957636dd63ecddebe2af08be1171b80..d27c544ccb4f071d267584d52c972140c8a9b964 100644 (file)
@@ -1806,7 +1806,6 @@ static KX_GameObject *gameobject_from_blenderobject(
        }
        if (gameobj) 
        {
-               gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment());
                gameobj->SetLayer(ob->lay);
                gameobj->SetBlenderObject(ob);
                /* set the visibility state based on the objects render option in the outliner */
index 6f66faaeafbcb39bf214b1baab05803c70e0d8bb..c90f4e23316b3d0de5c8c59f1490c880d93ae110 100644 (file)
@@ -36,6 +36,7 @@
 #include "MT_Matrix3x3.h"
 #include "KX_GameObject.h"
 #include "KX_RayCast.h"
+#include "KX_PythonInit.h" // KX_GetActiveScene
 #include "blendef.h"
 
 #ifdef HAVE_CONFIG_H
@@ -329,7 +330,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                        }
                        {
                                MT_Point3 topoint = position + (m_maximumBound) * direction;
-                               PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment();
+                               PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
                                KX_IPhysicsController *spc = obj->GetPhysicsController();
 
                                if (!pe) {
@@ -442,7 +443,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
                        }
                        normal.normalize();
                        {
-                               PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment();
+                               PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
                                KX_IPhysicsController *spc = obj->GetPhysicsController();
 
                                if (!pe) {
index e9263ee62e0de62942d03efd5b2791d500e98b69..d04174a32aa3c8c462a70be69e5f0cb25e74fef4 100644 (file)
@@ -103,7 +103,6 @@ KX_GameObject::KX_GameObject(
        m_bOccluder(false),
        m_pPhysicsController1(NULL),
        m_pGraphicController(NULL),
-       m_pPhysicsEnvironment(NULL),
        m_xray(false),
        m_pHitObject(NULL),
        m_isDeformable(false),
@@ -2604,8 +2603,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
                toDir.normalize();
                toPoint = fromPoint + (dist) * toDir;
        }
-
-       PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
+       PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
        KX_IPhysicsController *spc = GetPhysicsController();
        KX_GameObject *parent = GetParent();
        if (!spc && parent)
@@ -2732,7 +2730,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
                return none_tuple_3();
        }
        
-       PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
+       PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment();
        KX_IPhysicsController *spc = GetPhysicsController();
        KX_GameObject *parent = GetParent();
        if (!spc && parent)
index 32df5803f31c27f7a9e05c696bd347d7f6d8ed1f..88ef44c41c62a0cfdbafcf9e9115ad91ff00b100 100644 (file)
@@ -94,8 +94,6 @@ protected:
 
        KX_IPhysicsController*                          m_pPhysicsController1;
        PHY_IGraphicController*                         m_pGraphicController;
-       // used for ray casting
-       PHY_IPhysicsEnvironment*                        m_pPhysicsEnvironment;
        STR_String                                                      m_testPropName;
        bool                                                            m_xray;
        KX_GameObject*                                          m_pHitObject;
@@ -334,20 +332,6 @@ public:
                bool ang_vel_local
        );
 
-
-       /**
-        * @return a pointer to the physics environment in use during the game, for rayCasting
-        */
-       PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
-       {
-               return m_pPhysicsEnvironment;
-       }
-
-       void SetPhysicsEnvironment(PHY_IPhysicsEnvironment* physicsEnvironment)
-       {
-               m_pPhysicsEnvironment = physicsEnvironment;
-       }
-
        /**
         * @return a pointer to the physics controller owned by this class.
         */
index 200b1c6c89f1d516bf908a59116c44cf39004bc2..8b3c4990a7a83052ff6cf2a19073f091ba84669a 100644 (file)
@@ -126,10 +126,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList
                RAS_MaterialBucket* bucket = *bit;
                RAS_MeshSlot* ms;
                // remove the mesh slot form the list, it culls them automatically for next frame
-               for(ms = bucket->GetNextActiveMeshSlot();
-                       ms!= NULL;
-                       ms = bucket->GetNextActiveMeshSlot())
-               {
+               while((ms = bucket->GetNextActiveMeshSlot())) {
                        slots[i++].set(ms, bucket, pnorm);
                }
        }
@@ -179,9 +176,7 @@ void RAS_BucketManager::RenderSolidBuckets(
                RAS_MaterialBucket* bucket = *bit;
                RAS_MeshSlot* ms;
                // remove the mesh slot form the list, it culls them automatically for next frame
-               for(ms = bucket->GetNextActiveMeshSlot();
-                       ms!= NULL;
-                       ms = bucket->GetNextActiveMeshSlot())
+               while((ms = bucket->GetNextActiveMeshSlot()))
                {
                        rendertools->SetClientObject(rasty, ms->m_clientObj);
                        while (bucket->ActivateMaterial(cameratrans, rasty, rendertools))