forked from teamnwah/openmw-tes3coop
Rename getFacedObject and getFacedHandle for melee hits
This commit is contained in:
parent
2823e5693d
commit
f5d03a16c1
6 changed files with 23 additions and 15 deletions
|
@ -220,9 +220,10 @@ namespace MWBase
|
||||||
virtual MWWorld::Ptr getFacedObject() = 0;
|
virtual MWWorld::Ptr getFacedObject() = 0;
|
||||||
///< Return pointer to the object the player is looking at, if it is within activation range
|
///< Return pointer to the object the player is looking at, if it is within activation range
|
||||||
|
|
||||||
/// Returns a pointer to the object the provided object is facing (if within the
|
/// Returns a pointer to the object the provided object would hit (if within the
|
||||||
/// specified distance). This will attempt to use the "Bip01 Head" node as a basis.
|
/// specified distance), and the point where the hit occurs. This will attempt to
|
||||||
virtual MWWorld::Ptr getFacedObject(const MWWorld::Ptr &ptr, float distance) = 0;
|
/// use the "Head" node as a basis.
|
||||||
|
virtual std::pair<MWWorld::Ptr,Ogre::Vector3> getHitContact(const MWWorld::Ptr &ptr, float distance) = 0;
|
||||||
|
|
||||||
virtual void adjustPosition (const MWWorld::Ptr& ptr) = 0;
|
virtual void adjustPosition (const MWWorld::Ptr& ptr) = 0;
|
||||||
///< Adjust position after load to be on ground. Must be called after model load.
|
///< Adjust position after load to be on ground. Must be called after model load.
|
||||||
|
|
|
@ -332,7 +332,8 @@ namespace MWClass
|
||||||
float dist = 100.0f * (!weapon.isEmpty() ?
|
float dist = 100.0f * (!weapon.isEmpty() ?
|
||||||
weapon.get<ESM::Weapon>()->mBase->mData.mReach :
|
weapon.get<ESM::Weapon>()->mBase->mData.mReach :
|
||||||
gmst.find("fHandToHandReach")->getFloat());
|
gmst.find("fHandToHandReach")->getFloat());
|
||||||
MWWorld::Ptr victim = world->getFacedObject(ptr, dist);
|
// TODO: Use second to work out the hit angle and where to spawn the blood effect
|
||||||
|
MWWorld::Ptr victim = world->getHitContact(ptr, dist).first;
|
||||||
if(victim.isEmpty()) // Didn't hit anything
|
if(victim.isEmpty()) // Didn't hit anything
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,10 @@ namespace MWWorld
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string,float> PhysicsSystem::getFacedHandle(const Ogre::Vector3 &origin_, const Ogre::Quaternion &orient_, float queryDistance)
|
std::pair<std::string,Ogre::Vector3> PhysicsSystem::getHitContact(const std::string &name,
|
||||||
|
const Ogre::Vector3 &origin_,
|
||||||
|
const Ogre::Quaternion &orient_,
|
||||||
|
float queryDistance)
|
||||||
{
|
{
|
||||||
btVector3 origin(origin_.x, origin_.y, origin_.z);
|
btVector3 origin(origin_.x, origin_.y, origin_.z);
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,10 @@ namespace MWWorld
|
||||||
Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr);
|
Ogre::Vector3 traceDown(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
std::pair<float, std::string> getFacedHandle (MWWorld::World& world, float queryDistance);
|
std::pair<float, std::string> getFacedHandle (MWWorld::World& world, float queryDistance);
|
||||||
std::pair<std::string,float> getFacedHandle(const Ogre::Vector3 &origin,
|
std::pair<std::string,Ogre::Vector3> getHitContact(const std::string &name,
|
||||||
const Ogre::Quaternion &orientation,
|
const Ogre::Vector3 &origin,
|
||||||
float queryDistance);
|
const Ogre::Quaternion &orientation,
|
||||||
|
float queryDistance);
|
||||||
std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance);
|
std::vector < std::pair <float, std::string> > getFacedHandles (float queryDistance);
|
||||||
std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance);
|
std::vector < std::pair <float, std::string> > getFacedHandles (float mouseX, float mouseY, float queryDistance);
|
||||||
|
|
||||||
|
|
|
@ -784,7 +784,7 @@ namespace MWWorld
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr World::getFacedObject(const MWWorld::Ptr &ptr, float distance)
|
std::pair<MWWorld::Ptr,Ogre::Vector3> World::getHitContact(const MWWorld::Ptr &ptr, float distance)
|
||||||
{
|
{
|
||||||
const ESM::Position &posdata = ptr.getRefData().getPosition();
|
const ESM::Position &posdata = ptr.getRefData().getPosition();
|
||||||
Ogre::Vector3 pos(posdata.pos);
|
Ogre::Vector3 pos(posdata.pos);
|
||||||
|
@ -799,11 +799,12 @@ namespace MWWorld
|
||||||
pos += node->_getDerivedPosition();
|
pos += node->_getDerivedPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string,float> result = mPhysics->getFacedHandle(pos, rot, distance);
|
std::pair<std::string,Ogre::Vector3> result = mPhysics->getHitContact(ptr.getRefData().getHandle(),
|
||||||
|
pos, rot, distance);
|
||||||
if(result.first.empty())
|
if(result.first.empty())
|
||||||
return MWWorld::Ptr();
|
return std::make_pair(MWWorld::Ptr(), Ogre::Vector3(0.0f));
|
||||||
|
|
||||||
return searchPtrViaHandle(result.first);
|
return std::make_pair(searchPtrViaHandle(result.first), result.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::deleteObject (const Ptr& ptr)
|
void World::deleteObject (const Ptr& ptr)
|
||||||
|
|
|
@ -252,9 +252,10 @@ namespace MWWorld
|
||||||
virtual MWWorld::Ptr getFacedObject();
|
virtual MWWorld::Ptr getFacedObject();
|
||||||
///< Return pointer to the object the player is looking at, if it is within activation range
|
///< Return pointer to the object the player is looking at, if it is within activation range
|
||||||
|
|
||||||
/// Returns a pointer to the object the provided object is facing (if within the
|
/// Returns a pointer to the object the provided object would hit (if within the
|
||||||
/// specified distance). This will attempt to use the "Bip01 Head" node as a basis.
|
/// specified distance), and the point where the hit occurs. This will attempt to
|
||||||
virtual MWWorld::Ptr getFacedObject(const MWWorld::Ptr &ptr, float distance);
|
/// use the "Head" node as a basis.
|
||||||
|
virtual std::pair<MWWorld::Ptr,Ogre::Vector3> getHitContact(const MWWorld::Ptr &ptr, float distance);
|
||||||
|
|
||||||
virtual void deleteObject (const Ptr& ptr);
|
virtual void deleteObject (const Ptr& ptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue