2020-08-03 20:44:16 +00:00
|
|
|
#ifndef OPENMW_MWPHYSICS_RAYCASTING_H
|
|
|
|
#define OPENMW_MWPHYSICS_RAYCASTING_H
|
|
|
|
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
|
|
|
#include "collisiontype.hpp"
|
|
|
|
|
|
|
|
namespace MWPhysics
|
|
|
|
{
|
2022-03-17 23:27:16 +00:00
|
|
|
class RayCastingResult
|
2020-08-03 20:44:16 +00:00
|
|
|
{
|
2022-03-17 23:27:16 +00:00
|
|
|
public:
|
|
|
|
bool mHit;
|
|
|
|
osg::Vec3f mHitPos;
|
|
|
|
osg::Vec3f mHitNormal;
|
|
|
|
MWWorld::Ptr mHitObject;
|
2020-08-03 20:44:16 +00:00
|
|
|
};
|
2020-12-27 22:16:11 +00:00
|
|
|
|
2020-08-03 20:44:16 +00:00
|
|
|
class RayCastingInterface
|
|
|
|
{
|
|
|
|
public:
|
2023-02-03 20:29:26 +00:00
|
|
|
virtual ~RayCastingInterface() = default;
|
|
|
|
|
2020-08-03 20:44:16 +00:00
|
|
|
/// @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(),
|
2021-06-23 21:13:59 +00:00
|
|
|
const std::vector<MWWorld::Ptr>& targets = std::vector<MWWorld::Ptr>(), int mask = CollisionType_Default,
|
2021-09-27 19:34:26 +00:00
|
|
|
int group = 0xff) const = 0;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2022-11-06 19:49:59 +00:00
|
|
|
RayCastingResult castRay(const osg::Vec3f& from, const osg::Vec3f& to, int mask) const
|
|
|
|
{
|
|
|
|
return castRay(from, to, MWWorld::ConstPtr(), std::vector<MWWorld::Ptr>(), mask);
|
|
|
|
}
|
|
|
|
|
2021-09-27 19:34:26 +00:00
|
|
|
virtual RayCastingResult castSphere(const osg::Vec3f& from, const osg::Vec3f& to, float radius,
|
|
|
|
int mask = CollisionType_Default, int group = 0xff) const = 0;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2020-08-03 20:44:16 +00:00
|
|
|
/// Return true if actor1 can see actor2.
|
|
|
|
virtual bool getLineOfSight(const MWWorld::ConstPtr& actor1, const MWWorld::ConstPtr& actor2) const = 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|