SuperTuxKart
|
Classes | |
class | Settings |
Public Types | |
enum | BodyTypes { MP_NONE , MP_CONE_Y , MP_CONE_X , MP_CONE_Z , MP_CYLINDER_Y , MP_CYLINDER_X , MP_CYLINDER_Z , MP_BOX , MP_SPHERE , MP_EXACT } |
The supported collision shapes. | |
Public Member Functions | |
PhysicalObject (bool is_dynamic, const Settings &settings, TrackObject *object) | |
virtual void | reset () |
Nothing to do here. | |
virtual void | handleExplosion (const Vec3 &pos, bool directHit) |
void | update (float dt) |
Update, called once per physics time step. | |
void | updateGraphics (float dt) |
This updates all only graphical elements. | |
void | init (const Settings &settings) |
Additional initialisation after loading of the model is finished. | |
void | move (const Vec3 &xyz, const core::vector3df &hpr) |
void | hit (const Material *m, const Vec3 &normal) |
Called when a physical object hits the track. | |
bool | isSoccerBall () const |
Returns true if this object is a soccer ball. | |
bool | castRay (const btVector3 &from, const btVector3 &to, btVector3 *hit_point, const Material **material, btVector3 *normal, bool interpolate_normal) const |
Does a raycast against this physical object. | |
bool | isDynamic () const |
std::string | getID () |
Returns the ID of this physical object. | |
btDefaultMotionState * | getMotionState () const |
btRigidBody * | getBody () const |
Returns the rigid body of this physical object. | |
bool | isCrashReset () const |
Returns true if this object should trigger a rescue in a kart that hits it. | |
bool | isExplodeKartObject () const |
Returns true if this object should cause an explosion if a kart hits it. | |
void | setInteraction (std::string interaction) |
Sets the interaction type. | |
void | removeBody () |
Remove body from dynamic world. | |
void | addBody () |
Add body to dynamic world. | |
float | getRadius () const |
const std::string & | getOnKartCollisionFunction () const |
const std::string & | getOnItemCollisionFunction () const |
TrackObject * | getTrackObject () |
bool | isFlattenKartObject () const |
Returns true if this object should cause a kart that touches it to be flattened. | |
void | disable () |
void | enable () |
void | addForRewind () |
virtual void | saveTransform () |
Called before a rewind. | |
virtual void | computeError () |
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time). | |
virtual BareNetworkString * | saveState (std::vector< std::string > *ru) |
Provides a copy of the state of the object in one memory buffer. | |
virtual void | undoEvent (BareNetworkString *buffer) |
Called when an event needs to be undone. | |
virtual void | rewindToEvent (BareNetworkString *buffer) |
Called when an event needs to be replayed. | |
virtual void | restoreState (BareNetworkString *buffer, int count) |
Called when a state needs to be replayed. | |
virtual void | undoState (BareNetworkString *buffer) |
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo). | |
virtual std::function< void()> | getLocalStateRestoreFunction () |
bool | hasTriangleMesh () const |
void | joinToMainTrack () |
std::shared_ptr< PhysicalObject > | clone (TrackObject *track_obj) |
Public Member Functions inherited from Rewinder | |
Rewinder (const std::string &ui="") | |
virtual void | saveTransform ()=0 |
Called before a rewind. | |
virtual void | computeError ()=0 |
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time). | |
virtual BareNetworkString * | saveState (std::vector< std::string > *ru)=0 |
Provides a copy of the state of the object in one memory buffer. | |
virtual void | undoEvent (BareNetworkString *buffer)=0 |
Called when an event needs to be undone. | |
virtual void | rewindToEvent (BareNetworkString *buffer)=0 |
Called when an event needs to be replayed. | |
virtual void | restoreState (BareNetworkString *buffer, int count)=0 |
Called when a state needs to be replayed. | |
virtual void | undoState (BareNetworkString *buffer)=0 |
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo). | |
virtual void | reset () |
Nothing to do here. | |
virtual std::function< void()> | getLocalStateRestoreFunction () |
const std::string & | getUniqueIdentity () const |
bool | rewinderAdd () |
Add this object to the list of all rewindable objects in the rewind manager. | |
template<typename T > | |
std::shared_ptr< T > | getShared () |
Public Member Functions inherited from SmoothNetworkBody | |
SmoothNetworkBody (bool enable=false) | |
void | reset () |
void | setEnable (bool val) |
bool | isEnabled () const |
void | setSmoothRotation (bool val) |
void | setAdjustVerticalOffset (bool val) |
void | prepareSmoothing (const btTransform ¤t_transform, const Vec3 ¤t_velocity) |
void | checkSmoothing (const btTransform ¤t_transform, const Vec3 ¤t_velocity) |
Adds a new error between graphical and physical position/rotation. | |
void | updateSmoothedGraphics (const btTransform ¤t_transform, const Vec3 ¤t_velocity, float dt) |
void | setSmoothedTransform (const btTransform &t) |
const btTransform & | getSmoothedTrans () const |
const Vec3 & | getSmoothedXYZ () const |
void | setMinAdjustLength (float val) |
void | setMaxAdjustLength (float val) |
void | setMinAdjustSpeed (float val) |
void | setMaxAdjustTime (float val) |
void | setAdjustLengthThreshold (float val) |
Static Public Member Functions | |
static std::shared_ptr< PhysicalObject > | fromXML (bool is_dynamic, const XMLNode &node, TrackObject *object) |
Private Member Functions | |
void | copyFromMainProcess (TrackObject *track_obj) |
Private Attributes | |
core::vector3df | m_init_xyz |
The initial XYZ position of the object. | |
core::vector3df | m_init_hpr |
The initial hpr of the object. | |
core::vector3df | m_init_scale |
The initial scale of the object. | |
TrackObject * | m_object |
BodyTypes | m_body_type |
The shape of this object. | |
btCollisionShape * | m_shape |
The bullet collision shape. | |
std::string | m_id |
ID of the object. | |
btRigidBody * | m_body |
The corresponding bullet rigid body. | |
btDefaultMotionState * | m_motion_state |
Bullet's motion state for this object. | |
float | m_mass |
The mass of this object. | |
bool | m_body_added |
UserPointer | m_user_pointer |
The pointer that is stored in the bullet rigid body back to this object. | |
btTransform | m_init_pos |
This is the initial position of the object for the physics. | |
btTransform | m_current_transform |
Save current transform to avoid frequent lookup from world transform. | |
Vec3 | m_graphical_offset |
The mesh might not have the same center as bullet does. | |
float | m_radius |
Radius of the object - this obviously depends on the actual shape. | |
bool | m_crash_reset |
True if a kart colliding with this object should be rescued. | |
bool | m_explode_kart |
True if kart should "explode" when touching this. | |
bool | m_flatten_kart |
bool | m_reset_when_too_low |
True if object should be reset to its initial position if it's too low (see m_reset_height). | |
float | m_reset_height |
If m_reset_when_too_low this object is set back to its start position if its height is below this value. | |
std::string | m_on_kart_collision |
If non-empty, the name of the scripting function to call when a kart collides with this object. | |
std::string | m_on_item_collision |
If non-empty, the name of the scripting function to call when a (flyable) item collides with this object. | |
bool | m_is_dynamic |
If this body is a bullet dynamic body, i.e. | |
TriangleMesh * | m_triangle_mesh |
Non-null only if the shape is exact. | |
btTransform | m_last_transform |
Vec3 | m_last_lv |
Vec3 | m_last_av |
bool | m_no_server_state |
Additional Inherited Members | |
Protected Member Functions inherited from Rewinder | |
void | setUniqueIdentity (const std::string &uid) |
void PhysicalObject::addBody | ( | ) |
Add body to dynamic world.
Add body to physics dynamic world.
bool PhysicalObject::castRay | ( | const btVector3 & | from, |
const btVector3 & | to, | ||
btVector3 * | hit_point, | ||
const Material ** | material, | ||
btVector3 * | normal, | ||
bool | interpolate_normal | ||
) | const |
Does a raycast against this physical object.
The physical object must have an 'exact' shape, i.e. be a triangle mesh (for other physical objects no material information would be available).
from/to | The from and to position for the raycast. |
xyz | The position in world where the ray hit. |
material | The material of the mesh that was hit. |
normal | The intrapolated normal at that position. |
interpolate_normal | If true, the returned normal is the interpolated based on the three normals of the triangle and the location of the hit point (which is more compute intensive, but results in much smoother results). |
|
virtual |
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time).
Implements Rewinder.
|
virtual |
Reimplemented from Rewinder.
Called when a physical object hits the track.
Atm only used to push a soccer ball away from the edge of the field.
m | Material which was hit. |
normal | Normal of the track at the hit point. |
void PhysicalObject::removeBody | ( | ) |
Remove body from dynamic world.
Remove body from physics dynamic world interaction type for object.
|
virtual |
Nothing to do here.
Reimplemented from Rewinder.
|
virtual |
Called when a state needs to be replayed.
This is called during rewind, i.e. when going forward in time again, and only for confirmed states.
Implements Rewinder.
|
inlinevirtual |
Called when an event needs to be replayed.
This is called during rewind, i.e. when going forward in time again.
Implements Rewinder.
|
virtual |
Provides a copy of the state of the object in one memory buffer.
The memory is managed by the RewindManager.
[out] | ru | The unique identity of rewinder writing to. |
Implements Rewinder.
|
virtual |
Called before a rewind.
Is used to save the previous position of an object before a rewind, so that the error due to a rewind can be computed.
Implements Rewinder.
void PhysicalObject::setInteraction | ( | std::string | interaction | ) |
Sets the interaction type.
Sets interaction type for object.
|
inlinevirtual |
Called when an event needs to be undone.
This is called while going backwards for rewinding - all stored events will get an 'undo' call.
Implements Rewinder.
|
inlinevirtual |
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo).
This is called while going backwards for rewinding - all stored events will get an 'undo' call.
Implements Rewinder.
void PhysicalObject::update | ( | float | dt | ) |
Update, called once per physics time step.
dt | Timestep. |
void PhysicalObject::updateGraphics | ( | float | dt | ) |
This updates all only graphical elements.
It is only called once per rendered frame, not once per time step. float dt Time since last rame.
|
private |
The mesh might not have the same center as bullet does.
This offset is used to offset the location of the graphical mesh so that the graphics are aligned with the bullet collision shape.
|
private |
If this body is a bullet dynamic body, i.e.
affected by physics or not (static (not moving) or kinematic (animated outside of physics).
|
private |
Radius of the object - this obviously depends on the actual shape.
As a default the radius is being determined from the shape of the mesh, but in somce cases that could lead to incorrect results (if the mesh does not closely resemble a sphere, see init() for details, but is supposed to be a sphere). In this case the radius can be set in the scene file.