vertex snapping refactor corrections

This commit is contained in:
Norite SC
2024-03-04 19:15:15 +01:00
parent 508c07c5ea
commit 33bd6a56ce
4 changed files with 32 additions and 52 deletions

View File

@@ -23,20 +23,23 @@ namespace FlaxEditor.SceneGraph.Actors
: base(actor)
{
}
/// <inheritdoc />
public override bool OnVertexSnap(ref Vector3 point, out Vector3 result)
public override bool OnVertexSnap(ref Ray ray, float hitDistance, out Vector3 result)
{
result = point;
// Find the closest vertex to bounding box point (collision detection approximation)
result = ray.GetPoint(hitDistance);
var model = ((StaticModel)Actor).Model;
if (model && !model.WaitForLoaded())
{
// TODO: move to C++ and use cached vertex buffer internally inside the Mesh
if (_vertices == null)
_vertices = new();
var pointLocal = (Float3)Actor.Transform.WorldToLocal(point);
var pointLocal = (Float3)Actor.Transform.WorldToLocal(result);
var minDistance = float.MaxValue;
foreach (var lod in model.LODs)
foreach (var lod in model.LODs) //[ToDo] fix it [Nori_SC note] this is wrong it should get current lod level going it throw all lods will create ghost snaping points
{
var hit = false;
foreach (var mesh in lod.Meshes)