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
This commit is contained in:
Hans Goudey
2024-01-10 17:35:53 +01:00
committed by Hans Goudey
parent ae1e127f92
commit 66dc0ebf2e
3 changed files with 7 additions and 8 deletions

View File

@@ -266,7 +266,7 @@ std::unique_ptr<ColumnValues> GeometryDataSource::get_column_values(
if (STREQ(column_id.name, "Scale")) {
return std::make_unique<ColumnValues>(
column_id.name, VArray<float3>::ForFunc(domain_num, [transforms](int64_t index) {
return math::to_scale(transforms[index]);
return math::to_scale<true>(transforms[index]);
}));
}
}

View File

@@ -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<float3>::ForFunc(instances.instances_num(), scale_fn);
const Span<float4x4> transforms = instances.transforms();
return VArray<float3>::ForFunc(instances.instances_num(), [transforms](const int i) {
return math::to_scale<true>(transforms[i]);
});
}
uint64_t hash() const override

View File

@@ -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<true>(transform, location, rotation, scale);
}
else {
math::to_loc_rot_scale(object_matrix, location, rotation, scale);
math::to_loc_rot_scale<true>(object_matrix, location, rotation, scale);
}
params.set_output("Location", location);
params.set_output("Rotation", rotation);