godotengine / godotengine/godot

The scale gizmo can flip meshes inside out when scaling them up

Open
#106,547 1 comment 0 reactions 0 assignees View on GitHub
bug discussion needs testing topic:core topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in 4.3 stable and current master on Linux and Windows.

### System information

Godot v4.3.stable (77dcf97d8) - Linux Mint 22.1 (Xia) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 Ti (nvidia; 570.133.07) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)

### Issue description

The scale gizmo doesn't account for rotation properly. Obviously it can't be perfect, but I think it's reasonable to expect that scaling an object up will only increase the individual scale values and scaling it down will only decrease the scale values. It seems to be an issue [with this code](https://github.com/godotengine/godot/blob/master/core/math/basis.cpp#L274-L276).

Replacing that code with
```
for (int i = 0 ; i < 3; i++) {
if (std::signbit(dots[i]) != sign) {
dots[i] *= -1;
}
}
```
seems to fix the issue, but I'm not confident that that's actually the correct choice and that there isn't something in the earlier math that should be fixed instead.

Here's an example of the issue:

https://youtu.be/fQt9rtvfg1s

Every object that's been rotated on one axis has one axis where scaling it up will invert the object. If an object has been rotated on multiple axes, it will have multiple axes that cause inversion when scaled, as well.

### Steps to reproduce

Use the scale tool to scale up any object that's been rotated. Observe that at least one axis causes the mesh to flip inside out while scaling up.

### Minimal reproduction project (MRP)

[selection.zip](https://github.com/user-attachments/files/20271421/selection.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the linked code in core/math/basis.cpp around lines 274-276 and reproduce the problem using the scale tool on a rotated object. Compare the current sign handling with the proposed replacement and inspect the supplied selection.zip project. Done means scaling rotated meshes no longer flips them inside out while preserving expected scale-direction behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.