Beispiel #1
0
        public void Build()
        {
            if (_isBuilt)
            {
                return;
            }

            for (int triIndex = 0; triIndex < _mesh.NumTriangles; ++triIndex)
            {
                MeshTriangle meshTriangle = _mesh.GetTriangle(triIndex);
                _tree.AddNode(meshTriangle, new Sphere(meshTriangle.Vertices));
            }

            _isBuilt = true;
        }
        public void RegisterObject(GameObject gameObject)
        {
            if (!CanRegisterObject(gameObject))
            {
                return;
            }

            var boundsQConfig = new ObjectBounds.QueryConfig();

            boundsQConfig.ObjectTypes  = GameObjectTypeHelper.AllCombined;
            boundsQConfig.NoVolumeSize = Vector3Ex.FromValue(RTScene.Get.Settings.NonMeshObjectSize);

            AABB   worldAABB   = ObjectBounds.CalcWorldAABB(gameObject, boundsQConfig);
            Sphere worldSphere = new Sphere(worldAABB);

            SphereTreeNode <GameObject> objectNode = _objectTree.AddNode(gameObject, worldSphere);

            _objectToNode.Add(gameObject, objectNode);

            RTFocusCamera.Get.SetObjectVisibilityDirty();
        }