Differential D10109 Diff 32776 source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_align_rotation_to_vector.cc
| Show All 35 Lines | |||||
| static void align_rotations_on_component(GeometryComponent &component, | static void align_rotations_on_component(GeometryComponent &component, | ||||
| const GeoNodeExecParams ¶ms) | const GeoNodeExecParams ¶ms) | ||||
| { | { | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const NodeGeometryAlignRotationToVector &storage = *(const NodeGeometryAlignRotationToVector *) | const NodeGeometryAlignRotationToVector &storage = *(const NodeGeometryAlignRotationToVector *) | ||||
| node.storage; | node.storage; | ||||
| WriteAttributePtr rotation_attribute = component.attribute_try_ensure_for_write( | OutputAttributePtr rotation_attribute = component.attribute_try_get_for_output( | ||||
| "rotation", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); | "rotation", ATTR_DOMAIN_POINT, CD_PROP_FLOAT3); | ||||
| if (!rotation_attribute) { | if (!rotation_attribute) { | ||||
| return; | return; | ||||
| } | } | ||||
| MutableSpan<float3> rotations = rotation_attribute->get_span().typed<float3>(); | MutableSpan<float3> rotations = rotation_attribute->get_span<float3>(); | ||||
| FloatReadAttribute factors = params.get_input_attribute<float>( | FloatReadAttribute factors = params.get_input_attribute<float>( | ||||
| "Factor", component, ATTR_DOMAIN_POINT, 1.0f); | "Factor", component, ATTR_DOMAIN_POINT, 1.0f); | ||||
| Float3ReadAttribute vectors = params.get_input_attribute<float3>( | Float3ReadAttribute vectors = params.get_input_attribute<float3>( | ||||
| "Vector", component, ATTR_DOMAIN_POINT, {0, 0, 1}); | "Vector", component, ATTR_DOMAIN_POINT, {0, 0, 1}); | ||||
| float3 main_axis{0, 0, 0}; | float3 main_axis{0, 0, 0}; | ||||
| main_axis[storage.axis] = 1; | main_axis[storage.axis] = 1; | ||||
| Show All 22 Lines | for (const int i : IndexRange(domain_size)) { | ||||
| mul_m3_m3m3(new_rotation_matrix, rotation, old_rotation); | mul_m3_m3m3(new_rotation_matrix, rotation, old_rotation); | ||||
| float3 new_rotation; | float3 new_rotation; | ||||
| mat3_to_eul(new_rotation, new_rotation_matrix); | mat3_to_eul(new_rotation, new_rotation_matrix); | ||||
| rotations[i] = new_rotation; | rotations[i] = new_rotation; | ||||
| } | } | ||||
| rotation_attribute->apply_span(); | rotation_attribute.apply_span_and_save(); | ||||
| } | } | ||||
| static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) | static void geo_node_align_rotation_to_vector_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); | align_rotations_on_component(geometry_set.get_component_for_write<MeshComponent>(), params); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||