Optimize and improve ActorChildNodes handling
This commit is contained in:
@@ -19,6 +19,11 @@ namespace FlaxEditor.SceneGraph
|
||||
/// </summary>
|
||||
public readonly int Index;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this node can be selected directly without selecting parent actor node first.
|
||||
/// </summary>
|
||||
public virtual bool CanBeSelectedDirectly => false;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActorChildNode"/> class.
|
||||
/// </summary>
|
||||
@@ -66,6 +71,18 @@ namespace FlaxEditor.SceneGraph
|
||||
|
||||
/// <inheritdoc />
|
||||
public override object UndoRecordObject => ParentNode.UndoRecordObject;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
// Unlink from the parent
|
||||
if (parentNode is ActorNode parentActorNode && parentActorNode.ActorChildNodes != null)
|
||||
{
|
||||
parentActorNode.ActorChildNodes.Remove(this);
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace FlaxEditor.SceneGraph
|
||||
/// <summary>
|
||||
/// The actor child nodes used to represent special parts of the actor (meshes, links, surfaces).
|
||||
/// </summary>
|
||||
public readonly List<ActorChildNode> ActorChildNodes = new List<ActorChildNode>();
|
||||
public List<ActorChildNode> ActorChildNodes;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActorNode"/> class.
|
||||
@@ -108,6 +108,8 @@ namespace FlaxEditor.SceneGraph
|
||||
/// <returns>The node</returns>
|
||||
public ActorChildNode AddChildNode(ActorChildNode node)
|
||||
{
|
||||
if (ActorChildNodes == null)
|
||||
ActorChildNodes = new List<ActorChildNode>();
|
||||
ActorChildNodes.Add(node);
|
||||
node.ParentNode = this;
|
||||
return node;
|
||||
@@ -125,9 +127,12 @@ namespace FlaxEditor.SceneGraph
|
||||
root.OnActorChildNodesDispose(this);
|
||||
}
|
||||
|
||||
for (int i = 0; i < ActorChildNodes.Count; i++)
|
||||
ActorChildNodes[i].Dispose();
|
||||
ActorChildNodes.Clear();
|
||||
if (ActorChildNodes != null)
|
||||
{
|
||||
for (int i = 0; i < ActorChildNodes.Count; i++)
|
||||
ActorChildNodes[i].Dispose();
|
||||
ActorChildNodes.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -275,8 +280,12 @@ namespace FlaxEditor.SceneGraph
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
// Cleanup UI
|
||||
_treeNode.Dispose();
|
||||
if (ActorChildNodes != null)
|
||||
{
|
||||
ActorChildNodes.Clear();
|
||||
ActorChildNodes = null;
|
||||
}
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
@@ -78,14 +78,14 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
{
|
||||
get
|
||||
{
|
||||
var actor = (BoxVolume)((BoxVolumeNode)ParentNode).Actor;
|
||||
var actor = (BoxVolume)_actor.Actor;
|
||||
var localOffset = _offset * actor.Size;
|
||||
Transform localTrans = new Transform(localOffset);
|
||||
return actor.Transform.LocalToWorld(localTrans);
|
||||
}
|
||||
set
|
||||
{
|
||||
var actor = (BoxVolume)((BoxVolumeNode)ParentNode).Actor;
|
||||
var actor = (BoxVolume)_actor.Actor;
|
||||
Transform localTrans = actor.Transform.WorldToLocal(value);
|
||||
var prevLocalOffset = _offset * actor.Size;
|
||||
var localOffset = Vector3.Abs(_offset) * 2.0f * localTrans.Translation;
|
||||
|
||||
@@ -37,13 +37,13 @@ namespace FlaxEditor.SceneGraph.Actors
|
||||
{
|
||||
get
|
||||
{
|
||||
var actor = (NavLink)((NavLinkNode)ParentNode).Actor;
|
||||
var actor = (NavLink)_actor.Actor;
|
||||
Transform localTrans = new Transform(_isStart ? actor.Start : actor.End);
|
||||
return actor.Transform.LocalToWorld(localTrans);
|
||||
}
|
||||
set
|
||||
{
|
||||
var actor = (NavLink)((NavLinkNode)ParentNode).Actor;
|
||||
var actor = (NavLink)_actor.Actor;
|
||||
Transform localTrans = actor.Transform.WorldToLocal(value);
|
||||
if (_isStart)
|
||||
actor.Start = localTrans.Translation;
|
||||
|
||||
Reference in New Issue
Block a user