[Bf-blender-cvs] [cccaca258bb] functions-experimental-refactor: simplify naming
Jacques Lucke
noreply at git.blender.org
Thu Nov 7 11:44:18 CET 2019
Commit: cccaca258bbee1a9a29ffa9bb71e02483bd54a95
Author: Jacques Lucke
Date: Wed Nov 6 13:05:26 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rBcccaca258bbee1a9a29ffa9bb71e02483bd54a95
simplify naming
===================================================================
M source/blender/functions2/intern/vtree_multi_function_network/builder.h
M source/blender/functions2/intern/vtree_multi_function_network/mappings_nodes.cc
M source/blender/functions2/intern/vtree_multi_function_network/mappings_sockets.cc
===================================================================
diff --git a/source/blender/functions2/intern/vtree_multi_function_network/builder.h b/source/blender/functions2/intern/vtree_multi_function_network/builder.h
index 91c3c59148d..c06e307b14b 100644
--- a/source/blender/functions2/intern/vtree_multi_function_network/builder.h
+++ b/source/blender/functions2/intern/vtree_multi_function_network/builder.h
@@ -47,7 +47,7 @@ class VTreeMFNetworkBuilder : BLI::NonCopyable, BLI::NonMovable {
m_builder->add_link(from, to);
}
- template<typename T, typename... Args> T &allocate(const char *name, Args &&... args)
+ template<typename T, typename... Args> T &construct(const char *name, Args &&... args)
{
void *buffer = m_resources.allocate(sizeof(T), alignof(T));
T *value = new (buffer) T(std::forward<Args>(args)...);
@@ -55,7 +55,7 @@ class VTreeMFNetworkBuilder : BLI::NonCopyable, BLI::NonMovable {
return *value;
}
- template<typename T, typename... Args> T &allocate_function(Args &&... args)
+ template<typename T, typename... Args> T &construct_fn(Args &&... args)
{
BLI_STATIC_ASSERT((std::is_base_of<MultiFunction, T>::value), "");
void *buffer = m_resources.allocate(sizeof(T), alignof(T));
diff --git a/source/blender/functions2/intern/vtree_multi_function_network/mappings_nodes.cc b/source/blender/functions2/intern/vtree_multi_function_network/mappings_nodes.cc
index 7c721ad2824..4568308c31b 100644
--- a/source/blender/functions2/intern/vtree_multi_function_network/mappings_nodes.cc
+++ b/source/blender/functions2/intern/vtree_multi_function_network/mappings_nodes.cc
@@ -7,7 +7,7 @@ namespace FN {
static void INSERT_vector_math(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_AddFloat3s>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_AddFloat3s>();
builder.add_function(fn, {0, 1}, {2}, vnode);
}
@@ -28,7 +28,7 @@ static const MultiFunction &get_vectorized_function(
}
if (input_is_vectorized.contains(true)) {
- return builder.allocate_function<FN::MF_SimpleVectorize>(base_function, input_is_vectorized);
+ return builder.construct_fn<FN::MF_SimpleVectorize>(base_function, input_is_vectorized);
}
else {
return base_function;
@@ -37,7 +37,7 @@ static const MultiFunction &get_vectorized_function(
static void INSERT_float_math(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &base_fn = builder.allocate_function<FN::MF_AddFloats>();
+ const MultiFunction &base_fn = builder.construct_fn<FN::MF_AddFloats>();
const MultiFunction &fn = get_vectorized_function(
builder, base_fn, vnode.rna(), {"use_list__a", "use_list__b"});
@@ -46,7 +46,7 @@ static void INSERT_float_math(VTreeMFNetworkBuilder &builder, const VNode &vnode
static void INSERT_combine_vector(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &base_fn = builder.allocate_function<FN::MF_CombineVector>();
+ const MultiFunction &base_fn = builder.construct_fn<FN::MF_CombineVector>();
const MultiFunction &fn = get_vectorized_function(
builder, base_fn, vnode.rna(), {"use_list__x", "use_list__y", "use_list__z"});
builder.add_function(fn, {0, 1, 2}, {3}, vnode);
@@ -54,7 +54,7 @@ static void INSERT_combine_vector(VTreeMFNetworkBuilder &builder, const VNode &v
static void INSERT_separate_vector(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &base_fn = builder.allocate_function<FN::MF_SeparateVector>();
+ const MultiFunction &base_fn = builder.construct_fn<FN::MF_SeparateVector>();
const MultiFunction &fn = get_vectorized_function(
builder, base_fn, vnode.rna(), {"use_list__vector"});
builder.add_function(fn, {0}, {1, 2, 3}, vnode);
@@ -63,14 +63,14 @@ static void INSERT_separate_vector(VTreeMFNetworkBuilder &builder, const VNode &
static void INSERT_list_length(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
const CPPType &type = builder.cpp_type_from_property(vnode, "active_type");
- const MultiFunction &fn = builder.allocate_function<FN::MF_ListLength>(type);
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ListLength>(type);
builder.add_function(fn, {0}, {1}, vnode);
}
static void INSERT_get_list_element(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
const CPPType &type = builder.cpp_type_from_property(vnode, "active_type");
- const MultiFunction &fn = builder.allocate_function<FN::MF_GetListElement>(type);
+ const MultiFunction &fn = builder.construct_fn<FN::MF_GetListElement>(type);
builder.add_function(fn, {0, 1, 2}, {3}, vnode);
}
@@ -106,7 +106,7 @@ static MFBuilderOutputSocket &build_pack_list_node(VTreeMFNetworkBuilder &builde
uint input_amount = list_states.size();
uint output_param_index = (input_amount > 0 && list_states[0]) ? 0 : input_amount;
- const MultiFunction &fn = builder.allocate_function<FN::MF_PackList>(base_type, list_states);
+ const MultiFunction &fn = builder.construct_fn<FN::MF_PackList>(base_type, list_states);
MFBuilderFunctionNode &node = builder.add_function(
fn, IndexRange(input_amount).as_array_ref(), {output_param_index});
@@ -127,31 +127,31 @@ static void INSERT_pack_list(VTreeMFNetworkBuilder &builder, const VNode &vnode)
static void INSERT_object_location(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_ObjectWorldLocation>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ObjectWorldLocation>();
builder.add_function(fn, {0}, {1}, vnode);
}
static void INSERT_text_length(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_TextLength>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_TextLength>();
builder.add_function(fn, {0}, {1}, vnode);
}
static void INSERT_vertex_info(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_ContextVertexPosition>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ContextVertexPosition>();
builder.add_function(fn, {}, {0}, vnode);
}
static void INSERT_float_range(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_FloatRange>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_FloatRange>();
builder.add_function(fn, {0, 1, 2}, {3}, vnode);
}
static void INSERT_time_info(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &fn = builder.allocate_function<FN::MF_ContextCurrentFrame>();
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ContextCurrentFrame>();
builder.add_function(fn, {}, {0}, vnode);
}
@@ -162,14 +162,14 @@ static const MultiFunction &get_simple_math_function(VTreeMFNetworkBuilder &buil
T default_value)
{
if (list_states.size() == 0) {
- return builder.allocate_function<FN::MF_ConstantValue<T>>(default_value);
+ return builder.construct_fn<FN::MF_ConstantValue<T>>(default_value);
}
else {
- const MultiFunction &math_fn = builder.allocate_function<FN::MF_SimpleMath<T, Compute>>(
+ const MultiFunction &math_fn = builder.construct_fn<FN::MF_SimpleMath<T, Compute>>(
name, list_states.size());
if (list_states.contains(true)) {
- return builder.allocate_function<FN::MF_SimpleVectorize>(math_fn, list_states);
+ return builder.construct_fn<FN::MF_SimpleVectorize>(math_fn, list_states);
}
else {
return math_fn;
@@ -247,8 +247,7 @@ template<typename T> T safe_power_func_cb(T a, T b)
template<typename T, T (*Compute)(T, T)>
void insert_two_inputs_math_function(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &base_fn = builder.allocate_function<MF_SimpleMath<T, Compute>>(vnode.name(),
- 2);
+ const MultiFunction &base_fn = builder.construct_fn<MF_SimpleMath<T, Compute>>(vnode.name(), 2);
const MultiFunction &fn = get_vectorized_function(
builder, base_fn, vnode.rna(), {"use_list__a", "use_list__b"});
builder.add_function(fn, {0, 1}, {2}, vnode);
@@ -272,7 +271,7 @@ static void INSERT_power_floats(VTreeMFNetworkBuilder &builder, const VNode &vno
template<typename T, T (*Compute)(const T &)>
static void insert_single_input_math_function(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
- const MultiFunction &base_fn = builder.allocate_function<FN::MF_Mappping<T, T, Compute>>(
+ const MultiFunction &base_fn = builder.construct_fn<FN::MF_Mappping<T, T, Compute>>(
vnode.name());
const MultiFunction &fn = get_vectorized_function(builder, base_fn, vnode.rna(), {"use_list"});
builder.add_function(fn, {0}, {1}, vnode);
diff --git a/source/blender/functions2/intern/vtree_multi_function_network/mappings_sockets.cc b/source/blender/functions2/intern/vtree_multi_function_network/mappings_sockets.cc
index 5a42fa5fa69..1cc93145285 100644
--- a/source/blender/functions2/intern/vtree_multi_function_network/mappings_sockets.cc
+++ b/source/blender/functions2/intern/vtree_multi_function_network/mappings_sockets.cc
@@ -16,7 +16,7 @@ static MFBuilderOutputSocket &INSERT_vector_socket(VTreeMFNetworkBuilder &builde
BLI::float3 value;
RNA_float_get_array(vsocket.rna(), "value", value);
- const MultiFunction &fn = builder.allocate_function<FN::MF_ConstantValue<BLI::float3>>(value);
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ConstantValue<BLI::float3>>(value);
MFBuilderFunctionNode &node = builder.add_function(fn, {}, {0});
return *node.outputs()[0];
}
@@ -26,7 +26,7 @@ static MFBuilderOutputSocket &INSERT_float_socket(VTreeMFNetworkBuilder &builder
{
float value = RNA_float_get(vsocket.rna(), "value");
- const MultiFunction &fn = builder.allocate_function<FN::MF_ConstantValue<float>>(value);
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ConstantValue<float>>(value);
MFBuilderFunctionNode &node = builder.add_function(fn, {}, {0});
return *node.outputs()[0];
}
@@ -36,7 +
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list