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_points_to_volume.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_points_to_volume.cc')
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
index 0a7d2aa198c..c356e1cf22b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
@@ -30,6 +30,8 @@
namespace blender::nodes::node_geo_points_to_volume_cc {
+NODE_STORAGE_FUNCS(NodeGeometryPointsToVolume)
+
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Geometry>(N_("Points"));
@@ -61,16 +63,16 @@ static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
static void node_update(bNodeTree *ntree, bNode *node)
{
- NodeGeometryPointsToVolume *data = (NodeGeometryPointsToVolume *)node->storage;
+ const NodeGeometryPointsToVolume &storage = node_storage(*node);
bNodeSocket *voxel_size_socket = nodeFindSocket(node, SOCK_IN, "Voxel Size");
bNodeSocket *voxel_amount_socket = nodeFindSocket(node, SOCK_IN, "Voxel Amount");
nodeSetSocketAvailability(ntree,
voxel_amount_socket,
- data->resolution_mode ==
+ storage.resolution_mode ==
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_AMOUNT);
nodeSetSocketAvailability(ntree,
voxel_size_socket,
- data->resolution_mode ==
+ storage.resolution_mode ==
GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_SIZE);
}
@@ -134,8 +136,7 @@ static float compute_voxel_size(const GeoNodeExecParams &params,
Span<float3> positions,
const float radius)
{
- const NodeGeometryPointsToVolume &storage =
- *(const NodeGeometryPointsToVolume *)params.node().storage;
+ const NodeGeometryPointsToVolume &storage = node_storage(params.node());
if (storage.resolution_mode == GEO_NODE_POINTS_TO_VOLUME_RESOLUTION_MODE_SIZE) {
return params.get_input<float>("Voxel Size");