diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5eb7cd130..f7e2c248a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -466,6 +466,7 @@ set( SRCS ${SRCS} src/main.cpp
src/physics/physical_object.hpp
src/physics/physics.cpp
src/physics/physics.hpp
+ src/physics/stk_dynamics_world.hpp
src/physics/triangle_mesh.cpp
src/physics/triangle_mesh.hpp
src/physics/user_pointer.hpp
diff --git a/src/Makefile.am b/src/Makefile.am
index b04fb4d9c..8b2cf41a9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -289,6 +289,7 @@ supertuxkart_SOURCES = \
physics/physical_object.hpp \
physics/physics.cpp \
physics/physics.hpp \
+ phsyics/stk_dynamics_world.hpp \
physics/triangle_mesh.cpp \
physics/triangle_mesh.hpp \
physics/user_pointer.hpp \
diff --git a/src/ide/vc9/supertuxkart.vcproj b/src/ide/vc9/supertuxkart.vcproj
index 3897cc53c..f07be912f 100644
--- a/src/ide/vc9/supertuxkart.vcproj
+++ b/src/ide/vc9/supertuxkart.vcproj
@@ -414,6 +414,26 @@
>
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
@@ -1704,6 +1704,10 @@
RelativePath="..\..\physics\physics.hpp"
>
+
+
diff --git a/src/modes/world.cpp b/src/modes/world.cpp
index c4e63fc0c..0e6f88f4f 100644
--- a/src/modes/world.cpp
+++ b/src/modes/world.cpp
@@ -368,6 +368,10 @@ void World::terminateRace()
*/
void World::resetAllKarts()
{
+ // Reset the physics 'remaining' time to 0 so that the number
+ // of timesteps is reproducible if doing a physics-based history run
+ getPhysics()->getPhysicsWorld()->resetLocalTime();
+
// If track checking is requested, check all rescue positions if
// they are heigh enough.
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES &&
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index 5c4d4cf2c..6681df49a 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -27,6 +27,7 @@
#include "physics/btUprightConstraint.hpp"
#include "physics/irr_debug_drawer.hpp"
#include "physics/physical_object.hpp"
+#include "physics/stk_dynamics_world.hpp"
#include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp"
@@ -48,10 +49,10 @@ Physics::Physics() : btSequentialImpulseConstraintSolver()
void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
{
m_axis_sweep = new btAxisSweep3(world_min, world_max);
- m_dynamics_world = new btDiscreteDynamicsWorld(m_dispatcher,
- m_axis_sweep,
- this,
- m_collision_conf);
+ m_dynamics_world = new STKDynamicsWorld(m_dispatcher,
+ m_axis_sweep,
+ this,
+ m_collision_conf);
m_dynamics_world->setGravity(btVector3(0.0f,
-World::getWorld()->getTrack()->getGravity(),
0.0f));
diff --git a/src/physics/physics.hpp b/src/physics/physics.hpp
index bde791fd0..9739cba20 100644
--- a/src/physics/physics.hpp
+++ b/src/physics/physics.hpp
@@ -31,10 +31,12 @@
#include "btBulletDynamicsCommon.h"
#include "physics/irr_debug_drawer.hpp"
+#include "physics/stk_dynamics_world.hpp"
#include "physics/user_pointer.hpp"
-class Vec3;
class Kart;
+class STKDynamicsWorld;
+class Vec3;
/**
* \ingroup physics
@@ -89,7 +91,10 @@ private:
}
}; // CollisionList
- btDynamicsWorld *m_dynamics_world;
+ /** Pointer to the physics dynamics world. */
+ STKDynamicsWorld *m_dynamics_world;
+
+ /** Used in physics debugging to draw the physics world. */
IrrDebugDrawer *m_debug_drawer;
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
@@ -107,7 +112,7 @@ public:
void KartKartCollision(Kart *ka, Kart *kb);
void update (float dt);
void draw ();
- btDynamicsWorld*
+ STKDynamicsWorld*
getPhysicsWorld () const {return m_dynamics_world;}
/** Activates the next debug mode (or switches it off again).
*/
diff --git a/src/physics/stk_dynamics_world.hpp b/src/physics/stk_dynamics_world.hpp
new file mode 100644
index 000000000..3d5d7b677
--- /dev/null
+++ b/src/physics/stk_dynamics_world.hpp
@@ -0,0 +1,47 @@
+// $Id$
+//
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2011 Joerg Henrichs
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_STK_DYNAMICS_WORLD_HPP
+#define HEADER_STK_DYNAMICS_WORLD_HPP
+
+#include "btBulletDynamicsCommon.h"
+
+class STKDynamicsWorld : public btDiscreteDynamicsWorld
+{
+public:
+ /** The standard constructor which just created a btDiscreteDynamicsWorld. */
+ STKDynamicsWorld(btDispatcher* dispatcher,
+ btBroadphaseInterface* pairCache,
+ btConstraintSolver* constraintSolver,
+ btCollisionConfiguration* collisionConfiguration)
+
+ : btDiscreteDynamicsWorld(dispatcher, pairCache,
+ constraintSolver,
+ collisionConfiguration)
+ {
+ }
+
+ /** Resets m_localTime to 0. This allows more precise replay of
+ * physics, which is important for replaying histories. */
+ virtual void resetLocalTime() { m_localTime = 0; }
+
+}; // STKDynamicsWorld
+#endif
+/* EOF */
+