From 5fccd67bada2be7a3fbb2df3abf08bfde58b600b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Sep 2013 19:08:51 +0200 Subject: Added line collision calculation to cBoundingBox. --- source/BoundingBox.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/BoundingBox.h') diff --git a/source/BoundingBox.h b/source/BoundingBox.h index 5a07df20e..7b6391942 100644 --- a/source/BoundingBox.h +++ b/source/BoundingBox.h @@ -51,6 +51,22 @@ public: /// Returns true if a boundingbox specified by a_Min and a_Max is inside this bounding box bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max); + /// Returns true if the specified point is inside the bounding box specified by its min/max corners + static bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Point); + + /// Returns true if the specified point is inside the bounding box specified by its min/max corners + static bool IsInside(const Vector3d & a_Min, const Vector3d & a_Max, double a_X, double a_Y, double a_Z); + + /** Returns true if this bounding box is intersected by the line specified by its two points + Also calculates the distance along the line in which the intersection occurs (0 .. 1) + */ + bool CalcLineIntersection(const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face); + + /** Returns true if the specified bounding box is intersected by the line specified by its two points + Also calculates the distance along the line in which the intersection occurs (0 .. 1) and the face hit (BLOCK_FACE_ constants) + */ + static bool CalcLineIntersection(const Vector3d & a_Min, const Vector3d & a_Max, const Vector3d & a_Line1, const Vector3d & a_Line2, double & a_LineCoeff, char & a_Face); + // tolua_end /// Calculates the intersection of the two bounding boxes; returns true if nonempty -- cgit v1.2.3