mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Set angle now working for npcs and creatures
This commit is contained in:
parent
1f5bc229e0
commit
7b8b4c366d
4 changed files with 26 additions and 7 deletions
|
@ -379,8 +379,7 @@ namespace MWClass
|
||||||
|
|
||||||
void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
||||||
{
|
{
|
||||||
y = 0;
|
|
||||||
x = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr
|
MWWorld::Ptr
|
||||||
|
|
|
@ -286,11 +286,16 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||||
// start positions others than 0, 0, 0
|
// start positions others than 0, 0, 0
|
||||||
btTransform tr = body->getWorldTransform();
|
|
||||||
Ogre::Vector3 position = node->getPosition();
|
Ogre::Vector3 position = node->getPosition();
|
||||||
|
|
||||||
|
if(dynamic_cast<btBoxShape*>(body->getCollisionShape()) == NULL){
|
||||||
|
btTransform tr = body->getWorldTransform();
|
||||||
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
||||||
body->setWorldTransform(tr);
|
body->setWorldTransform(tr);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, position, node->getOrientation());
|
||||||
|
}
|
||||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||||
{
|
{
|
||||||
/*// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
/*// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||||
|
@ -315,7 +320,10 @@ namespace MWWorld
|
||||||
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
||||||
{
|
{
|
||||||
Ogre::Quaternion rotation = node->getOrientation();
|
Ogre::Quaternion rotation = node->getOrientation();
|
||||||
|
if(dynamic_cast<btBoxShape*>(body->getCollisionShape()) == NULL)
|
||||||
body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
|
body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
|
||||||
|
else
|
||||||
|
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -345,6 +345,18 @@ namespace Physic
|
||||||
tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w));
|
tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w));
|
||||||
body->setWorldTransform(tr);
|
body->setWorldTransform(tr);
|
||||||
}
|
}
|
||||||
|
void PhysicEngine::boxAdjustExternal(std::string mesh, RigidBody* body, float scale, Ogre::Vector3 position, Ogre::Quaternion rotation){
|
||||||
|
std::string sid = (boost::format("%07.3f") % scale).str();
|
||||||
|
std::string outputstring = mesh + sid;
|
||||||
|
//std::cout << "The string" << outputstring << "\n";
|
||||||
|
|
||||||
|
//get the shape from the .nif
|
||||||
|
mShapeLoader->load(outputstring,"General");
|
||||||
|
BulletShapeManager::getSingletonPtr()->load(outputstring,"General");
|
||||||
|
BulletShapePtr shape = BulletShapeManager::getSingleton().getByName(outputstring,"General");
|
||||||
|
|
||||||
|
adjustRigidBody(shape, body, scale, position, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
RigidBody* PhysicEngine::createAndAdjustRigidBody(std::string mesh,std::string name,float scale, Ogre::Vector3 position, Ogre::Quaternion rotation)
|
RigidBody* PhysicEngine::createAndAdjustRigidBody(std::string mesh,std::string name,float scale, Ogre::Vector3 position, Ogre::Quaternion rotation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace Physic
|
||||||
RigidBody* createAndAdjustRigidBody(std::string mesh,std::string name,float scale, Ogre::Vector3 position, Ogre::Quaternion rotation);
|
RigidBody* createAndAdjustRigidBody(std::string mesh,std::string name,float scale, Ogre::Vector3 position, Ogre::Quaternion rotation);
|
||||||
|
|
||||||
void adjustRigidBody(BulletShapePtr shape, RigidBody* body, float scale, Ogre::Vector3 position, Ogre::Quaternion rotation);
|
void adjustRigidBody(BulletShapePtr shape, RigidBody* body, float scale, Ogre::Vector3 position, Ogre::Quaternion rotation);
|
||||||
|
void boxAdjustExternal(std::string mesh, RigidBody* body, float scale, Ogre::Vector3 position, Ogre::Quaternion rotation);
|
||||||
/**
|
/**
|
||||||
* Add a HeightField to the simulation
|
* Add a HeightField to the simulation
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue