aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs150
1 files changed, 31 insertions, 119 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0ff9388..6d0854b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -716,14 +716,12 @@ namespace OpenSim.Region.Framework.Scenes
716 set { m_particleSystem = value; } 716 set { m_particleSystem = value; }
717 } 717 }
718 718
719
720 public DateTime Expires 719 public DateTime Expires
721 { 720 {
722 get { return m_expires; } 721 get { return m_expires; }
723 set { m_expires = value; } 722 set { m_expires = value; }
724 } 723 }
725 724
726
727 public DateTime Rezzed 725 public DateTime Rezzed
728 { 726 {
729 get { return m_rezzed; } 727 get { return m_rezzed; }
@@ -1932,20 +1930,14 @@ namespace OpenSim.Region.Framework.Scenes
1932 else 1930 else
1933 { 1931 {
1934 data = new byte[16]; 1932 data = new byte[16];
1935 int pos = 0;
1936
1937 // The flags don't like conversion from uint to byte, so we have to do
1938 // it the crappy way. See the above function :(
1939
1940 data[pos] = ConvertScriptUintToByte((uint)pTexAnim.Flags); pos++;
1941 data[pos] = (byte)pTexAnim.Face; pos++;
1942 data[pos] = (byte)pTexAnim.SizeX; pos++;
1943 data[pos] = (byte)pTexAnim.SizeY; pos++;
1944
1945 Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos);
1946 Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4);
1947 Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8);
1948 1933
1934 data[0] = (byte)pTexAnim.Flags;
1935 data[1] = (byte)pTexAnim.Face;
1936 data[2] = (byte)pTexAnim.SizeX;
1937 data[3] = (byte)pTexAnim.SizeY;
1938 Utils.FloatToBytesSafepos(pTexAnim.Start, data, 4);
1939 Utils.FloatToBytesSafepos(pTexAnim.Length, data, 8);
1940 Utils.FloatToBytesSafepos(pTexAnim.Rate, data, 12);
1949 } 1941 }
1950 m_TextureAnimation = data; 1942 m_TextureAnimation = data;
1951 } 1943 }
@@ -1970,23 +1962,15 @@ namespace OpenSim.Region.Framework.Scenes
1970 /// </summary> 1962 /// </summary>
1971 /// <param name="impulsei">Vector force</param> 1963 /// <param name="impulsei">Vector force</param>
1972 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1964 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1973 public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF) 1965 public void ApplyImpulse(Vector3 impulse, bool localGlobalTF)
1974 { 1966 {
1975 Vector3 impulse = impulsei; 1967 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
1968 return;
1976 1969
1977 if (localGlobalTF) 1970 if (localGlobalTF)
1978 { 1971 impulse *= GetWorldRotation();
1979 Quaternion grot = GetWorldRotation();
1980 Quaternion AXgrot = grot;
1981 Vector3 AXimpulsei = impulsei;
1982 Vector3 newimpulse = AXimpulsei * AXgrot;
1983 impulse = newimpulse;
1984 }
1985 1972
1986 if (ParentGroup != null) 1973 ParentGroup.applyImpulse(impulse);
1987 {
1988 ParentGroup.applyImpulse(impulse);
1989 }
1990 } 1974 }
1991 1975
1992 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future 1976 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
@@ -2009,9 +1993,7 @@ namespace OpenSim.Region.Framework.Scenes
2009 return; 1993 return;
2010 1994
2011 if (localGlobalTF) 1995 if (localGlobalTF)
2012 { 1996 pVel *= GetWorldRotation();
2013 pVel = pVel * GetWorldRotation();
2014 }
2015 1997
2016 ParentGroup.Velocity = pVel; 1998 ParentGroup.Velocity = pVel;
2017 } 1999 }
@@ -2036,9 +2018,7 @@ namespace OpenSim.Region.Framework.Scenes
2036 return; 2018 return;
2037 2019
2038 if (localGlobalTF) 2020 if (localGlobalTF)
2039 { 2021 pAngVel *= GetWorldRotation();
2040 pAngVel = pAngVel * GetWorldRotation();
2041 }
2042 2022
2043 root.AngularVelocity = pAngVel; 2023 root.AngularVelocity = pAngVel;
2044 } 2024 }
@@ -2051,23 +2031,15 @@ namespace OpenSim.Region.Framework.Scenes
2051 /// </summary> 2031 /// </summary>
2052 /// <param name="impulsei">Vector force</param> 2032 /// <param name="impulsei">Vector force</param>
2053 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 2033 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
2054 public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) 2034 public void ApplyAngularImpulse(Vector3 impulse, bool localGlobalTF)
2055 { 2035 {
2056 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit) 2036 if (ParentGroup == null || ParentGroup.IsDeleted || ParentGroup.inTransit)
2057 return; 2037 return;
2058 2038
2059 Vector3 impulse = impulsei;
2060
2061 if (localGlobalTF) 2039 if (localGlobalTF)
2062 { 2040 ParentGroup.ApplyAngularImpulse(impulse * GetWorldRotation());
2063 Quaternion grot = GetWorldRotation(); 2041 else
2064 Quaternion AXgrot = grot; 2042 ParentGroup.ApplyAngularImpulse(impulse);
2065 Vector3 AXimpulsei = impulsei;
2066 Vector3 newimpulse = AXimpulsei * AXgrot;
2067 impulse = newimpulse;
2068 }
2069
2070 ParentGroup.ApplyAngularImpulse(impulse);
2071 } 2043 }
2072 2044
2073 /// <summary> 2045 /// <summary>
@@ -2084,9 +2056,7 @@ namespace OpenSim.Region.Framework.Scenes
2084 Vector3 torque = torquei; 2056 Vector3 torque = torquei;
2085 2057
2086 if (localGlobalTF) 2058 if (localGlobalTF)
2087 {
2088 torque *= GetWorldRotation(); 2059 torque *= GetWorldRotation();
2089 }
2090 2060
2091 Torque = torque; 2061 Torque = torque;
2092 } 2062 }
@@ -2135,19 +2105,6 @@ namespace OpenSim.Region.Framework.Scenes
2135 } 2105 }
2136 } 2106 }
2137 2107
2138 public byte ConvertScriptUintToByte(uint indata)
2139 {
2140 byte outdata = (byte)TextureAnimFlags.NONE;
2141 if ((indata & 1) != 0) outdata |= (byte)TextureAnimFlags.ANIM_ON;
2142 if ((indata & 2) != 0) outdata |= (byte)TextureAnimFlags.LOOP;
2143 if ((indata & 4) != 0) outdata |= (byte)TextureAnimFlags.REVERSE;
2144 if ((indata & 8) != 0) outdata |= (byte)TextureAnimFlags.PING_PONG;
2145 if ((indata & 16) != 0) outdata |= (byte)TextureAnimFlags.SMOOTH;
2146 if ((indata & 32) != 0) outdata |= (byte)TextureAnimFlags.ROTATE;
2147 if ((indata & 64) != 0) outdata |= (byte)TextureAnimFlags.SCALE;
2148 return outdata;
2149 }
2150
2151 /// <summary> 2108 /// <summary>
2152 /// Duplicates this part. 2109 /// Duplicates this part.
2153 /// </summary> 2110 /// </summary>
@@ -2505,14 +2462,6 @@ namespace OpenSim.Region.Framework.Scenes
2505 return 0; 2462 return 0;
2506 } 2463 }
2507 2464
2508 public double GetDistanceTo(Vector3 a, Vector3 b)
2509 {
2510 float dx = a.X - b.X;
2511 float dy = a.Y - b.Y;
2512 float dz = a.Z - b.Z;
2513 return Math.Sqrt(dx * dx + dy * dy + dz * dz);
2514 }
2515
2516 public uint GetEffectiveObjectFlags() 2465 public uint GetEffectiveObjectFlags()
2517 { 2466 {
2518 // Commenting this section of code out since it doesn't actually do anything, as enums are handled by 2467 // Commenting this section of code out since it doesn't actually do anything, as enums are handled by
@@ -2647,20 +2596,13 @@ namespace OpenSim.Region.Framework.Scenes
2647 /// <returns>A Linked Child Prim objects position in world</returns> 2596 /// <returns>A Linked Child Prim objects position in world</returns>
2648 public Vector3 GetWorldPosition() 2597 public Vector3 GetWorldPosition()
2649 { 2598 {
2650 Vector3 ret;
2651 if (_parentID == 0) 2599 if (_parentID == 0)
2652 // if a root SOP, my position is what it is 2600 return GroupPosition;
2653 ret = GroupPosition; 2601
2654 else 2602 // If a child SOP, my position is relative to the root SOP so take
2655 { 2603 // my info and add the root's position and rotation to
2656 // If a child SOP, my position is relative to the root SOP so take 2604 // get my world position.
2657 // my info and add the root's position and rotation to 2605 return ParentGroup.AbsolutePosition + OffsetPosition * ParentGroup.RootPart.RotationOffset;
2658 // get my world position.
2659 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2660 Vector3 translationOffsetPosition = OffsetPosition * parentRot;
2661 ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
2662 }
2663 return ret;
2664 } 2606 }
2665 2607
2666 /// <summary> 2608 /// <summary>
@@ -2669,22 +2611,12 @@ namespace OpenSim.Region.Framework.Scenes
2669 /// <returns></returns> 2611 /// <returns></returns>
2670 public Quaternion GetWorldRotation() 2612 public Quaternion GetWorldRotation()
2671 { 2613 {
2672 Quaternion newRot; 2614 if (_parentID == 0)
2673 2615 return RotationOffset;
2674 if (this.LinkNum == 0 || this.LinkNum == 1)
2675 {
2676 newRot = RotationOffset;
2677 }
2678 else
2679 {
2680 // A child SOP's rotation is relative to the root SOP's rotation.
2681 // Combine them to get my absolute rotation.
2682 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2683 Quaternion oldRot = RotationOffset;
2684 newRot = parentRot * oldRot;
2685 }
2686 2616
2687 return newRot; 2617 // A child SOP's rotation is relative to the root SOP's rotation.
2618 // Combine them to get my absolute rotation.
2619 return ParentGroup.RootPart.RotationOffset * RotationOffset;
2688 } 2620 }
2689 2621
2690 /// <summary> 2622 /// <summary>
@@ -3066,27 +2998,7 @@ namespace OpenSim.Region.Framework.Scenes
3066 } 2998 }
3067 //ParentGroup.RootPart.m_groupPosition = newpos; 2999 //ParentGroup.RootPart.m_groupPosition = newpos;
3068 } 3000 }
3069/* 3001
3070 if (pa != null && _parentID != 0 && ParentGroup != null)
3071 {
3072 // Special case where a child object is requesting property updates.
3073 // This happens when linksets are modified to use flexible links rather than
3074 // the default links.
3075 // The simulator code presumes that child parts are only modified by scripts
3076 // so the logic for changing position/rotation/etc does not take into
3077 // account the physical object actually moving.
3078 // This code updates the offset position and rotation of the child and then
3079 // lets the update code push the update to the viewer.
3080 // Since physics engines do not normally generate this event for linkset children,
3081 // this code will not be active unless you have a specially configured
3082 // physics engine.
3083 Quaternion invRootRotation = Quaternion.Normalize(Quaternion.Inverse(ParentGroup.RootPart.RotationOffset));
3084 m_offsetPosition = pa.Position - m_groupPosition;
3085 RotationOffset = pa.Orientation * invRootRotation;
3086 // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}",
3087 // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset);
3088 }
3089*/
3090 ScheduleTerseUpdate(); 3002 ScheduleTerseUpdate();
3091 } 3003 }
3092 3004
@@ -4460,7 +4372,7 @@ namespace OpenSim.Region.Framework.Scenes
4460 q = iray.Origin + iray.Direction * a; 4372 q = iray.Origin + iray.Direction * a;
4461 //} 4373 //}
4462 4374
4463 float distance2 = (float)GetDistanceTo(q, AXpos); 4375 float distance2 = Vector3.Distance(q, AXpos);
4464 // Is this the closest hit to the object's origin? 4376 // Is this the closest hit to the object's origin?
4465 //if (faceCenters) 4377 //if (faceCenters)
4466 //{ 4378 //{