From 3d3dbe099d565e2bce4eb99bf36bfed580a53508 Mon Sep 17 00:00:00 2001 From: "Douglas R. Miles" Date: Sat, 2 Jun 2012 03:35:41 -0700 Subject: [PATCH] Many features to the BVHDecoder --- OpenMetaverse/BVHDecoder.cs | 134 ++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/OpenMetaverse/BVHDecoder.cs b/OpenMetaverse/BVHDecoder.cs index fac3bfb6..808e5065 100644 --- a/OpenMetaverse/BVHDecoder.cs +++ b/OpenMetaverse/BVHDecoder.cs @@ -355,13 +355,147 @@ namespace OpenMetaverse } return m_keys; } + + public bool Equals(BinBVHAnimationReader other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + return other.Loop.Equals(Loop) && other.OutPoint == OutPoint && other.InPoint == InPoint && other.Length == Length && other.HandPose == HandPose && other.JointCount == JointCount && Equals(other.joints, joints) && other.EaseInTime == EaseInTime && other.EaseOutTime == EaseOutTime && other.Priority == Priority && other.unknown1 == unknown1 && other.unknown0 == unknown0 && other.positionkeys == positionkeys && other.rotationkeys == rotationkeys; + } + + /// + /// Determines whether the specified is equal to the current . + /// + /// + /// true if the specified is equal to the current ; otherwise, false. + /// + /// The to compare with the current . + /// The parameter is null. + /// 2 + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != typeof(BinBVHAnimationReader)) return false; + return Equals((BinBVHAnimationReader)obj); } /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + /// 2 + public override int GetHashCode() + { + unchecked + { + int result = Loop.GetHashCode(); + result = (result * 397) ^ OutPoint.GetHashCode(); + result = (result * 397) ^ InPoint.GetHashCode(); + result = (result * 397) ^ Length.GetHashCode(); + result = (result * 397) ^ HandPose.GetHashCode(); + result = (result * 397) ^ JointCount.GetHashCode(); + result = (result * 397) ^ (joints != null ? joints.GetHashCode() : 0); + result = (result * 397) ^ EaseInTime.GetHashCode(); + result = (result * 397) ^ EaseOutTime.GetHashCode(); + result = (result * 397) ^ Priority; + result = (result * 397) ^ unknown1.GetHashCode(); + result = (result * 397) ^ unknown0.GetHashCode(); + result = (result * 397) ^ positionkeys; + result = (result * 397) ^ rotationkeys; + return result; + } + } + + public static bool Equals(binBVHJoint[] arr1, binBVHJoint[] arr2) + { + if (arr1.Length == arr2.Length) + { + for (int i = 0; i < arr1.Length; i++) + if (!arr1[i].Equals(arr2[i])) + return false; + /* not same*/ + return true; + } + return false; + } + + } + + + /// /// A Joint and it's associated meta data and keyframes /// public struct binBVHJoint { + public static bool Equals(binBVHJointKey[] arr1, binBVHJointKey[] arr2) + { + if (arr1.Length == arr2.Length) + { + for (int i = 0; i < arr1.Length; i++) + if (!Equals(arr1[i], arr2[i])) + return false; + /* not same*/ + return true; + } + return false; + } + public static bool Equals(binBVHJointKey arr1, binBVHJointKey arr2) + { + return (arr1.time == arr2.time && arr1.key_element == arr2.key_element); + } + + public bool Equals(binBVHJoint other) + { + return other.Priority == Priority && Equals(other.rotationkeys, rotationkeys) && Equals(other.Name, Name) && Equals(other.positionkeys, positionkeys); + } + + /// + /// Indicates whether this instance and a specified object are equal. + /// + /// + /// true if and this instance are the same type and represent the same value; otherwise, false. + /// + /// Another object to compare to. + /// 2 + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (obj.GetType() != typeof(binBVHJoint)) return false; + return Equals((binBVHJoint)obj); + } + + /// + /// Returns the hash code for this instance. + /// + /// + /// A 32-bit signed integer that is the hash code for this instance. + /// + /// 2 + public override int GetHashCode() + { + unchecked + { + int result = Priority; + result = (result * 397) ^ (rotationkeys != null ? rotationkeys.GetHashCode() : 0); + result = (result * 397) ^ (Name != null ? Name.GetHashCode() : 0); + result = (result * 397) ^ (positionkeys != null ? positionkeys.GetHashCode() : 0); + return result; + } + } + + public static bool operator ==(binBVHJoint left, binBVHJoint right) + { + return left.Equals(right); + } + + public static bool operator !=(binBVHJoint left, binBVHJoint right) + { + return !left.Equals(right); + } + /// /// Name of the Joint. Matches the avatar_skeleton.xml in client distros ///