/// <summary> /// Registers the specified object with the tree. /// </summary> private bool RegisterGameObject(GameObject gameObject) { if (!CanGameObjectBeRegisteredWithTree(gameObject)) { return(false); } // Build the object's sphere Box objectWorldBox = gameObject.GetWorldBox(); Sphere3D objectSphere = objectWorldBox.GetEncapsulatingSphere(); // Add the object as a terminal node. Also store the node in the dictionary so that we can // use it when it's needed. SphereTreeNode <GameObject> objectNode = _sphereTree.AddTerminalNode(objectSphere, gameObject); _gameObjectToNode.Add(gameObject, objectNode); #if !USE_TRANSFORM_HAS_CHANGED _gameObjectToTransformData.Add(gameObject, GetGameObjectTransformData(gameObject)); #endif // If it is a mesh object, start silent building the mesh if (gameObject.HasMesh()) { EditorMesh editorMesh = EditorMeshDatabase.Instance.CreateEditorMesh(gameObject.GetMesh()); if (editorMesh != null) { EditorMeshDatabase.Instance.AddMeshToSilentBuild(editorMesh); } } EditorCamera.Instance.AdjustObjectVisibility(gameObject); return(true); }
/// <summary> /// Registers the mesh trianlge with the specified index with the tree. /// </summary> private bool RegisterTriangle(int triangleIndex) { Triangle3D triangle = _editorMesh.GetTriangle(triangleIndex); if (!IsTriangleValid(triangle)) { return(false); } // Create the triangle node data and instruct the tree to add this node var meshSphereTreeTriangle = new MeshSphereTreeTriangle(triangleIndex); _sphereTree.AddTerminalNode(triangle.GetEncapsulatingSphere(), meshSphereTreeTriangle); return(true); }
protected override void DoJob() { for (int triIndex = 0; triIndex < _meshTriangles.Count; ++triIndex) { Triangle3D triangle = _meshTriangles[triIndex]; if (ValidateTriangle != null && !ValidateTriangle(triangle)) { continue; } var meshSphereTreeTriangle = new MeshSphereTreeTriangle(triIndex); _sphereTree.AddTerminalNode(triangle.GetEncapsulatingSphere(), meshSphereTreeTriangle); } if (SilentBuildFinished != null) { SilentBuildFinished(); } }