[Bf-blender-cvs] [de3d75110ce] functions-experimental-refactor: bring back object mesh info node
Jacques Lucke
noreply at git.blender.org
Fri Nov 8 18:31:22 CET 2019
Commit: de3d75110ceedadee6fa5a85cca8ff48b8678e0c
Author: Jacques Lucke
Date: Fri Nov 8 17:50:19 2019 +0100
Branches: functions-experimental-refactor
https://developer.blender.org/rBde3d75110ceedadee6fa5a85cca8ff48b8678e0c
bring back object mesh info node
===================================================================
M source/blender/functions/intern/multi_functions/mixed.cc
M source/blender/functions/intern/multi_functions/mixed.h
M source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
===================================================================
diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc
index 64e4a6cec17..2ae08f85ffd 100644
--- a/source/blender/functions/intern/multi_functions/mixed.cc
+++ b/source/blender/functions/intern/multi_functions/mixed.cc
@@ -7,13 +7,18 @@
#include "BLI_math_cxx.h"
#include "BLI_lazy_init_cxx.h"
#include "BLI_string_map.h"
+#include "BLI_array_cxx.h"
#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
namespace FN {
using BLI::float3;
+using BLI::float4x4;
using BLI::rgba_f;
+using BLI::TemporaryArray;
MF_AddFloats::MF_AddFloats()
{
@@ -230,6 +235,38 @@ void MF_FloatRange::call(const MFMask &mask, MFParams ¶ms, MFContext &UNUSED
}
}
+MF_ObjectVertexPositions::MF_ObjectVertexPositions()
+{
+ MFSignatureBuilder signature{"Object Vertex Positions"};
+ signature.readonly_single_input<Object *>("Object");
+ signature.vector_output<float3>("Positions");
+ this->set_signature(signature);
+}
+
+void MF_ObjectVertexPositions::call(const MFMask &mask,
+ MFParams ¶ms,
+ MFContext &UNUSED(context)) const
+{
+ VirtualListRef<Object *> objects = params.readonly_single_input<Object *>(0, "Object");
+ auto positions = params.vector_output<float3>(1, "Positions");
+
+ for (uint i : mask.indices()) {
+ Object *object = objects[i];
+ if (object == nullptr || object->type != OB_MESH) {
+ continue;
+ }
+
+ float4x4 transform = object->obmat;
+
+ Mesh *mesh = (Mesh *)object->data;
+ TemporaryArray<float3> coords(mesh->totvert);
+ for (uint j = 0; j < mesh->totvert; j++) {
+ coords[j] = transform.transform_position(mesh->mvert[j].co);
+ }
+ positions.extend_single(i, coords);
+ }
+}
+
MF_ObjectWorldLocation::MF_ObjectWorldLocation()
{
MFSignatureBuilder signature("Object Location");
diff --git a/source/blender/functions/intern/multi_functions/mixed.h b/source/blender/functions/intern/multi_functions/mixed.h
index 8c7bc3467e0..6fad879459a 100644
--- a/source/blender/functions/intern/multi_functions/mixed.h
+++ b/source/blender/functions/intern/multi_functions/mixed.h
@@ -64,6 +64,12 @@ class MF_ObjectWorldLocation final : public MultiFunction {
void call(const MFMask &mask, MFParams ¶ms, MFContext &context) const override;
};
+class MF_ObjectVertexPositions final : public MultiFunction {
+ public:
+ MF_ObjectVertexPositions();
+ void call(const MFMask &mask, MFParams ¶ms, MFContext &context) const override;
+};
+
class MF_TextLength final : public MultiFunction {
public:
MF_TextLength();
diff --git a/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
index 8b0dfcb45c1..85ea9c1d857 100644
--- a/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
+++ b/source/blender/functions/intern/vtree_multi_function_network/mappings_nodes.cc
@@ -139,6 +139,12 @@ static void INSERT_object_location(VTreeMFNetworkBuilder &builder, const VNode &
builder.add_function(fn, {0}, {1}, vnode);
}
+static void INSERT_object_mesh_info(VTreeMFNetworkBuilder &builder, const VNode &vnode)
+{
+ const MultiFunction &fn = builder.construct_fn<FN::MF_ObjectVertexPositions>();
+ builder.add_function(fn, {0}, {1}, vnode);
+}
+
static void INSERT_text_length(VTreeMFNetworkBuilder &builder, const VNode &vnode)
{
const MultiFunction &fn = builder.construct_fn<FN::MF_TextLength>();
@@ -418,6 +424,7 @@ void add_vtree_node_mapping_info(VTreeMultiFunctionMappings &mappings)
mappings.vnode_inserters.add_new("fn_PackListNode", INSERT_pack_list);
mappings.vnode_inserters.add_new("fn_GetListElementNode", INSERT_get_list_element);
mappings.vnode_inserters.add_new("fn_ObjectTransformsNode", INSERT_object_location);
+ mappings.vnode_inserters.add_new("fn_ObjectMeshNode", INSERT_object_mesh_info);
mappings.vnode_inserters.add_new("fn_TextLengthNode", INSERT_text_length);
mappings.vnode_inserters.add_new("fn_VertexInfoNode", INSERT_vertex_info);
mappings.vnode_inserters.add_new("fn_FloatRangeNode", INSERT_float_range);
More information about the Bf-blender-cvs
mailing list