19 #ifndef HEADER_PHYSICAL_OBJECT_HPP 20 #define HEADER_PHYSICAL_OBJECT_HPP 24 #include "btBulletDynamicsCommon.h" 26 #include "network/rewinder.hpp" 28 #include "physics/user_pointer.hpp" 29 #include "utils/vec3.hpp" 44 MP_CONE_Y, MP_CONE_X, MP_CONE_Z,
45 MP_CYLINDER_Y, MP_CYLINDER_X, MP_CYLINDER_Z,
46 MP_BOX, MP_SPHERE, MP_EXACT};
190 btTransform m_last_transform;
196 bool m_no_server_state;
203 static std::shared_ptr<PhysicalObject> fromXML
207 virtual void reset ();
208 virtual void handleExplosion(
const Vec3& pos,
bool directHit);
212 void move (
const Vec3& xyz,
const core::vector3df& hpr);
215 bool castRay(
const btVector3 &from,
216 const btVector3 &to, btVector3 *hit_point,
217 const Material **material, btVector3 *normal,
218 bool interpolate_normal)
const;
226 btDefaultMotionState* getMotionState()
const {
return m_motion_state; }
248 float getRadius()
const {
return m_radius; }
270 void disable(
void *memory)
276 void enable(
void *memory)
292 virtual std::function<void()> getLocalStateRestoreFunction();
293 bool hasTriangleMesh()
const {
return m_triangle_mesh != NULL; }
294 void joinToMainTrack();
295 std::shared_ptr<PhysicalObject> clone(
TrackObject* track_obj)
298 obj->copyFromMainProcess(track_obj);
299 return std::shared_ptr<PhysicalObject>(obj);
btCollisionShape * m_shape
The bullet collision shape.
Definition: physical_object.hpp:118
std::string m_id
ID of the object.
Definition: physical_object.hpp:121
btTransform m_init_pos
This is the initial position of the object for the physics.
Definition: physical_object.hpp:139
std::string m_on_item_collision
If non-empty, the name of the scripting function to call when a (flyable) item collides with this obj...
Definition: physical_object.hpp:93
bool m_is_dynamic
If this body is a bullet dynamic body, i.e.
Definition: physical_object.hpp:184
std::string m_on_kart_collision
If non-empty, the name of the scripting function to call when a kart collides with this object...
Definition: physical_object.hpp:176
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
float m_reset_height
If the item is below that height, it is reset (when m_reset_when_too_low is true).
Definition: physical_object.hpp:85
bool m_reset_when_too_low
Reset the object when it falls under the track (useful e.g.
Definition: physical_object.hpp:82
Definition: smooth_network_body.hpp:38
void removeBody()
Remove body from dynamic world.
Definition: physical_object.cpp:748
Definition: rewinder.hpp:43
std::string m_on_item_collision
If non-empty, the name of the scripting function to call when a (flyable) item collides with this obj...
Definition: physical_object.hpp:180
Vec3 m_linear_factor
Bullet's linear factor.
Definition: physical_object.hpp:66
A special class to store a triangle mesh with a separate material per triangle.
Definition: triangle_mesh.hpp:34
btRigidBody * getBody() const
Returns the rigid body of this physical object.
Definition: physical_object.hpp:229
bool m_crash_reset
True if a kart colliding with this object should be rescued.
Definition: physical_object.hpp:159
Definition: script_track.cpp:250
bool isSoccerBall() const
Returns true if this object is a soccer ball.
Definition: physical_object.cpp:727
BodyTypes m_body_type
The shape of this object.
Definition: physical_object.hpp:115
bool isCrashReset() const
Returns true if this object should trigger a rescue in a kart that hits it.
Definition: physical_object.hpp:233
void hit(const Material *m, const Vec3 &normal)
Called when a physical object hits the track.
Definition: physical_object.cpp:774
bool m_crash_reset
Trigger a reset in karts touching it?
Definition: physical_object.hpp:75
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).
Definition: physical_object.hpp:168
virtual void undoEvent(BareNetworkString *buffer)
Called when an event needs to be undone.
Definition: physical_object.hpp:288
virtual void undoState(BareNetworkString *buffer)
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo)...
Definition: physical_object.hpp:291
PhysicalObject::BodyTypes m_body_type
Shape of the object.
Definition: physical_object.hpp:60
void update(float dt)
Update, called once per physics time step.
Definition: physical_object.cpp:632
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 val...
Definition: physical_object.hpp:172
btRigidBody * m_body
The corresponding bullet rigid body.
Definition: physical_object.hpp:124
core::vector3df m_init_scale
The initial scale of the object.
Definition: physical_object.hpp:110
Definition: physical_object.hpp:38
Vec3 m_angular_factor
Bullet angular factor.
Definition: physical_object.hpp:68
void init()
Initialises a Settings object.
Definition: physical_object.cpp:109
bool m_explode_kart
True if kart should "explode" when touching this.
Definition: physical_object.hpp:162
virtual BareNetworkString * saveState(std::vector< std::string > *ru)
Provides a copy of the state of the object in one memory buffer.
Definition: physical_object.cpp:815
float m_friction
Friction for this object.
Definition: physical_object.hpp:64
float m_angular_damping
Bullet's angular damping factor.
Definition: physical_object.hpp:72
bool isExplodeKartObject() const
Returns true if this object should cause an explosion if a kart hits it.
Definition: physical_object.hpp:237
virtual void rewindToEvent(BareNetworkString *buffer)
Called when an event needs to be replayed.
Definition: physical_object.hpp:289
Definition: physical_object.hpp:48
float m_restitution
Restitution of the physical object.
Definition: physical_object.hpp:62
bool isFlattenKartObject() const
Returns true if this object should cause a kart that touches it to be flattened.
Definition: physical_object.hpp:269
Vec3 m_graphical_offset
The mesh might not have the same center as bullet does.
Definition: physical_object.hpp:148
std::string m_on_kart_collision
If non-empty, the name of the scripting function to call when a kart collides with this object...
Definition: physical_object.hpp:89
TriangleMesh * m_triangle_mesh
Non-null only if the shape is exact.
Definition: physical_object.hpp:187
btDefaultMotionState * m_motion_state
Bullet's motion state for this object.
Definition: physical_object.hpp:127
float m_mass
The mass of this object.
Definition: physical_object.hpp:130
bool m_knock_kart
Knock the kart around.
Definition: physical_object.hpp:77
btTransform m_current_transform
Save current transform to avoid frequent lookup from world transform.
Definition: physical_object.hpp:143
Definition: material.hpp:47
This class help to smooth the graphicial transformation of network controlled object. In case there is any difference between server and client predicted values, instead of showing the server one immediately, it will interpolate between them with an extrapolated value from the old predicted values stored in m_adjust_control_point estimated by current speed of object.
core::vector3df m_init_xyz
The initial XYZ position of the object.
Definition: physical_object.hpp:104
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
virtual void saveTransform()
Called before a rewind.
Definition: physical_object.cpp:800
float m_radius
Radius of the object - this obviously depends on the actual shape.
Definition: physical_object.hpp:156
float m_radius
Radius of the object, to overwrite the graphical dimension.
Definition: physical_object.hpp:56
Settings(BodyTypes type, float radius, float mass)
Creates a physical Settings object with the given type, radius and mass.
Definition: physical_object.cpp:53
A UserPointer is stored as a user pointer in all bullet bodies.
Definition: user_pointer.hpp:35
std::string m_id
ID of the object.
Definition: physical_object.hpp:52
utility class used to parse XML files
Definition: xml_node.hpp:47
virtual void computeError()
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is the...
Definition: physical_object.cpp:808
void addBody()
Add body to dynamic world.
Definition: physical_object.cpp:759
float m_linear_damping
Bullet's linear damping factor.
Definition: physical_object.hpp:70
BodyTypes
The supported collision shapes.
Definition: physical_object.hpp:43
core::vector3df m_init_hpr
The initial hpr of the object.
Definition: physical_object.hpp:107
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.
Definition: physical_object.cpp:666
UserPointer m_user_pointer
The pointer that is stored in the bullet rigid body back to this object.
Definition: physical_object.hpp:136
float m_height
Height of an object, to overwrite the graphical dimension.
Definition: physical_object.hpp:58
float m_mass
Mass of the object.
Definition: physical_object.hpp:54
bool m_flatten_kart
Flatten the kart when this object is touched.
Definition: physical_object.hpp:79
void setInteraction(std::string interaction)
Sets the interaction type.
Definition: physical_object.cpp:734
virtual void restoreState(BareNetworkString *buffer, int count)
Called when a state needs to be replayed.
Definition: physical_object.cpp:848
virtual void reset()
Nothing to do here.
Definition: physical_object.cpp:682
std::string getID()
Returns the ID of this physical object.
Definition: physical_object.hpp:224
void updateGraphics(float dt)
This updates all only graphical elements.
Definition: physical_object.cpp:606