Merge branch 'Zode-absolutesnap'

This commit is contained in:
Wojtek Figat
2025-04-15 22:25:32 +02:00

View File

@@ -42,7 +42,6 @@ namespace FlaxEditor.Gizmo
private Vector3 _intersectPosition; private Vector3 _intersectPosition;
private bool _isActive; private bool _isActive;
private bool _isDuplicating; private bool _isDuplicating;
private bool _hasAbsoluteSnapped;
private bool _isTransforming; private bool _isTransforming;
private bool _isSelected; private bool _isSelected;
@@ -390,10 +389,9 @@ namespace FlaxEditor.Gizmo
} }
Vector3 absoluteDelta = Vector3.Zero; Vector3 absoluteDelta = Vector3.Zero;
if (!_hasAbsoluteSnapped && AbsoluteSnapEnabled && ActiveTransformSpace == TransformSpace.World) if (AbsoluteSnapEnabled && ActiveTransformSpace == TransformSpace.World)
{ {
// Remove delta to offset local-space grid into the world-space grid // Remove delta to offset local-space grid into the world-space grid
_hasAbsoluteSnapped = true;
Vector3 currentTranslationScale = isScaling ? GetSelectedTransform(0).Scale : GetSelectedTransform(0).Translation; Vector3 currentTranslationScale = isScaling ? GetSelectedTransform(0).Scale : GetSelectedTransform(0).Translation;
absoluteDelta = currentTranslationScale - new Vector3( absoluteDelta = currentTranslationScale - new Vector3(
Mathr.Round(currentTranslationScale.X / snapValue.X) * snapValue.X, Mathr.Round(currentTranslationScale.X / snapValue.X) * snapValue.X,
@@ -408,10 +406,6 @@ namespace FlaxEditor.Gizmo
_translationScaleSnapDelta -= delta; _translationScaleSnapDelta -= delta;
delta -= absoluteDelta; delta -= absoluteDelta;
} }
else
{
_hasAbsoluteSnapped = false;
}
if (_activeMode == Mode.Translate) if (_activeMode == Mode.Translate)
{ {
@@ -442,10 +436,9 @@ namespace FlaxEditor.Gizmo
float snapValue = RotationSnapValue * Mathf.DegreesToRadians; float snapValue = RotationSnapValue * Mathf.DegreesToRadians;
float absoluteDelta = 0.0f; float absoluteDelta = 0.0f;
if (!_hasAbsoluteSnapped && AbsoluteSnapEnabled && ActiveTransformSpace == TransformSpace.World) if (AbsoluteSnapEnabled && ActiveTransformSpace == TransformSpace.World)
{ {
// Remove delta to offset world-space grid into the local-space grid // Remove delta to offset world-space grid into the local-space grid
_hasAbsoluteSnapped = true;
float currentAngle = 0.0f; float currentAngle = 0.0f;
switch (_activeAxis) switch (_activeAxis)
{ {
@@ -464,10 +457,6 @@ namespace FlaxEditor.Gizmo
delta = snapped; delta = snapped;
delta -= absoluteDelta * Mathf.DegreesToRadians; delta -= absoluteDelta * Mathf.DegreesToRadians;
} }
else
{
_hasAbsoluteSnapped = false;
}
switch (_activeAxis) switch (_activeAxis)
{ {