From 66dc0ebf2eb7e572991dc32d5cbab56b9d2f571f Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 10 Jan 2024 17:35:53 +0100 Subject: [PATCH] Fix #104926: Object Info node doesn't give negative scale The previous behavior was giving a completely negated scale if any of the object's original scale values was negative. Restore that behavior here. Pull Request: https://projects.blender.org/blender/blender/pulls/116989 --- .../spreadsheet_data_source_geometry.cc | 2 +- .../geometry/nodes/node_geo_input_instance_scale.cc | 9 ++++----- .../blender/nodes/geometry/nodes/node_geo_object_info.cc | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc index ad543c0b639..f6d11876042 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc @@ -266,7 +266,7 @@ std::unique_ptr GeometryDataSource::get_column_values( if (STREQ(column_id.name, "Scale")) { return std::make_unique( column_id.name, VArray::ForFunc(domain_num, [transforms](int64_t index) { - return math::to_scale(transforms[index]); + return math::to_scale(transforms[index]); })); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_instance_scale.cc b/source/blender/nodes/geometry/nodes/node_geo_input_instance_scale.cc index ff66afb53fc..5f59aaefae2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_instance_scale.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_instance_scale.cc @@ -22,11 +22,10 @@ class InstanceScaleFieldInput final : public bke::InstancesFieldInput { GVArray get_varray_for_context(const bke::Instances &instances, const IndexMask & /*mask*/) const final { - auto scale_fn = [&](const int i) -> float3 { - return math::to_scale(instances.transforms()[i]); - }; - - return VArray::ForFunc(instances.instances_num(), scale_fn); + const Span transforms = instances.transforms(); + return VArray::ForFunc(instances.instances_num(), [transforms](const int i) { + return math::to_scale(transforms[i]); + }); } uint64_t hash() const override diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index 8cc79129c7f..7625774e276 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -58,10 +58,10 @@ static void node_geo_exec(GeoNodeExecParams params) float3 location, scale; math::Quaternion rotation; if (transform_space_relative) { - math::to_loc_rot_scale(transform, location, rotation, scale); + math::to_loc_rot_scale(transform, location, rotation, scale); } else { - math::to_loc_rot_scale(object_matrix, location, rotation, scale); + math::to_loc_rot_scale(object_matrix, location, rotation, scale); } params.set_output("Location", location); params.set_output("Rotation", rotation);