[Bf-blender-cvs] [f7af5f99330] geometry-tree-evaluation: initial evaluation code
Jacques Lucke
noreply at git.blender.org
Wed Oct 21 17:29:41 CEST 2020
Commit: f7af5f993303086f5382c7689ca4c272cbcc81e9
Author: Jacques Lucke
Date: Wed Oct 21 15:42:19 2020 +0200
Branches: geometry-tree-evaluation
https://developer.blender.org/rBf7af5f993303086f5382c7689ca4c272cbcc81e9
initial evaluation code
===================================================================
A source/blender/blenkernel/BKE_geometry.hh
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/CMakeLists.txt
A source/blender/blenkernel/intern/geometry.cc
M source/blender/functions/CMakeLists.txt
A source/blender/functions/FN_generic_pointer.hh
M source/blender/modifiers/intern/MOD_triangulate.c
M source/blender/nodes/CMakeLists.txt
A source/blender/nodes/NOD_geometry_exec.hh
A source/blender/nodes/geometry/node_geometry_exec.cc
M source/blender/nodes/geometry/node_geometry_util.cc
R097 source/blender/nodes/geometry/node_geometry_util.h source/blender/nodes/geometry/node_geometry_util.hh
M source/blender/nodes/geometry/nodes/node_geo_common.cc
M source/blender/nodes/geometry/nodes/node_geo_triangulate.cc
===================================================================
diff --git a/source/blender/nodes/geometry/node_geometry_util.h b/source/blender/blenkernel/BKE_geometry.hh
similarity index 54%
copy from source/blender/nodes/geometry/node_geometry_util.h
copy to source/blender/blenkernel/BKE_geometry.hh
index 9d949e8d1ef..d75b0f8f6c7 100644
--- a/source/blender/nodes/geometry/node_geometry_util.h
+++ b/source/blender/blenkernel/BKE_geometry.hh
@@ -16,22 +16,43 @@
#pragma once
-#include <string.h>
-
-#include "BLI_utildefines.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_node_types.h"
-
-#include "BKE_node.h"
-
-#include "BLT_translation.h"
-
-#include "NOD_geometry.h"
-
-#include "node_util.h"
+/** \file
+ * \ingroup bke
+ */
-void geo_node_type_base(
- struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
-bool geo_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
+struct Mesh;
+
+namespace blender::bke {
+
+class Geometry {
+ private:
+ /* Only contains a mesh for now. */
+ Mesh *mesh_ = nullptr;
+
+ public:
+ Geometry() = default;
+ ~Geometry();
+
+ /** Takes ownership of the mesh. */
+ static Geometry *from_mesh(Mesh *mesh)
+ {
+ Geometry *geometry = new Geometry();
+ geometry->mesh_ = mesh;
+ return geometry;
+ }
+
+ Mesh *mesh()
+ {
+ return mesh_;
+ }
+
+ /* The caller takes ownership of the mesh and removes it from the geometry. */
+ Mesh *extract_mesh()
+ {
+ Mesh *mesh = mesh_;
+ mesh_ = mesh;
+ return mesh;
+ }
+};
+
+} // namespace blender::bke
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index ab1e5afb8aa..3158c1d5acf 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -112,6 +112,8 @@ namespace blender {
namespace nodes {
class SocketMFNetworkBuilder;
class NodeMFNetworkBuilder;
+class GeoNodeInput;
+class GeoNodeOutput;
} // namespace nodes
namespace fn {
class MFDataType;
@@ -121,11 +123,15 @@ class MFDataType;
using NodeExpandInMFNetworkFunction = void (*)(blender::nodes::NodeMFNetworkBuilder &builder);
using SocketGetMFDataTypeFunction = blender::fn::MFDataType (*)();
using SocketExpandInMFNetworkFunction = void (*)(blender::nodes::SocketMFNetworkBuilder &builder);
+using GeometryNodeExecFunction = void (*)(struct bNode *,
+ blender::nodes::GeoNodeInput input,
+ blender::nodes::GeoNodeOutput output);
#else
typedef void *NodeExpandInMFNetworkFunction;
typedef void *SocketGetMFDataTypeFunction;
typedef void *SocketExpandInMFNetworkFunction;
+typedef void *GeometryNodeExecFunction;
#endif
/**
@@ -302,6 +308,9 @@ typedef struct bNodeType {
/* Expands the bNode into nodes in a multi-function network, which will be evaluated later on. */
NodeExpandInMFNetworkFunction expand_in_mf_network;
+ /* Execute a geometry node. */
+ GeometryNodeExecFunction geometry_node_execute;
+
/* RNA integration */
ExtensionRNA rna_ext;
} bNodeType;
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 0fbc8c4c229..070e54653fd 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -124,6 +124,7 @@ set(SRC
intern/fmodifier.c
intern/font.c
intern/freestyle.c
+ intern/geometry.cc
intern/gpencil.c
intern/gpencil_curve.c
intern/gpencil_geom.c
@@ -310,6 +311,7 @@ set(SRC
BKE_fluid.h
BKE_font.h
BKE_freestyle.h
+ BKE_geometry.hh
BKE_global.h
BKE_gpencil.h
BKE_gpencil_curve.h
diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/blenkernel/intern/geometry.cc
similarity index 66%
copy from source/blender/nodes/geometry/node_geometry_util.cc
copy to source/blender/blenkernel/intern/geometry.cc
index 82354d6cf66..d1e62f6b3c1 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/blenkernel/intern/geometry.cc
@@ -14,16 +14,19 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "node_geometry_util.h"
-#include "node_util.h"
+#include "BKE_geometry.hh"
+#include "BKE_mesh.h"
-bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
-{
- return STREQ(ntree->idname, "GeometryNodeTree");
-}
+#include "MEM_guardedalloc.h"
-void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
+namespace blender::bke {
+
+Geometry::~Geometry()
{
- node_type_base(ntype, type, name, nclass, flag);
- ntype->poll = geo_node_poll_default;
+ if (mesh_ != nullptr) {
+ BKE_mesh_free(mesh_);
+ MEM_freeN(mesh_);
+ }
}
+
+} // namespace blender::bke
diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index 9a6b6f4a4db..e005753e228 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -38,6 +38,7 @@ set(SRC
FN_array_spans.hh
FN_attributes_ref.hh
FN_cpp_type.hh
+ FN_generic_pointer.hh
FN_generic_vector_array.hh
FN_multi_function.hh
FN_multi_function_builder.hh
diff --git a/source/blender/functions/FN_generic_pointer.hh b/source/blender/functions/FN_generic_pointer.hh
new file mode 100644
index 00000000000..4538d7169c2
--- /dev/null
+++ b/source/blender/functions/FN_generic_pointer.hh
@@ -0,0 +1,70 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "FN_cpp_type.hh"
+
+namespace blender::fn {
+
+/**
+ * A generic pointer whose type is only known at runtime.
+ */
+class GMutablePointer {
+ private:
+ const CPPType *type_ = nullptr;
+ void *data_ = nullptr;
+
+ public:
+ GMutablePointer() = default;
+
+ GMutablePointer(const CPPType *type, void *data = nullptr) : type_(type), data_(data)
+ {
+ /* If there is data, there has to be a type. */
+ BLI_assert(data_ == nullptr || type_ != nullptr);
+ }
+
+ GMutablePointer(const CPPType &type, void *data = nullptr) : GMutablePointer(&type, data)
+ {
+ }
+
+ template<typename T> GMutablePointer(T *data) : GMutablePointer(&CPPType::get<T>(), data)
+ {
+ }
+
+ void *get() const
+ {
+ return data_;
+ }
+
+ const CPPType *type() const
+ {
+ return type_;
+ }
+
+ template<typename T> T *get() const
+ {
+ BLI_assert(this->is_type<T>());
+ return reinterpret_cast<T *>(data_);
+ }
+
+ template<typename T> bool is_type() const
+ {
+ return type_ != nullptr && type_->is<T>();
+ }
+};
+
+} // namespace blender::fn
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 5a07c4e5e64..1930a38b825 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -48,11 +48,17 @@
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
-static Mesh *triangulate_mesh(Mesh *mesh,
- const int quad_method,
- const int ngon_method,
- const int min_vertices,
- const int flag)
+Mesh *triangulate_mesh(Mesh *mesh,
+ const int quad_method,
+ const int ngon_method,
+ const int min_vertices,
+ const int flag);
+
+Mesh *triangulate_mesh(Mesh *mesh,
+ const int quad_method,
+ const int ngon_method,
+ const int min_vertices,
+ const int flag)
{
Mesh *result;
BMesh *bm;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index fe098ea2491..31c010377ad 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -139,6 +139,7 @@ set(SRC
geometry/nodes/node_geo_common.cc
geometry/nodes/node_geo_triangulate.cc
+ geometry/node_geometry_exec.cc
geometry/node_geometry_tree.cc
geometry/node_geometry_util.cc
@@ -273,7 +274,7 @@ set(SRC
composite/node_composite_util.h
function/node_function_util.hh
shader/node_shader_util.h
- geometry/node_geometry_util.h
+ geometry/node_geometry_util.hh
texture/node_texture_util.h
NOD_common.h
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
new file mode 100644
index 00000000000..47b387a97a0
--- /dev/null
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -0,0 +1,119 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "FN_generic_pointer.hh"
+
+#include "BLI_linear_allocator.hh"
+#include "BLI_map.hh"
+
+#include "BKE_geometry.hh"
+
+namespace blender::nodes {
+
+using bke::Geometry;
+using fn::CPPType;
+using fn::GMutablePointer;
+
+class GeoNodeInputBuilder {
+ private:
+ Map<StringRef, GMutablePoi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list