Fix snap to the ground to use scene graph query instead of physics only raycast
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using FlaxEditor.Gizmo;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEditor.Tools.Foliage.Undo;
|
||||
using FlaxEngine;
|
||||
|
||||
@@ -87,6 +88,12 @@ namespace FlaxEditor.Tools.Foliage
|
||||
navigationDirty = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool IsSelected(SceneGraphNode obj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnStartTransforming()
|
||||
{
|
||||
@@ -231,6 +238,21 @@ namespace FlaxEditor.Tools.Foliage
|
||||
Owner.Undo?.AddAction(action);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SnapToGround()
|
||||
{
|
||||
if (Physics.RayCast(Position, Vector3.Down, out var hit, float.MaxValue, uint.MaxValue, false))
|
||||
{
|
||||
// Snap
|
||||
StartTransforming();
|
||||
var translationDelta = hit.Point - Position;
|
||||
var rotationDelta = Quaternion.Identity;
|
||||
var scaleDelta = Vector3.Zero;
|
||||
OnApplyTransformation(ref translationDelta, ref rotationDelta, ref scaleDelta);
|
||||
EndTransforming();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnActivated()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user