forked from blender/blender
Allow "Instance on Points" node to instance on physics component #2
@ -135,6 +135,7 @@ typedef enum GeometryNodeDefaultInputType {
|
|||||||
GEO_NODE_DEFAULT_FIELD_INPUT_NORMAL_FIELD = 3,
|
GEO_NODE_DEFAULT_FIELD_INPUT_NORMAL_FIELD = 3,
|
||||||
GEO_NODE_DEFAULT_FIELD_INPUT_POSITION_FIELD = 4,
|
GEO_NODE_DEFAULT_FIELD_INPUT_POSITION_FIELD = 4,
|
||||||
GEO_NODE_DEFAULT_FIELD_INPUT_INSTANCE_TRANSFORM_FIELD = 5,
|
GEO_NODE_DEFAULT_FIELD_INPUT_INSTANCE_TRANSFORM_FIELD = 5,
|
||||||
|
GEO_NODE_DEFAULT_FIELD_INPUT_ROTATION_FIELD = 6,
|
||||||
} GeometryNodeDefaultInputType;
|
} GeometryNodeDefaultInputType;
|
||||||
|
|
||||||
typedef struct bNodeTreeInterfacePanel {
|
typedef struct bNodeTreeInterfacePanel {
|
||||||
|
@ -456,6 +456,14 @@ static const EnumPropertyItem *rna_NodeTreeInterfaceSocket_default_input_itemf(
|
|||||||
N_("Transformation of each instance from the geometry context")};
|
N_("Transformation of each instance from the geometry context")};
|
||||||
RNA_enum_item_add(&items, &items_count, &instance_transform);
|
RNA_enum_item_add(&items, &items_count, &instance_transform);
|
||||||
}
|
}
|
||||||
|
else if (type->type == SOCK_ROTATION) {
|
||||||
|
const EnumPropertyItem rotation{GEO_NODE_DEFAULT_FIELD_INPUT_ROTATION_FIELD,
|
||||||
|
"ROTATION",
|
||||||
|
0,
|
||||||
|
N_("Rotation"),
|
||||||
|
N_("The rotation from the context")};
|
||||||
|
RNA_enum_item_add(&items, &items_count, &rotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RNA_enum_item_end(&items, &items_count);
|
RNA_enum_item_end(&items, &items_count);
|
||||||
|
@ -602,6 +602,7 @@ void normal(const bNode &node, void *r_value);
|
|||||||
void index(const bNode &node, void *r_value);
|
void index(const bNode &node, void *r_value);
|
||||||
void id_or_index(const bNode &node, void *r_value);
|
void id_or_index(const bNode &node, void *r_value);
|
||||||
void instance_transform(const bNode &node, void *r_value);
|
void instance_transform(const bNode &node, void *r_value);
|
||||||
|
void rotation(const bNode &node, void *r_value);
|
||||||
} // namespace implicit_field_inputs
|
} // namespace implicit_field_inputs
|
||||||
|
|
||||||
void build_node_declaration(const bke::bNodeType &typeinfo,
|
void build_node_declaration(const bke::bNodeType &typeinfo,
|
||||||
|
@ -31,7 +31,9 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||||||
.description(
|
.description(
|
||||||
"Index of the instance used for each point. This is only used when Pick Instances "
|
"Index of the instance used for each point. This is only used when Pick Instances "
|
||||||
"is on. By default the point index is used");
|
"is on. By default the point index is used");
|
||||||
b.add_input<decl::Rotation>("Rotation").field_on({0}).description("Rotation of the instances");
|
b.add_input<decl::Rotation>("Rotation")
|
||||||
|
.implicit_field_on(implicit_field_inputs::rotation, {0})
|
||||||
|
.description("Rotation of the instances");
|
||||||
b.add_input<decl::Vector>("Scale")
|
b.add_input<decl::Vector>("Scale")
|
||||||
.default_value({1.0f, 1.0f, 1.0f})
|
.default_value({1.0f, 1.0f, 1.0f})
|
||||||
.subtype(PROP_XYZ)
|
.subtype(PROP_XYZ)
|
||||||
@ -200,7 +202,8 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||||||
|
|
||||||
const Array<GeometryComponent::Type> types{GeometryComponent::Type::Mesh,
|
const Array<GeometryComponent::Type> types{GeometryComponent::Type::Mesh,
|
||||||
GeometryComponent::Type::PointCloud,
|
GeometryComponent::Type::PointCloud,
|
||||||
GeometryComponent::Type::Curve};
|
GeometryComponent::Type::Curve,
|
||||||
|
GeometryComponent::Type::Physics};
|
||||||
|
|
||||||
Map<AttributeIDRef, AttributeKind> attributes_to_propagate;
|
Map<AttributeIDRef, AttributeKind> attributes_to_propagate;
|
||||||
geometry_set.gather_attributes_for_propagation(types,
|
geometry_set.gather_attributes_for_propagation(types,
|
||||||
|
@ -457,6 +457,11 @@ static void set_default_input_field(const bNodeTreeInterfaceSocket &input, Socke
|
|||||||
implicit_field_inputs::instance_transform);
|
implicit_field_inputs::instance_transform);
|
||||||
decl.hide_value = true;
|
decl.hide_value = true;
|
||||||
}
|
}
|
||||||
|
else if (decl.socket_type == SOCK_ROTATION) {
|
||||||
|
decl.implicit_input_fn = std::make_unique<ImplicitInputValueFn>(
|
||||||
|
implicit_field_inputs::rotation);
|
||||||
|
decl.hide_value = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void node_group_declare(NodeDeclarationBuilder &b)
|
void node_group_declare(NodeDeclarationBuilder &b)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "NOD_socket_declarations.hh"
|
#include "NOD_socket_declarations.hh"
|
||||||
#include "NOD_socket_declarations_geometry.hh"
|
#include "NOD_socket_declarations_geometry.hh"
|
||||||
|
|
||||||
|
#include "BLI_math_quaternion_types.hh"
|
||||||
#include "BLI_stack.hh"
|
#include "BLI_stack.hh"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
@ -870,6 +871,12 @@ void instance_transform(const bNode & /*node*/, void *r_value)
|
|||||||
bke::SocketValueVariant(bke::AttributeFieldInput::Create<float4x4>("instance_transform"));
|
bke::SocketValueVariant(bke::AttributeFieldInput::Create<float4x4>("instance_transform"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rotation(const bNode & /*node*/, void *r_value)
|
||||||
filedescriptor marked this conversation as resolved
|
|||||||
|
{
|
||||||
|
new (r_value)
|
||||||
|
bke::SocketValueVariant(bke::AttributeFieldInput::Create<math::Quaternion>("rotation"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace implicit_field_inputs
|
} // namespace implicit_field_inputs
|
||||||
|
|
||||||
} // namespace blender::nodes
|
} // namespace blender::nodes
|
||||||
|
Loading…
Reference in New Issue
Block a user
If you're adding a new implicit field input it should probably also be supported in node groups.
GeometryNodeDefaultInputType
enumrna_NodeTreeInterfaceSocket_default_input_itemf
set_default_input_field
in `node_common.cc