/// <summary> /// Allows us to render joint info into the scene. This GUI is /// used for displaying and manipulating the joint itself. /// </summary> /// <returns>Reports if the object's value was changed</returns> public override bool OnSceneManipulatorGUI(IKBoneModifier rModifier) { #if UNITY_EDITOR //Quaternion lSwing = mBone.Swing; //Quaternion lTwist = mBone.Twist; bool lIsSwingDirty = HandlesHelper.JointSwingHandle(mBone, rModifier); if (lIsSwingDirty) { //rModifier.Swing = lSwing; rModifier.IsDirty = true; } if (_AllowTwist) { bool lIsTwistDirty = HandlesHelper.JointTwistHandle(mBone, rModifier); if (lIsTwistDirty) { //rModifier.Twist = lTwist; rModifier.IsDirty = true; } } if (rModifier.IsDirty) { ApplyLimits(ref rModifier.Swing, ref rModifier.Twist); } #endif return(rModifier.IsDirty); }
/// <summary> /// Allow for rendering in the editor /// </summary> /// <returns></returns> public override bool OnSceneConstraintGUI(bool rIsSelected) { bool lIsDirty = false; #if UNITY_EDITOR IKBoneModifier lModifier = IKBoneModifier.Allocate(); lModifier.Swing = _Swing; lModifier.Twist = _Twist; bool lIsSwingDirty = HandlesHelper.JointSwingHandle(mBone, lModifier); if (lIsSwingDirty) { lIsDirty = true; } bool lIsTwistDirty = HandlesHelper.JointTwistHandle(mBone, lModifier); if (lIsTwistDirty) { lIsDirty = true; } if (lIsDirty) { _Swing = lModifier.Swing; _Twist = lModifier.Twist; mBone.SetLocalRotation(_Swing, _Twist, 1f); } IKBoneModifier.Release(lModifier); #endif return(lIsDirty); }
/// <summary> /// Allows us to render joint info into the scene. This GUI is /// used for displaying and manipulating the joint itself. /// </summary> /// <returns>Reports if the object's value was changed</returns> public override bool OnSceneManipulatorGUI(IKBoneModifier rModifier) { #if UNITY_EDITOR //Quaternion lSwing = mBone.Swing; //Quaternion lTwist = mBone.Twist; bool lIsSwingDirty = HandlesHelper.JointSwingHandle(mBone, rModifier); if (lIsSwingDirty) { //rModifier.Swing = lSwing; rModifier.IsDirty = true; } bool lIsTwistDirty = HandlesHelper.JointTwistHandle(mBone, rModifier); if (lIsTwistDirty) { //rModifier.Twist = lTwist; rModifier.IsDirty = true; } if (rModifier.IsDirty) { // Before we go to far, see if we are within the joint limits. If not, // we need to go back to a good position. bool lIsInLimits = ApplyLimits(ref rModifier.Swing, ref rModifier.Twist); if (lIsInLimits || QuaternionExt.IsEqual(rModifier.Swing, Quaternion.identity)) { mLastSwing = rModifier.Swing; mLastTwist = rModifier.Twist; } else { rModifier.Swing = mLastSwing; rModifier.Twist = mLastTwist; } } #endif return(rModifier.IsDirty); }