void HandleBeginDrag(VrEventArgs args) { _frameGfx.Visible = false; var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>; var hitSegment = args.HitResult as HitResult <PathSegment>; if (hitInstruction != null) { _dragOffset = args.Frame.InverseRigid() * hitInstruction.HitObject.GetToTarget().Transform.GlobalMatrix; WithUndo("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(hitInstruction.HitObject, args.Frame * _dragOffset)); _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget(); } else if (hitSegment != null) { WithUndo("VR Drag", () => _newInstruction = PathEditingHelper.InsertMoveInstruction(hitSegment.HitObject, args.Frame)); } else if (args.HitResult != null) { throw new InvalidOperationException("unrecognized HitResult"); } else { WithUndo("VR Create Instruction", () => _newInstruction = PathEditingHelper.CreateNewInstructionInActivePath(args.Frame)); _dragOffset = Matrix4.Identity; args.CreatedObject = () => new HitResult <RsMoveInstruction>(_newInstruction, 0, args.Frame.Translation); } }
void HandleAlternateClick(VrEventArgs args) { var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>; if (hitInstruction != null) { WithUndo("VR Delete", () => PathEditingHelper.DeleteInstruction(hitInstruction.HitObject)); } }
public override void Update(VrUpdateArgs args) { var session = args.Session; var input = session.SemanticInput(); Matrix4 pointer = PointerFilter(session.RightController.PointerTransform); var hitResult = GetClosestHit(pointer.Translation); //KNARK: Review Deletebutton usage (used to capture on down, execute on up) /*if(input.SelectClick || input.DeleteClick) * { * _pressedAt = pointer; * } * else */if (input.IsSelectPressed && !_dragging) { _dragging = true; _hitResult = hitResult; var eventArgs = new VrEventArgs(pointer, _hitResult); BeginDrag?.Invoke(eventArgs); if (eventArgs.CreatedObject != null) { _hitResult = eventArgs.CreatedObject(); } } else if (_dragging && input.IsSelectPressed) { DeltaDrag?.Invoke(new VrEventArgs(pointer, _hitResult)); } else if (!input.IsSelectPressed && _dragging) { _dragging = false; EndDrag?.Invoke(new VrEventArgs(pointer, _hitResult)); } //else if (_gripPressed && !session.RightController.InputState.GripPressed // && CloseEnough(_pressedAt, pointer)) else if (input.DeleteClick) { AlternateClick?.Invoke(new VrEventArgs(pointer, hitResult)); } else if (hitResult != null) { HoverObject?.Invoke(new VrEventArgs(pointer, hitResult)); } }
void HandleDeltaDrag(VrEventArgs args) { //_frameGfx.Visible = false; var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>; var hitSegment = args.HitResult as HitResult <PathSegment>; if (hitInstruction != null) { WithUndoAppend("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(hitInstruction.HitObject, args.Frame * _dragOffset)); _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget(); _forceUpdateLine = true; } else if (hitSegment != null) { WithUndoAppend("VR Drag", () => PathEditingHelper.MoveInstructionToFrame(_newInstruction, args.Frame)); } else if (args.HitResult != null) { throw new InvalidOperationException("unrecognized HitResult"); } }
void HandleHover(VrEventArgs args) { var hitInstruction = args.HitResult as HitResult <RsMoveInstruction>; _newHighlightTarget = hitInstruction?.HitObject?.GetToTarget(); }
void HandleEndDrag(VrEventArgs args) { HandleDeltaDrag(args); _frameGfx.Visible = true; }