public Pose Apply(Pose panelPose, Vector3 pivotPoint) { var constrainedPose = PivotLook.Solve(panelPose, pivotPoint, lookTarget, horizonNormal); return(constrainedPose); }
private void onGraspedMovement(Vector3 oldPos, Quaternion oldRot, Vector3 newPos, Quaternion newRot, List <InteractionController> controllers) { if (!gameObject.activeInHierarchy || !this.enabled) { return; } // An important reason this method works is that even though the various rigidbodies // have constantly-fluctuating poses with respect to one another, there are rigid // "ideal" poses and relative poses stored on Start() that allow target positions // to always be rigidly calculatable. // Introduce any sort of dynamic "relative pose" calculation INSIDE this method, // and you'll see a ton of erratic behaviour and terrible instability. var newPose = new Pose(newPos, newRot); var newPanelPose = newPose.Then(_handleToPanelPose); var graspingCentroid = controllers.Query() .Select(c => c.GetGraspPoint()) .Fold((sum, p) => p + sum) / controllers.Count; var targetLookFromPose = PivotLook.Solve(newPanelPose, graspingCentroid, lookTarget.position, Vector3.up, flip180: flip180); var targetHandlePose = targetLookFromPose.Then(_handleToPanelPose.inverse); intObj.rigidbody.MovePosition(targetHandlePose.position); intObj.rigidbody.MoveRotation(targetHandlePose.rotation); intObj.rigidbody.position = targetHandlePose.position; intObj.rigidbody.rotation = targetHandlePose.rotation; }