Added support for setting the restitution for physical objects.

This commit is contained in:
hiker 2016-05-19 13:25:29 +10:00
parent 5b2cb52dc5
commit 92be0c65ad
3 changed files with 14 additions and 9 deletions

View File

@ -57,13 +57,14 @@ PhysicalObject::Settings::Settings(const XMLNode &xml_node)
{
init();
std::string shape;
xml_node.get("id", &m_id );
xml_node.get("mass", &m_mass );
xml_node.get("radius", &m_radius );
xml_node.get("shape", &shape );
xml_node.get("reset", &m_crash_reset );
xml_node.get("explode", &m_knock_kart );
xml_node.get("flatten", &m_flatten_kart);
xml_node.get("id", &m_id );
xml_node.get("mass", &m_mass );
xml_node.get("radius", &m_radius );
xml_node.get("restitution", &m_restitution );
xml_node.get("shape", &shape );
xml_node.get("reset", &m_crash_reset );
xml_node.get("explode", &m_knock_kart );
xml_node.get("flatten", &m_flatten_kart );
xml_node.get("on-kart-collision", &m_on_kart_collision);
xml_node.get("on-item-collision", &m_on_item_collision);
m_reset_when_too_low =
@ -97,6 +98,7 @@ void PhysicalObject::Settings::init()
m_knock_kart = false;
m_mass = 0.0f;
m_radius = -1.0f;
m_restitution = 0.0f;
m_reset_when_too_low = false;
m_flatten_kart = false;
} // Settings
@ -159,6 +161,7 @@ PhysicalObject::PhysicalObject(bool is_dynamic,
m_is_dynamic = is_dynamic;
init();
m_body->setRestitution(settings.m_restitution);
} // PhysicalObject
// ----------------------------------------------------------------------------
@ -471,7 +474,7 @@ void PhysicalObject::init()
if (m_is_dynamic)
{
m_init_pos.setOrigin(m_init_pos.getOrigin() +
btVector3(0, extend.getY()*0.5f, 0));
btVector3(0, extend.getY()*0.5f, 0));
}

View File

@ -55,6 +55,8 @@ public:
float m_radius;
/** Shape of the object. */
PhysicalObject::BodyTypes m_body_type;
/** Restitution of the physical object. */
float m_restitution;
/** Trigger a reset in karts touching it? */
bool m_crash_reset;
/** Knock the kart around. */

View File

@ -57,11 +57,11 @@ class MusicInformation;
class ParticleEmitter;
class ParticleKind;
class PhysicalObject;
class TrackObject;
class TrackObjectManager;
class TriangleMesh;
class World;
class XMLNode;
class TrackObject;
namespace Scripting
{