public bool OnRaycastHitchanged(Input input, QbMatrix matrix, RaycastHit hit, ref Colort color, MouseButtonEventArgs e) { lastmatrix = matrix; switch (state) { case ToolState.Start: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { state = ToolState.Base; Singleton <Raycaster> .INSTANCE.testdirt = true; startPosition = new VoxelLocation(hit, false); endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); modifiedVoxels.Clear(); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); lastvolume = volume; return(true); } break; case ToolState.Base: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); CleanLastVolume(lastvolume, volume, matrix, modifiedVoxels); lastvolume = volume; return(true); } else if ((e != null && !e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mouseup(MouseButton.Left))) { state = ToolState.Start; lastvolume = VoxelVolume.NEGATIVE_ZERO; Singleton <UndoRedo> .INSTANCE.AddUndo(BrushType, matrix, volume, color, modifiedVoxels); return(true); } break; case ToolState.Limit: break; } return(false); }
public bool OnRaycastHitchanged(Input input, QbMatrix matrix, RaycastHit hit, ref Colort color, MouseButtonEventArgs e) { lastmatrix = matrix; switch (state) { case ToolState.Start: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { state = ToolState.Base; Singleton<Raycaster>.INSTANCE.testdirt = true; startPosition = new VoxelLocation(hit, false); endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); modifiedVoxels.Clear(); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); lastvolume = volume; return true; } break; case ToolState.Base: if ((e != null && e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mousedown(MouseButton.Left))) { endPosition = new VoxelLocation(hit, false); volume = new VoxelVolume(startPosition, endPosition); EnumerateVolume(volume, lastvolume, matrix, ref color, modifiedVoxels); CleanLastVolume(lastvolume, volume, matrix, modifiedVoxels); lastvolume = volume; return true; } else if ((e != null && !e.IsPressed && e.Button == MouseButton.Left) || (e == null && input.mouseup(MouseButton.Left))) { state = ToolState.Start; lastvolume = VoxelVolume.NEGATIVE_ZERO; Singleton<UndoRedo>.INSTANCE.AddUndo(BrushType, matrix, volume, color, modifiedVoxels); return true; } break; case ToolState.Limit: break; } return false; }