private void clearDragTarget() { if (poseStartPosition != null) { //Only record undo if we moved far enough if (travelTracker.TraveledOverLimit) { musclePositionController.pushUndoState(poseStartPosition); } poseStartPosition = null; } if (currentHandler != null) { currentHandler.posingEnded(activeModes); currentHandler = null; } if (dragControl.TargetBone != null) { dragControl.TargetBone.Pinned = repinBone; } ikScene.removeExternalControl(dragControl); dragControl.TargetBone = null; }
protected override void link() { base.link(); SimObject entitySimObject = Owner.getOtherSimObject(anatomySimObjectName); if (entitySimObject == null) { blacklist("Cannot find Anatomy SimObject named '{0}'", anatomySimObjectName); } anatomy = entitySimObject.getElement(anatomyName) as AnatomyIdentifier; if (anatomy == null) { blacklist("Cannot find AnatomyIdentifier '{0}' on Anatomy SimObject '{1}'", anatomyName, anatomySimObjectName); } SimObject poseHandlerSimObject = Owner.getOtherSimObject(poseHandlerSimObjectName); if (poseHandlerSimObject == null) { blacklist("Cannot find PoseHandler SimObject named '{0}'", poseHandlerSimObjectName); } poseHandler = poseHandlerSimObject.getElement(poseHandlerName) as PoseHandler; if (poseHandler == null) { blacklist("Cannot find PoseHandler '{0}' in SimObject '{1}'", poseHandlerName, poseHandlerSimObjectName); } PoseableObjectsManager.add(this); }
private bool findDragTarget(Ray3 cameraRay) { var matches = PoseableObjectsManager.findPoseable(cameraRay); foreach (var match in matches.Results) { var bone = match.PoseableIdentifier.PoseHandler.Bone; if (bone != null) { if (bone.Pinned) { repinBone = true; bone.Pinned = false; } else { repinBone = false; } dragControl.TargetBone = bone; hitDistance = match.Distance; Vector3 hitPosition = cameraRay.Direction * hitDistance + cameraRay.Origin; dragControl.LinearMotor.Offset = (hitPosition - bone.Owner.Translation).toBepuVec3(); dragControl.LinearMotor.TargetPosition = hitPosition.toBepuVec3(); ikScene.addExternalControl(dragControl); poseStartPosition = new MusclePosition(true); currentHandler = match.PoseableIdentifier.PoseHandler; currentHandler.posingStarted(activeModes); return(true); } } return(false); }