88 template<
typename T> T
as()
const;
101 pmin(-0.5f, -0.5f, -0.5f),
102 pmax(+0.5f, +0.5f, +0.5f)
157 return (this->
pmax - this->
pmin) * 0.5f;
185 this->
pmin.
set(+1000000.0f, +1000000.0f, +1000000.0f);
186 this->
pmax.
set(-1000000.0f, -1000000.0f, -1000000.0f);
198 if ((this->
pmin ==
point(+1000000.0f, +1000000.0f, +1000000.0f)) &&
199 (this->
pmax ==
point(-1000000.0f, -1000000.0f, -1000000.0f)))
201 this->
pmin.
set(0.0f, 0.0f, 0.0f);
202 this->
pmax.
set(0.0f, 0.0f, 0.0f);
244 point minP(1000000, 1000000,1000000);
245 point maxP(-1000000, -1000000, -1000000);
248 for(i = 0; i < 8; ++i)
268 n_warn2(m.
r[0].
w == 0 && m.
r[1].
w == 0 && m.
r[2].
w == 0 && m.
r[3].
w == 1,
"Matrix is not affine");
307 for (
int i = 0; i < 3; i++)
309 if (fabs(ray.
m[i]) < 0.00001f)
312 if (ray.
b[i] < this->pmin[i] || ray.
b[i] > this->pmax[i])
320 float ood = 1.0f / ray.
m[i];
321 float t1 = (this->
pmin[i] - ray.
b[i]) * ood;
322 float t2 = (this->
pmax[i] - ray.
b[i]) * ood;
400 m_col_x[0] =
splat_x(viewProjection.
r[0]);
401 m_col_x[1] =
splat_x(viewProjection.
r[1]);
402 m_col_x[2] =
splat_x(viewProjection.
r[2]);
403 m_col_x[3] =
splat_x(viewProjection.
r[3]);
405 m_col_y[0] =
splat_y(viewProjection.
r[0]);
406 m_col_y[1] =
splat_y(viewProjection.
r[1]);
407 m_col_y[2] =
splat_y(viewProjection.
r[2]);
408 m_col_y[3] =
splat_y(viewProjection.
r[3]);
410 m_col_z[0] =
splat_z(viewProjection.
r[0]);
411 m_col_z[1] =
splat_z(viewProjection.
r[1]);
412 m_col_z[2] =
splat_z(viewProjection.
r[2]);
413 m_col_z[3] =
splat_z(viewProjection.
r[3]);
415 m_col_w[0] =
splat_w(viewProjection.
r[0]);
416 m_col_w[1] =
splat_w(viewProjection.
r[1]);
417 m_col_w[2] =
splat_w(viewProjection.
r[2]);
418 m_col_w[3] =
splat_w(viewProjection.
r[3]);
420 return this->
clipstatus(m_col_x, m_col_y, m_col_z, m_col_w, isOrtho);
429 using namespace Math;
430 int andFlags = 0xffff;
469 px[0] = xs[1] *
vec4(1, 1, 0, 0) + xs[0] *
vec4(0, 0, 1, 1);
470 px[1] = xs[1] *
vec4(0, 0, 1, 1) + xs[0] *
vec4(1, 1, 0, 0);
475 pz[0] = zs[1] *
vec4(1, 0, 0, 1) + zs[0] *
vec4(0, 1, 1, 0);
476 pz[1] = zs[1] *
vec4(0, 1, 1, 0) + zs[0] *
vec4(1, 0, 0, 1);
488 for (i = 0; i < 2; ++i)
520 const vec4 nws = -ws[i];
521 const vec4 pws = ws[i];
530 (
greater(zs[i], pws) * zNearFlags)
539 alignas(16)
uint res1_u[4];
540 __m128i result = _mm_cvttps_epi32(res1.
vec);
541 _mm_storeu_si128(
reinterpret_cast<__m128i*
>(res1_u), result);
544 andFlags &= res1_u[0];
545 orFlags |= res1_u[0];
546 andFlags &= res1_u[1];
547 orFlags |= res1_u[1];
548 andFlags &= res1_u[2];
549 orFlags |= res1_u[2];
550 andFlags &= res1_u[3];
551 orFlags |= res1_u[3];
566 return extent.
x * extent.
y + extent.
y * extent.
z + extent.
z * extent.
x;
Type
Definition clipstatus.h:22
@ Outside
Definition clipstatus.h:24
@ Inside
Definition clipstatus.h:23
@ Clipped
Definition clipstatus.h:25
Nebula's bounding box class.
Definition bbox.h:24
void end_extend()
this resets the bounding box size to zero if no extend() method was called after begin_extend()
Definition bbox.h:196
vec3 size() const
get size of box
Definition bbox.h:164
vector extents() const
get extents of box
Definition bbox.h:155
point corner_point(int index) const
return one of the 8 corner points
Definition bbox.cc:38
point pmax
Definition bbox.h:93
mat4 to_mat4() const
create a matrix which transforms a unit cube to this bounding box
Definition bbox.h:371
ClipStatus::Type clipstatus(const bbox &other) const
check for intersection with other bounding box
Definition bbox.cc:17
T as() const
convert to any type
void begin_extend()
begin extending the box
Definition bbox.h:183
void extend(const vec3 &p)
extend the box
Definition bbox.h:210
point center() const
get center of box
Definition bbox.h:146
bbox()
constructor 1
Definition bbox.h:100
void transform(const mat4 &m)
transform bounding box
Definition bbox.h:241
scalar diagonal_size() const
get diagonal size of box
Definition bbox.h:383
void affine_transform(const mat4 &m)
affine transform bounding box, does not allow for projections
Definition bbox.h:266
void set(const mat4 &m)
set from mat4
Definition bbox.h:124
@ ClipTop
Definition bbox.h:32
@ ClipNear
Definition bbox.h:33
@ ClipRight
Definition bbox.h:30
@ ClipLeft
Definition bbox.h:29
@ ClipBottom
Definition bbox.h:31
@ ClipFar
Definition bbox.h:34
point pmin
Definition bbox.h:92
float area() const
calculate half-area of the surface of the box. If you need the full area, just multiply by 2.
Definition bbox.h:563
void get_clipplanes(const mat4 &viewProjection, Util::Array< vec4 > &outPlanes) const
return side planes in clip space
Definition bbox.cc:59
bool contains(const bbox &box) const
check if this box completely contains the parameter box
Definition bbox.h:346
bool intersects(const bbox &box) const
check for intersection with axis aligned bounding box
Definition bbox.h:289
A line in 3d space.
Definition line.h:22
point b
Definition line.h:55
vector m
Definition line.h:56
Nebula's dynamic array class.
Definition array.h:60
#define n_warn2(exp, msg)
Definition debug.h:55
Different curves.
Definition angularpfeedbackloop.h:17
__forceinline point less(const point &v0, const point &v1)
Definition point.h:501
__forceinline point maximize(const point &v0, const point &v1)
Definition point.h:368
__forceinline vec3 splat_z(const vec3 &v)
Definition vec3.h:823
__forceinline vec4 perspective_div(const vec4 &v)
Definition vec4.h:711
__forceinline vec3 splat_x(const vec3 &v)
Definition vec3.h:801
__forceinline scalar length(const quat &q)
Definition quat.h:259
__forceinline bool greaterequal_all(const point &v0, const point &v1)
Definition point.h:463
__forceinline bool greater_any(const point &v0, const point &v1)
Definition point.h:430
__forceinline mat4 scaling(scalar scale)
Definition mat4.h:1074
__forceinline bool less_any(const point &v0, const point &v1)
Definition point.h:386
__forceinline bool less_all(const point &v0, const point &v1)
Definition point.h:397
__forceinline vec3 splat_y(const vec3 &v)
Definition vec3.h:812
__forceinline point minimize(const point &v0, const point &v1)
Definition point.h:377
float scalar
Definition scalar.h:45
__forceinline point greater(const point &v0, const point &v1)
Definition point.h:510
__forceinline scalar abs(scalar a)
Definition scalar.h:432
__forceinline vec3 multiplyadd(const vec3 &v0, const vec3 &v1, const vec3 &v2)
Definition vec3.h:384
__forceinline vec3 xyz(const point &v)
Definition point.h:528
__forceinline vec4 splat_w(const vec4 &v)
Definition vec4.h:1047
Definition conversion.h:35
A 4x4 single point precision float matrix.
Definition mat4.h:49
vec4 y_axis
Definition mat4.h:116
vec4 position
Definition mat4.h:118
vec4 z_axis
Definition mat4.h:117
vec4 r[4]
as a two-dimensional array
Definition mat4.h:132
vec4 x_axis
Definition mat4.h:115
Represents a 3D point in space.
Definition point.h:22
void set(scalar x, scalar y, scalar z)
set content
Definition point.h:332
float z
Definition point.h:78
float x
Definition point.h:78
float y
Definition point.h:78
A 3D vector.
Definition vec3.h:40
float x
Definition vec3.h:94
float z
Definition vec3.h:94
float y
Definition vec3.h:94
A 4D vector.
Definition vec4.h:24
__m128 vec
Definition vec4.h:95
float w
Definition vec4.h:93
A vector is a 3D direction in space.
Definition vector.h:22
#define N_BIT(x)
Definition types.h:59
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48