Beispiel #1
0
 private void DrawContacts()
 {
     if (PhysicsVisualizationSettings.showContacts)
     {
         PhysicsDebugDraw.GetPooledContacts();
     }
 }
        public void OnEnable()
        {
            m_ShowColliderTypeFoldout = new SavedBool("PhysicsDebugWindow.ShowColliderType", false);
            m_CurrentTab = new SavedInt("PhysicsDebugWindow.CurrentTab", 0);
            m_Collumns   = new SavedInt("PhysicsDebugWindow.Collumns", 1);

            SceneView.duringSceneGui                 += OnSceneGUI;
            Selection.selectionChanged               += UpdateSelection;
            EditorSceneManager.sceneClosed           += OnSceneClose;
            EditorSceneManager.sceneOpened           += OnSceneOpen;
            EditorApplication.playModeStateChanged   += PlayModeStateChanged;
            PhysicsDebugDraw.OnDrawPooledContacts    += DrawContacts_Internal;
            PhysicsDebugDraw.OnRetrievePooledQueries += OnQueriesRetrieved;
            PhysicsDebugDraw.BeforeSimulate          += BeforeSimulate;
            SetPickingEnabled(PhysicsVisualizationSettings.showCollisionGeometry &&
                              PhysicsVisualizationSettings.enableMouseSelect);

            LoadDictionary();
            ClearInvalidObjects();
            UpdateSelection();

            PhysicsDebugDraw.ClearAllPools();

            wantsLessLayoutEvents = true;
        }
        private void Update()
        {
            bool canFetch = s_Window != null && PhysicsVisualizationSettings.GetQueryFilterState(PhysicsVisualizationSettings.QueryFilter.ShowQueries);

            if (canFetch && m_SimulationOccured)
            {
                m_ShapesToDraw.Clear();
                PhysicsDebugDraw.GetPooledQueries();
                m_SimulationOccured = false;
            }
        }
        public void OnDisable()
        {
            SceneView.duringSceneGui                 -= OnSceneGUI;
            Selection.selectionChanged               -= UpdateSelection;
            EditorSceneManager.sceneClosed           -= OnSceneClose;
            EditorSceneManager.sceneOpened           -= OnSceneOpen;
            EditorApplication.playModeStateChanged   -= PlayModeStateChanged;
            PhysicsDebugDraw.OnDrawPooledContacts    -= DrawContacts_Internal;
            PhysicsDebugDraw.OnRetrievePooledQueries -= OnQueriesRetrieved;
            PhysicsDebugDraw.BeforeSimulate          -= BeforeSimulate;
            SetPickingEnabled(false);

            SaveDictionary();
            ClearInvalidObjects();

            PhysicsDebugDraw.ClearAllPools();
        }
Beispiel #5
0
 private void ClearAllPoolsAndStoredQueries()
 {
     PhysicsDebugDraw.ClearAllPools();
     ClearQueryShapes();
 }
Beispiel #6
0
        private void DrawContacts_Internal(NativeArray <PhysicsDebugDraw.VisContactPoint> array)
        {
            var useRandomColor = PhysicsVisualizationSettings.useVariedContactColors;
            var impulseColor   = useRandomColor ? Color.black : PhysicsVisualizationSettings.contactImpulseColor;

            for (int i = 0; i < array.Length; i++)
            {
                bool passedFiltering = (!PhysicsVisualizationSettings.useContactFiltering || PhysicsDebugDraw.IsContactVisualised(array[i].otherCollider));
                if (passedFiltering && IsContactSeenByCamera(array[i].point))
                {
                    DrawSingleCollision(array[i], impulseColor, useRandomColor);
                }
            }
        }
Beispiel #7
0
 private void OnSceneOpen(Scene scene, OpenSceneMode mode)
 {
     PhysicsDebugDraw.UpdateFilter();
 }
Beispiel #8
0
 private void OnSceneClose(Scene scene)
 {
     ClearInvalidObjects();
     PhysicsDebugDraw.UpdateFilter();
 }