2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _BASE_AABB_HPP_
|
|
|
|
#define _BASE_AABB_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Base/Vector3.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
*
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
|
|
|
struct AABB
|
|
|
|
{
|
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
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
static const AABB NIL;
|
2016-02-20 23:25:00 +01:00
|
|
|
static const AABB MIN;
|
|
|
|
static const AABB MAX;
|
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
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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-02-20 23:25:00 +01:00
|
|
|
*
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB();
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
AABB(Value sv);
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
AABB(Value xv, Value yv, Value zv);
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB(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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB(const Vector3 & vmin, const Vector3 & vmax);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
*
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
AABB(const AABB & o);
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
*
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
~AABB();
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
*
|
2015-11-01 09:55:47 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
AABB & operator = (const AABB & o);
|
|
|
|
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB & operator = (const Vector4 & v);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator ++ (int);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB operator -- (int);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
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-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const AABB & b) const;
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(Value ns);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(Value nx, Value ny, Value nz);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(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
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const AABB & b);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const Vector3 & v);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const Vector3 & nmin, const Vector3 & nmax);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const Vector4 & v);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void Set(const Vector4 & nmin, const Vector4 & nmax);
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void Set(CSStr values, SQChar delim);
|
|
|
|
|
2015-11-01 09:55:47 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
min.Clear();
|
|
|
|
max.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
AABB Abs() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _BASE_AABB_HPP_
|