2020-03-22 00:45:04 +01:00
|
|
|
#pragma once
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Base/Vector3.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Class used to represent an axis aligned bounding box in three-dimensional space.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
|
|
|
struct AABB
|
|
|
|
{
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The type of value used by components of type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
typedef float Value;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Helper instances for common values mostly used as return types or comparison.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static const AABB NIL;
|
2016-03-10 04:57:13 +01:00
|
|
|
static const AABB MIN;
|
|
|
|
static const AABB MAX;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The delimiter character to be used when extracting values from strings.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static SQChar Delim;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* The minimum and maximum components of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
Vector3 min, max;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Construct with zero size.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB() noexcept;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Construct a an equally sized and perfectly shaped box from scalar values.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
explicit AABB(Value mins, Value maxs) noexcept;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a an equally sized but imperfectly shaped box from individual components of a
|
|
|
|
* three-dimensional point.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB(Value xv, Value yv, Value zv) noexcept;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a an unequally sized and imperfectly shaped box from individual components of two
|
|
|
|
* three-dimensional points.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) noexcept;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Construct a an unequally sized and imperfectly shaped box from two three-dimensional
|
|
|
|
* vectors representing two three-dimensional points.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB(const Vector3 & vmin, const Vector3 & vmax) noexcept;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB(const AABB & o) noexcept = default;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Move constructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB(AABB && o) noexcept = default;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Destructor.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
~AABB() = default;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
|
|
|
AABB & operator = (const AABB & o) = default;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
|
|
|
AABB & operator = (AABB && o) = default;
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Three-dimensional vector assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator = (const Vector3 & v);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator += (const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator -= (const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator *= (const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator /= (const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator %= (const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value addition assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator += (Value s);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value subtraction assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator -= (Value s);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value multiplication assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator *= (Value s);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value division assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator /= (Value s);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value modulo assignment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator %= (Value s);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator ++ ();
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Pre-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator -- ();
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-increment operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB operator ++ (int); // NOLINT(cert-dcl21-cpp)
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Post-decrement operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2020-03-22 08:16:40 +01:00
|
|
|
AABB operator -- (int); // NOLINT(cert-dcl21-cpp)
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator + (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator - (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator * (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator / (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator % (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value addition operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator + (Value s) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value subtraction operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator - (Value s) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value multiplication operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator * (Value s) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value division operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator / (Value s) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Scalar value modulo operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator % (Value s) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary plus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator + () const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Unary minus operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator - () const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Equality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator == (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Inequality comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator != (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator < (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator > (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Less than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator <= (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Greater than or equal comparison operator.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator >= (const AABB & b) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const AABB & b) const;
|
|
|
|
|
2016-08-24 22:16:53 +02:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2016-08-25 00:01:03 +02:00
|
|
|
Int32 Cmp(SQFloat s) const
|
2016-08-24 22:16:53 +02:00
|
|
|
{
|
|
|
|
return Cmp(AABB(s, s, s, s, s, s));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
2016-08-25 00:01:03 +02:00
|
|
|
Int32 Cmp(SQInteger s) const
|
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
const auto v = static_cast< Value >(s);
|
2016-08-25 00:01:03 +02:00
|
|
|
return Cmp(AABB(v, v, v, v, v, v));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
|
|
|
Int32 Cmp(bool s) const
|
2016-08-24 22:16:53 +02:00
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
const auto v = static_cast< Value >(s);
|
2016-08-24 22:16:53 +02:00
|
|
|
return Cmp(AABB(v, v, v, v, v, v));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script engine to compare an instance of this type with a scalar value.
|
|
|
|
*/
|
|
|
|
Int32 Cmp(std::nullptr_t) const
|
|
|
|
{
|
2020-03-22 08:16:40 +01:00
|
|
|
const auto v = static_cast< Value >(0);
|
2016-08-24 22:16:53 +02:00
|
|
|
return Cmp(AABB(v, v, v, v, v, v));
|
|
|
|
}
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Set the values extracted from the specified string using the specified delimiter.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
void SetStr(SQChar delim, StackStrF & values);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Clear the component values to default.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void Clear();
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from minimum and maximum floats (all dimensions same).
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineScalar(Value mins, Value maxs);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from a point.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineVector3(const Vector3 & point);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from a point.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineVector3Ex(Value x, Value y, Value z);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from minimum and maximum vectors.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineAllVector3(const Vector3 & nmin, const Vector3 & nmax);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from minimum and maximum vectors.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineAllVector3Ex(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from another bounding box.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineAABB(const AABB & box);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from a sphere.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineSphere(const Sphere & sphere);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Define from a sphere.
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
void DefineSphereEx(Value x, Value y, Value z, Value r);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge a point into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeVector3(const Vector3 & point);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge a point into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeVector3Ex(Value x, Value y, Value z);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge another bounding box into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeAABB(const AABB & box);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge another bounding box into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeAABBEx(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge a sphere into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeSphere(const Sphere & sphere);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Merge a sphere into this bounding box.
|
|
|
|
*/
|
|
|
|
void MergeSphereEx(Value x, Value y, Value z, Value r);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Check if the box is empty. This means that there is no space between the min and max edge.
|
|
|
|
*/
|
|
|
|
bool Empty() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return true if this bounding box is defined via a previous call to Define() or Merge().
|
|
|
|
*/
|
|
|
|
bool Defined() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return center.
|
|
|
|
*/
|
|
|
|
Vector3 Center() const;
|
2015-11-01 09:55:47 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-11-13 07:32:04 +01:00
|
|
|
* Get size/extent of the box (maximal distance of two points in the box).
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-11-13 07:32:04 +01:00
|
|
|
Vector3 Size() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Return half-size.
|
|
|
|
*/
|
|
|
|
Vector3 HalfSize() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Get radius of the bounding sphere.
|
|
|
|
*/
|
|
|
|
Value Radius() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Get the volume enclosed by the box in cubed units.
|
|
|
|
*/
|
|
|
|
Value Volume() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Get the surface area of the box in squared units.
|
|
|
|
*/
|
|
|
|
Value Area() const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a point is inside.
|
|
|
|
*/
|
|
|
|
Int32 IsVector3Inside(const Vector3 & point) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a point is inside.
|
|
|
|
*/
|
|
|
|
Int32 IsVector3InsideEx(Value x, Value y, Value z) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if another bounding box is inside, outside or intersects.
|
|
|
|
*/
|
|
|
|
Int32 IsAABBInside(const AABB & box) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if another bounding box is inside, outside or intersects.
|
|
|
|
*/
|
|
|
|
Int32 IsAABBInsideEx(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if another bounding box is (partially) inside or outside.
|
|
|
|
*/
|
|
|
|
Int32 IsAABBInsideFast(const AABB & box) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if another bounding box is (partially) inside or outside.
|
|
|
|
*/
|
|
|
|
Int32 IsAABBInsideFastEx(Value xmin, Value ymin, Value zmin, Value xmax, Value ymax, Value zmax) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a sphere is inside, outside or intersects.
|
|
|
|
*/
|
|
|
|
Int32 IsSphereInside(const Sphere & sphere) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a sphere is inside, outside or intersects.
|
|
|
|
*/
|
|
|
|
Int32 IsSphereInsideEx(Value x, Value y, Value z, Value r) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a sphere is (partially) inside or outside.
|
|
|
|
*/
|
|
|
|
Int32 IsSphereInsideFast(const Sphere & sphere) const;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Test if a sphere is (partially) inside or outside.
|
|
|
|
*/
|
|
|
|
Int32 IsSphereInsideFastEx(Value x, Value y, Value z, Value r) const;
|
2016-05-22 05:20:38 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the AABB type from a string.
|
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
static const AABB & Get(StackStrF & str);
|
2016-05-22 05:20:38 +02:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Extract the values for components of the AABB type from a string.
|
|
|
|
*/
|
2019-02-17 16:23:59 +01:00
|
|
|
static const AABB & GetEx(SQChar delim, StackStrF & str);
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|