aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/PrimitiveBaseShape.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index d873071..1b6a1d2 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -859,6 +859,67 @@ namespace OpenSim.Framework
859 } 859 }
860 } 860 }
861 861
862 public ulong GetMeshKey(Vector3 size, float lod)
863 {
864 ulong hash = 5381;
865
866 hash = djb2(hash, this.PathCurve);
867 hash = djb2(hash, (byte)((byte)this.HollowShape | (byte)this.ProfileShape));
868 hash = djb2(hash, this.PathBegin);
869 hash = djb2(hash, this.PathEnd);
870 hash = djb2(hash, this.PathScaleX);
871 hash = djb2(hash, this.PathScaleY);
872 hash = djb2(hash, this.PathShearX);
873 hash = djb2(hash, this.PathShearY);
874 hash = djb2(hash, (byte)this.PathTwist);
875 hash = djb2(hash, (byte)this.PathTwistBegin);
876 hash = djb2(hash, (byte)this.PathRadiusOffset);
877 hash = djb2(hash, (byte)this.PathTaperX);
878 hash = djb2(hash, (byte)this.PathTaperY);
879 hash = djb2(hash, this.PathRevolutions);
880 hash = djb2(hash, (byte)this.PathSkew);
881 hash = djb2(hash, this.ProfileBegin);
882 hash = djb2(hash, this.ProfileEnd);
883 hash = djb2(hash, this.ProfileHollow);
884
885 // TODO: Separate scale out from the primitive shape data (after
886 // scaling is supported at the physics engine level)
887 byte[] scaleBytes = size.GetBytes();
888 for (int i = 0; i < scaleBytes.Length; i++)
889 hash = djb2(hash, scaleBytes[i]);
890
891 // Include LOD in hash, accounting for endianness
892 byte[] lodBytes = new byte[4];
893 Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
894 if (!BitConverter.IsLittleEndian)
895 {
896 Array.Reverse(lodBytes, 0, 4);
897 }
898 for (int i = 0; i < lodBytes.Length; i++)
899 hash = djb2(hash, lodBytes[i]);
900
901 // include sculpt UUID
902 if (this.SculptEntry)
903 {
904 scaleBytes = this.SculptTexture.GetBytes();
905 for (int i = 0; i < scaleBytes.Length; i++)
906 hash = djb2(hash, scaleBytes[i]);
907 }
908
909 return hash;
910 }
911
912 private ulong djb2(ulong hash, byte c)
913 {
914 return ((hash << 5) + hash) + (ulong)c;
915 }
916
917 private ulong djb2(ulong hash, ushort c)
918 {
919 hash = ((hash << 5) + hash) + (ulong)((byte)c);
920 return ((hash << 5) + hash) + (ulong)(c >> 8);
921 }
922
862 public byte[] ExtraParamsToBytes() 923 public byte[] ExtraParamsToBytes()
863 { 924 {
864// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); 925// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()");