private static void UpdateMesh(Tree tree, bool callExitGUI) { TreeData treeData = GetTreeData(tree); if (treeData != null) { Material[] materialArray; Profiler.BeginSample("TreeEditor.UpdateMesh"); treeData.UpdateMesh(tree.transform.worldToLocalMatrix, out materialArray); AssignMaterials(tree.GetComponent<Renderer>(), materialArray, true); s_SavedSourceMaterialsHash = treeData.materialHash; Profiler.EndSample(); if (callExitGUI) { GUIUtility.ExitGUI(); } } }
private void FrameSelected(Tree tree) { TreeData treeData = GetTreeData(tree); Matrix4x4 localToWorldMatrix = tree.transform.localToWorldMatrix; Bounds bounds = new Bounds(localToWorldMatrix.MultiplyPoint(Vector3.zero), Vector3.zero); if (s_SelectedGroup != null) { if (s_SelectedGroup.GetType() == typeof(TreeGroupRoot)) { MeshFilter component = tree.GetComponent<MeshFilter>(); if ((component == null) || (s_SelectedGroup.childGroupIDs.Length == 0)) { float rootSpread = s_SelectedGroup.GetRootSpread(); Vector3 introduced14 = localToWorldMatrix.MultiplyPoint(Vector3.zero); bounds = new Bounds(introduced14, localToWorldMatrix.MultiplyVector(new Vector3(rootSpread, rootSpread, rootSpread))); } else { Vector3 introduced15 = localToWorldMatrix.MultiplyPoint(component.sharedMesh.bounds.center); bounds = new Bounds(introduced15, localToWorldMatrix.MultiplyVector(component.sharedMesh.bounds.size)); } } else if (s_SelectedNode != null) { if ((s_SelectedGroup.GetType() == typeof(TreeGroupLeaf)) && (s_SelectedPoint >= 0)) { Matrix4x4 matrixx2 = localToWorldMatrix * s_SelectedNode.matrix; bounds = new Bounds(matrixx2.MultiplyPoint(s_SelectedNode.spline.nodes[s_SelectedPoint].point), Vector3.zero); } else { bounds = this.CalcBounds(treeData, localToWorldMatrix, s_SelectedNode); } } else { for (int i = 0; i < s_SelectedGroup.nodeIDs.Length; i++) { Bounds bounds4 = this.CalcBounds(treeData, localToWorldMatrix, treeData.GetNode(s_SelectedGroup.nodeIDs[i])); if (i == 0) { bounds = bounds4; } else { bounds.Encapsulate(bounds4); } } } } Vector3 center = bounds.center; float newSize = bounds.size.magnitude + 1f; SceneView lastActiveSceneView = SceneView.lastActiveSceneView; if (lastActiveSceneView != null) { lastActiveSceneView.LookAt(center, lastActiveSceneView.rotation, newSize); } }
private static void PreviewMesh(Tree tree, bool callExitGUI) { TreeData treeData = GetTreeData(tree); if (treeData != null) { Material[] materialArray; Profiler.BeginSample("TreeEditor.PreviewMesh"); treeData.PreviewMesh(tree.transform.worldToLocalMatrix, out materialArray); AssignMaterials(tree.GetComponent<Renderer>(), materialArray, false); Profiler.EndSample(); if (callExitGUI) { GUIUtility.ExitGUI(); } } }