View-frustum data types and related operations. More...
#include "generic/enumeration.h"
#include "math/matrix.h"
#include "math/plane.h"
#include "math/aabb.h"
#include "math/line.h"
Go to the source code of this file.
Data Structures | |
class | Vector4ClipLT< Index > |
class | Vector4ClipGT< Index > |
class | Vector4ClipPolygon< ClipPlane > |
struct | Frustum |
struct | VolumeIntersection |
Defines | |
#define | INCLUDED_MATH_FRUSTUM_H |
#define | CLIP_X_LT_W(p) (Vector4ClipLT< IntegralConstant<0> >::compare(p)) |
#define | CLIP_X_GT_W(p) (Vector4ClipGT< IntegralConstant<0> >::compare(p)) |
#define | CLIP_Y_LT_W(p) (Vector4ClipLT< IntegralConstant<1> >::compare(p)) |
#define | CLIP_Y_GT_W(p) (Vector4ClipGT< IntegralConstant<1> >::compare(p)) |
#define | CLIP_Z_LT_W(p) (Vector4ClipLT< IntegralConstant<2> >::compare(p)) |
#define | CLIP_Z_GT_W(p) (Vector4ClipGT< IntegralConstant<2> >::compare(p)) |
Typedefs | |
typedef unsigned char | ClipResult |
typedef EnumeratedValue < VolumeIntersection > | VolumeIntersectionValue |
Functions | |
Matrix4 | matrix4_frustum (float left, float right, float bottom, float top, float nearval, float farval) |
ClipResult | homogenous_clip_point (const Vector4 &clipped) |
ClipResult | matrix4_clip_point (const Matrix4 &self, const Vector3 &point, Vector4 &clipped) |
Clips point by canonical matrix self . Stores the result in clipped . Returns a bitmask indicating which clip-planes the point was outside. | |
std::size_t | homogenous_clip_triangle (Vector4 clipped[9]) |
std::size_t | matrix4_clip_triangle (const Matrix4 &self, const Vector3 &p0, const Vector3 &p1, const Vector3 &p2, Vector4 clipped[9]) |
Transforms and clips the triangle formed by p0 , p1 , p2 by the canonical matrix self . Stores the resulting polygon in clipped . Returns the number of points in the resulting polygon. | |
std::size_t | homogenous_clip_line (Vector4 clipped[2]) |
std::size_t | matrix4_clip_line (const Matrix4 &self, const Vector3 &p0, const Vector3 &p1, Vector4 clipped[2]) |
Transforms and clips the line formed by p0 , p1 by the canonical matrix self . Stores the resulting line in clipped . Returns the number of points in the resulting line. | |
Frustum | frustum_transformed (const Frustum &frustum, const Matrix4 &transform) |
Frustum | frustum_inverse_transformed (const Frustum &frustum, const Matrix4 &transform) |
bool | viewproj_test_point (const Matrix4 &viewproj, const Vector3 &point) |
bool | viewproj_test_transformed_point (const Matrix4 &viewproj, const Vector3 &point, const Matrix4 &localToWorld) |
Frustum | frustum_from_viewproj (const Matrix4 &viewproj) |
const VolumeIntersectionValue | c_volumeOutside (VolumeIntersectionValue::OUTSIDE) |
const VolumeIntersectionValue | c_volumeInside (VolumeIntersectionValue::INSIDE) |
const VolumeIntersectionValue | c_volumePartial (VolumeIntersectionValue::PARTIAL) |
VolumeIntersectionValue | frustum_test_aabb (const Frustum &frustum, const AABB &aabb) |
double | plane_distance_to_point (const Plane3 &plane, const Vector3 &point) |
double | plane_distance_to_oriented_extents (const Plane3 &plane, const Vector3 &extents, const Matrix4 &orientation) |
bool | plane_contains_oriented_aabb (const Plane3 &plane, const AABB &aabb, const Matrix4 &orientation) |
Return false if aabb with orientation is partially or completely outside plane . | |
VolumeIntersectionValue | frustum_intersects_transformed_aabb (const Frustum &frustum, const AABB &aabb, const Matrix4 &localToWorld) |
bool | plane3_test_point (const Plane3 &plane, const Vector3 &point) |
bool | plane3_test_line (const Plane3 &plane, const Segment &segment) |
bool | frustum_test_point (const Frustum &frustum, const Vector3 &point) |
bool | frustum_test_line (const Frustum &frustum, const Segment &segment) |
bool | viewer_test_plane (const Vector4 &viewer, const Plane3 &plane) |
Vector3 | triangle_cross (const Vector3 &p0, const Vector3 &p1, const Vector3 &p2) |
bool | viewer_test_triangle (const Vector4 &viewer, const Vector3 &p0, const Vector3 &p1, const Vector3 &p2) |
Vector4 | viewer_from_transformed_viewer (const Vector4 &viewer, const Matrix4 &transform) |
bool | viewer_test_transformed_plane (const Vector4 &viewer, const Plane3 &plane, const Matrix4 &localToWorld) |
Vector4 | viewer_from_viewproj (const Matrix4 &viewproj) |
Variables | |
const ClipResult | c_CLIP_PASS = 0x00 |
const ClipResult | c_CLIP_LT_X = 0x01 |
const ClipResult | c_CLIP_GT_X = 0x02 |
const ClipResult | c_CLIP_LT_Y = 0x04 |
const ClipResult | c_CLIP_GT_Y = 0x08 |
const ClipResult | c_CLIP_LT_Z = 0x10 |
const ClipResult | c_CLIP_GT_Z = 0x20 |
const ClipResult | c_CLIP_FAIL = 0x3F |
View-frustum data types and related operations.
Definition in file frustum.h.
#define CLIP_X_GT_W | ( | p | ) | (Vector4ClipGT< IntegralConstant<0> >::compare(p)) |
Definition at line 124 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
#define CLIP_X_LT_W | ( | p | ) | (Vector4ClipLT< IntegralConstant<0> >::compare(p)) |
Definition at line 123 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
#define CLIP_Y_GT_W | ( | p | ) | (Vector4ClipGT< IntegralConstant<1> >::compare(p)) |
Definition at line 126 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
#define CLIP_Y_LT_W | ( | p | ) | (Vector4ClipLT< IntegralConstant<1> >::compare(p)) |
Definition at line 125 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
#define CLIP_Z_GT_W | ( | p | ) | (Vector4ClipGT< IntegralConstant<2> >::compare(p)) |
Definition at line 128 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
#define CLIP_Z_LT_W | ( | p | ) | (Vector4ClipLT< IntegralConstant<2> >::compare(p)) |
Definition at line 127 of file frustum.h.
Referenced by homogenous_clip_line(), and homogenous_clip_point().
typedef unsigned char ClipResult |
const VolumeIntersectionValue c_volumeInside | ( | VolumeIntersectionValue::INSIDE | ) |
Referenced by frustum_intersects_transformed_aabb(), frustum_test_aabb(), and ui::MapPreviewView::TestAABB().
const VolumeIntersectionValue c_volumeOutside | ( | VolumeIntersectionValue::OUTSIDE | ) |
Referenced by frustum_intersects_transformed_aabb(), and frustum_test_aabb().
const VolumeIntersectionValue c_volumePartial | ( | VolumeIntersectionValue::PARTIAL | ) |
Referenced by frustum_test_aabb().
Frustum frustum_from_viewproj | ( | const Matrix4 & | viewproj | ) | [inline] |
Definition at line 383 of file frustum.h.
References plane3_normalised().
VolumeIntersectionValue frustum_intersects_transformed_aabb | ( | const Frustum & | frustum, | |
const AABB & | aabb, | |||
const Matrix4 & | localToWorld | |||
) | [inline] |
Definition at line 478 of file frustum.h.
References Frustum::back, Frustum::bottom, c_volumeInside(), c_volumeOutside(), Frustum::front, Frustum::left, plane_contains_oriented_aabb(), Frustum::right, and Frustum::top.
Definition at line 362 of file frustum.h.
References Frustum::back, Frustum::bottom, Frustum::front, Frustum::left, plane3_inverse_transformed(), Frustum::right, and Frustum::top.
VolumeIntersectionValue frustum_test_aabb | ( | const Frustum & | frustum, | |
const AABB & | aabb | |||
) | [inline] |
Definition at line 410 of file frustum.h.
References Frustum::back, Frustum::bottom, c_volumeInside(), c_volumeOutside(), c_volumePartial(), Frustum::front, Frustum::left, Frustum::right, and Frustum::top.
bool frustum_test_line | ( | const Frustum & | frustum, | |
const Segment & | segment | |||
) | [inline] |
Definition at line 510 of file frustum.h.
References Frustum::back, Frustum::bottom, Frustum::front, Frustum::left, plane3_test_line(), Frustum::right, and Frustum::top.
Definition at line 503 of file frustum.h.
References Frustum::back, Frustum::bottom, Frustum::front, Frustum::left, plane3_test_point(), Frustum::right, and Frustum::top.
Definition at line 355 of file frustum.h.
References Frustum::back, Frustum::bottom, Frustum::front, Frustum::left, plane3_transformed(), Frustum::right, and Frustum::top.
std::size_t homogenous_clip_line | ( | Vector4 | clipped[2] | ) | [inline] |
Definition at line 199 of file frustum.h.
References c_CLIP_PASS, CLIP_X_GT_W, CLIP_X_LT_W, CLIP_Y_GT_W, CLIP_Y_LT_W, CLIP_Z_GT_W, CLIP_Z_LT_W, homogenous_clip_point(), and scale.
Referenced by matrix4_clip_line().
ClipResult homogenous_clip_point | ( | const Vector4 & | clipped | ) | [inline] |
Definition at line 130 of file frustum.h.
References c_CLIP_FAIL, c_CLIP_GT_X, c_CLIP_GT_Y, c_CLIP_GT_Z, c_CLIP_LT_X, c_CLIP_LT_Y, c_CLIP_LT_Z, CLIP_X_GT_W, CLIP_X_LT_W, CLIP_Y_GT_W, CLIP_Y_LT_W, CLIP_Z_GT_W, and CLIP_Z_LT_W.
Referenced by homogenous_clip_line(), and matrix4_clip_point().
std::size_t homogenous_clip_triangle | ( | Vector4 | clipped[9] | ) | [inline] |
std::size_t matrix4_clip_line | ( | const Matrix4 & | self, | |
const Vector3 & | p0, | |||
const Vector3 & | p1, | |||
Vector4 | clipped[2] | |||
) | [inline] |
Transforms and clips the line formed by p0
, p1
by the canonical matrix self
. Stores the resulting line in clipped
. Returns the number of points in the resulting line.
Definition at line 324 of file frustum.h.
References homogenous_clip_line().
ClipResult matrix4_clip_point | ( | const Matrix4 & | self, | |
const Vector3 & | point, | |||
Vector4 & | clipped | |||
) | [inline] |
Clips point
by canonical matrix self
. Stores the result in clipped
. Returns a bitmask indicating which clip-planes the point was outside.
Definition at line 151 of file frustum.h.
References homogenous_clip_point().
std::size_t matrix4_clip_triangle | ( | const Matrix4 & | self, | |
const Vector3 & | p0, | |||
const Vector3 & | p1, | |||
const Vector3 & | p2, | |||
Vector4 | clipped[9] | |||
) | [inline] |
Transforms and clips the triangle formed by p0
, p1
, p2
by the canonical matrix self
. Stores the resulting polygon in clipped
. Returns the number of points in the resulting polygon.
Definition at line 176 of file frustum.h.
References homogenous_clip_triangle().
Matrix4 matrix4_frustum | ( | float | left, | |
float | right, | |||
float | bottom, | |||
float | top, | |||
float | nearval, | |||
float | farval | |||
) | [inline] |
bool plane3_test_line | ( | const Plane3 & | plane, | |
const Segment & | segment | |||
) | [inline] |
Definition at line 498 of file frustum.h.
Referenced by frustum_test_line().
Definition at line 493 of file frustum.h.
References Plane3::dist(), BasicVector3< Element >::dot(), and Plane3::normal().
Referenced by frustum_test_point().
bool plane_contains_oriented_aabb | ( | const Plane3 & | plane, | |
const AABB & | aabb, | |||
const Matrix4 & | orientation | |||
) | [inline] |
Return false if aabb
with orientation
is partially or completely outside plane
.
Definition at line 472 of file frustum.h.
References plane_distance_to_oriented_extents(), and plane_distance_to_point().
Referenced by frustum_intersects_transformed_aabb().
double plane_distance_to_oriented_extents | ( | const Plane3 & | plane, | |
const Vector3 & | extents, | |||
const Matrix4 & | orientation | |||
) | [inline] |
Definition at line 464 of file frustum.h.
References Plane3::normal().
Referenced by plane_contains_oriented_aabb().
Definition at line 459 of file frustum.h.
References Plane3::d, and Plane3::normal().
Referenced by plane_contains_oriented_aabb().
Definition at line 522 of file frustum.h.
References BasicVector3< Element >::crossProduct().
Referenced by triangles_same_winding(), and viewer_test_triangle().
Vector4 viewer_from_transformed_viewer | ( | const Vector4 & | viewer, | |
const Matrix4 & | transform | |||
) | [inline] |
Definition at line 533 of file frustum.h.
References BasicVector4< Element >::getVector3().
Referenced by viewer_test_transformed_plane().
Vector4 viewer_from_viewproj | ( | const Matrix4 & | viewproj | ) | [inline] |
bool viewer_test_transformed_plane | ( | const Vector4 & | viewer, | |
const Plane3 & | plane, | |||
const Matrix4 & | localToWorld | |||
) | [inline] |
Definition at line 542 of file frustum.h.
References plane3_transformed(), viewer_from_transformed_viewer(), and viewer_test_plane().
bool viewer_test_triangle | ( | const Vector4 & | viewer, | |
const Vector3 & | p0, | |||
const Vector3 & | p1, | |||
const Vector3 & | p2 | |||
) | [inline] |
Definition at line 527 of file frustum.h.
References triangle_cross().
bool viewproj_test_point | ( | const Matrix4 & | viewproj, | |
const Vector3 & | point | |||
) | [inline] |
Definition at line 370 of file frustum.h.
References f.
Referenced by viewproj_test_transformed_point().
bool viewproj_test_transformed_point | ( | const Matrix4 & | viewproj, | |
const Vector3 & | point, | |||
const Matrix4 & | localToWorld | |||
) | [inline] |
Definition at line 378 of file frustum.h.
References viewproj_test_point().
const ClipResult c_CLIP_FAIL = 0x3F |
Definition at line 52 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_GT_X = 0x02 |
Definition at line 47 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_GT_Y = 0x08 |
Definition at line 49 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_GT_Z = 0x20 |
Definition at line 51 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_LT_X = 0x01 |
Definition at line 46 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_LT_Y = 0x04 |
Definition at line 48 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_LT_Z = 0x10 |
Definition at line 50 of file frustum.h.
Referenced by homogenous_clip_point().
const ClipResult c_CLIP_PASS = 0x00 |
Definition at line 45 of file frustum.h.
Referenced by homogenous_clip_line().