Refactor vertex snapping to use SceneGraphNode layer instead of Model-impl only

#2045
This commit is contained in:
Wojtek Figat
2024-02-24 18:38:23 +01:00
parent f771b0cd59
commit 1dfc8b0a47
4 changed files with 130 additions and 95 deletions

View File

@@ -94,6 +94,18 @@ namespace FlaxEditor.SceneGraph
/// </summary>
public virtual bool CanTransform => true;
/// <summary>
/// Gets a value indicating whether this node can be used for the vertex snapping feature.
/// </summary>
public bool CanVertexSnap
{
get
{
var v = Vector3.Zero;
return OnVertexSnap(ref v, out _);
}
}
/// <summary>
/// Gets a value indicating whether this <see cref="SceneGraphNode"/> is active.
/// </summary>
@@ -359,6 +371,18 @@ namespace FlaxEditor.SceneGraph
}
}
/// <summary>
/// Performs the vertex snapping of a given point on the object surface that is closest to a given location.
/// </summary>
/// <param name="point">The position to snap.</param>
/// <param name="result">The result point on the object mesh that is closest to the specified location.</param>
/// <returns>True if got a valid result value, otherwise false (eg. if missing data or not initialized).</returns>
public virtual bool OnVertexSnap(ref Vector3 point, out Vector3 result)
{
result = point;
return false;
}
/// <summary>
/// Called when selected nodes should draw debug shapes using <see cref="DebugDraw"/> interface.
/// </summary>