protected virtual IOperation CreateOperationFromEditor(Vector3 start, Vector3 end, TerrainToolEditor editor) { var voxelType = EditorUtils.GetVoxelTypeFromIndex(VoxelTypeIndex, editor.Terrain.VoxelTypeSet); Vector3 vL, vH, vW; UMath.ComputeEdgeVectors(start, end, Width, Height, out vL, out vH, out vW); return(Parallelepiped.CreateFromUnityWorld(editor.Terrain, Dig, start, vL, vH, vW, voxelType)); }
public void OnScene(TerrainToolEditor editor, SceneView sceneview) { if (Reticle == null) { Reticle = editor.LoadReticle <ReticleLinesForEditor>("ReticleLinesForEditor"); } if (Event.current.control || Event.current.type == EventType.MouseDown && Event.current.button == 1) { startPosition = null; } var hit = editor.GetIntersectionWithTerrain(true); if (hit.HasValue) { var p = hit.Value.point - new Vector3(0, Height * 0.5f, Width * 0.5f); Vector3 vL, vH, vW; if (startPosition.HasValue) { UMath.ComputeEdgeVectors(startPosition.Value, p, Width, Height, out vL, out vH, out vW); Reticle.SetCornerAndEdges(startPosition.Value, vL, vH, vW); } else { UMath.ComputeEdgeVectors(p, p + Vector3.forward, Width, Height, out vL, out vH, out vW); Reticle.SetCornerAndEdges(p, vL, vH, vW); } if (editor.Clicking) { Event.current.Use(); if (!startPosition.HasValue) { startPosition = p; } else { editor.PerformOperation(CreateOperationFromEditor(startPosition.Value, p, editor), sceneview); startPosition = null; } } } }
private void UpdateForParallelepiped(Vector3 wpos) { reticleLinesForEditor.EnableRenderer(true); if (Input.GetKey(KeyCode.LeftControl) || Input.GetMouseButtonDown(1)) { firstClickPosition = null; } var p = wpos - new Vector3(0, BrushSize * 0.5f, BrushSize * 0.5f); Vector3 vL, vH, vW; if (firstClickPosition.HasValue) { UMath.ComputeEdgeVectors(firstClickPosition.Value, p, BrushSize, BrushSize, out vL, out vH, out vW); reticleLinesForEditor.SetCornerAndEdges(firstClickPosition.Value, vL, vH, vW); } else { UMath.ComputeEdgeVectors(p, p + Vector3.forward, BrushSize, BrushSize, out vL, out vH, out vW); reticleLinesForEditor.SetCornerAndEdges(p, vL, vH, vW); } if (clicking && Terrain.OperationsManager.IsReadyToComputeAsync) { if (!firstClickPosition.HasValue) { firstClickPosition = p; } else { Vector3 vLd, vHd, vWd; UMath.ComputeEdgeVectors( firstClickPosition.Value, p, BrushSize, BrushSize, out vLd, out vHd, out vWd); Terrain.OperationsManager .Add(Parallelepiped.CreateFromUnityWorld(Terrain, dig, firstClickPosition.Value, vLd, vHd, vWd, voxelType), true) .PerformAll(asyncOperations); firstClickPosition = null; } } }