[Bf-blender-cvs] [a6b383bd69c] tmp-worbench-rewrite2-optimizations: Revert "Skip bbox allocation by retrieving bounds min/max"

Miguel Pozo noreply at git.blender.org
Tue Jan 17 16:15:32 CET 2023


Commit: a6b383bd69caa50fb35a8ffefcd276a26f4fa6e8
Author: Miguel Pozo
Date:   Tue Jan 17 16:13:25 2023 +0100
Branches: tmp-worbench-rewrite2-optimizations
https://developer.blender.org/rBa6b383bd69caa50fb35a8ffefcd276a26f4fa6e8

Revert "Skip bbox allocation by retrieving bounds min/max"

This reverts commit c2022d6d3691ddcced42c24488344393249ba631.

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

M	source/blender/blenkernel/intern/object.cc
M	source/blender/draw/intern/draw_manager_data.cc
M	source/blender/draw/intern/draw_resource.hh

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

diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index 817bc50cba4..d33f8fe5de7 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -3882,12 +3882,8 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us
       break;
     }
     case OB_MESH: {
-      Mesh *me = (Mesh *)ob->data;
-      INIT_MINMAX(r_min, r_max);
-      if (!BKE_mesh_wrapper_minmax(me, r_min, r_max)) {
-        r_min[0] = r_min[1] = r_min[2] = -1.0f;
-        r_max[0] = r_max[1] = r_max[2] = 1.0f;
-      }
+      const BoundBox bb = *BKE_mesh_boundbox_get(ob);
+      BKE_boundbox_minmax(&bb, ob->object_to_world, r_min, r_max);
       changed = true;
       break;
     }
diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc
index 5c06233054d..5b4e0792577 100644
--- a/source/blender/draw/intern/draw_manager_data.cc
+++ b/source/blender/draw/intern/draw_manager_data.cc
@@ -719,16 +719,12 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
 
 static void drw_call_culling_init(DRWCullingState *cull, Object *ob)
 {
-  if (ob != nullptr) {
-    float3 min, max;
-    BKE_object_minmax(ob, min, max, false);
-    BoundBox bbox;
-    BKE_boundbox_init_from_minmax(&bbox, min, max);
-
+  const BoundBox *bbox;
+  if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) {
     float corner[3];
     /* Get BoundSphere center and radius from the BoundBox. */
-    mid_v3_v3v3(cull->bsphere.center, bbox.vec[0], bbox.vec[6]);
-    mul_v3_m4v3(corner, ob->object_to_world, bbox.vec[0]);
+    mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]);
+    mul_v3_m4v3(corner, ob->object_to_world, bbox->vec[0]);
     mul_m4_v3(ob->object_to_world, cull->bsphere.center);
     cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner);
 
diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh
index 69e7c3a0687..a2de084b900 100644
--- a/source/blender/draw/intern/draw_resource.hh
+++ b/source/blender/draw/intern/draw_resource.hh
@@ -151,15 +151,15 @@ inline void ObjectBounds::sync()
 
 inline void ObjectBounds::sync(Object &ob)
 {
-  float3 min, max;
-  BKE_object_minmax(&ob, min, max, false);
-  BoundBox bbox;
-  BKE_boundbox_init_from_minmax(&bbox, min, max);
-
-  *reinterpret_cast<float3 *>(&bounding_corners[0]) = bbox.vec[0];
-  *reinterpret_cast<float3 *>(&bounding_corners[1]) = bbox.vec[4];
-  *reinterpret_cast<float3 *>(&bounding_corners[2]) = bbox.vec[3];
-  *reinterpret_cast<float3 *>(&bounding_corners[3]) = bbox.vec[1];
+  const BoundBox *bbox = BKE_object_boundbox_get(&ob);
+  if (bbox == nullptr) {
+    bounding_sphere.w = -1.0f; /* Disable test. */
+    return;
+  }
+  *reinterpret_cast<float3 *>(&bounding_corners[0]) = bbox->vec[0];
+  *reinterpret_cast<float3 *>(&bounding_corners[1]) = bbox->vec[4];
+  *reinterpret_cast<float3 *>(&bounding_corners[2]) = bbox->vec[3];
+  *reinterpret_cast<float3 *>(&bounding_corners[3]) = bbox->vec[1];
   bounding_sphere.w = 0.0f; /* Enable test. */
 }



More information about the Bf-blender-cvs mailing list