SceneSelection.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using BansheeEngine;
  6. namespace BansheeEditor
  7. {
  8. /** @addtogroup Scene-Editor
  9. * @{
  10. */
  11. /// <summary>
  12. /// Handles rendering of the selection overlay and picking of objects in the target camera's view.
  13. /// </summary>
  14. internal sealed class SceneSelection : ScriptObject
  15. {
  16. /// <summary>
  17. /// Creates a new scene selection manager.
  18. /// </summary>
  19. /// <param name="sceneCamera">Camera into which to render the selection overlay, and perform picking from.</param>
  20. internal SceneSelection(Camera sceneCamera)
  21. {
  22. Internal_Create(this, sceneCamera.Native.GetCachedPtr());
  23. }
  24. /// <summary>
  25. /// Queues selection overlay drawing for this frame.
  26. /// </summary>
  27. internal void Draw()
  28. {
  29. Internal_Draw(mCachedPtr);
  30. }
  31. /// <summary>
  32. /// Attempts to select a scene object under the pointer position.
  33. /// </summary>
  34. /// <param name="pointerPos">Position of the pointer relative to the scene camera viewport.</param>
  35. /// <param name="controlHeld">Should this selection add to the existing selection, or replace it.</param>
  36. internal void PickObject(Vector2I pointerPos, bool controlHeld)
  37. {
  38. Internal_PickObject(mCachedPtr, ref pointerPos, controlHeld);
  39. }
  40. [MethodImpl(MethodImplOptions.InternalCall)]
  41. private static extern void Internal_Create(SceneSelection managedInstance, IntPtr camera);
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. private static extern void Internal_Draw(IntPtr thisPtr);
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern void Internal_PickObject(IntPtr thisPtr, ref Vector2I pointerPos, bool controlHeld);
  46. }
  47. /** @} */
  48. }