public int GetHashCode(ref IList <LeftRightPair <object, int> > hashCodes) { if (hashCodes is null) { throw new ArgumentNullException(nameof(hashCodes)); } foreach (LeftRightPair <object, int> pair in hashCodes) { if (pair.Left == this) { return(pair.Right); } } LeftRightPair <object, int> sourceHash = new LeftRightPair <object, int>(this, 0); hashCodes.Add(sourceHash); unchecked { int hashCode = 3371; foreach (string property in _properties.Keys) { hashCode *= 2; hashCode += CyclicalMethods.GetHashCode(_properties[property], ref hashCodes); } sourceHash.Right = hashCode; return(hashCode); } }
/// <summary> /// Initialize hand controller pairs corresponding to each of the hand model pairs /// configured in _handPool.HandPairs list. If any of the hand model in /// _handPool.HandPairs is not configured properly, its corresponding hand controller /// will be null and will not be updated afterwards. /// </summary> private void InitHandControllers() { _handModelCalibProfileManager = CalibrationProfileManager.Instance; _handControllerPairs = new List <LeftRightPair <UnityHandController> >(); _handControllers = new List <UnityHandController>(); int n = _handPool.HandPairs.Count; int vrControllerPairNum = _vrControllerObjReferencePairs.Count; for (int i = 0; i < n; i++) { UnityHandRepresentation leftRep = _handPool.HandPairs[i].Left; UnityHandController left = null; if (leftRep.Initialized) { HandModelCalibrationProfile profile = _handModelCalibProfileManager.FindProfile( leftRep.GraphicsHandModel.Hand); left = new UnityHandController(false, leftRep, this); GameObject vrControllerObj = i < vrControllerPairNum ? _vrControllerObjReferencePairs[i].Left : null; Debug.Log(leftRep.GraphicsHandModel.Hand + "+++++++++++++++"); Debug.Log(profile); Debug.Log("_handModelCalibProfileManager" + _handModelCalibProfileManager); //Debug.Log(vrControllerObj); //Debug.Log(rightRep.BendInwardLocalDirection); left.StartInit(profile, vrControllerObj, leftRep.BendInwardLocalDirection); _handControllers.Add(left); } UnityHandRepresentation rightRep = _handPool.HandPairs[i].Right; UnityHandController right = null; if (rightRep.Initialized) { HandModelCalibrationProfile profile = _handModelCalibProfileManager.FindProfile( rightRep.GraphicsHandModel.Hand); right = new UnityHandController(true, rightRep, this); GameObject vrControllerObj = i < vrControllerPairNum ? _vrControllerObjReferencePairs[i].Right : null; right.StartInit(profile, vrControllerObj, rightRep.BendInwardLocalDirection); _handControllers.Add(right); } LeftRightPair <UnityHandController> pair = new LeftRightPair <UnityHandController>(left, right); _handControllerPairs.Add(pair); } }
public static int GetHashCode(object source, ref IList <LeftRightPair <object, int> > hashCodes) { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (hashCodes is null) { throw new ArgumentNullException(nameof(hashCodes)); } foreach (LeftRightPair <object, int> pair in hashCodes) { if (pair.Left == source) { return(pair.Right); } } int hash = 0; if (source is ICyclical cyclical) { return(cyclical.GetHashCode(ref hashCodes)); } else if (source is Array array) { LeftRightPair <object, int> pair = new LeftRightPair <object, int>(source, hash); hashCodes.Add(pair); unchecked { for (int i = 0; i < array.GetLength(0); ++i) { hash *= 2; hash += GetHashCode(array.GetValue(i), ref hashCodes); } } pair.Right = hash; return(hash); } else { LeftRightPair <object, int> pair = new LeftRightPair <object, int>(source, source.GetHashCode()); hashCodes.Add(pair); return(pair.Right); } }
public virtual int GetHashCode(ref IList <LeftRightPair <object, int> > hashCodes) { if (hashCodes is null) { throw new ArgumentNullException(nameof(hashCodes)); } foreach (LeftRightPair <object, int> pair in hashCodes) { if (pair.Left == this) { return(pair.Right); } } LeftRightPair <object, int> sourceHash = new LeftRightPair <object, int>(this, 0); hashCodes.Add(sourceHash); return(sourceHash.Right); }
/// <summary> /// When VR controller GameObject is used as the reference to move hand models, it switches /// the left/right VR controller reference for the left/right hand models, so if originally /// left VR conroller moves the left hand model, it is now the right VR controller that moves /// the left hand model. /// </summary> private void SwitchHandPositionAndAttitudeReference() { _isLeftRightReferenceReversed = !_isLeftRightReferenceReversed; int pairNum = _vrControllerObjReferencePairs.Count; int handControllerPairNum = _handControllerPairs.Count; for (int i = 0; i < pairNum && i < handControllerPairNum; i++) { LeftRightPair <UnityHandController> handControllerPair = _handControllerPairs[i]; LeftRightPair <GameObject> vrControllerObjReferencePair = _vrControllerObjReferencePairs[i]; GameObject leftReference = vrControllerObjReferencePair.Left; GameObject rightReference = vrControllerObjReferencePair.Right; UnityHandController leftHandController = handControllerPair.Left; UnityHandController rightHandController = handControllerPair.Right; if (_isLeftRightReferenceReversed) { if (leftHandController != null) { leftHandController.AssignPositionAndAttitudeReference(rightReference); } if (rightHandController != null) { rightHandController.AssignPositionAndAttitudeReference(leftReference); } } else { if (leftHandController != null) { leftHandController.AssignPositionAndAttitudeReference(leftReference); } if (rightHandController != null) { rightHandController.AssignPositionAndAttitudeReference(rightReference); } } } }