Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Ketsji/KX_Scene.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp80
1 files changed, 52 insertions, 28 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 4fa51b48ab8..2f23bdaccb7 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -62,6 +62,7 @@
#include "SCA_IScene.h"
#include "RAS_IRasterizer.h"
+#include "RAS_ICanvas.h"
#include "RAS_BucketManager.h"
#include "FloatValue.h"
@@ -81,7 +82,6 @@
#include "KX_NetworkEventManager.h"
#include "NG_NetworkScene.h"
#include "PHY_IPhysicsEnvironment.h"
-#include "KX_IPhysicsController.h"
#include "PHY_IGraphicController.h"
#include "KX_BlenderSceneConverter.h"
#include "KX_MotionState.h"
@@ -544,7 +544,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
for (cit = scenegraphcontrollers.begin();!(cit==scenegraphcontrollers.end());++cit)
{
// controller replication is quite complicated
- // only replicate ipo and physics controller for now
+ // only replicate ipo controller for now
SG_Controller* replicacontroller = (*cit)->GetReplica((SG_Node*) replicanode);
if (replicacontroller)
@@ -558,9 +558,29 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
{
PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
PHY_IGraphicController* newctrl = orgobj->GetGraphicController()->GetReplica(motionstate);
- newctrl->setNewClientInfo(newobj->getClientInfo());
+ newctrl->SetNewClientInfo(newobj->getClientInfo());
newobj->SetGraphicController(newctrl);
}
+
+#ifdef WITH_BULLET
+ // replicate physics controller
+ if (orgobj->GetPhysicsController())
+ {
+ PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
+ PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica();
+
+ KX_GameObject *parent = newobj->GetParent();
+ PHY_IPhysicsController* parentctrl = (parent) ? parent->GetPhysicsController() : NULL;
+
+ newctrl->SetNewClientInfo(newobj->getClientInfo());
+ newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
+ newctrl->PostProcessReplica(motionstate, parentctrl);
+
+ if (parent)
+ parent->Release();
+ }
+#endif
+
return newobj;
}
@@ -610,7 +630,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
newsensorobj = (SCA_IObject*)(*h_obj);
if (!newsensorobj)
{
- // no, then the sensor points outside the hierachy, keep it the same
+ // no, then the sensor points outside the hierarchy, keep it the same
if (m_objectlist->SearchValue(oldsensorobj))
// only replicate links that points to active objects
m_logicmgr->RegisterToSensor(cont,oldsensor);
@@ -650,7 +670,7 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
if (!newactuatorobj)
{
- // no, then the sensor points outside the hierachy, keep it the same
+ // no, then the sensor points outside the hierarchy, keep it the same
if (m_objectlist->SearchValue(oldactuatorobj))
// only replicate links that points to active objects
m_logicmgr->RegisterToActuator(cont,oldactuator);
@@ -1524,7 +1544,7 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int
double pmat[16] = {0};
cam->GetProjectionMatrix().getValue(pmat);
- dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
+ dbvt_culling = m_physicsEnvironment->CullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res,
KX_GetActiveEngine()->GetCanvas()->GetViewPort(),
mvmat, pmat);
}
@@ -1593,16 +1613,29 @@ void KX_Scene::UpdateAnimations(double curtime)
CListValue *children = gameobj->GetChildren();
KX_GameObject *child;
+ bool has_mesh = false, has_non_mesh = false;
+
// Check for meshes that haven't been culled
for (int j=0; j<children->GetCount(); ++j) {
child = (KX_GameObject*)children->GetValue(j);
- if (child->GetMeshCount() > 0 && !child->GetCulled()) {
+ if (!child->GetCulled()) {
needs_update = true;
break;
}
+
+ if (child->GetMeshCount() == 0)
+ has_non_mesh = true;
+ else
+ has_mesh = true;
}
+ // If we didn't find a non-culled mesh, check to see
+ // if we even have any meshes, and update if this
+ // armature has only non-mesh children.
+ if (!needs_update && !has_mesh && has_non_mesh)
+ needs_update = true;
+
children->Release();
}
@@ -1678,10 +1711,9 @@ RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool
void KX_Scene::RenderBuckets(const MT_Transform & cameratransform,
- class RAS_IRasterizer* rasty,
- class RAS_IRenderTools* rendertools)
+ class RAS_IRasterizer* rasty)
{
- m_bucketmanager->Renderbuckets(cameratransform,rasty,rendertools);
+ m_bucketmanager->Renderbuckets(cameratransform,rasty);
KX_BlenderMaterial::EndFrame();
}
@@ -1755,14 +1787,14 @@ void KX_Scene::SetNetworkScene(NG_NetworkScene *newScene)
void KX_Scene::SetGravity(const MT_Vector3& gravity)
{
- GetPhysicsEnvironment()->setGravity(gravity[0],gravity[1],gravity[2]);
+ GetPhysicsEnvironment()->SetGravity(gravity[0],gravity[1],gravity[2]);
}
MT_Vector3 KX_Scene::GetGravity()
{
MT_Vector3 gravity;
- GetPhysicsEnvironment()->getGravity(gravity);
+ GetPhysicsEnvironment()->GetGravity(gravity);
return gravity;
}
@@ -1803,10 +1835,6 @@ short KX_Scene::GetAnimationFPS()
return m_blenderScene->r.frs_sec;
}
-#ifdef WITH_BULLET
-#include "KX_BulletPhysicsController.h"
-#endif
-
static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
{
SCA_LogicManager *logicmgr= to->GetLogicManager();
@@ -1839,7 +1867,6 @@ static void MergeScene_LogicBrick(SCA_ILogicBrick* brick, KX_Scene *to)
#ifdef WITH_BULLET
#include "CcdGraphicController.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
#include "CcdPhysicsEnvironment.h" // XXX ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
-#include "KX_BulletPhysicsController.h"
#endif
static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene *from)
@@ -1888,12 +1915,19 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
}
/* graphics controller */
- PHY_IGraphicController *ctrl = gameobj->GetGraphicController();
+ PHY_IController *ctrl = gameobj->GetGraphicController();
if (ctrl) {
/* SHOULD update the m_cullingTree */
ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
}
+#ifdef WITH_BULLET
+ ctrl = gameobj->GetPhysicsController();
+ if (ctrl) {
+ ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
+ }
+#endif
+
/* SG_Node can hold a scene reference */
SG_Node *sg= gameobj->GetSGNode();
if (sg) {
@@ -1905,16 +1939,6 @@ static void MergeScene_GameObject(KX_GameObject* gameobj, KX_Scene *to, KX_Scene
for (int i=0; i<children.size(); i++)
children[i]->SetSGClientInfo(to);
}
-#ifdef WITH_BULLET
- SGControllerList::iterator contit;
- SGControllerList& controllers = sg->GetSGControllerList();
- for (contit = controllers.begin();contit!=controllers.end();++contit)
- {
- KX_BulletPhysicsController *phys_ctrl= dynamic_cast<KX_BulletPhysicsController *>(*contit);
- if (phys_ctrl)
- phys_ctrl->SetPhysicsEnvironment(to->GetPhysicsEnvironment());
- }
-#endif // WITH_BULLET
}
/* If the object is a light, update it's scene */
if (gameobj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT)