SceneView.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. TODO:
  2. - Core thread gets stuck on shutdown when OpenGL is used...Somewhere in kernel
  3. Weekend:
  4. - Set up grid material and hook it up to renderer (+ actually instantiate it in EditorApplication)
  5. TODO - Think about:
  6. - How will I allow user from C# to draw gizmos and handles?
  7. - Unity uses immediate mode
  8. - I should probably focus more on implementing a nice C# drawing interface so I don't constantly have to go and use C++
  9. - Although this might be overkill for this point - I think even Unitys handles/gizmos are C++ in the end
  10. ----------------------------------------------------------------------
  11. Handles
  12. - Make a few different base handle types:
  13. - Slider 1D (e.g. for movement using an arrow cap)
  14. - Slider 2D (e.g. for movement in 2D using a plane render)
  15. - Similar for scale/rotation handles (see Unity for its implementations of those)
  16. Handles should have colliders which will be queries whenever user input is detected in scene view
  17. If any handle is hit the input will not proceed further (e.g. no picking will be done) and that handle control
  18. will become active.
  19. Base handle types should just be positioned in space and then return value every frame as user moves them.
  20. - This way they can also easily be used from C# for custom user-made stuff
  21. TODO - Think about this
  22. See for inspiration: http://docs.unity3d.com/ScriptReference/Handles.html
  23. ----------------------------------------------------------------------
  24. Picking
  25. BsPicking
  26. - HGameObject PickClosestGameObject(Camera cam, Vector2 position, Vector2 area)
  27. - PickResult PickClosestObject(Camera cam, Vector2 position, Vector2 area)
  28. - void PickGameObjects(Camera cam, Vector2 position, Vector2 area, Vector<HGameObject>& selection)
  29. - void PickObjects(Camera cam, Vector2 position, Vector2 area, Vector<PickResults>& selection)
  30. PickResult
  31. Type (GameObject or Gizmo)
  32. Data (Handle to GameObject or gizmo ID)
  33. Picking will internally:
  34. - Be performed on the Scene render target just before actual rendering
  35. - Use scissor rect to limit itself to the specified screen area
  36. - TODO later - I could also limit the camera frustum to this area for additional culling
  37. - Go through every scene object and find all renderables
  38. - Perform culling over all renderables and generate a list of visible nodes
  39. - Access GizmoManager and get a list of all gizmos and their IDs
  40. - Generate unique colors for all renderables and gizmos
  41. - Send meshes/colors/ids to core thread to be rendered with a special shader
  42. - Wait until core thread completes and returns an AsyncOp with a list of selected IDs
  43. - Ensure I can read-back from a render target on the core thread
  44. - Check DX9, DX11 and OpenGL implementations for both render textures and render windows
  45. Also:
  46. - I need to send the primary used texture so I properly determine transparent areas using alpha
  47. - TODO - But I do not have a way of defining a primary texture in-engine. Add a renderer semantic?
  48. ----------------------------------------------------------------------
  49. Rendering selection
  50. Get the mesh from the selected Renderable
  51. Draw that same mesh again using a shader that grays out the original
  52. The second mesh will likely need to use depth bias (sloped depth bias too?)
  53. ----------------------------------------------------------------------
  54. Grid
  55. Generate grid of X size around Y point
  56. Normally Y is (0, 0, 0) but we should be able to move it with camera
  57. There will be minor and major axes with slightly different color (and thickness?)
  58. Instead of pixel perfect lines draw 2D quads (Using DrawHelper which has thick line support)
  59. Mesh can be static, I can just move its origin by length of the major line (+ maybe have a fadeout in shader with 1 invisible major line so the movement is not noticeable)
  60. Material is retrieved from builtin materials list
  61. This can be drawn directly using the draw list and not a renderable
  62. ----------------------------------------------------------------------
  63. Gizmos
  64. Custom gizmos:
  65. - Users can override the Gizmo class to create their own custom gizmos
  66. - It contains various methods that can be used for constructing the gizmo
  67. - DrawCube
  68. - DrawSphere
  69. - DrawWireCube
  70. - DrawWireSphere
  71. - DrawRay
  72. - DrawLine
  73. - DrawFrustum
  74. - DrawIcon
  75. - Any Gizmo is registered with GizmoTypes manager
  76. - Components may associate themselves with a gizmo using [SetGizmo(Gizmo)] attribute
  77. - It contains other properties, like when should gizmo be displayed (active, selected, not selected, parent selected) and whether
  78. or not the gizmo is pickable
  79. - When drawing an icon
  80. - It should always face the camera
  81. - It can be static size in screen space, or resizable with distance
  82. - Need a way to notify the gizmo needs updating from component with the gizmo
  83. - Gizmos.MarkDirty(GameObject)
  84. - How do I assign a texture to DrawIcon? I'm assuming Gizmo class will not have an inspector.
  85. - A special ManagedResource that allows you to assign textures to it?
  86. - WIll need a Dictionary inspector?
  87. Gizmo rendering:
  88. GizmoTypes
  89. - All gizmo types are registered here
  90. - It contains prebuilt gizmo meshes and textures
  91. GizmoManager
  92. - Every frame goes through all game objects and create/removes their gizmos. It keeps a cached version of all gizmos
  93. - It keeps a list of gizmo descriptors
  94. - A "diff" of this list is sent to Core thread every frame
  95. GizmosRenderer
  96. - Batches all gizmos into a single buffer and renders them with a single call
  97. - It might be a bit problematic if custom textures are used for gizmos
  98. - Just don't batch those? Yep, probably not worth batching at this point.
  99. When picking GizmosRenderer can draw the gizmos as normal but using a special shader.