Geometry Nodes: new Axes to Rotation node #104416
|
@ -1619,8 +1619,6 @@ typedef struct NodeShaderMix {
|
|||
typedef struct NodeFunctionAxisToEuler {
|
||||
int8_t primary_axis;
|
||||
int8_t secondary_axis;
|
||||
int8_t legacy_distribute_node_behavior;
|
||||
char _pad;
|
||||
} NodeFunctionAxisToEuler;
|
||||
|
||||
/* script node mode */
|
||||
|
|
|
@ -9924,13 +9924,6 @@ static void def_fn_axis_to_euler(StructRNA *srna)
|
|||
"Secondary Axis",
|
||||
"Axis that is aligned as good as possible given the alignment of the primary axis");
|
||||
JacquesLucke marked this conversation as resolved
Outdated
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "legacy_distribute_node_behavior", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Legacy Distribute Node Behavior",
|
||||
"Use the exact behavior that the distribute points on faces node used to compute rotations");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
|
||||
}
|
||||
|
||||
static void def_geo_object_info(StructRNA *srna)
|
||||
|
|
|
@ -34,30 +34,12 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
|||
{
|
||||
const bNode &node = *static_cast<const bNode *>(ptr->data);
|
||||
const NodeFunctionAxisToEuler &storage = node_storage(node);
|
||||
if (storage.legacy_distribute_node_behavior) {
|
||||
uiItemR(layout, ptr, "legacy_distribute_node_behavior", 0, "Legacy Behavior", ICON_NONE);
|
||||
uiItemR(layout, ptr, "primary_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "secondary_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
|
||||
if (storage.primary_axis == storage.secondary_axis) {
|
||||
uiItemL(layout, N_("Must not be equal"), ICON_ERROR);
|
||||
JacquesLucke marked this conversation as resolved
Outdated
Hans Goudey
commented
Just reads a bit better IMO `Must not be equal` -> `Axes must not be equal`
Just reads a bit better IMO
|
||||
}
|
||||
else {
|
||||
uiItemR(layout, ptr, "primary_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "secondary_axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
|
||||
if (storage.primary_axis == storage.secondary_axis) {
|
||||
uiItemL(layout, N_("Must not be equal"), ICON_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void node_layout_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "legacy_distribute_node_behavior", 0, "Legacy Behavior", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_update(bNodeTree *tree, bNode *node)
|
||||
{
|
||||
const NodeFunctionAxisToEuler &storage = node_storage(*node);
|
||||
bNodeSocket *primary_axis_socket = static_cast<bNodeSocket *>(node->inputs.first);
|
||||
bNodeSocket *secondary_axis_socket = primary_axis_socket->next;
|
||||
nodeSetSocketAvailability(tree, secondary_axis_socket, !storage.legacy_distribute_node_behavior);
|
||||
}
|
||||
|
||||
static float3 get_orthogonal_of_non_zero_vector(const float3 &v)
|
||||
|
@ -159,19 +141,6 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
|
|||
{
|
||||
const bNode &node = builder.node();
|
||||
const NodeFunctionAxisToEuler &storage = node_storage(node);
|
||||
if (storage.legacy_distribute_node_behavior) {
|
||||
static const auto fn = mf::build::SI1_SO<float3, float3>(
|
||||
"Axis to Euler (Legacy)", [](const float3 &axis) {
|
||||
float quat[4];
|
||||
vec_to_quat(quat, axis, OB_NEGZ, OB_POSY);
|
||||
float3 rotation;
|
||||
quat_to_eul(rotation, quat);
|
||||
return rotation;
|
||||
});
|
||||
builder.set_matching_fn(fn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (storage.primary_axis == storage.secondary_axis) {
|
||||
return;
|
||||
}
|
||||
|
@ -190,10 +159,8 @@ void register_node_type_fn_axis_to_euler()
|
|||
fn_node_type_base(&ntype, FN_NODE_AXIS_TO_EULER, "Axis to Euler", NODE_CLASS_CONVERTER);
|
||||
ntype.declare = file_ns::node_declare;
|
||||
ntype.initfunc = file_ns::node_init;
|
||||
ntype.updatefunc = file_ns::node_update;
|
||||
ntype.build_multi_function = file_ns::node_build_multi_function;
|
||||
ntype.draw_buttons = file_ns::node_layout;
|
||||
ntype.draw_buttons_ex = file_ns::node_layout_ex;
|
||||
node_type_storage(
|
||||
&ntype, "NodeFunctionAxisToEuler", node_free_standard_storage, node_copy_standard_storage);
|
||||
nodeRegisterType(&ntype);
|
||||
|
|
Loading…
Reference in New Issue
as good
->as well