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:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
commit7b2567924b9b86961cd4c07b76653f49939cab1c (patch)
treeadcf1091db6f3f78c05c6b02c567a9b77fc10092 /source/gameengine/Physics/Sumo/Fuzzics
parent063982914038ecd578bab7849a1e94cccbb8d8b9 (diff)
Switch fixed time system. Logic updates should now happen at 30Hz, physics at 60Hz. (By default, use Python to set.) Some actuators still run at framerate (IPO, Action) for nice smooth animation, and an excuse to buy high end hardware.
Keyboard sensors can now hook escape key. Ctrl-Break can be used from within blender if you've forgotten an end game actuator. Fixed a stupid bug preventing some actuators working (like TrackTo).
Diffstat (limited to 'source/gameengine/Physics/Sumo/Fuzzics')
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h1
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h4
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp17
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp48
4 files changed, 53 insertions, 17 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
index db7f5f07603..54574f9fc55 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h
@@ -227,6 +227,7 @@ public:
SM_Object *getDynamicParent() ;
+ void beginFrame();
void integrateForces(MT_Scalar timeStep);
void integrateMomentum(MT_Scalar timeSteo);
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
index 7afa2a59084..1c11df66c38 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h
@@ -107,7 +107,7 @@ public:
// The maximum time interval between two collision checks.
// 'subSampling' can be used to control aliasing effects
// (fast moving objects traversing through walls and such).
- void proceed(MT_Scalar timeStep, MT_Scalar subSampling);
+ void proceed(MT_Scalar curtime, MT_Scalar ticrate);
/**
* Test whether any objects lie on the line defined by from and
@@ -178,6 +178,8 @@ private:
* timestep. The list is built during the proceed(). During that
* time, it is not valid. */
T_PairList m_pairList;
+
+ MT_Scalar m_lastTime;
};
#endif
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
index 613212b642a..940f0d221a0 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
+++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp
@@ -101,15 +101,23 @@ SM_Object::SM_Object(
m_suspended = false;
}
- void
+ void
SM_Object::
-integrateForces(
- MT_Scalar timeStep
+beginFrame(
){
if (!m_suspended) {
m_prev_state = *this;
m_prev_state.setLinearVelocity(actualLinVelocity());
m_prev_state.setAngularVelocity(actualAngVelocity());
+ }
+}
+
+ void
+SM_Object::
+integrateForces(
+ MT_Scalar timeStep
+){
+ if (!m_suspended) {
if (isDynamic()) {
// Integrate momentum (forward Euler)
m_lin_mom += m_force * timeStep;
@@ -447,7 +455,8 @@ DT_Bool SM_Object::fix(
// Get collision data from SOLID
MT_Vector3 normal(local2 - local1);
- if (normal.dot(normal) < MT_EPSILON)
+ MT_Scalar dist = normal.dot(normal);
+ if (dist < MT_EPSILON || dist > obj2->m_shapeProps->m_radius*obj2->m_shapeProps->m_radius)
return DT_CONTINUE;
// This distinction between dynamic and non-dynamic objects should not be
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
index 8034cfdc86d..aee0f1470fe 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
+++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
@@ -53,7 +53,8 @@ SM_Scene::SM_Scene() :
m_respTable(DT_CreateRespTable()),
m_secondaryRespTable(DT_CreateRespTable()),
m_fixRespTable(DT_CreateRespTable()),
- m_forceField(0.0, 0.0, 0.0)
+ m_forceField(0.0, 0.0, 0.0),
+ m_lastTime(-1.0)
{
for (int i = 0 ; i < NUM_RESPONSE; i++)
{
@@ -158,20 +159,43 @@ void SM_Scene::remove(SM_Object& object) {
// tried to remove an object that is not in the scene
//assert(false);
}
-}
-
-void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
- // Don't waste time...but it's OK to spill a little.
- //if (timeStep < 0.001)
- // return;
+}
+void SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate) {
+ if (m_lastTime < 0.0)
+ {
+ m_lastTime = curtime;
+ return;
+ }
+
// Divide the timeStep into a number of subsamples of size roughly
- // equal to subSampling (might be a little smaller).
- int num_samples = (int)ceil(timeStep / subSampling);
-
- MT_Scalar subStep = timeStep / num_samples;
+ // equal to subS (might be a little smaller).
+ MT_Scalar timeStep = curtime - m_lastTime;
+ MT_Scalar subStep = 1.0/ticrate;
+ int num_samples = int(timeStep * ticrate);
+
T_ObjectList::iterator i;
+
+ // No timestep! (should do a mini update)
+ if (!num_samples)
+ {
+ // Apply a forcefield (such as gravity)
+#if 0
+ for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
+ {
+ //(*i)->applyForceField(m_forceField);
+ //(*i)->integrateForces(timeStep);
+ // And second we update the object positions by performing
+ // an integration step for each object
+ (*i)->integrateMomentum(timeStep);
+ //(*i)->clearForce();
+ }
+#endif
+ return;
+ }
+ m_lastTime += MT_Scalar(num_samples)*subStep;
+
// Apply a forcefield (such as gravity)
for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
(*i)->applyForceField(m_forceField);
@@ -183,6 +207,7 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
for (step = 0; step != num_samples; ++step) {
for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
+ (*i)->beginFrame();
(*i)->integrateForces(subStep);
// And second we update the object positions by performing
// an integration step for each object
@@ -210,7 +235,6 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
// Finish this timestep by saving al state information for the next
// timestep and clearing the accumulated forces.
-
for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
(*i)->relax();
(*i)->proceedKinematic(timeStep);