Geometry Nodes: Change Instance Rotation node to use rotation socket

See #92967. Since the versioning is idempotent, I just moved it to the
latest subversion bump again.
This commit is contained in:
Hans Goudey
2023-12-12 12:25:51 -05:00
parent c00c8b1b37
commit a6838c8a12
2 changed files with 20 additions and 14 deletions

View File

@@ -1382,7 +1382,11 @@ static void version_geometry_nodes_use_rotation_socket(bNodeTree &ntree)
bNodeSocket *socket = nodeFindSocket(node, SOCK_IN, "Rotation");
change_input_socket_to_rotation_type(ntree, *node, *socket);
}
if (STR_ELEM(node->idname, "GeometryNodeDistributePointsOnFaces", "GeometryNodeObjectInfo")) {
if (STR_ELEM(node->idname,
"GeometryNodeDistributePointsOnFaces",
"GeometryNodeObjectInfo",
"GeometryNodeInputInstanceRotation"))
{
bNodeSocket *socket = nodeFindSocket(node, SOCK_OUT, "Rotation");
change_output_socket_to_rotation_type(ntree, *node, *socket);
}
@@ -2503,12 +2507,6 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 401, 9)) {
LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
if (ntree->type == NTREE_GEOMETRY) {
version_geometry_nodes_use_rotation_socket(*ntree);
}
}
if (!DNA_struct_member_exists(fd->filesdna, "Material", "char", "displacement_method")) {
/* Replace Cycles.displacement_method by Material::displacement_method. */
LISTBASE_FOREACH (Material *, material, &bmain->materials) {
@@ -2576,6 +2574,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
scene->eevee.ray_tracing_options.resolution_scale = 2;
}
}
LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
if (ntree->type == NTREE_GEOMETRY) {
version_geometry_nodes_use_rotation_socket(*ntree);
}
}
}
/* Always run this versioning; meshes are written with the legacy format which always needs to

View File

@@ -12,21 +12,23 @@ namespace blender::nodes::node_geo_input_instance_rotation_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_output<decl::Vector>("Rotation").field_source();
b.add_output<decl::Rotation>("Rotation").field_source();
}
class InstanceRotationFieldInput final : public bke::InstancesFieldInput {
public:
InstanceRotationFieldInput() : bke::InstancesFieldInput(CPPType::get<float3>(), "Rotation") {}
InstanceRotationFieldInput()
: bke::InstancesFieldInput(CPPType::get<math::Quaternion>(), "Rotation")
{
}
GVArray get_varray_for_context(const bke::Instances &instances,
const IndexMask & /*mask*/) const final
{
auto rotation_fn = [&](const int i) -> float3 {
return float3(math::to_euler(math::normalize(instances.transforms()[i])));
};
return VArray<float3>::ForFunc(instances.instances_num(), rotation_fn);
const Span<float4x4> transforms = instances.transforms();
return VArray<math::Quaternion>::ForFunc(instances.instances_num(), [transforms](const int i) {
return math::to_quaternion(math::normalize(transforms[i]));
});
}
uint64_t hash() const override