diff --git a/Source/Editor/SceneGraph/ActorNode.cs b/Source/Editor/SceneGraph/ActorNode.cs
index 318d8379b..9543c8d58 100644
--- a/Source/Editor/SceneGraph/ActorNode.cs
+++ b/Source/Editor/SceneGraph/ActorNode.cs
@@ -263,6 +263,12 @@ namespace FlaxEditor.SceneGraph
return _actor.IntersectsItself(ray.Ray, out distance, out normal);
}
+ ///
+ public override void GetEditorSphere(out BoundingSphere sphere)
+ {
+ Editor.GetActorEditorSphere(_actor, out sphere);
+ }
+
///
public override void OnDebugDraw(ViewportDebugDrawData data)
{
diff --git a/Source/Editor/SceneGraph/SceneGraphNode.cs b/Source/Editor/SceneGraph/SceneGraphNode.cs
index 01a832c5a..11c3b7709 100644
--- a/Source/Editor/SceneGraph/SceneGraphNode.cs
+++ b/Source/Editor/SceneGraph/SceneGraphNode.cs
@@ -309,6 +309,20 @@ namespace FlaxEditor.SceneGraph
return false;
}
+ ///
+ /// Gets the object bounding sphere (including child actors).
+ ///
+ /// The bounding sphere.
+ public virtual void GetEditorSphere(out BoundingSphere sphere)
+ {
+ sphere = new BoundingSphere(Transform.Translation, 15.0f);
+ for (int i = 0; i < ChildNodes.Count; i++)
+ {
+ ChildNodes[i].GetEditorSphere(out var childSphere);
+ BoundingSphere.Merge(ref sphere, ref childSphere, out sphere);
+ }
+ }
+
///
/// Called when selected nodes should draw debug shapes using interface.
///
diff --git a/Source/Editor/Viewport/Cameras/FPSCamera.cs b/Source/Editor/Viewport/Cameras/FPSCamera.cs
index 374d01ccc..22abccf69 100644
--- a/Source/Editor/Viewport/Cameras/FPSCamera.cs
+++ b/Source/Editor/Viewport/Cameras/FPSCamera.cs
@@ -103,45 +103,43 @@ namespace FlaxEditor.Viewport.Cameras
///
/// Moves the viewport to visualize selected actors.
///
- /// The actors to show.
- public void ShowActors(List actors)
+ /// The actors to show.
+ public void ShowActors(List selection)
{
- if (actors.Count == 0)
+ if (selection.Count == 0)
return;
BoundingSphere mergesSphere = BoundingSphere.Empty;
- for (int i = 0; i < actors.Count; i++)
+ for (int i = 0; i < selection.Count; i++)
{
- if (actors[i] is ActorNode actor)
- {
- Editor.GetActorEditorSphere(actor.Actor, out BoundingSphere sphere);
- BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
- }
+ selection[i].GetEditorSphere(out var sphere);
+ BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
}
+ if (mergesSphere == BoundingSphere.Empty)
+ return;
ShowSphere(ref mergesSphere);
}
///
/// Moves the viewport to visualize selected actors.
///
- /// The actors to show.
+ /// The actors to show.
/// The used orientation.
- public void ShowActors(List actors, ref Quaternion orientation)
+ public void ShowActors(List selection, ref Quaternion orientation)
{
- if (actors.Count == 0)
+ if (selection.Count == 0)
return;
BoundingSphere mergesSphere = BoundingSphere.Empty;
- for (int i = 0; i < actors.Count; i++)
+ for (int i = 0; i < selection.Count; i++)
{
- if (actors[i] is ActorNode actor)
- {
- Editor.GetActorEditorSphere(actor.Actor, out BoundingSphere sphere);
- BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
- }
+ selection[i].GetEditorSphere(out var sphere);
+ BoundingSphere.Merge(ref mergesSphere, ref sphere, out mergesSphere);
}
+ if (mergesSphere == BoundingSphere.Empty)
+ return;
ShowSphere(ref mergesSphere, ref orientation);
}
diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp
index 56aa20fa0..fa5bce1ff 100644
--- a/Source/Engine/Level/Actor.cpp
+++ b/Source/Engine/Level/Actor.cpp
@@ -1139,20 +1139,28 @@ BoundingBox Actor::GetBoxWithChildren() const
#if USE_EDITOR
+BoundingBox Actor::GetEditorBox() const
+{
+ return GetBox();
+}
+
BoundingBox Actor::GetEditorBoxChildren() const
{
BoundingBox result = GetEditorBox();
-
for (int32 i = 0; i < Children.Count(); i++)
{
BoundingBox::Merge(result, Children[i]->GetEditorBoxChildren(), result);
}
-
return result;
}
#endif
+bool Actor::HasContentLoaded() const
+{
+ return true;
+}
+
void Actor::UnregisterObjectHierarchy()
{
if (IsRegistered())
@@ -1170,6 +1178,10 @@ void Actor::UnregisterObjectHierarchy()
}
}
+void Actor::Draw(RenderContext& renderContext)
+{
+}
+
void Actor::DrawGeneric(RenderContext& renderContext)
{
// Generic drawing uses only GBuffer Fill Pass and simple frustum culling (see SceneRendering for more optimized drawing)
diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h
index 69d4c8681..233ebe04c 100644
--- a/Source/Engine/Level/Actor.h
+++ b/Source/Engine/Level/Actor.h
@@ -629,10 +629,7 @@ public:
///
/// Gets actor bounding box (single actor, no children included) for editor tools.
///
- API_PROPERTY() virtual BoundingBox GetEditorBox() const
- {
- return GetBox();
- }
+ API_PROPERTY() virtual BoundingBox GetEditorBox() const;
///
/// Gets actor bounding box of the actor including all child actors for editor tools.
@@ -644,10 +641,7 @@ public:
///
/// Returns true if actor has loaded content.
///
- API_PROPERTY() virtual bool HasContentLoaded() const
- {
- return true;
- }
+ API_PROPERTY() virtual bool HasContentLoaded() const;
///
/// Calls UnregisterObject for all objects in the actor hierarchy.
@@ -660,9 +654,7 @@ public:
/// Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. models are rendered during all passed but other actors are invoked only during GBufferFill pass).
///
/// The rendering context.
- virtual void Draw(RenderContext& renderContext)
- {
- }
+ virtual void Draw(RenderContext& renderContext);
///
/// Draws this actor. Called during custom actor rendering or any other generic rendering from code.