SceneSelection.cs 2.0 KB

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