diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/PrimitiveBaseShape.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 83ddf95..9cfc7ed 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs | |||
@@ -879,6 +879,67 @@ namespace OpenSim.Framework | |||
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
882 | public ulong GetMeshKey(Vector3 size, float lod) | ||
883 | { | ||
884 | ulong hash = 5381; | ||
885 | |||
886 | hash = djb2(hash, this.PathCurve); | ||
887 | hash = djb2(hash, (byte)((byte)this.HollowShape | (byte)this.ProfileShape)); | ||
888 | hash = djb2(hash, this.PathBegin); | ||
889 | hash = djb2(hash, this.PathEnd); | ||
890 | hash = djb2(hash, this.PathScaleX); | ||
891 | hash = djb2(hash, this.PathScaleY); | ||
892 | hash = djb2(hash, this.PathShearX); | ||
893 | hash = djb2(hash, this.PathShearY); | ||
894 | hash = djb2(hash, (byte)this.PathTwist); | ||
895 | hash = djb2(hash, (byte)this.PathTwistBegin); | ||
896 | hash = djb2(hash, (byte)this.PathRadiusOffset); | ||
897 | hash = djb2(hash, (byte)this.PathTaperX); | ||
898 | hash = djb2(hash, (byte)this.PathTaperY); | ||
899 | hash = djb2(hash, this.PathRevolutions); | ||
900 | hash = djb2(hash, (byte)this.PathSkew); | ||
901 | hash = djb2(hash, this.ProfileBegin); | ||
902 | hash = djb2(hash, this.ProfileEnd); | ||
903 | hash = djb2(hash, this.ProfileHollow); | ||
904 | |||
905 | // TODO: Separate scale out from the primitive shape data (after | ||
906 | // scaling is supported at the physics engine level) | ||
907 | byte[] scaleBytes = size.GetBytes(); | ||
908 | for (int i = 0; i < scaleBytes.Length; i++) | ||
909 | hash = djb2(hash, scaleBytes[i]); | ||
910 | |||
911 | // Include LOD in hash, accounting for endianness | ||
912 | byte[] lodBytes = new byte[4]; | ||
913 | Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4); | ||
914 | if (!BitConverter.IsLittleEndian) | ||
915 | { | ||
916 | Array.Reverse(lodBytes, 0, 4); | ||
917 | } | ||
918 | for (int i = 0; i < lodBytes.Length; i++) | ||
919 | hash = djb2(hash, lodBytes[i]); | ||
920 | |||
921 | // include sculpt UUID | ||
922 | if (this.SculptEntry) | ||
923 | { | ||
924 | scaleBytes = this.SculptTexture.GetBytes(); | ||
925 | for (int i = 0; i < scaleBytes.Length; i++) | ||
926 | hash = djb2(hash, scaleBytes[i]); | ||
927 | } | ||
928 | |||
929 | return hash; | ||
930 | } | ||
931 | |||
932 | private ulong djb2(ulong hash, byte c) | ||
933 | { | ||
934 | return ((hash << 5) + hash) + (ulong)c; | ||
935 | } | ||
936 | |||
937 | private ulong djb2(ulong hash, ushort c) | ||
938 | { | ||
939 | hash = ((hash << 5) + hash) + (ulong)((byte)c); | ||
940 | return ((hash << 5) + hash) + (ulong)(c >> 8); | ||
941 | } | ||
942 | |||
882 | public byte[] ExtraParamsToBytes() | 943 | public byte[] ExtraParamsToBytes() |
883 | { | 944 | { |
884 | // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); | 945 | // m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); |