Compare commits
7 Commits
geometry-n
...
geometry-n
Author | SHA1 | Date | |
---|---|---|---|
83d7dd528d | |||
46e2f4761c | |||
24474a60b6 | |||
0bd0e08790 | |||
faac263d97 | |||
97c0158cda | |||
97a9576959 |
@@ -495,6 +495,10 @@ geometry_node_categories = [
|
||||
NodeItem("GeometryNodeBoolean"),
|
||||
NodeItem("GeometryNodeSubdivisionSurface"),
|
||||
]),
|
||||
GeometryNodeCategory("GEO_ATTRIBUTES", "Attributes", items=[
|
||||
NodeItem("GeometryNodeRandomAttribute"),
|
||||
NodeItem("GeometryNodeAttributeMath"),
|
||||
]),
|
||||
GeometryNodeCategory("GEO_SCATTERING", "Scattering", items=[
|
||||
NodeItem("GeometryNodePointDistribute"),
|
||||
NodeItem("GeometryNodePointInstance"),
|
||||
|
@@ -1345,6 +1345,8 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
|
||||
#define GEO_NODE_POINT_INSTANCE 1005
|
||||
#define GEO_NODE_SUBDIVISION_SURFACE 1006
|
||||
#define GEO_NODE_OBJECT_INFO 1007
|
||||
#define GEO_NODE_ATTRIBUTE_RANDOM 1008
|
||||
#define GEO_NODE_ATTRIBUTE_MATH 1009
|
||||
|
||||
/** \} */
|
||||
|
||||
|
@@ -4680,6 +4680,8 @@ static void registerGeometryNodes(void)
|
||||
{
|
||||
register_node_type_geo_group();
|
||||
|
||||
register_node_type_geo_attribute_math();
|
||||
register_node_type_geo_attribute_random();
|
||||
register_node_type_geo_triangulate();
|
||||
register_node_type_geo_edge_split();
|
||||
register_node_type_geo_transform();
|
||||
|
@@ -3141,6 +3141,21 @@ static void node_texture_set_butfunc(bNodeType *ntype)
|
||||
|
||||
/* ****************** BUTTON CALLBACKS FOR GEOMETRY NODES ***************** */
|
||||
|
||||
static void node_geometry_buts_attribute_math(uiLayout *layout,
|
||||
bContext *UNUSED(C),
|
||||
PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_geometry_buts_attribute_random(uiLayout *layout,
|
||||
bContext *UNUSED(C),
|
||||
PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "data_type", DEFAULT_FLAGS, "", ICON_NONE);
|
||||
uiItemR(layout, ptr, "domain", DEFAULT_FLAGS, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_geometry_buts_boolean_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
|
||||
@@ -3166,6 +3181,12 @@ static void node_geometry_buts_triangulate(uiLayout *layout, bContext *UNUSED(C)
|
||||
static void node_geometry_set_butfunc(bNodeType *ntype)
|
||||
{
|
||||
switch (ntype->type) {
|
||||
case GEO_NODE_ATTRIBUTE_MATH:
|
||||
ntype->draw_buttons = node_geometry_buts_attribute_math;
|
||||
break;
|
||||
case GEO_NODE_ATTRIBUTE_RANDOM:
|
||||
ntype->draw_buttons = node_geometry_buts_attribute_random;
|
||||
break;
|
||||
case GEO_NODE_BOOLEAN:
|
||||
ntype->draw_buttons = node_geometry_buts_boolean_math;
|
||||
break;
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_customdata_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
@@ -36,6 +37,7 @@
|
||||
#include "DNA_texture_types.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_attribute.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_texture.h"
|
||||
@@ -8238,6 +8240,42 @@ static void def_geo_boolean(StructRNA *srna)
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_geo_attribute_create_common(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "custom1");
|
||||
RNA_def_property_enum_items(prop, rna_enum_attribute_type_items);
|
||||
RNA_def_property_enum_default(prop, CD_PROP_FLOAT);
|
||||
RNA_def_property_ui_text(prop, "Data Type", "Type of data stored in attribute");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "domain", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "custom2");
|
||||
RNA_def_property_enum_items(prop, rna_enum_attribute_domain_items);
|
||||
RNA_def_property_enum_default(prop, ATTR_DOMAIN_VERTEX);
|
||||
RNA_def_property_ui_text(prop, "Domain", "");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_geo_attribute_math(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "custom1");
|
||||
RNA_def_property_enum_items(prop, rna_enum_node_vec_math_items);
|
||||
RNA_def_property_enum_default(prop, NODE_VECTOR_MATH_ADD);
|
||||
RNA_def_property_ui_text(prop, "Operation", "");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
static void def_geo_attribute_random(StructRNA *srna)
|
||||
{
|
||||
def_geo_attribute_create_common(srna);
|
||||
}
|
||||
|
||||
static void def_geo_triangulate(StructRNA *srna)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
@@ -138,6 +138,8 @@ set(SRC
|
||||
function/nodes/node_fn_switch.cc
|
||||
function/node_function_util.cc
|
||||
|
||||
geometry/nodes/node_geo_attribute_math.cc
|
||||
geometry/nodes/node_geo_attribute_random.cc
|
||||
geometry/nodes/node_geo_common.cc
|
||||
geometry/nodes/node_geo_boolean.cc
|
||||
geometry/nodes/node_geo_edge_split.cc
|
||||
|
@@ -26,6 +26,8 @@ void register_node_tree_type_geo(void);
|
||||
|
||||
void register_node_type_geo_group(void);
|
||||
|
||||
void register_node_type_geo_attribute_math(void);
|
||||
void register_node_type_geo_attribute_random(void);
|
||||
void register_node_type_geo_boolean(void);
|
||||
void register_node_type_geo_edge_split(void);
|
||||
void register_node_type_geo_transform(void);
|
||||
|
@@ -274,6 +274,9 @@ DefNode(GeometryNode, GEO_NODE_BOOLEAN, def_geo_boolean, "BOOLEAN", Boolean, "Bo
|
||||
DefNode(GeometryNode, GEO_NODE_POINT_DISTRIBUTE, 0, "POINT_DISTRIBUTE", PointDistribute, "Point Distribute", "")
|
||||
DefNode(GeometryNode, GEO_NODE_POINT_INSTANCE, 0, "POINT_INSTANCE", PointInstance, "Point Instance", "")
|
||||
DefNode(GeometryNode, GEO_NODE_OBJECT_INFO, 0, "OBJECT_INFO", ObjectInfo, "Object Info", "")
|
||||
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_RANDOM, def_geo_attribute_random, "ATTRIBUTE_RANDOM", RandomAttribute, "Random Attribute", "")
|
||||
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_MATH, def_geo_attribute_math, "ATTRIBUTE_MATH", AttributeMath, "Attribute Math", "")
|
||||
|
||||
|
||||
/* undefine macros */
|
||||
#undef DefNode
|
||||
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BKE_attribute.h"
|
||||
|
||||
#include "node_geometry_util.hh"
|
||||
|
||||
static bNodeSocketTemplate geo_node_attribute_math_in[] = {
|
||||
{SOCK_GEOMETRY, N_("Geometry")},
|
||||
{SOCK_STRING, N_("Attribute A")},
|
||||
{SOCK_STRING, N_("Attribute B")},
|
||||
{-1, ""},
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate geo_node_attribute_math_out[] = {
|
||||
{SOCK_GEOMETRY, N_("Geometry")},
|
||||
{-1, ""},
|
||||
};
|
||||
|
||||
namespace blender::nodes {
|
||||
static void geo_attribute_math_exec(GeoNodeExecParams params)
|
||||
{
|
||||
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry A");
|
||||
std::string attribute_name_a = params.extract_input<std::string>("Attribute A");
|
||||
std::string attribute_name_b = params.extract_input<std::string>("Attribute B");
|
||||
|
||||
if (geometry_set.has_mesh()) {
|
||||
Mesh *mesh = geometry_set.get_mesh_for_write();
|
||||
}
|
||||
|
||||
if (geometry_set.has_pointcloud()) {
|
||||
PointCloud *point_cloud = geometry_set.get_pointcloud_for_write();
|
||||
}
|
||||
|
||||
params.set_output("Geometry", std::move(geometry_set));
|
||||
}
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_geo_attribute_math()
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_MATH, "Attribute Math", 0, 0);
|
||||
node_type_socket_templates(&ntype, geo_node_attribute_math_in, geo_node_attribute_math_out);
|
||||
ntype.geometry_node_execute = blender::nodes::geo_attribute_math_exec;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "BLI_rand.hh"
|
||||
|
||||
#include "DNA_customdata_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BKE_attribute.h"
|
||||
|
||||
#include "node_geometry_util.hh"
|
||||
|
||||
static bNodeSocketTemplate geo_node_attribute_random_in[] = {
|
||||
{SOCK_GEOMETRY, N_("Geometry")},
|
||||
{SOCK_STRING, N_("Attribute")},
|
||||
{-1, ""},
|
||||
};
|
||||
|
||||
static bNodeSocketTemplate geo_node_attribute_random_out[] = {
|
||||
{SOCK_GEOMETRY, N_("Geometry")},
|
||||
{-1, ""},
|
||||
};
|
||||
|
||||
static void geo_attribute_random_init(bNodeTree *UNUSED(tree), bNode *node)
|
||||
{
|
||||
node->custom1 = CD_PROP_FLOAT;
|
||||
}
|
||||
|
||||
namespace blender::nodes {
|
||||
static void geo_attribute_random_exec(GeoNodeExecParams params)
|
||||
{
|
||||
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
|
||||
std::string attribute_name = params.extract_input<std::string>("Attribute");
|
||||
|
||||
RandomNumberGenerator rng(0);
|
||||
CustomDataType data_type = static_cast<CustomDataType>(params.node().custom1);
|
||||
AttributeDomain domain = static_cast<AttributeDomain>(params.node().custom2);
|
||||
|
||||
if (geometry_set.has_mesh()) {
|
||||
Mesh *mesh = geometry_set.get_mesh_for_write();
|
||||
}
|
||||
|
||||
if (geometry_set.has_pointcloud()) {
|
||||
PointCloud *point_cloud = geometry_set.get_pointcloud_for_write();
|
||||
}
|
||||
|
||||
params.set_output("Geometry", std::move(geometry_set));
|
||||
}
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_geo_attribute_random()
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_RANDOM, "Random Attribute", 0, 0);
|
||||
node_type_socket_templates(&ntype, geo_node_attribute_random_in, geo_node_attribute_random_out);
|
||||
node_type_init(&ntype, geo_attribute_random_init);
|
||||
ntype.geometry_node_execute = blender::nodes::geo_attribute_random_exec;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
Reference in New Issue
Block a user