[Bf-blender-cvs] [03bde25be97] functions: fix context in vectorized functions
Jacques Lucke
noreply at git.blender.org
Wed Dec 11 15:28:16 CET 2019
Commit: 03bde25be9794779689cc48b31fd2b79b5bbac29
Author: Jacques Lucke
Date: Wed Dec 11 15:27:53 2019 +0100
Branches: functions
https://developer.blender.org/rB03bde25be9794779689cc48b31fd2b79b5bbac29
fix context in vectorized functions
===================================================================
M source/blender/functions/FN_multi_function_context.h
M source/blender/functions/intern/multi_functions/vectorize.cc
===================================================================
diff --git a/source/blender/functions/FN_multi_function_context.h b/source/blender/functions/FN_multi_function_context.h
index 8d1816cc1e8..05a531435c5 100644
--- a/source/blender/functions/FN_multi_function_context.h
+++ b/source/blender/functions/FN_multi_function_context.h
@@ -72,6 +72,8 @@ class MFGlobalContexts {
}
};
+class MFContext;
+
class MFContextBuilder : BLI::NonCopyable, BLI::NonMovable {
private:
MFElementContexts m_element_contexts;
@@ -84,6 +86,8 @@ class MFContextBuilder : BLI::NonCopyable, BLI::NonMovable {
{
}
+ void add_global_contexts(const MFContext &other);
+
template<typename T> void add_element_context(const T &context, VirtualListRef<uint> indices)
{
m_element_contexts.m_ids.append(BLI::get_class_id<T>());
@@ -108,6 +112,8 @@ class MFContext {
private:
MFContextBuilder *m_builder;
+ friend MFContextBuilder;
+
public:
MFContext(MFContextBuilder &builder) : m_builder(&builder)
{
@@ -124,6 +130,19 @@ class MFContext {
}
};
+inline void MFContextBuilder::add_global_contexts(const MFContext &other)
+{
+ const MFGlobalContexts &global_contexts = other.m_builder->m_global_contexts;
+
+ for (uint i : global_contexts.m_ids.index_iterator()) {
+ BLI::class_id_t id = other.m_builder->m_global_contexts.m_ids[i];
+ const void *context = other.m_builder->m_global_contexts.m_contexts[i];
+
+ m_global_contexts.m_ids.append(id);
+ m_global_contexts.m_contexts.append(context);
+ }
+}
+
} // namespace FN
#endif /* __FN_MULTI_FUNCTION_CONTEXT_H__ */
diff --git a/source/blender/functions/intern/multi_functions/vectorize.cc b/source/blender/functions/intern/multi_functions/vectorize.cc
index 9aba5a0f66a..9e77274ca95 100644
--- a/source/blender/functions/intern/multi_functions/vectorize.cc
+++ b/source/blender/functions/intern/multi_functions/vectorize.cc
@@ -79,6 +79,9 @@ void MF_SimpleVectorize::call(MFMask mask, MFParams params, MFContext context) c
Array<int> vectorization_lengths(mask.min_array_size());
get_vectorization_lengths(mask, params, m_vectorized_inputs, vectorization_lengths);
+ MFContextBuilder sub_context_builder;
+ sub_context_builder.add_global_contexts(context);
+
for (uint index : mask.indices()) {
uint length = vectorization_lengths[index];
MFParamsBuilder params_builder(m_function, length);
@@ -115,9 +118,9 @@ void MF_SimpleVectorize::call(MFMask mask, MFParams params, MFContext context) c
}
}
- /* TODO: Call with updated context. */
+ /* TODO: Pass modified per element contexts. */
ArrayRef<uint> sub_mask_indices = IndexRange(length).as_array_ref();
- m_function.call(sub_mask_indices, params_builder, context);
+ m_function.call(sub_mask_indices, params_builder, sub_context_builder);
}
}
More information about the Bf-blender-cvs
mailing list