DRW: New function DRW_culling_min_max_test
For testing intersection with frustrum planes without having to transform all bound box vertices into global space.
This commit is contained in:
parent
78b56fa7d9
commit
261a02fc59
|
@ -597,6 +597,7 @@ bool DRW_view_is_persp_get(const DRWView *view);
|
|||
bool DRW_culling_sphere_test(const DRWView *view, const BoundSphere *bsphere);
|
||||
bool DRW_culling_box_test(const DRWView *view, const BoundBox *bbox);
|
||||
bool DRW_culling_plane_test(const DRWView *view, const float plane[4]);
|
||||
bool DRW_culling_min_max_test(const DRWView *view, float obmat[4][4], float min[3], float max[3]);
|
||||
|
||||
void DRW_culling_frustum_corners_get(const DRWView *view, BoundBox *corners);
|
||||
void DRW_culling_frustum_planes_get(const DRWView *view, float planes[6][4]);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "draw_manager.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_memblock.h"
|
||||
|
||||
|
@ -488,6 +489,26 @@ bool DRW_culling_plane_test(const DRWView *view, const float plane[4])
|
|||
return draw_culling_plane_test(&view->frustum_corners, plane);
|
||||
}
|
||||
|
||||
/* Return True if the given box intersect the current view frustum.
|
||||
* This function will have to be replaced when world space bb per objects is implemented. */
|
||||
bool DRW_culling_min_max_test(const DRWView *view, float obmat[4][4], float min[3], float max[3])
|
||||
{
|
||||
view = view ? view : DST.view_default;
|
||||
float tobmat[4][4];
|
||||
transpose_m4_m4(tobmat, obmat);
|
||||
for (int i = 6; i--;) {
|
||||
float frustum_plane_local[4], bb_near[3], bb_far[3];
|
||||
mul_v4_m4v4(frustum_plane_local, tobmat, view->frustum_planes[i]);
|
||||
aabb_get_near_far_from_plane(frustum_plane_local, min, max, bb_near, bb_far);
|
||||
|
||||
if (plane_point_side_v3(frustum_plane_local, bb_far) < 0.0f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DRW_culling_frustum_corners_get(const DRWView *view, BoundBox *corners)
|
||||
{
|
||||
view = view ? view : DST.view_default;
|
||||
|
|
Loading…
Reference in New Issue