forked from mirror/openmw-tes3mp
physics getObjectHeight(), MWWorld::Class::getModel() definition
This commit is contained in:
parent
71253c64ab
commit
87050e48c8
6 changed files with 42 additions and 0 deletions
|
@ -212,4 +212,9 @@ namespace MWWorld
|
||||||
void Class::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
void Class::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Class::getModel() const
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,6 +204,8 @@ namespace MWWorld
|
||||||
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;
|
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;
|
||||||
|
|
||||||
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
||||||
|
|
||||||
|
virtual std::string getModel() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "../mwbase/world.hpp" // FIXME
|
#include "../mwbase/world.hpp" // FIXME
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
@ -365,4 +366,13 @@ namespace MWWorld
|
||||||
addActor (node->getName(), model, node->getPosition());
|
addActor (node->getName(), model, node->getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float PhysicsSystem::getObjectHeight(const MWWorld::Ptr &ptr) {
|
||||||
|
std::string model = MWWorld::Class::get(ptr).getModel();
|
||||||
|
if (model.empty()) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
float scale = ptr.getRefData().getBaseNode()->getScale().x;
|
||||||
|
return mEngine->getObjectHeight(model, scale);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,8 @@ namespace MWWorld
|
||||||
|
|
||||||
void setCurrentWater(bool hasWater, int waterHeight);
|
void setCurrentWater(bool hasWater, int waterHeight);
|
||||||
|
|
||||||
|
float getObjectHeight(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OEngine::Render::OgreRenderer &mRender;
|
OEngine::Render::OgreRenderer &mRender;
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
|
|
|
@ -568,4 +568,25 @@ namespace Physic
|
||||||
|
|
||||||
return results2;
|
return results2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float PhysicEngine::getObjectHeight(const std::string &mesh, float scale) {
|
||||||
|
char uniqueID[8];
|
||||||
|
sprintf( uniqueID, "%07.3f", scale );
|
||||||
|
std::string sid = uniqueID;
|
||||||
|
std::string outputstring = mesh + uniqueID + "\"|";
|
||||||
|
|
||||||
|
mShapeLoader->load(outputstring, "General");
|
||||||
|
BulletShapeManager::getSingletonPtr()->load(outputstring, "General");
|
||||||
|
BulletShapePtr shape =
|
||||||
|
BulletShapeManager::getSingleton().getByName(outputstring, "General");
|
||||||
|
|
||||||
|
|
||||||
|
btTransform trans;
|
||||||
|
btVector3 min, max;
|
||||||
|
|
||||||
|
trans.setIdentity();
|
||||||
|
shape->Shape->getAabb(trans, min, max);
|
||||||
|
|
||||||
|
return max.z() - min.z();
|
||||||
|
}
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -221,6 +221,8 @@ namespace Physic
|
||||||
|
|
||||||
bool toggleDebugRendering();
|
bool toggleDebugRendering();
|
||||||
|
|
||||||
|
float getObjectHeight(const std::string &mesh, float scale);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the closest object hit by a ray. If there are no objects, it will return ("",-1).
|
* Return the closest object hit by a ray. If there are no objects, it will return ("",-1).
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue