[Bf-blender-cvs] [f094b4fa08c] master: Fix T86172: check if attribute is actually accessible

Jacques Lucke noreply at git.blender.org
Tue Mar 2 13:32:17 CET 2021


Commit: f094b4fa08c970c48ff8f70952ecb3adf353539b
Author: Jacques Lucke
Date:   Tue Mar 2 13:29:01 2021 +0100
Branches: master
https://developer.blender.org/rBf094b4fa08c970c48ff8f70952ecb3adf353539b

Fix T86172: check if attribute is actually accessible

The crash happened when the density in the Point Distribute node was
above zero but so small, that no point was generated. In this case, there
was a point cloud component, but the point cloud was empty, making some
attributes unavailable.

One could also make more attributes available in this case, but that can
be done separately if necessary.

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

M	source/blender/blenkernel/intern/attribute_access.cc
M	source/blender/nodes/geometry/nodes/node_geo_point_scale.cc

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

diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 8974190d0e3..aeb7fba47e8 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -1886,7 +1886,7 @@ OutputAttributePtr GeometryComponent::attribute_try_get_for_output(const StringR
   if (!attribute) {
     this->attribute_try_create(attribute_name, domain, data_type);
     attribute = this->attribute_try_get_for_write(attribute_name);
-    if (default_value != nullptr) {
+    if (attribute && default_value != nullptr) {
       void *data = attribute->get_span_for_write_only().data();
       cpp_type->fill_initialized(default_value, data, attribute->size());
       attribute->apply_span();
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
index e28013a8bfc..9df103ff057 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_scale.cc
@@ -47,6 +47,9 @@ static void execute_on_component(GeoNodeExecParams params, GeometryComponent &co
   static const float3 scale_default = float3(1.0f);
   OutputAttributePtr scale_attribute = component.attribute_try_get_for_output(
       "scale", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, &scale_default);
+  if (!scale_attribute) {
+    return;
+  }
   ReadAttributePtr attribute = params.get_input_attribute(
       "Factor", component, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, nullptr);
   if (!attribute) {



More information about the Bf-blender-cvs mailing list