Merge branch 'MovablesAlwaysAtSceneRoot'

This commit is contained in:
Marianne Gagnon 2015-03-06 21:27:44 -05:00
commit bc0d7a5ef7
2 changed files with 21 additions and 5 deletions

View File

@ -246,6 +246,10 @@ void PhysicalObject::init()
{
Log::fatal("PhysicalObject", "Unknown node type");
}
max = max * Vec3(m_init_scale);
min = min * Vec3(m_init_scale);
Vec3 extend = max-min;
// Adjust the mesth of the graphical object so that its center is where it
// is in bullet (usually at (0,0,0)). It can be changed in the case clause
@ -503,10 +507,8 @@ void PhysicalObject::update(float dt)
hpr.setHPR(t.getRotation());
//m_node->setRotation(hpr.toIrrHPR());
core::vector3df scale(1,1,1);
m_object->move(xyz.toIrrVector(), hpr.toIrrVector()*RAD_TO_DEGREE,
scale, false);
return;
m_init_scale, false);
} // update
// ----------------------------------------------------------------------------

View File

@ -27,7 +27,7 @@
#include "physics/physical_object.hpp"
#include "race/race_manager.hpp"
#include "utils/helpers.hpp"
#include <ISceneManager.h>
/** A track object: any additional object on the track. This object implements
* a graphics-only representation, i.e. there is no physical representation.
@ -191,7 +191,21 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
m_presentation = new TrackObjectPresentationMesh(xml_node,
m_enabled,
parent);
glownode = ((TrackObjectPresentationMesh *) m_presentation)->getNode();
scene::ISceneNode* node = ((TrackObjectPresentationMesh *)m_presentation)->getNode();
if (type == "movable" && parent != NULL)
{
// HACK: unparent movables from their parent library object if any,
// because bullet provides absolute transforms, not transforms relative
// to the parent object
node->updateAbsolutePosition();
core::matrix4 absTransform = node->getAbsoluteTransformation();
node->setParent(irr_driver->getSceneManager()->getRootSceneNode());
node->setPosition(absTransform.getTranslation());
node->setRotation(absTransform.getRotationDegrees());
node->setScale(absTransform.getScale());
}
glownode = node;
}
std::string render_pass;