Scale Shift+wheel brush resize geometrically

Replace the fixed additive brush-size step with a fraction of the current
size, so small brushes resize a texel at a time (fine control) while large
ones jump in bigger increments. Always moves at least one texel per notch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-01 22:11:27 +02:00
1 parent ae0e2de7cf
commit 9b9cc8fab8
1 file changed
+8 -3
+8 -3
View File
@@ -204,8 +204,11 @@ public partial class MeshPainter : MonoBehaviour
[Range(1, 256)]
public int brushSize = 16;
[Tooltip("Texels added/removed per mouse-wheel notch while Shift is held (paint mode brush resize).")]
public int brushSizeScrollStep = 4;
[Tooltip("Fraction of the current brush size added/removed per mouse-wheel notch while Shift is held. " +
"The step scales with the size, so small brushes resize slowly (fine control) and large ones " +
"resize faster. Always moves at least one texel per notch.")]
[Range(0.01f, 1f)]
public float brushSizeScrollFactor = 0.15f;
/// <summary>
/// Raised after Shift+wheel changes <see cref="brushSize"/> so the in-game HUD can re-sync its
@@ -1108,7 +1111,9 @@ public partial class MeshPainter : MonoBehaviour
float scroll = ReadScroll();
if (Mathf.Approximately(scroll, 0f)) return;
int step = Mathf.Max(1, brushSizeScrollStep);
// Geometric resize: the step scales with the current size, so small brushes change a texel
// at a time (fine control) while large brushes jump in bigger increments. Min one texel.
int step = Mathf.Max(1, Mathf.RoundToInt(brushSize * brushSizeScrollFactor));
int next = Mathf.Clamp(brushSize + (int)Mathf.Sign(scroll) * step, 1, 256);
if (next == brushSize) return;