Reset the 'reminder' time maintained by bullet (which uses fixed
time steps), so that in physics replay the time steps are now correct. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/physics@10219 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6ece9c5624
commit
e37c225654
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -414,6 +414,26 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="input"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\input\binding.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\device_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\input_device.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\input_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="challenges"
|
||||
@ -927,26 +947,6 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="input"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\input\binding.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\device_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\input_device.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\input\input_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="race"
|
||||
>
|
||||
@ -1704,6 +1704,10 @@
|
||||
RelativePath="..\..\physics\physics.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\physics\stk_dynamics_world.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\physics\triangle_mesh.hpp"
|
||||
>
|
||||
|
@ -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 &&
|
||||
|
@ -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));
|
||||
|
@ -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).
|
||||
*/
|
||||
|
47
src/physics/stk_dynamics_world.hpp
Normal file
47
src/physics/stk_dynamics_world.hpp
Normal file
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user