Commit: aa34408b038d0cab2837f10c5e6aa0d123603215 Author: mano-wii Date: Thu Aug 15 10:17:41 2019 -0300 Branches: temp-lanpr-staging https://developer.blender.org/rBaa34408b038d0cab2837f10c5e6aa0d123603215
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. =================================================================== M source/blender/draw/intern/DRW_render.h M source/blender/draw/intern/draw_manager_exec.c =================================================================== diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 383b57cb74e..8e4ca1cefab 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -608,6 +608,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]); diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 949d3e1d38b..3bf442b4f39 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -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; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs