SceneSelection.cs 1.8 KB

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