[Bf-blender-cvs] [9bb2afb55e5] master: Start of Bevel V2, as being worked on with task T98674.
Howard Trickey
noreply at git.blender.org
Sat Jul 2 16:13:19 CEST 2022
Commit: 9bb2afb55e50f9353cfc76cf2d8df7521b0b5feb
Author: Howard Trickey
Date: Sat Jul 2 10:09:18 2022 -0400
Branches: master
https://developer.blender.org/rB9bb2afb55e50f9353cfc76cf2d8df7521b0b5feb
Start of Bevel V2, as being worked on with task T98674.
This is the start of a geometry node to do edge, vertex, and face
bevels.
It doesn't yet do anything but analyze the "Vertex cap" around
selected vertices for vertex bevel.
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/intern/node.cc
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/NOD_geometry.h
M source/blender/nodes/NOD_static_types.h
M source/blender/nodes/geometry/CMakeLists.txt
A source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 21bb3d01616..e6c9d62905e 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -107,6 +107,7 @@ def mesh_node_items(context):
space = context.space_data
if not space:
return
+ yield NodeItem("GeometryNodeBevelMesh")
yield NodeItem("GeometryNodeDualMesh")
yield NodeItem("GeometryNodeExtrudeMesh")
yield NodeItem("GeometryNodeFlipFaces")
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index e13ac3180ec..dc86adc9046 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1340,6 +1340,7 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
struct TexResult;
+#define GEO_NODE_BEVEL_MESH 1400
#define TEX_NODE_OUTPUT 401
#define TEX_NODE_CHECKER 402
#define TEX_NODE_TEXTURE 403
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 5be912ffb2b..ba9b28b4a29 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4722,6 +4722,7 @@ static void registerGeometryNodes()
register_node_type_geo_attribute_capture();
register_node_type_geo_attribute_domain_size();
register_node_type_geo_attribute_statistic();
+ register_node_type_geo_bevel_mesh();
register_node_type_geo_boolean();
register_node_type_geo_bounding_box();
register_node_type_geo_collection_info();
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 76d8207eead..79e1c9c2c14 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1221,6 +1221,11 @@ typedef struct NodeGeometryExtrudeMesh {
uint8_t mode;
} NodeGeometryExtrudeMesh;
+typedef struct NodeGeometryBevelMesh {
+ /* GeometryNodeBevelMode */
+ uint8_t mode;
+} NodeGeometryBevelMesh;
+
typedef struct NodeGeometryObjectInfo {
/* GeometryNodeTransformSpace. */
uint8_t transform_space;
@@ -1966,6 +1971,12 @@ typedef enum GeometryNodeExtrudeMeshMode {
GEO_NODE_EXTRUDE_MESH_FACES = 2,
} GeometryNodeExtrudeMeshMode;
+typedef enum GeometryNodeBevelMeshMode {
+ GEO_NODE_BEVEL_MESH_VERTICES = 0,
+ GEO_NODE_BEVEL_MESH_EDGES = 1,
+ GEO_NODE_BEVEL_MESH_FACES = 2,
+} GeometryNodeBevelMeshMode;
+
typedef enum FunctionNodeRotateEulerType {
FN_NODE_ROTATE_EULER_TYPE_EULER = 0,
FN_NODE_ROTATE_EULER_TYPE_AXIS_ANGLE = 1,
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 386ef3f74a3..2966dc97519 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9551,6 +9551,27 @@ static void def_geo_extrude_mesh(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_geo_bevel_mesh(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem mode_items[] = {
+ {GEO_NODE_BEVEL_MESH_VERTICES, "VERTICES", 0, "Vertices", ""},
+ {GEO_NODE_BEVEL_MESH_EDGES, "EDGES", 0, "Edges", ""},
+ {GEO_NODE_BEVEL_MESH_FACES, "FACES", 0, "Faces", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+ RNA_def_struct_sdna_from(srna, "NodeGeometryBevelMesh", "storage");
+
+ prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, mode_items);
+ RNA_def_property_enum_default(prop, GEO_NODE_BEVEL_MESH_FACES);
+ RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
static void def_geo_distribute_points_on_faces(StructRNA *srna)
{
PropertyRNA *prop;
diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h
index 8f15add33fd..7e813aef85e 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -20,6 +20,7 @@ void register_node_type_geo_attribute_capture(void);
void register_node_type_geo_attribute_domain_size(void);
void register_node_type_geo_attribute_separate_xyz(void);
void register_node_type_geo_attribute_statistic(void);
+void register_node_type_geo_bevel_mesh(void);
void register_node_type_geo_boolean(void);
void register_node_type_geo_bounding_box(void);
void register_node_type_geo_collection_info(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 609791ad091..da324c98a26 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -281,6 +281,7 @@ DefNode(FunctionNode, FN_NODE_VALUE_TO_STRING, 0, "VALUE_TO_STRING", ValueToStri
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_DOMAIN_SIZE, def_geo_attribute_domain_size, "ATTRIBUTE_DOMAIN_SIZE", AttributeDomainSize, "Domain Size", "")
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_STATISTIC, def_geo_attribute_statistic, "ATTRIBUTE_STATISTIC", AttributeStatistic, "Attribute Statistic", "")
+DefNode(GeometryNode, GEO_NODE_BEVEL_MESH, def_geo_bevel_mesh, "BEVEL_MESH", BevelMesh, "Bevel Mesh", "")
DefNode(GeometryNode, GEO_NODE_BOUNDING_BOX, 0, "BOUNDING_BOX", BoundBox, "Bounding Box", "")
DefNode(GeometryNode, GEO_NODE_CAPTURE_ATTRIBUTE, def_geo_attribute_capture, "CAPTURE_ATTRIBUTE", CaptureAttribute, "Capture Attribute", "")
DefNode(GeometryNode, GEO_NODE_COLLECTION_INFO, def_geo_collection_info, "COLLECTION_INFO", CollectionInfo, "Collection Info", "")
diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt
index 950124f75d0..1f83b375a84 100644
--- a/source/blender/nodes/geometry/CMakeLists.txt
+++ b/source/blender/nodes/geometry/CMakeLists.txt
@@ -29,6 +29,7 @@ set(SRC
nodes/node_geo_attribute_capture.cc
nodes/node_geo_attribute_domain_size.cc
nodes/node_geo_attribute_statistic.cc
+ nodes/node_geo_bevel_mesh.cc
nodes/node_geo_boolean.cc
nodes/node_geo_bounding_box.cc
nodes/node_geo_collection_info.cc
diff --git a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
new file mode 100644
index 00000000000..f14535a3c65
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
@@ -0,0 +1,461 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
+
+#include "BLI_array.hh"
+#include "BLI_set.hh"
+#include "BLI_sort.hh"
+#include "BLI_task.hh"
+#include "BLI_timeit.hh"
+#include "BLI_vector.hh"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "node_geometry_util.hh"
+
+#include <algorithm>
+
+namespace blender::nodes::node_geo_bevel_mesh_cc {
+
+NODE_STORAGE_FUNCS(NodeGeometryBevelMesh)
+
+static void node_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Geometry>("Mesh").supported_type(GEO_COMPONENT_TYPE_MESH);
+ b.add_input<decl::Bool>(N_("Selection")).default_value(true).supports_field().hide_value();
+ b.add_input<decl::Float>(N_("Amount")).default_value(1.0f).supports_field();
+ b.add_output<decl::Geometry>("Mesh");
+}
+
+static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayoutSetPropSep(layout, true);
+ uiLayoutSetPropDecorate(layout, false);
+ uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
+}
+
+static void node_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+ NodeGeometryBevelMesh *data = MEM_cnew<NodeGeometryBevelMesh>(__func__);
+ data->mode = GEO_NODE_BEVEL_MESH_EDGES;
+ node->storage = data;
+}
+
+static void node_update(bNodeTree *UNUSED(ntree), bNode *UNUSED(node))
+{
+}
+
+/* While Mesh uses the term 'poly' for polygon, most of Blender uses the term 'face',
+ * so we'll go with 'face' in this code except in the final to/from mesh routines.
+ */
+class MeshTopology {
+ MeshElemMap *vert_edge_map_;
+ int *vert_edge_map_mem_;
+ MeshElemMap *edge_poly_map_;
+ int *edge_poly_map_mem_;
+ const Mesh &mesh_;
+
+ public:
+ MeshTopology(const Mesh &mesh);
+ ~MeshTopology();
+
+ /* Edges adjacent to vertex v. */
+ Span<int> vert_edges(int v) const
+ {
+ const MeshElemMap &m = vert_edge_map_[v];
+ return Span<int>{m.indices, m.count};
+ }
+
+ /* Faces adjacent to edge e. */
+ Span<int> edge_faces(int e) const
+ {
+ const MeshElemMap &m = edge_poly_map_[e];
+ return Span<int>{m.indices, m.count};
+ }
+
+ /* Does edge e have exactly two adjacent faces? */
+ bool edge_is_manifold(int e) const
+ {
+ return edge_poly_map_[e].count == 2;
+ }
+
+ /* What is the other manifold face (i.e., not f) attached to edge e?
+ * Edge e must be manifold and f must be one of the incident faces. */
+ int edge_other_manifold_face(int e, int f) const;
+
+ /* What is the other edge of f (i.e., not e) attached to vertex v.
+ * Face f must contain e, and e must have v as one of its vertices. */
+ int face_other_edge_at_vert(int f, int v, int e) const;
+
+ /* Is edge e1 the successor of e0 when going around face f? */
+ bool edge_is_successor_in_face(int e0, int e1, int f) const;
+
+ int num_verts() const
+ {
+ return mesh_.totvert;
+ }
+ int num_edges() const
+ {
+ return mesh_.totedge;
+ }
+ int num_faces() const
+ {
+ return mesh_.totpoly;
+ }
+};
+
+MeshTopology::MeshTopology(const Mesh &mesh) : mesh_(mesh)
+{
+ timeit::ScopedTimer t("MeshTopology construction");
+ BKE_mesh_vert_edge_map_create(
+ &vert_edge_map_, &vert_edge_map_mem_, mesh.medge, mesh.totvert, mesh.totedge);
+ BKE_mesh_edge_poly_map_create(&edge_poly_map_,
+ &edge_poly_map_mem_,
+ mesh.medge,
+ mesh.totedge,
+ mesh.mpoly,
+ mesh.totpoly,
+ mesh.mloop,
+ mesh.totloop);
+}
+
+MeshTopology::~MeshTopology()
+{
+ MEM_freeN(vert_edge_map_);
+ MEM_freeN(vert_edge_map
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list