diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-17 00:35:12 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-17 00:35:36 +0300 |
commit | 9a56a3865c06b472ac54c0351e270dcf738add07 (patch) | |
tree | 375bfcdabd2bb184be581ebb95f249938952ad19 /source/blender/makesrna | |
parent | 3e87d8a4315d794efff659e40f0bb9e34e2aec8a (diff) |
Geometry Nodes: Add initial version of mesh primitives
This commit includes nodes to build the following primitives:
- Cone
- Cylinder
- Circle
- Cube
- UV Sphere
- Ico Sphere
- Line
- Plane/Grid
In general the inputs are the same as the corresponding operators
in the 3D view.
**Line Primitive**
The line primitive has two modes-- adding vertices between two end
points, or adding vertices each at an offset from the start point.
For the former mode, there is a choice between a vertex count
and a distance between each point.
**Plane Primitive**
This commit includes the "Plane" and "Grid" primitives as one node.
Generally primitives are named after the simpler form of the shape they
create (i.e. "Cone" can make some more complex shapes). Also, generally
you want to tweak the number of subdivisions anyway, so defaulting to
plane is not an inconvenience. And generally having fewer redundant
base primitives is better.
**Future Improvements**
A following patch proposes to improve the speed of the cylinder, cone,
and sphere primitives: D10730. Additional possible future improvements
would be adding subdivisions to the cube node and rings to the cone
and cylinder nodes.
Differential Revision: https://developer.blender.org/D10715
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 35c319c2f79..04ff181d9b5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -402,8 +402,15 @@ static const EnumPropertyItem node_cryptomatte_layer_name_items[] = { {0, "CryptoObject", 0, "Object", "Use Object layer"}, {1, "CryptoMaterial", 0, "Material", "Use Material layer"}, {2, "CryptoAsset", 0, "Asset", "Use Asset layer"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}, +}; +static EnumPropertyItem rna_node_geometry_mesh_circle_fill_type_items[] = { + {GEO_NODE_MESH_CIRCLE_FILL_NONE, "NONE", 0, "None", ""}, + {GEO_NODE_MESH_CIRCLE_FILL_NGON, "NGON", 0, "N-Gon", ""}, + {GEO_NODE_MESH_CIRCLE_FILL_TRIANGLE_FAN, "TRIANGLE_FAN", 0, "Triangles", ""}, + {0, NULL, 0, NULL, NULL}, +}; #endif #define ITEM_ATTRIBUTE \ @@ -9437,6 +9444,87 @@ static void def_geo_attribute_separate_xyz(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } +static void def_geo_mesh_circle(StructRNA *srna) +{ + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeGeometryMeshCircle", "storage"); + + prop = RNA_def_property(srna, "fill_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_node_geometry_mesh_circle_fill_type_items); + RNA_def_property_ui_text(prop, "Fill Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + +static void def_geo_mesh_cylinder(StructRNA *srna) +{ + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeGeometryMeshCylinder", "storage"); + + prop = RNA_def_property(srna, "fill_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_node_geometry_mesh_circle_fill_type_items); + RNA_def_property_ui_text(prop, "Fill Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + +static void def_geo_mesh_cone(StructRNA *srna) +{ + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeGeometryMeshCone", "storage"); + + prop = RNA_def_property(srna, "fill_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, rna_node_geometry_mesh_circle_fill_type_items); + RNA_def_property_ui_text(prop, "Fill Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + +static void def_geo_mesh_line(StructRNA *srna) +{ + PropertyRNA *prop; + + static EnumPropertyItem mode_items[] = { + {GEO_NODE_MESH_LINE_MODE_OFFSET, + "OFFSET", + 0, + "Offset", + "Specify the offset from one vertex to the next"}, + {GEO_NODE_MESH_LINE_MODE_END_POINTS, + "END_POINTS", + 0, + "End Points", + "Specify the line's start and end points"}, + {0, NULL, 0, NULL, NULL}, + }; + + static EnumPropertyItem count_mode_items[] = { + {GEO_NODE_MESH_LINE_COUNT_TOTAL, + "TOTAL", + 0, + "Count", + "Specify the total number of vertices"}, + {GEO_NODE_MESH_LINE_COUNT_RESOLUTION, + "RESOLUTION", + 0, + "Resolution", + "Specify the distance between vertices"}, + {0, NULL, 0, NULL, NULL}, + }; + + RNA_def_struct_sdna_from(srna, "NodeGeometryMeshLine", "storage"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); + + prop = RNA_def_property(srna, "count_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, count_mode_items); + RNA_def_property_ui_text(prop, "Count Mode", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); +} + /* -------------------------------------------------------------------------- */ static void rna_def_shader_node(BlenderRNA *brna) |