Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-09-24 17:38:43 +0300
committerJacques Lucke <jacques@blender.org>2021-09-24 17:42:20 +0300
commit90b410fe74b8710eaaa0372cb4f2d7da60f002a7 (patch)
tree8e24298bc8ba8f589330b3781940fb9ae94f0646
parent25d4de92fa763a5d1d72696cf1b4567a01099c4d (diff)
Fix: field evaluation crash when the domain size is zero
-rw-r--r--source/blender/functions/intern/field.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index fbd35c2c377..4f7ea8ec0ef 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -418,7 +418,10 @@ Vector<const GVArray *> evaluate_fields(ResourceScope &scope,
build_multi_function_procedure_for_fields(
procedure, scope, field_tree_info, constant_fields_to_evaluate);
MFProcedureExecutor procedure_executor{"Procedure", procedure};
- MFParamsBuilder mf_params{procedure_executor, 1};
+ /* Run the code below even when the mask is empty, so that outputs are properly prepared.
+ * Higher level code can detect this as well and just skip evaluating the field. */
+ const int mask_size = mask.is_empty() ? 0 : 1;
+ MFParamsBuilder mf_params{procedure_executor, mask_size};
MFContextBuilder mf_context;
/* Provide inputs to the procedure executor. */
@@ -435,11 +438,11 @@ Vector<const GVArray *> evaluate_fields(ResourceScope &scope,
/* Use this to make sure that the value is destructed in the end. */
PartiallyInitializedArray &destruct_helper = scope.construct<PartiallyInitializedArray>();
destruct_helper.buffer = buffer;
- destruct_helper.mask = IndexRange(1);
+ destruct_helper.mask = IndexRange(mask_size);
destruct_helper.type = &type;
/* Pass output buffer to the procedure executor. */
- mf_params.add_uninitialized_single_output({type, buffer, 1});
+ mf_params.add_uninitialized_single_output({type, buffer, mask_size});
/* Create virtual array that can be used after the procedure has been executed below. */
const int out_index = constant_field_indices[i];