In preparing a small sample that demonstrates the issue, I managed to identify that the problem was related to the motionState. When creating the sample, I temporarily used a btDefaultMotionState instead, and when I ran the program using it the collider was identical to in release. I can't understand why the motionstate would have that effect, as all it does is sync the physics for the object with Ogre, but there we go. Following this, I created a new motion state class using the example OgreMotionState from the Bullet wiki, which, as far as I can tell does everything exactly the same way I was doing things, but yet this new motion state class works in release but the original messes up the collider.
Working MotionState header:
Code: Select all
#ifndef NEW_MOTION_STATE_H
#define NEW_MOTION_STATE_H
#include <btBulletCollisionCommon.h>
#include <Ogre.h>
class NewMotionState : public btMotionState
{
public:
NewMotionState(const btTransform& _initialPosition, Ogre::SceneNode* _node);
virtual ~NewMotionState();
virtual void getWorldTransform(btTransform& _initialPosition) const;
virtual void setWorldTransform(const btTransform& _worldTrans);
protected:
Ogre::SceneNode* m_sceneNode;
btTransform m_initialPosition;
};
#endif
Working MotionState cpp
Code: Select all
#include "NewMotionState.h"
NewMotionState::NewMotionState(const btTransform& _initialPosition, Ogre::SceneNode* _sceneNode)
{
m_sceneNode = _sceneNode;
m_initialPosition = _initialPosition;
}
void NewMotionState::getWorldTransform(btTransform& _worldTrans) const
{
_worldTrans = m_initialPosition;
}
void NewMotionState::setWorldTransform(const btTransform& _worldTrans)
{
btQuaternion rot = _worldTrans.getRotation();
m_sceneNode->setOrientation(Ogre::Quaternion(rot.w(), rot.x(), rot.y(), rot.z()));
btVector3 pos = _worldTrans.getOrigin();
m_sceneNode->setPosition(Ogre::Vector3(pos.x(), pos.y(), pos.z()));
}
NewMotionState::~NewMotionState()
{
}
Broken MotionState header:
Code: Select all
#ifndef TEST_MOTION_STATE_H
#define TEST_MOTION_STATE_H
#include <btBulletDynamicsCommon.h>
#include <Ogre.h>
class TestMotionState : public btMotionState
{
public:
TestMotionState(btTransform _transform, Ogre::SceneNode* _sn);
virtual ~TestMotionState() {};
virtual void setWorldTransform(const btTransform &_transform);
virtual void getWorldTransform(btTransform& _transform) const;
protected:
btTransform m_initialPosition;
Ogre::SceneNode* m_sn;
};
#endif
Broken MotionState cpp:
Code: Select all
#include "TestMotionState.h"
TestMotionState::TestMotionState(btTransform _transform, Ogre::SceneNode* _sn)
m_initialPosition = _transform;
m_sn = _sn;
}
void TestMotionState::getWorldTransform(btTransform& _transform) const
{
_transform = m_initialPosition;
}
void TestMotionState::setWorldTransform(const btTransform& _transform)
{
btQuaternion rot = _transform.getRotation();
m_sn->setOrientation(Ogre::Quaternion(rot.w(), rot.x(), rot.y(), rot.z()));
btVector3 pos = _transform.getOrigin();
m_sn->setPosition(Ogre::Vector3(pos.x(), pos.y(), pos.z()));
}
As the new MotionState class is working, I think I'll just continue using that one, but if you can see anything that would have caused this strange behaviour, that would be very welcome too.
Thanks.