/// <summary>
        /// Builds the mesh tree if it hasn't already been built.
        /// </summary>
        public void Build()
        {
            if (_wasBuilt || _buildJob.IsRunning)
            {
                return;
            }

            // Loop through all trianlges and register them with the tree
            for (int triangleIndex = 0; triangleIndex < _editorMesh.NumberOfTriangles; ++triangleIndex)
            {
                RegisterTriangle(triangleIndex);
            }
            _sphereTree.PerformPendingUpdates();

            // The tree was built
            _wasBuilt = true;
        }
        /// <summary>
        /// Must be called from an 'Update' method to perform any necessary tree
        /// updates.
        /// </summary>
        public void Update()
        {
            _nullCleanupTime += Time.deltaTime;
            if (_nullCleanupTime >= 1.0f)
            {
                RemoveNullObjectNodes();
                _nullCleanupTime = 0.0f;
            }

            if (_container == null)
            {
                if (LevelEditor.Instance != null && LevelEditor.Instance.curLevelChunk != null)
                {
                    _container = LevelEditor.Instance.curLevelChunk.trfmProps.gameObject;
                }
                else
                {
                    _container = GameObject.Find("[Container]");
                }
            }
            if (_container == null)
            {
                return;
            }

            GameObject[] sceneObjects = _container.GetAllChildren().ToArray();            // MonoBehaviour.FindObjectsOfType<GameObject>();
            foreach (GameObject gameObject in sceneObjects)
            {
                if (!IsGameObjectRegistered(gameObject))
                {
                    if (!RegisterGameObject(gameObject))
                    {
                        continue;
                    }
                }

                #if !USE_TRANSFORM_HAS_CHANGED
                Transform objectTransform = gameObject.transform;
                GameObjectTransformData objectTransformData = _gameObjectToTransformData[gameObject];
                if (objectTransformData.Position != objectTransform.position ||
                    objectTransformData.Rotation != objectTransform.rotation ||
                    objectTransformData.Scale != objectTransform.lossyScale)
                {
                    HandleObjectTransformChange(objectTransform);
                    _gameObjectToTransformData[gameObject] = GetGameObjectTransformData(gameObject);
                }
                #else
                Transform objectTransform = gameObject.transform;
                if (objectTransform.hasChanged)
                {
                    HandleObjectTransformChange(objectTransform);
                    objectTransform.hasChanged = false;
                }
                #endif
            }

            _sphereTree.PerformPendingUpdates();
        }
Beispiel #3
0
        /// <summary>
        /// Builds the mesh tree if it hasn't already been built.
        /// </summary>
        public void Build()
        {
            if (_wasBuilt)
            {
                return;
            }

            // Loop through all trianlges and register them with the tree
            for (int triangleIndex = 0; triangleIndex < _editorMesh.NumberOfTriangles; ++triangleIndex)
            {
                RegisterTriangle(triangleIndex);
            }
            _sphereTree.PerformPendingUpdates();

            // The tree was built
            _wasBuilt = true;

            EditorMeshDatabase.Instance.OnMeshTreeBuildFinished(_editorMesh, false);
        }
        /// <summary>
        /// Must be called from an 'Update' method to perform any necessary tree
        /// updates.
        /// </summary>
        public void Update()
        {
            _nullCleanupTime += Time.deltaTime;
            if (_nullCleanupTime >= 1.0f)
            {
                RemoveNullObjectNodes();
                _nullCleanupTime = 0.0f;
            }

            GameObject[] sceneObjects = MonoBehaviour.FindObjectsOfType <GameObject>();
            foreach (GameObject gameObject in sceneObjects)
            {
                if (!IsGameObjectRegistered(gameObject))
                {
                    if (!RegisterGameObject(gameObject))
                    {
                        continue;
                    }
                }

                #if !USE_TRANSFORM_HAS_CHANGED
                Transform objectTransform = gameObject.transform;
                GameObjectTransformData objectTransformData = _gameObjectToTransformData[gameObject];
                if (objectTransformData.Position != objectTransform.position ||
                    objectTransformData.Rotation != objectTransform.rotation ||
                    objectTransformData.Scale != objectTransform.lossyScale)
                {
                    HandleObjectTransformChange(objectTransform);
                    _gameObjectToTransformData[gameObject] = GetGameObjectTransformData(gameObject);
                }
                #else
                Transform objectTransform = gameObject.transform;
                if (objectTransform.hasChanged)
                {
                    HandleObjectTransformChange(objectTransform);
                    objectTransform.hasChanged = false;
                }
                #endif
            }

            _sphereTree.PerformPendingUpdates();
        }