WIP: DNA: experiment with supporting decentralized DNA structs #110322
|
@ -1644,11 +1644,6 @@ typedef struct NodeGeometryCurveFill {
|
|||
uint8_t mode;
|
||||
} NodeGeometryCurveFill;
|
||||
|
||||
typedef struct NodeGeometryMeshToPoints {
|
||||
/** #GeometryNodeMeshToPointsMode */
|
||||
uint8_t mode;
|
||||
} NodeGeometryMeshToPoints;
|
||||
|
||||
typedef struct NodeGeometryAttributeCapture {
|
||||
/** #eCustomDataType. */
|
||||
int8_t data_type;
|
||||
|
@ -2618,13 +2613,6 @@ typedef enum GeometryNodeCurveFillMode {
|
|||
GEO_NODE_CURVE_FILL_MODE_NGONS = 1,
|
||||
} GeometryNodeCurveFillMode;
|
||||
|
||||
typedef enum GeometryNodeMeshToPointsMode {
|
||||
GEO_NODE_MESH_TO_POINTS_VERTICES = 0,
|
||||
GEO_NODE_MESH_TO_POINTS_EDGES = 1,
|
||||
GEO_NODE_MESH_TO_POINTS_FACES = 2,
|
||||
GEO_NODE_MESH_TO_POINTS_CORNERS = 3,
|
||||
} GeometryNodeMeshToPointsMode;
|
||||
|
||||
typedef enum GeometryNodeStringToCurvesOverflowMode {
|
||||
GEO_NODE_STRING_TO_CURVES_MODE_OVERFLOW = 0,
|
||||
GEO_NODE_STRING_TO_CURVES_MODE_SCALE_TO_FIT = 1,
|
||||
|
|
|
@ -889,6 +889,16 @@ static int convert_include(const char *filepath)
|
|||
md++;
|
||||
}
|
||||
|
||||
if (STREQ(filepath, "/home/jacques/blender/blender/source/blender/makesdna/DNA_node_types.h")) {
|
||||
const int struct_type = add_type("NodeGeometryMeshToPoints", 0);
|
||||
short *structpoin = add_struct(struct_type);
|
||||
const int name = add_name("mode");
|
||||
short *sp = structpoin + 2;
|
||||
sp[0] = add_type("uint8_t", 0);
|
||||
sp[1] = name;
|
||||
structpoin[1]++;
|
||||
}
|
||||
|
||||
MEM_freeN(maindata);
|
||||
|
||||
return 0;
|
||||
|
@ -986,12 +996,12 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char
|
|||
const char *str_pair[2] = {types[structtype], name_static};
|
||||
const char *name_alias = static_cast<const char *>(
|
||||
BLI_ghash_lookup(g_version_data.elem_map_alias_from_static, str_pair));
|
||||
fprintf(file_verify,
|
||||
"BLI_STATIC_ASSERT(offsetof(struct %s, %s) == %d, \"DNA member offset "
|
||||
"verify\");\n",
|
||||
structname,
|
||||
name_alias ? name_alias : name_static,
|
||||
size_native);
|
||||
// fprintf(file_verify,
|
||||
// "BLI_STATIC_ASSERT(offsetof(struct %s, %s) == %d, \"DNA member offset "
|
||||
// "verify\");\n",
|
||||
// structname,
|
||||
// name_alias ? name_alias : name_static,
|
||||
// size_native);
|
||||
}
|
||||
|
||||
/* is it a pointer or function pointer? */
|
||||
|
@ -1154,10 +1164,10 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char
|
|||
}
|
||||
|
||||
/* Write size verification to file. */
|
||||
fprintf(file_verify,
|
||||
"BLI_STATIC_ASSERT(sizeof(struct %s) == %d, \"DNA struct size verify\");\n\n",
|
||||
structname,
|
||||
size_native);
|
||||
// fprintf(file_verify,
|
||||
// "BLI_STATIC_ASSERT(sizeof(struct %s) == %d, \"DNA struct size verify\");\n\n",
|
||||
// structname,
|
||||
// size_native);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1592,43 +1602,3 @@ int main(int argc, char **argv)
|
|||
|
||||
return return_status;
|
||||
}
|
||||
|
||||
/* handy but fails on struct bounds which makesdna doesn't care about
|
||||
* with quite the same strictness as GCC does */
|
||||
#if 0
|
||||
/* include files for automatic dependencies */
|
||||
|
||||
/* extra safety check that we are aligned,
|
||||
* warnings here are easier to fix the makesdna's */
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC diagnostic error "-Wpadded"
|
||||
# endif
|
||||
|
||||
#endif /* if 0 */
|
||||
|
||||
/* The include file below is automatically generated from the `SRC_DNA_INC`
|
||||
* variable in 'source/blender/CMakeLists.txt'. */
|
||||
#include "dna_includes_all.h"
|
||||
|
||||
/* end of list */
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name DNA Renaming Sanity Check
|
||||
*
|
||||
* Without this it's possible to reference struct members that don't exist,
|
||||
* breaking backward & forward compatibility.
|
||||
*
|
||||
* \{ */
|
||||
|
||||
static void UNUSED_FUNCTION(dna_rename_defs_ensure)()
|
||||
{
|
||||
#define DNA_STRUCT_RENAME(old, new) (void)sizeof(new);
|
||||
#define DNA_STRUCT_RENAME_ELEM(struct_name, old, new) (void)offsetof(struct_name, new);
|
||||
#include "dna_rename_defs.h"
|
||||
#undef DNA_STRUCT_RENAME
|
||||
#undef DNA_STRUCT_RENAME_ELEM
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -231,6 +231,7 @@ set(INC
|
|||
../../imbuf
|
||||
../../modifiers
|
||||
../../nodes
|
||||
../../nodes/geometry/include
|
||||
../../sequencer
|
||||
../../simulation
|
||||
../../windowmanager
|
||||
|
@ -490,4 +491,3 @@ set(LIB
|
|||
)
|
||||
|
||||
blender_add_lib(bf_rna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
|
||||
|
|
|
@ -4691,6 +4691,10 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const
|
|||
}
|
||||
fprintf(f, "\n");
|
||||
fprintf(f, "#ifdef __cplusplus\n");
|
||||
if (STREQ(filename, "rna_nodetree.cc")) {
|
||||
fprintf(f,
|
||||
"using NodeGeometryMeshToPoints = blender::nodes::NodeGeometryMeshToPoints::DNA;\n\n");
|
||||
}
|
||||
fprintf(f, "# define RNA_EXTERN_C extern \"C\"\n");
|
||||
fprintf(f, "# define RNA_EXTERN_C_OR_EXTERN extern \"C\"\n");
|
||||
fprintf(f, "#else\n");
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
|
||||
#include "BLI_string_utils.h"
|
||||
|
||||
#include "NOD_geo_mesh_to_points.hh"
|
||||
|
||||
const EnumPropertyItem rna_enum_node_socket_in_out_items[] = {{SOCK_IN, "IN", 0, "Input", ""},
|
||||
{SOCK_OUT, "OUT", 0, "Output", ""},
|
||||
{0, nullptr, 0, nullptr, nullptr}};
|
||||
|
@ -10631,23 +10633,25 @@ static void def_geo_mesh_to_points(StructRNA *srna)
|
|||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
using namespace blender::nodes;
|
||||
|
||||
static EnumPropertyItem mode_items[] = {
|
||||
{GEO_NODE_MESH_TO_POINTS_VERTICES,
|
||||
{GeometryNodeMeshToPointsMode::Vertices,
|
||||
"VERTICES",
|
||||
0,
|
||||
"Vertices",
|
||||
"Create a point in the point cloud for each selected vertex"},
|
||||
{GEO_NODE_MESH_TO_POINTS_EDGES,
|
||||
{GeometryNodeMeshToPointsMode::Edges,
|
||||
"EDGES",
|
||||
0,
|
||||
"Edges",
|
||||
"Create a point in the point cloud for each selected edge"},
|
||||
{GEO_NODE_MESH_TO_POINTS_FACES,
|
||||
{GeometryNodeMeshToPointsMode::Faces,
|
||||
"FACES",
|
||||
0,
|
||||
"Faces",
|
||||
"Create a point in the point cloud for each selected face"},
|
||||
{GEO_NODE_MESH_TO_POINTS_CORNERS,
|
||||
{GeometryNodeMeshToPointsMode::Corners,
|
||||
"CORNERS",
|
||||
0,
|
||||
"Corners",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
set(INC
|
||||
.
|
||||
..
|
||||
./include
|
||||
../intern
|
||||
../../editors/include
|
||||
../../blentranslation
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
namespace blender::nodes {
|
||||
|
||||
enum GeometryNodeMeshToPointsMode {
|
||||
Vertices = 0,
|
||||
Edges = 1,
|
||||
Faces = 2,
|
||||
Corners = 3,
|
||||
};
|
||||
|
||||
struct NodeGeometryMeshToPoints {
|
||||
struct DNA {
|
||||
/** #GeometryNodeMeshToPointsMode */
|
||||
uint8_t mode;
|
||||
} dna_;
|
||||
|
||||
GeometryNodeMeshToPointsMode mode() const
|
||||
{
|
||||
return GeometryNodeMeshToPointsMode(dna_.mode);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace blender::nodes
|
|
@ -15,6 +15,7 @@
|
|||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "NOD_geo_mesh_to_points.hh"
|
||||
#include "node_geometry_util.hh"
|
||||
|
||||
namespace blender::nodes::node_geo_mesh_to_points_cc {
|
||||
|
@ -42,7 +43,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
|||
static void node_init(bNodeTree * /*tree*/, bNode *node)
|
||||
{
|
||||
NodeGeometryMeshToPoints *data = MEM_cnew<NodeGeometryMeshToPoints>(__func__);
|
||||
data->mode = GEO_NODE_MESH_TO_POINTS_VERTICES;
|
||||
data->dna_.mode = GeometryNodeMeshToPointsMode::Vertices;
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
|
@ -154,14 +155,14 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
const Field<float> positive_radius(FieldOperation::Create(max_zero_fn, {std::move(radius)}), 0);
|
||||
|
||||
const NodeGeometryMeshToPoints &storage = node_storage(params.node());
|
||||
const GeometryNodeMeshToPointsMode mode = (GeometryNodeMeshToPointsMode)storage.mode;
|
||||
const GeometryNodeMeshToPointsMode mode = storage.mode();
|
||||
|
||||
const AnonymousAttributePropagationInfo &propagation_info = params.get_output_propagation_info(
|
||||
"Points");
|
||||
|
||||
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
|
||||
switch (mode) {
|
||||
case GEO_NODE_MESH_TO_POINTS_VERTICES:
|
||||
case GeometryNodeMeshToPointsMode::Vertices:
|
||||
geometry_set_mesh_to_points(geometry_set,
|
||||
position,
|
||||
positive_radius,
|
||||
|
@ -169,7 +170,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
ATTR_DOMAIN_POINT,
|
||||
propagation_info);
|
||||
break;
|
||||
case GEO_NODE_MESH_TO_POINTS_EDGES:
|
||||
case GeometryNodeMeshToPointsMode::Edges:
|
||||
geometry_set_mesh_to_points(geometry_set,
|
||||
position,
|
||||
positive_radius,
|
||||
|
@ -177,7 +178,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
ATTR_DOMAIN_EDGE,
|
||||
propagation_info);
|
||||
break;
|
||||
case GEO_NODE_MESH_TO_POINTS_FACES:
|
||||
case GeometryNodeMeshToPointsMode::Faces:
|
||||
geometry_set_mesh_to_points(geometry_set,
|
||||
position,
|
||||
positive_radius,
|
||||
|
@ -185,7 +186,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
ATTR_DOMAIN_FACE,
|
||||
propagation_info);
|
||||
break;
|
||||
case GEO_NODE_MESH_TO_POINTS_CORNERS:
|
||||
case GeometryNodeMeshToPointsMode::Corners:
|
||||
geometry_set_mesh_to_points(geometry_set,
|
||||
position,
|
||||
positive_radius,
|
||||
|
|
Loading…
Reference in New Issue