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/physical_object.hpp
|
||||||
src/physics/physics.cpp
|
src/physics/physics.cpp
|
||||||
src/physics/physics.hpp
|
src/physics/physics.hpp
|
||||||
|
src/physics/stk_dynamics_world.hpp
|
||||||
src/physics/triangle_mesh.cpp
|
src/physics/triangle_mesh.cpp
|
||||||
src/physics/triangle_mesh.hpp
|
src/physics/triangle_mesh.hpp
|
||||||
src/physics/user_pointer.hpp
|
src/physics/user_pointer.hpp
|
||||||
|
@ -289,6 +289,7 @@ supertuxkart_SOURCES = \
|
|||||||
physics/physical_object.hpp \
|
physics/physical_object.hpp \
|
||||||
physics/physics.cpp \
|
physics/physics.cpp \
|
||||||
physics/physics.hpp \
|
physics/physics.hpp \
|
||||||
|
phsyics/stk_dynamics_world.hpp \
|
||||||
physics/triangle_mesh.cpp \
|
physics/triangle_mesh.cpp \
|
||||||
physics/triangle_mesh.hpp \
|
physics/triangle_mesh.hpp \
|
||||||
physics/user_pointer.hpp \
|
physics/user_pointer.hpp \
|
||||||
|
@ -414,6 +414,26 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</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>
|
||||||
<Filter
|
<Filter
|
||||||
Name="challenges"
|
Name="challenges"
|
||||||
@ -927,26 +947,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</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="race"
|
Name="race"
|
||||||
>
|
>
|
||||||
@ -1704,6 +1704,10 @@
|
|||||||
RelativePath="..\..\physics\physics.hpp"
|
RelativePath="..\..\physics\physics.hpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\physics\stk_dynamics_world.hpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\physics\triangle_mesh.hpp"
|
RelativePath="..\..\physics\triangle_mesh.hpp"
|
||||||
>
|
>
|
||||||
|
@ -368,6 +368,10 @@ void World::terminateRace()
|
|||||||
*/
|
*/
|
||||||
void World::resetAllKarts()
|
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
|
// If track checking is requested, check all rescue positions if
|
||||||
// they are heigh enough.
|
// they are heigh enough.
|
||||||
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES &&
|
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_3_STRIKES &&
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "physics/btUprightConstraint.hpp"
|
#include "physics/btUprightConstraint.hpp"
|
||||||
#include "physics/irr_debug_drawer.hpp"
|
#include "physics/irr_debug_drawer.hpp"
|
||||||
#include "physics/physical_object.hpp"
|
#include "physics/physical_object.hpp"
|
||||||
|
#include "physics/stk_dynamics_world.hpp"
|
||||||
#include "physics/triangle_mesh.hpp"
|
#include "physics/triangle_mesh.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ Physics::Physics() : btSequentialImpulseConstraintSolver()
|
|||||||
void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
|
void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
|
||||||
{
|
{
|
||||||
m_axis_sweep = new btAxisSweep3(world_min, world_max);
|
m_axis_sweep = new btAxisSweep3(world_min, world_max);
|
||||||
m_dynamics_world = new btDiscreteDynamicsWorld(m_dispatcher,
|
m_dynamics_world = new STKDynamicsWorld(m_dispatcher,
|
||||||
m_axis_sweep,
|
m_axis_sweep,
|
||||||
this,
|
this,
|
||||||
m_collision_conf);
|
m_collision_conf);
|
||||||
|
@ -31,10 +31,12 @@
|
|||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
#include "physics/irr_debug_drawer.hpp"
|
#include "physics/irr_debug_drawer.hpp"
|
||||||
|
#include "physics/stk_dynamics_world.hpp"
|
||||||
#include "physics/user_pointer.hpp"
|
#include "physics/user_pointer.hpp"
|
||||||
|
|
||||||
class Vec3;
|
|
||||||
class Kart;
|
class Kart;
|
||||||
|
class STKDynamicsWorld;
|
||||||
|
class Vec3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup physics
|
* \ingroup physics
|
||||||
@ -89,7 +91,10 @@ private:
|
|||||||
}
|
}
|
||||||
}; // CollisionList
|
}; // 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;
|
IrrDebugDrawer *m_debug_drawer;
|
||||||
btCollisionDispatcher *m_dispatcher;
|
btCollisionDispatcher *m_dispatcher;
|
||||||
btBroadphaseInterface *m_axis_sweep;
|
btBroadphaseInterface *m_axis_sweep;
|
||||||
@ -107,7 +112,7 @@ public:
|
|||||||
void KartKartCollision(Kart *ka, Kart *kb);
|
void KartKartCollision(Kart *ka, Kart *kb);
|
||||||
void update (float dt);
|
void update (float dt);
|
||||||
void draw ();
|
void draw ();
|
||||||
btDynamicsWorld*
|
STKDynamicsWorld*
|
||||||
getPhysicsWorld () const {return m_dynamics_world;}
|
getPhysicsWorld () const {return m_dynamics_world;}
|
||||||
/** Activates the next debug mode (or switches it off again).
|
/** 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