Minor code cleanup, renamed a variable and function.

This commit is contained in:
hiker 2014-01-24 22:25:55 +11:00
parent a257c1a35c
commit 9651a9f224
7 changed files with 61 additions and 58 deletions

View File

@ -116,7 +116,7 @@ void SoccerWorld::reset()
continue; continue;
obj->reset(); obj->reset();
obj->getPhysics()->reset(); obj->getPhysicalObject()->reset();
} }
if (m_goal_sound != NULL && if (m_goal_sound != NULL &&
@ -205,7 +205,7 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal)
continue; continue;
obj->reset(); obj->reset();
obj->getPhysics()->reset(); obj->getPhysicalObject()->reset();
} }
//Resetting the ball triggers the goal check line one more time. //Resetting the ball triggers the goal check line one more time.

View File

@ -349,7 +349,7 @@ void ThreeStrikesBattle::update(float dt)
getTrack()->getTrackObjectManager()->insertObject(tire_obj); getTrack()->getTrackObjectManager()->insertObject(tire_obj);
// FIXME: orient the force relative to kart orientation // FIXME: orient the force relative to kart orientation
tire_obj->getPhysics()->getBody() tire_obj->getPhysicalObject()->getBody()
->applyCentralForce(btVector3(60.0f, 0.0f, 0.0f)); ->applyCentralForce(btVector3(60.0f, 0.0f, 0.0f));
m_insert_tire--; m_insert_tire--;

View File

@ -187,9 +187,7 @@ void PhysicalObject::move(const Vec3& xyz, const core::vector3df& hpr)
irr::core::quaternion tempQuat(mat); irr::core::quaternion tempQuat(mat);
q = btQuaternion(tempQuat.X, tempQuat.Y, tempQuat.Z, tempQuat.W); q = btQuaternion(tempQuat.X, tempQuat.Y, tempQuat.Z, tempQuat.W);
btTransform trans(q,xyz);
Vec3 p(xyz);
btTransform trans(q,p);
m_motion_state->setWorldTransform(trans); m_motion_state->setWorldTransform(trans);
} // move } // move

View File

@ -38,7 +38,8 @@
* model, enable/disable status, timer information. * model, enable/disable status, timer information.
* \param lod_node Lod node (defaults to NULL). * \param lod_node Lod node (defaults to NULL).
*/ */
TrackObject::TrackObject(const XMLNode &xml_node, scene::ISceneNode* parent, LodNodeLoader& lod_loader) TrackObject::TrackObject(const XMLNode &xml_node, scene::ISceneNode* parent,
LodNodeLoader& lod_loader)
{ {
init(xml_node, parent, lod_loader); init(xml_node, parent, lod_loader);
} }
@ -61,7 +62,7 @@ TrackObject::TrackObject(const core::vector3df& xyz, const core::vector3df& hpr,
m_enabled = true; m_enabled = true;
m_presentation = NULL; m_presentation = NULL;
m_animator = NULL; m_animator = NULL;
m_rigid_body = NULL; m_physical_object = NULL;
m_interaction = interaction; m_interaction = interaction;
m_presentation = presentation; m_presentation = presentation;
@ -69,7 +70,7 @@ TrackObject::TrackObject(const core::vector3df& xyz, const core::vector3df& hpr,
if (m_interaction != "ghost" && m_interaction != "none" && if (m_interaction != "ghost" && m_interaction != "none" &&
physics_settings ) physics_settings )
{ {
m_rigid_body = new PhysicalObject(is_dynamic, m_physical_object = new PhysicalObject(is_dynamic,
*physics_settings, *physics_settings,
this); this);
} }
@ -78,8 +79,8 @@ TrackObject::TrackObject(const core::vector3df& xyz, const core::vector3df& hpr,
} // TrackObject } // TrackObject
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, LodNodeLoader& lod_loader) LodNodeLoader& lod_loader)
{ {
m_init_xyz = core::vector3df(0,0,0); m_init_xyz = core::vector3df(0,0,0);
m_init_hpr = core::vector3df(0,0,0); m_init_hpr = core::vector3df(0,0,0);
@ -88,7 +89,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, LodNo
m_presentation = NULL; m_presentation = NULL;
m_animator = NULL; m_animator = NULL;
m_rigid_body = NULL; m_physical_object = NULL;
xml_node.get("xyz", &m_init_xyz ); xml_node.get("xyz", &m_init_xyz );
xml_node.get("hpr", &m_init_hpr ); xml_node.get("hpr", &m_init_hpr );
@ -158,7 +159,8 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, LodNo
if (lod_instance) if (lod_instance)
{ {
m_type = "lod"; m_type = "lod";
TrackObjectPresentationLOD* lod_node = new TrackObjectPresentationLOD(xml_node, parent, lod_loader); TrackObjectPresentationLOD* lod_node =
new TrackObjectPresentationLOD(xml_node, parent, lod_loader);
m_presentation = lod_node; m_presentation = lod_node;
glownode = ((LODNode*)lod_node->getNode())->getAllNodes()[0]; glownode = ((LODNode*)lod_node->getNode())->getAllNodes()[0];
@ -175,9 +177,10 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent, LodNo
std::string render_pass; std::string render_pass;
xml_node.get("renderpass", &render_pass); xml_node.get("renderpass", &render_pass);
if (m_interaction != "ghost" && m_interaction != "none" && render_pass != "skybox") if (m_interaction != "ghost" && m_interaction != "none" &&
render_pass != "skybox" )
{ {
m_rigid_body = PhysicalObject::fromXML(type == "movable", m_physical_object = PhysicalObject::fromXML(type == "movable",
xml_node, xml_node,
this); this);
} }
@ -228,7 +231,7 @@ TrackObject::~TrackObject()
{ {
delete m_presentation; delete m_presentation;
delete m_animator; delete m_animator;
delete m_rigid_body; delete m_physical_object;
} // ~TrackObject } // ~TrackObject
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -240,6 +243,7 @@ void TrackObject::reset()
if (m_animator != NULL) m_animator->reset(); if (m_animator != NULL) m_animator->reset();
} // reset } // reset
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Enables or disables this object. This affects the visibility, i.e. /** Enables or disables this object. This affects the visibility, i.e.
* disabled objects will not be displayed anymore. * disabled objects will not be displayed anymore.
@ -250,12 +254,13 @@ void TrackObject::setEnable(bool mode)
m_enabled = mode; m_enabled = mode;
if (m_presentation != NULL) m_presentation->setEnable(m_enabled); if (m_presentation != NULL) m_presentation->setEnable(m_enabled);
} // setEnable } // setEnable
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObject::update(float dt) void TrackObject::update(float dt)
{ {
if (m_presentation != NULL) m_presentation->update(dt); if (m_presentation != NULL) m_presentation->update(dt);
if (m_rigid_body != NULL) m_rigid_body->update(dt); if (m_physical_object != NULL) m_physical_object->update(dt);
if (m_animator != NULL) m_animator->update(dt); if (m_animator != NULL) m_animator->update(dt);
} // update } // update
@ -264,21 +269,21 @@ void TrackObject::update(float dt)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObject::move(const core::vector3df& xyz, const core::vector3df& hpr, void TrackObject::move(const core::vector3df& xyz, const core::vector3df& hpr,
const core::vector3df& scale, bool updateRigidBody) const core::vector3df& scale, bool update_rigid_body)
{ {
if (m_presentation != NULL) m_presentation->move(xyz, hpr, scale); if (m_presentation != NULL) m_presentation->move(xyz, hpr, scale);
if (updateRigidBody && m_rigid_body != NULL) m_rigid_body->move(xyz, hpr); if (update_rigid_body && m_physical_object != NULL)
} m_physical_object->move(xyz, hpr);
} // move
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const core::vector3df& TrackObject::getPosition() const const core::vector3df& TrackObject::getPosition() const
{ {
if (m_presentation != NULL) if (m_presentation != NULL)
return m_presentation->getPosition(); return m_presentation->getPosition();
else else
return m_init_xyz; return m_init_xyz;
} } // getPosition
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -288,7 +293,7 @@ const core::vector3df TrackObject::getAbsolutePosition() const
return m_presentation->getAbsolutePosition(); return m_presentation->getAbsolutePosition();
else else
return m_init_xyz; return m_init_xyz;
} } // getAbsolutePosition
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -298,7 +303,7 @@ const core::vector3df& TrackObject::getRotation() const
return m_presentation->getRotation(); return m_presentation->getRotation();
else else
return m_init_xyz; return m_init_xyz;
} } // getRotation
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -308,4 +313,4 @@ const core::vector3df& TrackObject::getScale() const
return m_presentation->getScale(); return m_presentation->getScale();
else else
return m_init_xyz; return m_init_xyz;
} } // getScale

View File

@ -78,7 +78,7 @@ protected:
float m_distance; float m_distance;
PhysicalObject* m_rigid_body; PhysicalObject* m_physical_object;
ThreeDAnimation* m_animator; ThreeDAnimation* m_animator;
@ -113,8 +113,8 @@ public:
bool isGarage() const { return m_garage; } bool isGarage() const { return m_garage; }
float getDistance() const { return m_distance; } float getDistance() const { return m_distance; }
const PhysicalObject* getPhysics() const { return m_rigid_body; } const PhysicalObject* getPhysicalObject() const { return m_physical_object; }
PhysicalObject* getPhysics() { return m_rigid_body; } PhysicalObject* getPhysicalObject() { return m_physical_object; }
const core::vector3df getInitXYZ() const { return m_init_xyz; } const core::vector3df getInitXYZ() const { return m_init_xyz; }
const core::vector3df getInitRotation() const { return m_init_hpr; } const core::vector3df getInitRotation() const { return m_init_hpr; }

View File

@ -101,8 +101,8 @@ void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *
TrackObject* curr; TrackObject* curr;
for_in (curr, m_all_objects) for_in (curr, m_all_objects)
{ {
if(secondary_hits || mp == curr->getPhysics()) if(secondary_hits || mp == curr->getPhysicalObject())
curr->handleExplosion(pos, mp == curr->getPhysics()); curr->handleExplosion(pos, mp == curr->getPhysicalObject());
} }
} // handleExplosion } // handleExplosion