[Bf-blender-cvs] [a96b2f39b82] master: Geometry Nodes: improve check if object has geometry set instances

Jacques Lucke noreply at git.blender.org
Mon Nov 1 12:00:59 CET 2021


Commit: a96b2f39b82373d05f543bba325b2dd21baabf63
Author: Jacques Lucke
Date:   Mon Nov 1 12:00:34 2021 +0100
Branches: master
https://developer.blender.org/rBa96b2f39b82373d05f543bba325b2dd21baabf63

Geometry Nodes: improve check if object has geometry set instances

The improves playback speed in my instance heavy scene from ~3.7 fps to ~3.9 fps.

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

M	source/blender/blenkernel/intern/geometry_set.cc

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

diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc
index cd1bafe445a..c250c14f1d7 100644
--- a/source/blender/blenkernel/intern/geometry_set.cc
+++ b/source/blender/blenkernel/intern/geometry_set.cc
@@ -610,24 +610,32 @@ bool BKE_object_has_geometry_set_instances(const Object *ob)
   if (geometry_set == nullptr) {
     return false;
   }
-  if (geometry_set->has_instances()) {
-    return true;
-  }
-  const bool has_mesh = geometry_set->has_mesh();
-  const bool has_pointcloud = geometry_set->has_pointcloud();
-  const bool has_volume = geometry_set->has_volume();
-  const bool has_curve = geometry_set->has_curve();
-  if (ob->type == OB_MESH) {
-    return has_pointcloud || has_volume || has_curve;
-  }
-  if (ob->type == OB_POINTCLOUD) {
-    return has_mesh || has_volume || has_curve;
-  }
-  if (ob->type == OB_VOLUME) {
-    return has_mesh || has_pointcloud || has_curve;
-  }
-  if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
-    return has_mesh || has_pointcloud || has_volume;
+  for (const GeometryComponent *component : geometry_set->get_components_for_read()) {
+    if (component->is_empty()) {
+      continue;
+    }
+    const GeometryComponentType type = component->type();
+    bool is_instance = false;
+    switch (type) {
+      case GEO_COMPONENT_TYPE_MESH:
+        is_instance = ob->type != OB_MESH;
+        break;
+      case GEO_COMPONENT_TYPE_POINT_CLOUD:
+        is_instance = ob->type != OB_POINTCLOUD;
+        break;
+      case GEO_COMPONENT_TYPE_INSTANCES:
+        is_instance = true;
+        break;
+      case GEO_COMPONENT_TYPE_VOLUME:
+        is_instance = ob->type != OB_VOLUME;
+        break;
+      case GEO_COMPONENT_TYPE_CURVE:
+        is_instance = !ELEM(ob->type, OB_CURVE, OB_FONT);
+        break;
+    }
+    if (is_instance) {
+      return true;
+    }
   }
   return false;
 }



More information about the Bf-blender-cvs mailing list