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
path: root/source
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2006-04-01 07:30:15 +0400
committerErwin Coumans <blender@erwincoumans.com>2006-04-01 07:30:15 +0400
commit36fd42ac85c40861b960b1f896dff972afc75691 (patch)
treef7c3e52ffa17a022829a4e22d6c67e25f4587f7b /source
parent63bc0b3847366bc21adc7bfcf5f03e223cf4d8f8 (diff)
more Bullet physics improvements, mainly stability and performance related.
AddObjectActuator has new python method to immediately create objects (this allows to create multiple objects in 1 frame in different positions)
Diffstat (limited to 'source')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp49
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp6
4 files changed, 43 insertions, 17 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 85fdc51826a..3b1e4f7ce59 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -1091,6 +1091,7 @@ PyObject* KX_GameObject::PySetPosition(PyObject* self,
if (PyVecArgTo(args, pos))
{
NodeSetLocalPosition(pos);
+ NodeUpdateGS(0.f,true);
Py_Return;
}
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index d9517a3a65b..322f41e11a3 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -85,28 +85,16 @@ bool KX_SCA_AddObjectActuator::Update()
RemoveAllEvents();
if (bNegativeEvent) return false; // do nothing on negative events
- if (m_OriginalObject)
- {
- // Add an identical object, with properties inherited from the original object
- // Now it needs to be added to the current scene.
- SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
- KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
- game_obj->setLinearVelocity(m_linear_velocity,m_localFlag);
- game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false);
- // keep a copy of the last object, to allow python scripters to change it
- if (m_lastCreatedObject)
- m_lastCreatedObject->Release();
-
- m_lastCreatedObject = replica;
- m_lastCreatedObject->AddRef();
- }
+ InstantAddObject();
+
return false;
}
+
SCA_IObject* KX_SCA_AddObjectActuator::GetLastCreatedObject() const
{
return m_lastCreatedObject;
@@ -169,6 +157,8 @@ PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
{"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_VARARGS, GetLinearVelocity_doc},
{"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc},
{"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_VARARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
+ {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_VARARGS,"instantAddObject() : immediately add object without delay\n"},
+
{NULL,NULL} //Sentinel
};
@@ -315,6 +305,35 @@ PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self,
Py_Return;
}
+void KX_SCA_AddObjectActuator::InstantAddObject()
+{
+ if (m_OriginalObject)
+ {
+ // Add an identical object, with properties inherited from the original object
+ // Now it needs to be added to the current scene.
+ SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
+ KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
+ game_obj->setLinearVelocity(m_linear_velocity,m_localFlag);
+ game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false);
+
+ // keep a copy of the last object, to allow python scripters to change it
+ if (m_lastCreatedObject)
+ m_lastCreatedObject->Release();
+
+ m_lastCreatedObject = replica;
+ m_lastCreatedObject->AddRef();
+ }
+}
+
+PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ InstantAddObject();
+
+ Py_Return;
+}
+
/* 7. GetLastCreatedObject */
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
index 2a7c27669fa..60adcb27b12 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
@@ -104,6 +104,8 @@ public:
GetLastCreatedObject(
) const ;
+ void InstantAddObject();
+
/* 1. setObject */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetObject);
/* 2. setTime */
@@ -118,6 +120,8 @@ public:
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetLinearVelocity);
/* 7. getLastCreatedObject */
KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLastCreatedObject);
+ /* 8. instantAddObject*/
+ KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,InstantAddObject);
}; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 98387076892..2c4f98c5624 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -315,7 +315,7 @@ m_solverType(-1)
//broadphase = new SimpleBroadphase();
}
- setSolverType(0);
+ setSolverType(1);
m_collisionWorld = new CollisionWorld(dispatcher,broadphase);
@@ -524,6 +524,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
DispatcherInfo dispatchInfo;
dispatchInfo.m_timeStep = timeStep;
dispatchInfo.m_stepCount = 0;
+ dispatchInfo.m_debugDraw = m_debugDrawer;
scene->DispatchAllCollisionPairs(*GetDispatcher(),dispatchInfo);///numsubstep,g);
@@ -882,7 +883,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType)
{
m_solver = new SimpleConstraintSolver();
-
+ //printf("Iterative Impulse ConstraintSolver\n");
break;
}
}
@@ -892,6 +893,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType)
if (m_solverType != solverType)
{
m_solver = new OdeConstraintSolver();
+ //printf("Quickstep ConstraintSolver\n");
break;
}