1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/apps/openmw/mwphysics/raycasting.hpp
Petr Mikheev e760a6c7e6 Merge branch 'forlua' into 'master'
Simple Physics API modification for Lua

See merge request OpenMW/openmw!1216

(cherry picked from commit d88494c90b501d0832ae0330a0ca81d8b8e5aa50)

02dd055a Save hitObject in castSphere() just like in castRay()
0793d0bf Allow to override collision mask and group for castSphere() as for castRay()
2021-09-27 19:50:57 +00:00

43 lines
1.7 KiB
C++

#ifndef OPENMW_MWPHYSICS_RAYCASTING_H
#define OPENMW_MWPHYSICS_RAYCASTING_H
#include <osg/Vec3f>
#include "../mwworld/ptr.hpp"
#include "collisiontype.hpp"
namespace MWPhysics
{
struct RayCastingResult
{
bool mHit;
osg::Vec3f mHitPos;
osg::Vec3f mHitNormal;
MWWorld::Ptr mHitObject;
};
class RayCastingInterface
{
public:
/// Get distance from \a point to the collision shape of \a target. Uses a raycast to find where the
/// target vector hits the collision shape and then calculates distance from the intersection point.
/// This can be used to find out how much nearer we need to move to the target for a "getHitContact" to be successful.
/// \note Only Actor targets are supported at the moment.
virtual float getHitDistance(const osg::Vec3f& point, const MWWorld::ConstPtr& target) const = 0;
/// @param me Optional, a Ptr to ignore in the list of results. targets are actors to filter for, ignoring all other actors.
virtual RayCastingResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(),
const std::vector<MWWorld::Ptr>& targets = std::vector<MWWorld::Ptr>(),
int mask = CollisionType_Default, int group=0xff) const = 0;
virtual RayCastingResult castSphere(const osg::Vec3f& from, const osg::Vec3f& to, float radius,
int mask = CollisionType_Default, int group=0xff) const = 0;
/// Return true if actor1 can see actor2.
virtual bool getLineOfSight(const MWWorld::ConstPtr& actor1, const MWWorld::ConstPtr& actor2) const = 0;
};
}
#endif