[Bf-blender-cvs] [742848843dd] master: DRW: Add view param to DRW_culling_* functions

Clément Foucault noreply at git.blender.org
Wed May 22 13:30:38 CEST 2019


Commit: 742848843dd04df530f25ac5111cfc2f16237f51
Author: Clément Foucault
Date:   Tue May 21 16:55:17 2019 +0200
Branches: master
https://developer.blender.org/rB742848843dd04df530f25ac5111cfc2f16237f51

DRW: Add view param to DRW_culling_* functions

===================================================================

M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/eevee_lights.c
M	source/blender/draw/engines/workbench/workbench_studiolight.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager_exec.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 56038892ca8..9b193c3a837 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -466,7 +466,8 @@ static bool eevee_lightprobes_culling_test(Object *ob)
       for (int v = 0; v < 8; ++v) {
         mul_m4_v3(tmp, bbox.vec[v]);
       }
-      return DRW_culling_box_test(&bbox);
+      const DRWView *default_view = DRW_view_default_get();
+      return DRW_culling_box_test(default_view, &bbox);
     }
     case LIGHTPROBE_TYPE_CUBE:
       return true; /* TODO */
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index b4eda1b0f29..e966fadbcdb 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -1347,8 +1347,9 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
         .center = {ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2]},
         .radius = light_attenuation_radius_get(la, light_threshold),
     };
-    cube_visible[i] = DRW_culling_sphere_test(&bsphere);
+    cube_visible[i] = DRW_culling_sphere_test(view, &bsphere);
   }
+
   bool cascade_visible[MAX_SHADOW_CASCADE];
   for (i = 0; (ob = linfo->shadow_cascade_ref[i]) && (i < MAX_SHADOW_CASCADE); i++) {
     EEVEE_LightEngineData *led = EEVEE_light_data_get(ob);
@@ -1359,7 +1360,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
     plane_from_point_normal_v3(plane, sh_data->viewmat[3], sh_data->viewmat[2]);
     /* TODO: check against near/far instead of "local Z = 0" plane.
      * Or even the cascades AABB. */
-    cascade_visible[i] = DRW_culling_plane_test(plane);
+    cascade_visible[i] = DRW_culling_plane_test(view, plane);
   }
 
   /* Cube Shadow Maps */
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
index af07a818533..fbe538c5994 100644
--- a/source/blender/draw/engines/workbench/workbench_studiolight.c
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -230,7 +230,8 @@ bool studiolight_object_cast_visible_shadow(WORKBENCH_PrivateData *wpd,
                                             WORKBENCH_ObjectData *oed)
 {
   BoundBox *shadow_bbox = studiolight_object_shadow_bbox_get(wpd, ob, oed);
-  return DRW_culling_box_test(shadow_bbox);
+  const DRWView *default_view = DRW_view_default_get();
+  return DRW_culling_box_test(default_view, shadow_bbox);
 }
 
 float studiolight_object_shadow_distance(WORKBENCH_PrivateData *wpd,
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index b2ae71d8653..378bb23188c 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -573,10 +573,9 @@ float DRW_view_far_distance_get(const DRWView *view);
 bool DRW_view_is_persp_get(const DRWView *view);
 
 /* Culling, return true if object is inside view frustum. */
-/* TODO */
-// bool DRW_culling_sphere_test(DRWView *view, BoundSphere *bsphere);
-// bool DRW_culling_box_test(DRWView *view, BoundBox *bbox);
-// bool DRW_culling_plane_test(DRWView *view, float plane[4]);
+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]);
 
 /* Viewport */
 typedef enum {
@@ -688,11 +687,6 @@ void DRW_state_lock(DRWState state);
 
 void DRW_state_clip_planes_len_set(uint plane_len);
 
-/* Culling, return true if object is inside view frustum. */
-bool DRW_culling_sphere_test(const BoundSphere *bsphere);
-bool DRW_culling_box_test(const BoundBox *bbox);
-bool DRW_culling_plane_test(const float plane[4]);
-
 void DRW_culling_frustum_corners_get(BoundBox *corners);
 void DRW_culling_frustum_planes_get(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 f6d18aeed3d..36e9244df06 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -479,24 +479,26 @@ static bool draw_culling_plane_test(const BoundBox *corners, const float plane[4
 
 /* Return True if the given BoundSphere intersect the current view frustum.
  * bsphere must be in world space. */
-bool DRW_culling_sphere_test(const BoundSphere *bsphere)
+bool DRW_culling_sphere_test(const DRWView *view, const BoundSphere *bsphere)
 {
-  return draw_culling_sphere_test(
-      &DST.view_active->frustum_bsphere, DST.view_active->frustum_planes, bsphere);
+  view = view ? view : DST.view_default;
+  return draw_culling_sphere_test(&view->frustum_bsphere, view->frustum_planes, bsphere);
 }
 
 /* Return True if the given BoundBox intersect the current view frustum.
  * bbox must be in world space. */
-bool DRW_culling_box_test(const BoundBox *bbox)
+bool DRW_culling_box_test(const DRWView *view, const BoundBox *bbox)
 {
-  return draw_culling_box_test(DST.view_active->frustum_planes, bbox);
+  view = view ? view : DST.view_default;
+  return draw_culling_box_test(view->frustum_planes, bbox);
 }
 
 /* Return True if the view frustum is inside or intersect the given plane.
  * plane must be in world space. */
-bool DRW_culling_plane_test(const float plane[4])
+bool DRW_culling_plane_test(const DRWView *view, const float plane[4])
 {
-  return draw_culling_plane_test(&DST.view_active->frustum_corners, plane);
+  view = view ? view : DST.view_default;
+  return draw_culling_plane_test(&view->frustum_corners, plane);
 }
 
 void DRW_culling_frustum_corners_get(BoundBox *corners)



More information about the Bf-blender-cvs mailing list