Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-07 17:09:30 +0300
committerHans Goudey <h.goudey@me.com>2021-12-07 17:09:30 +0300
commit2309fa20af416d479fc220d0841483eb3bcf55b0 (patch)
tree5ece68f40841756e8a2293f926f8f93fcebbe7c5 /source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
parent6a9775ec6fd38c26e66ca513cf2914d7344b8f51 (diff)
Cleanup: Add macro and functions for node storage
The `node_storage` functions to retrieve const and mutable structs from a node are generated by a short macro that can be placed at the top of each relevant file. I use this in D8286 to make code snippets in the socket declarations much shorter, but I thought it would be good to use it consistently everywhere else too. The functions are also useful to avoid copy and paste errors, like the one corrected in the cylinder node in this commit. Differential Revision: https://developer.blender.org/D13491
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
index 8ac105fb95c..b8d2ed3be92 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc
@@ -27,6 +27,8 @@
namespace blender::nodes::node_geo_mesh_primitive_cylinder_cc {
+NODE_STORAGE_FUNCS(NodeGeometryMeshCylinder)
+
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Int>(N_("Vertices"))
@@ -83,20 +85,16 @@ static void node_update(bNodeTree *ntree, bNode *node)
bNodeSocket *rings_socket = vertices_socket->next;
bNodeSocket *fill_subdiv_socket = rings_socket->next;
- const NodeGeometryMeshCone &storage = *(const NodeGeometryMeshCone *)node->storage;
- const GeometryNodeMeshCircleFillType fill_type =
- static_cast<const GeometryNodeMeshCircleFillType>(storage.fill_type);
- const bool has_fill = fill_type != GEO_NODE_MESH_CIRCLE_FILL_NONE;
+ const NodeGeometryMeshCylinder &storage = node_storage(*node);
+ const GeometryNodeMeshCircleFillType fill = (GeometryNodeMeshCircleFillType)storage.fill_type;
+ const bool has_fill = fill != GEO_NODE_MESH_CIRCLE_FILL_NONE;
nodeSetSocketAvailability(ntree, fill_subdiv_socket, has_fill);
}
static void node_geo_exec(GeoNodeExecParams params)
{
- const bNode &node = params.node();
- const NodeGeometryMeshCylinder &storage = *(const NodeGeometryMeshCylinder *)node.storage;
-
- const GeometryNodeMeshCircleFillType fill_type = (const GeometryNodeMeshCircleFillType)
- storage.fill_type;
+ const NodeGeometryMeshCylinder &storage = node_storage(params.node());
+ const GeometryNodeMeshCircleFillType fill = (GeometryNodeMeshCircleFillType)storage.fill_type;
const float radius = params.extract_input<float>("Radius");
const float depth = params.extract_input<float>("Depth");
@@ -114,7 +112,7 @@ static void node_geo_exec(GeoNodeExecParams params)
return;
}
- const bool no_fill = fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE;
+ const bool no_fill = fill == GEO_NODE_MESH_CIRCLE_FILL_NONE;
const int fill_segments = no_fill ? 1 : params.extract_input<int>("Fill Segments");
if (fill_segments < 1) {
params.error_message_add(NodeWarningType::Info, TIP_("Fill Segments must be at least 1"));
@@ -140,7 +138,7 @@ static void node_geo_exec(GeoNodeExecParams params)
circle_segments,
side_segments,
fill_segments,
- fill_type,
+ fill,
attribute_outputs);
if (attribute_outputs.top_id) {