설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DecalSkipCulledSystem.cs 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. /// <summary>
  5. /// System used for skipping culling. It is used with <see cref="Graphics.DrawMesh"/> as it already handles culling.
  6. /// </summary>
  7. internal class DecalSkipCulledSystem
  8. {
  9. private DecalEntityManager m_EntityManager;
  10. private ProfilingSampler m_Sampler;
  11. private Camera m_Camera;
  12. public DecalSkipCulledSystem(DecalEntityManager entityManager)
  13. {
  14. m_EntityManager = entityManager;
  15. m_Sampler = new ProfilingSampler("DecalSkipCulledSystem.Execute");
  16. }
  17. public void Execute(Camera camera)
  18. {
  19. using (new ProfilingScope(m_Sampler))
  20. {
  21. m_Camera = camera;
  22. for (int i = 0; i < m_EntityManager.chunkCount; ++i)
  23. Execute(m_EntityManager.culledChunks[i], m_EntityManager.culledChunks[i].count);
  24. }
  25. }
  26. private void Execute(DecalCulledChunk culledChunk, int count)
  27. {
  28. if (count == 0)
  29. return;
  30. culledChunk.currentJobHandle.Complete();
  31. for (int i = 0; i < count; ++i)
  32. culledChunk.visibleDecalIndices[i] = i;
  33. culledChunk.visibleDecalCount = count;
  34. culledChunk.cameraPosition = m_Camera.transform.position;
  35. culledChunk.cullingMask = m_Camera.cullingMask;
  36. #if UNITY_EDITOR
  37. culledChunk.sceneCullingMask = GetSceneCullingMaskFromCamera(m_Camera);
  38. #endif
  39. }
  40. internal static UInt64 GetSceneCullingMaskFromCamera(Camera camera)
  41. {
  42. #if UNITY_EDITOR
  43. if (camera.overrideSceneCullingMask != 0)
  44. return camera.overrideSceneCullingMask;
  45. if (camera.scene.IsValid())
  46. return UnityEditor.SceneManagement.EditorSceneManager.GetSceneCullingMask(camera.scene);
  47. switch (camera.cameraType)
  48. {
  49. case CameraType.SceneView:
  50. return UnityEditor.SceneManagement.SceneCullingMasks.MainStageSceneViewObjects;
  51. default:
  52. return UnityEditor.SceneManagement.SceneCullingMasks.GameViewObjects;
  53. }
  54. #else
  55. return 0;
  56. #endif
  57. }
  58. }
  59. }