Browse Source

Feature: Added 3D scene icons for camera/light/decal/particle/audio/etc.

BearishSun 6 years ago
parent
commit
cfce5c4694

+ 2 - 2
CMakeLists.txt

@@ -28,10 +28,10 @@ add_subdirectory(${BSF_SOURCE_DIR})
 
 
 set (BS_PREBUILT_DEPENDENCIES_VERSION 24)
 set (BS_PREBUILT_DEPENDENCIES_VERSION 24)
 set (BS_SRC_DEPENDENCIES_VERSION 15)
 set (BS_SRC_DEPENDENCIES_VERSION 15)
-set (BS_BUILTIN_ASSETS_VERSION 14)
+set (BS_BUILTIN_ASSETS_VERSION 15)
 
 
 # Options
 # Options
-set(SCRIPT_BINDING_GENERATION OFF CACHE BOOL "If true, script binding generation will be supported through a specialized build target. Enable this if you plan on modifying the scripting API. Requires the SBGen tool dependency. Only relevant if you have selected a SCRIPT_API other than \"None\".")
+set(SCRIPT_BINDING_GENERATION OFF CACHE BOOL "If true, script binding generation will be supported through a specialized build target. Enable this if you plan on modifying the scripting API. Requires the SBGen tool dependency.")
 
 
 # Ensure dependencies are up to date
 # Ensure dependencies are up to date
 ## Check data dependencies
 ## Check data dependencies

+ 1 - 1
Data/.reqversion

@@ -1 +1 @@
-5
+6

+ 42 - 0
Data/Raw/DataList.json

@@ -1645,5 +1645,47 @@
             "SpriteUUID": "bc2d60d6-4a4b-eef9-8c87-4a4baad3c2c7",
             "SpriteUUID": "bc2d60d6-4a4b-eef9-8c87-4a4baad3c2c7",
             "TextureUUID": "b41fb04a-44f2-e17e-b697-44f20a42b34d"
             "TextureUUID": "b41fb04a-44f2-e17e-b697-44f20a42b34d"
         }
         }
+    ],
+    "SpriteIcons3D": [
+        {
+            "Path": "SceneAudioListener.png",
+            "SpriteUUID": "a65f1c54-4651-6220-5ca4-4651c64998da",
+            "TextureUUID": "db857963-42e8-705a-60ae-42e808c56296"
+        },
+        {
+            "Path": "SceneAudioSource.png",
+            "SpriteUUID": "9069c9f3-4be9-98cf-21b2-4be9758201b0",
+            "TextureUUID": "59ae7925-435d-1df2-e0ba-435d183ba0ec"
+        },
+        {
+            "Path": "SceneCamera.png",
+            "SpriteUUID": "39c1e7da-49b2-6c27-70b4-49b2aefe04ef",
+            "TextureUUID": "208e1e11-4281-5e62-5c87-428187497e19"
+        },
+        {
+            "Path": "SceneDecal.png",
+            "SpriteUUID": "c568d4b9-4ea2-7cec-b1ba-4ea2daccbeff",
+            "TextureUUID": "d36bdb2d-42e1-d3b4-aab1-42e1e7403f1a"
+        },
+        {
+            "Path": "SceneLight.png",
+            "SpriteUUID": "4f60d738-4174-9cfc-4ea8-41742ff28869",
+            "TextureUUID": "0b0acf95-4b7c-fb2c-efa6-4b7c4da3b47a"
+        },
+        {
+            "Path": "SceneLightProbes.png",
+            "SpriteUUID": "61138f43-43a0-5af8-a1ab-43a0f253b7ae",
+            "TextureUUID": "963b4e7b-4f7f-ab34-a7a4-4f7f7c725a15"
+        },
+        {
+            "Path": "SceneParticleSystem.png",
+            "SpriteUUID": "3e1bd794-4dde-4edf-13a4-4ddebefc332d",
+            "TextureUUID": "62131253-4a3f-57b5-45a8-4a3f091e6dc8"
+        },
+        {
+            "Path": "SceneReflectionProbe.png",
+            "SpriteUUID": "c0ebfd2a-4f61-294a-a483-4f6120a1368e",
+            "TextureUUID": "a70c58f5-444f-37b6-dca3-444f126cadc8"
+        }
     ]
     ]
 }
 }

+ 1 - 0
Data/Raw/DataPackageContents.txt

@@ -1,4 +1,5 @@
 Data/Icons
 Data/Icons
+Data/Icons3D
 Data/Shaders
 Data/Shaders
 Data/Skin
 Data/Skin
 Data/.version
 Data/.version

+ 3 - 2
Source/EditorCore/SceneView/BsGizmoManager.cpp

@@ -27,7 +27,7 @@ namespace bs
 	const UINT32 GizmoManager::WIRE_SPHERE_QUALITY = 10;
 	const UINT32 GizmoManager::WIRE_SPHERE_QUALITY = 10;
 	const float GizmoManager::MAX_ICON_RANGE = 500.0f;
 	const float GizmoManager::MAX_ICON_RANGE = 500.0f;
 	const UINT32 GizmoManager::OPTIMAL_ICON_SIZE = 64;
 	const UINT32 GizmoManager::OPTIMAL_ICON_SIZE = 64;
-	const float GizmoManager::ICON_TEXEL_WORLD_SIZE = 0.05f;
+	const float GizmoManager::ICON_TEXEL_WORLD_SIZE = 0.015f;
 
 
 	GizmoManager::GizmoManager()
 	GizmoManager::GizmoManager()
 		: mPickable(false), mCurrentIdx(0), mTransformDirty(false), mColorDirty(false), mDrawHelper(nullptr)
 		: mPickable(false), mCurrentIdx(0), mTransformDirty(false), mColorDirty(false), mDrawHelper(nullptr)
@@ -1022,7 +1022,7 @@ namespace bs
 			SPtr<GpuParamsSet> paramsSet;
 			SPtr<GpuParamsSet> paramsSet;
 			if (iconMeshIdx >= mIconParamSets.size())
 			if (iconMeshIdx >= mIconParamSets.size())
 			{
 			{
-				mIconMaterial->createParamsSet();
+				paramsSet = mIconMaterial->createParamsSet();
 				paramsSet->setParamBlockBuffer("Uniforms", mIconGizmoBuffer, true);
 				paramsSet->setParamBlockBuffer("Uniforms", mIconGizmoBuffer, true);
 
 
 				mIconParamSets.push_back(paramsSet);
 				mIconParamSets.push_back(paramsSet);
@@ -1183,6 +1183,7 @@ namespace bs
 		// Negative near/far because Z is flipped for normalized device coordinates 
 		// Negative near/far because Z is flipped for normalized device coordinates 
 		// (positive Z goes into screen as opposed to view space here we're looking along negative Z)
 		// (positive Z goes into screen as opposed to view space here we're looking along negative Z)
 		projMat.makeProjectionOrtho(left, right, top, bottom, -near, -far);
 		projMat.makeProjectionOrtho(left, right, top, bottom, -near, -far);
+		rapi.convertProjectionMatrix(projMat, projMat);
 
 
 		if (!usePickingMaterial)
 		if (!usePickingMaterial)
 		{
 		{

+ 40 - 0
Source/EditorManaged/Windows/Scene/Gizmos/AudioGizmos.cs

@@ -0,0 +1,40 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//************** Copyright (c) 2016-2019 Marko Pintera ([email protected]). All rights reserved. *******************//
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /** @addtogroup Gizmos
+     *  @{
+     */
+
+    /// <summary>
+    /// Handles drawing of gizmos for audio components.
+    /// </summary>
+    internal class AudioGizmos
+    {
+        /// <summary>
+        /// Draws audio listener icon in scene view.
+        /// </summary>
+        /// <param name="listener">Audio listener to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(AudioListener listener)
+        {
+            Gizmos.DrawIcon(listener.SceneObject.Position,
+                EditorBuiltin.GetSceneViewIcon(SceneViewIcon.AudioListener), false);
+        }
+
+        /// <summary>
+        /// Draws audio source icon in scene view.
+        /// </summary>
+        /// <param name="source">Audio source to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(AudioSource source)
+        {
+            Gizmos.DrawIcon(source.SceneObject.Position,
+                EditorBuiltin.GetSceneViewIcon(SceneViewIcon.AudioSource), false);
+        }
+    }
+
+    /** @} */
+}

+ 13 - 2
Source/EditorManaged/Windows/Scene/Gizmos/CameraGizmo.cs

@@ -14,9 +14,9 @@ namespace BansheeEditor
     internal class CameraGizmo
     internal class CameraGizmo
     {
     {
         /// <summary>
         /// <summary>
-        /// Method called by the runtime when gizmos are meant to be drawn.
+        /// Draws camera shape gizmos when a camera is selected.
         /// </summary>
         /// </summary>
-        /// <param name="camera">Camera to draw gizmos for.</param>
+        /// <param name="camera">Camera to draw the gizmos for.</param>
         [DrawGizmo(DrawGizmoFlags.Selected)]
         [DrawGizmo(DrawGizmoFlags.Selected)]
         private static void Draw(Camera camera)
         private static void Draw(Camera camera)
         {
         {
@@ -27,6 +27,17 @@ namespace BansheeEditor
 
 
             Gizmos.DrawFrustum(Vector3.Zero, camera.AspectRatio, camera.FieldOfView, camera.NearClipPlane,
             Gizmos.DrawFrustum(Vector3.Zero, camera.AspectRatio, camera.FieldOfView, camera.NearClipPlane,
                 camera.FarClipPlane);
                 camera.FarClipPlane);
+
+        }
+
+        /// <summary>
+        /// Draws camera icon in scene view.
+        /// </summary>
+        /// <param name="camera">Camera to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(Camera camera)
+        {
+            Gizmos.DrawIcon(camera.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Camera), false);
         }
         }
     }
     }
 
 

+ 29 - 0
Source/EditorManaged/Windows/Scene/Gizmos/DecalGizmos.cs

@@ -0,0 +1,29 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//************** Copyright (c) 2016-2019 Marko Pintera ([email protected]). All rights reserved. *******************//
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /** @addtogroup Gizmos
+     *  @{
+     */
+
+    /// <summary>
+    /// Handles drawing of gizmos for <see cref="Decal"/> component.
+    /// </summary>
+    internal class DecalGizmos
+    {
+        /// <summary>
+        /// Draws decal icon in scene view.
+        /// </summary>
+        /// <param name="decal">Decal to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(Decal decal)
+        {
+            Gizmos.DrawIcon(decal.SceneObject.Position,
+                EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Decal), false);
+        }
+    }
+
+    /** @} */
+}

+ 12 - 2
Source/EditorManaged/Windows/Scene/Gizmos/LightGizmos.cs

@@ -14,9 +14,9 @@ namespace BansheeEditor
     internal class LightGizmos
     internal class LightGizmos
     {
     {
         /// <summary>
         /// <summary>
-        /// Method called by the runtime when gizmos are meant to be drawn.
+        /// Draws light shape gizmos when a light is selected.
         /// </summary>
         /// </summary>
-        /// <param name="light">Light to draw gizmos for.</param>
+        /// <param name="light">Light to draw the gizmos for.</param>
         [DrawGizmo(DrawGizmoFlags.Selected)]
         [DrawGizmo(DrawGizmoFlags.Selected)]
         private static void Draw(Light light)
         private static void Draw(Light light)
         {
         {
@@ -84,6 +84,16 @@ namespace BansheeEditor
                     break;
                     break;
             }
             }
         }
         }
+
+        /// <summary>
+        /// Draws light icon in scene view.
+        /// </summary>
+        /// <param name="light">Light to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(Light light)
+        {
+            Gizmos.DrawIcon(light.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.Light), false);
+        }
     }
     }
 
 
     /** @} */
     /** @} */

+ 28 - 5
Source/EditorManaged/Windows/Scene/Gizmos/LightProbeVolumeGizmo.cs

@@ -49,7 +49,7 @@ namespace BansheeEditor
             probeInfos = volume.GetProbes();
             probeInfos = volume.GetProbes();
             for (int i = 0; i < probeInfos.Length; i++)
             for (int i = 0; i < probeInfos.Length; i++)
             {
             {
-                if(i == nodeColliders.Count)
+                if (i == nodeColliders.Count)
                     nodeColliders.Add(new HandleSliderSphere(this, 1.0f, false));
                     nodeColliders.Add(new HandleSliderSphere(this, 1.0f, false));
 
 
                 Vector3 position = probeInfos[i].position;
                 Vector3 position = probeInfos[i].position;
@@ -66,7 +66,7 @@ namespace BansheeEditor
 
 
             if (selectedNode != uint.MaxValue)
             if (selectedNode != uint.MaxValue)
             {
             {
-                if(moveHandle == null)
+                if (moveHandle == null)
                     moveHandle = new MoveHandle();
                     moveHandle = new MoveHandle();
 
 
                 Vector3 position = Vector3.Zero;
                 Vector3 position = Vector3.Zero;
@@ -87,11 +87,11 @@ namespace BansheeEditor
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void PostInput()
         protected internal override void PostInput()
         {
         {
-            for(int i = 0; i < nodeColliders.Count; i++)
+            for (int i = 0; i < nodeColliders.Count; i++)
             {
             {
                 if (nodeColliders[i].State == HandleSlider.StateType.Active)
                 if (nodeColliders[i].State == HandleSlider.StateType.Active)
                 {
                 {
-                    selectedNode = (uint)probeInfos[i].handle;
+                    selectedNode = (uint) probeInfos[i].handle;
                     break;
                     break;
                 }
                 }
             }
             }
@@ -101,7 +101,7 @@ namespace BansheeEditor
                 moveHandle.PostInput();
                 moveHandle.PostInput();
 
 
                 if (moveHandle.IsDragged())
                 if (moveHandle.IsDragged())
-                    volume.SetProbePosition((int)selectedNode, moveHandle.Position + moveHandle.Delta);
+                    volume.SetProbePosition((int) selectedNode, moveHandle.Position + moveHandle.Delta);
             }
             }
         }
         }
 
 
@@ -117,4 +117,27 @@ namespace BansheeEditor
     }
     }
 
 
     /** @} */
     /** @} */
+
+    /** @addtogroup Gizmos
+     *  @{
+     */
+
+    /// <summary>
+    /// Handles drawing of gizmos for <see cref="LightProbeVolume"/> component.
+    /// </summary>
+    internal class LightProbeVolumeGizmos
+    {
+        /// <summary>
+        /// Draws light probe volume icon in scene view.
+        /// </summary>
+        /// <param name="volume">Light probe volume to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(LightProbeVolume volume)
+        {
+            Gizmos.DrawIcon(volume.SceneObject.Position,
+                EditorBuiltin.GetSceneViewIcon(SceneViewIcon.LightProbes), false);
+        }
+    }
+
+    /** @} */
 }
 }

+ 11 - 1
Source/EditorManaged/Windows/Scene/Gizmos/ParticleSystemGizmos.cs

@@ -84,7 +84,7 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Method called by the runtime when gizmos are meant to be drawn.
+        /// Draws the particle system shape when the particle system is selected.
         /// </summary>
         /// </summary>
         /// <param name="component">Component to draw gizmos for.</param>
         /// <param name="component">Component to draw gizmos for.</param>
         [DrawGizmo(DrawGizmoFlags.Selected)]
         [DrawGizmo(DrawGizmoFlags.Selected)]
@@ -279,6 +279,16 @@ namespace BansheeEditor
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// Draws particle system icon in scene view.
+        /// </summary>
+        /// <param name="component">Component to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(ParticleSystem component)
+        {
+            Gizmos.DrawIcon(component.SceneObject.Position, EditorBuiltin.GetSceneViewIcon(SceneViewIcon.ParticleSystem), false);
+        }
+
         /// <summary>
         /// <summary>
         /// Method called by the runtime when the component is selected or deselected.
         /// Method called by the runtime when the component is selected or deselected.
         /// </summary>
         /// </summary>

+ 12 - 1
Source/EditorManaged/Windows/Scene/Gizmos/ReflectionProbeGizmo.cs

@@ -14,7 +14,7 @@ namespace BansheeEditor
     internal class ReflectionProbeGizmos
     internal class ReflectionProbeGizmos
     {
     {
         /// <summary>
         /// <summary>
-        /// Method called by the runtime when gizmos are meant to be drawn.
+        /// Draws the reflection probe shape.
         /// </summary>
         /// </summary>
         /// <param name="reflProbe">Reflection probe to draw gizmos for.</param>
         /// <param name="reflProbe">Reflection probe to draw gizmos for.</param>
         [DrawGizmo(DrawGizmoFlags.Selected)]
         [DrawGizmo(DrawGizmoFlags.Selected)]
@@ -38,6 +38,17 @@ namespace BansheeEditor
                     break;
                     break;
             }
             }
         }
         }
+
+        /// <summary>
+        /// Draws reflection probe icon in scene view.
+        /// </summary>
+        /// <param name="reflProbe">Reflection probe to draw the icon for.</param>
+        [DrawGizmo(DrawGizmoFlags.NotSelected | DrawGizmoFlags.Pickable)]
+        private static void DrawIcon(ReflectionProbe reflProbe)
+        {
+            Gizmos.DrawIcon(reflProbe.SceneObject.Position, 
+                EditorBuiltin.GetSceneViewIcon(SceneViewIcon.ReflectionProbe), false);
+        }
     }
     }
 
 
     /** @} */
     /** @} */

+ 3 - 0
Source/EditorScript/BsScriptGizmoManager.cpp

@@ -65,6 +65,9 @@ namespace bs
 			HSceneObject curSO = todo.top();
 			HSceneObject curSO = todo.top();
 			todo.pop();
 			todo.pop();
 
 
+			if(curSO->hasFlag(SOF_Internal))
+				continue;
+
 			bool isSelected = std::count(selectedObjects.begin(), selectedObjects.end(), curSO) > 0;
 			bool isSelected = std::count(selectedObjects.begin(), selectedObjects.end(), curSO) > 0;
 			if (isSelected && !isParentSelected)
 			if (isSelected && !isParentSelected)
 			{
 			{

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 5b9720f5b25a3ad9d11471c277bda996ad853716
+Subproject commit b96c9a9c683bee88a075a71d01e00b73ae52a652