aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs109
1 files changed, 48 insertions, 61 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index c91658e..123c8ff 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -38,6 +38,9 @@
38 * switch between 'VEHICLE' parameter use and general dynamics 38 * switch between 'VEHICLE' parameter use and general dynamics
39 * settings use. 39 * settings use.
40 */ 40 */
41
42//#define SPAM
43
41using System; 44using System;
42using System.Collections.Generic; 45using System.Collections.Generic;
43using System.Reflection; 46using System.Reflection;
@@ -54,7 +57,6 @@ namespace OpenSim.Region.Physics.OdePlugin
54 /// <summary> 57 /// <summary>
55 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. 58 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves.
56 /// </summary> 59 /// </summary>
57
58 public class OdePrim : PhysicsActor 60 public class OdePrim : PhysicsActor
59 { 61 {
60 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 62 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -279,14 +281,14 @@ namespace OpenSim.Region.Physics.OdePlugin
279 281
280 public override bool Selected 282 public override bool Selected
281 { 283 {
282 set { 284 set
283 285 {
284
285 // This only makes the object not collidable if the object 286 // This only makes the object not collidable if the object
286 // is physical or the object is modified somehow *IN THE FUTURE* 287 // is physical or the object is modified somehow *IN THE FUTURE*
287 // without this, if an avatar selects prim, they can walk right 288 // without this, if an avatar selects prim, they can walk right
288 // through it while it's selected 289 // through it while it's selected
289 m_collisionscore = 0; 290 m_collisionscore = 0;
291
290 if ((m_isphysical && !_zeroFlag) || !value) 292 if ((m_isphysical && !_zeroFlag) || !value)
291 { 293 {
292 m_taintselected = value; 294 m_taintselected = value;
@@ -297,7 +299,9 @@ namespace OpenSim.Region.Physics.OdePlugin
297 m_taintselected = value; 299 m_taintselected = value;
298 m_isSelected = value; 300 m_isSelected = value;
299 } 301 }
300 if (m_isSelected) disableBodySoft(); 302
303 if (m_isSelected)
304 disableBodySoft();
301 } 305 }
302 } 306 }
303 307
@@ -324,8 +328,6 @@ namespace OpenSim.Region.Physics.OdePlugin
324 //m_log.Warn("Setting Geom to: " + prim_geom); 328 //m_log.Warn("Setting Geom to: " + prim_geom);
325 } 329 }
326 330
327
328
329 public void enableBodySoft() 331 public void enableBodySoft()
330 { 332 {
331 if (!childPrim) 333 if (!childPrim)
@@ -626,8 +628,6 @@ namespace OpenSim.Region.Physics.OdePlugin
626 break; 628 break;
627 } 629 }
628 630
629
630
631 float taperX1; 631 float taperX1;
632 float taperY1; 632 float taperY1;
633 float taperX; 633 float taperX;
@@ -682,9 +682,6 @@ namespace OpenSim.Region.Physics.OdePlugin
682// else if (returnMass > _parent_scene.maximumMassObject) 682// else if (returnMass > _parent_scene.maximumMassObject)
683// returnMass = _parent_scene.maximumMassObject; 683// returnMass = _parent_scene.maximumMassObject;
684 684
685
686
687
688 // Recursively calculate mass 685 // Recursively calculate mass
689 bool HasChildPrim = false; 686 bool HasChildPrim = false;
690 lock (childrenPrim) 687 lock (childrenPrim)
@@ -693,8 +690,8 @@ namespace OpenSim.Region.Physics.OdePlugin
693 { 690 {
694 HasChildPrim = true; 691 HasChildPrim = true;
695 } 692 }
696
697 } 693 }
694
698 if (HasChildPrim) 695 if (HasChildPrim)
699 { 696 {
700 OdePrim[] childPrimArr = new OdePrim[0]; 697 OdePrim[] childPrimArr = new OdePrim[0];
@@ -711,10 +708,12 @@ namespace OpenSim.Region.Physics.OdePlugin
711 break; 708 break;
712 } 709 }
713 } 710 }
711
714 if (returnMass > _parent_scene.maximumMassObject) 712 if (returnMass > _parent_scene.maximumMassObject)
715 returnMass = _parent_scene.maximumMassObject; 713 returnMass = _parent_scene.maximumMassObject;
714
716 return returnMass; 715 return returnMass;
717 }// end CalculateMass 716 }
718 717
719 #endregion 718 #endregion
720 719
@@ -750,7 +749,6 @@ namespace OpenSim.Region.Physics.OdePlugin
750 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 749 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
751 } 750 }
752 751
753
754 d.BodyDestroy(Body); 752 d.BodyDestroy(Body);
755 lock (childrenPrim) 753 lock (childrenPrim)
756 { 754 {
@@ -779,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin
779 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); 777 d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
780 } 778 }
781 779
782
783 Body = IntPtr.Zero; 780 Body = IntPtr.Zero;
784 } 781 }
785 } 782 }
@@ -791,6 +788,8 @@ namespace OpenSim.Region.Physics.OdePlugin
791 788
792 public void setMesh(OdeScene parent_scene, IMesh mesh) 789 public void setMesh(OdeScene parent_scene, IMesh mesh)
793 { 790 {
791// m_log.DebugFormat("[ODE PRIM]: Setting mesh on {0} to {1}", Name, mesh);
792
794 // This sleeper is there to moderate how long it takes between 793 // This sleeper is there to moderate how long it takes between
795 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object 794 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
796 795
@@ -869,7 +868,7 @@ namespace OpenSim.Region.Physics.OdePlugin
869 if (prim_geom != IntPtr.Zero) 868 if (prim_geom != IntPtr.Zero)
870 { 869 {
871 if (!_position.ApproxEquals(m_taintposition, 0f)) 870 if (!_position.ApproxEquals(m_taintposition, 0f))
872 changemove(timestep); 871 changemove(timestep);
873 872
874 if (m_taintrot != _orientation) 873 if (m_taintrot != _orientation)
875 { 874 {
@@ -887,19 +886,15 @@ namespace OpenSim.Region.Physics.OdePlugin
887 rotate(timestep); 886 rotate(timestep);
888 } 887 }
889 } 888 }
890 //
891 889
892 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) 890 if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
893 changePhysicsStatus(timestep); 891 changePhysicsStatus(timestep);
894 //
895 892
896 if (!_size.ApproxEquals(m_taintsize,0f)) 893 if (!_size.ApproxEquals(m_taintsize, 0f))
897 changesize(timestep); 894 changesize(timestep);
898 //
899 895
900 if (m_taintshape) 896 if (m_taintshape)
901 changeshape(timestep); 897 changeshape(timestep);
902 //
903 898
904 if (m_taintforce) 899 if (m_taintforce)
905 changeAddForce(timestep); 900 changeAddForce(timestep);
@@ -927,7 +922,6 @@ namespace OpenSim.Region.Physics.OdePlugin
927 922
928 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) 923 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
929 changeAngularLock(timestep); 924 changeAngularLock(timestep);
930
931 } 925 }
932 else 926 else
933 { 927 {
@@ -935,7 +929,6 @@ namespace OpenSim.Region.Physics.OdePlugin
935 } 929 }
936 } 930 }
937 931
938
939 private void changeAngularLock(float timestep) 932 private void changeAngularLock(float timestep)
940 { 933 {
941 // do we have a Physical object? 934 // do we have a Physical object?
@@ -963,7 +956,6 @@ namespace OpenSim.Region.Physics.OdePlugin
963 } 956 }
964 // Store this for later in case we get turned into a separate body 957 // Store this for later in case we get turned into a separate body
965 m_angularlock = m_taintAngularLock; 958 m_angularlock = m_taintAngularLock;
966
967 } 959 }
968 960
969 private void changelink(float timestep) 961 private void changelink(float timestep)
@@ -1102,7 +1094,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1102 m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name); 1094 m_log.DebugFormat("[PHYSICS]: {0} ain't got no boooooooooddy, no body", Name);
1103 } 1095 }
1104 1096
1105
1106 prm.m_interpenetrationcount = 0; 1097 prm.m_interpenetrationcount = 0;
1107 prm.m_collisionscore = 0; 1098 prm.m_collisionscore = 0;
1108 prm.m_disabled = false; 1099 prm.m_disabled = false;
@@ -1162,7 +1153,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1162 } 1153 }
1163 } 1154 }
1164 } 1155 }
1165
1166 } 1156 }
1167 1157
1168 private void ChildSetGeom(OdePrim odePrim) 1158 private void ChildSetGeom(OdePrim odePrim)
@@ -1223,17 +1213,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1223 //Console.WriteLine("childrenPrim.Remove " + odePrim); 1213 //Console.WriteLine("childrenPrim.Remove " + odePrim);
1224 childrenPrim.Remove(odePrim); 1214 childrenPrim.Remove(odePrim);
1225 } 1215 }
1226
1227
1228
1229 1216
1230 if (Body != IntPtr.Zero) 1217 if (Body != IntPtr.Zero)
1231 { 1218 {
1232 _parent_scene.remActivePrim(this); 1219 _parent_scene.remActivePrim(this);
1233 } 1220 }
1234 1221
1235
1236
1237 lock (childrenPrim) 1222 lock (childrenPrim)
1238 { 1223 {
1239 foreach (OdePrim prm in childrenPrim) 1224 foreach (OdePrim prm in childrenPrim)
@@ -1242,8 +1227,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1242 ParentPrim(prm); 1227 ParentPrim(prm);
1243 } 1228 }
1244 } 1229 }
1245
1246
1247 } 1230 }
1248 1231
1249 private void changeSelectedStatus(float timestep) 1232 private void changeSelectedStatus(float timestep)
@@ -1398,7 +1381,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1398 } 1381 }
1399 } 1382 }
1400 } 1383 }
1401
1402 else 1384 else
1403 { 1385 {
1404 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1386 _parent_scene.waitForSpaceUnlock(m_targetSpace);
@@ -1438,10 +1420,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1438 } 1420 }
1439 } 1421 }
1440 1422
1441
1442 lock (_parent_scene.OdeLock) 1423 lock (_parent_scene.OdeLock)
1443 { 1424 {
1444//Console.WriteLine("changeadd 1"); 1425#if SPAM
1426Console.WriteLine("changeadd 1");
1427#endif
1445 CreateGeom(m_targetSpace, _mesh); 1428 CreateGeom(m_targetSpace, _mesh);
1446 1429
1447 if (prim_geom != IntPtr.Zero) 1430 if (prim_geom != IntPtr.Zero)
@@ -1684,13 +1667,11 @@ Console.WriteLine(" JointCreateFixed");
1684 { 1667 {
1685 PID_G = m_PIDTau + 1; 1668 PID_G = m_PIDTau + 1;
1686 } 1669 }
1687
1688 1670
1689 // Where are we, and where are we headed? 1671 // Where are we, and where are we headed?
1690 d.Vector3 pos = d.BodyGetPosition(Body); 1672 d.Vector3 pos = d.BodyGetPosition(Body);
1691 d.Vector3 vel = d.BodyGetLinearVel(Body); 1673 d.Vector3 vel = d.BodyGetLinearVel(Body);
1692 1674
1693
1694 // Non-Vehicles have a limited set of Hover options. 1675 // Non-Vehicles have a limited set of Hover options.
1695 // determine what our target height really is based on HoverType 1676 // determine what our target height really is based on HoverType
1696 switch (m_PIDHoverType) 1677 switch (m_PIDHoverType)
@@ -1796,8 +1777,6 @@ Console.WriteLine(" JointCreateFixed");
1796 } 1777 }
1797 } 1778 }
1798 1779
1799
1800
1801 public void rotate(float timestep) 1780 public void rotate(float timestep)
1802 { 1781 {
1803 d.Quaternion myrot = new d.Quaternion(); 1782 d.Quaternion myrot = new d.Quaternion();
@@ -1908,7 +1887,10 @@ Console.WriteLine(" JointCreateFixed");
1908 1887
1909 public void changesize(float timestamp) 1888 public void changesize(float timestamp)
1910 { 1889 {
1911 1890#if SPAM
1891 m_log.DebugFormat("[ODE PRIM]: Called changesize");
1892#endif
1893
1912 string oldname = _parent_scene.geom_name_map[prim_geom]; 1894 string oldname = _parent_scene.geom_name_map[prim_geom];
1913 1895
1914 if (_size.X <= 0) _size.X = 0.01f; 1896 if (_size.X <= 0) _size.X = 0.01f;
@@ -1918,8 +1900,9 @@ Console.WriteLine(" JointCreateFixed");
1918 // Cleanup of old prim geometry 1900 // Cleanup of old prim geometry
1919 if (_mesh != null) 1901 if (_mesh != null)
1920 { 1902 {
1921 // Cleanup meshing here 1903 // TODO: Cleanup meshing here
1922 } 1904 }
1905
1923 //kill body to rebuild 1906 //kill body to rebuild
1924 if (IsPhysical && Body != IntPtr.Zero) 1907 if (IsPhysical && Body != IntPtr.Zero)
1925 { 1908 {
@@ -1936,11 +1919,13 @@ Console.WriteLine(" JointCreateFixed");
1936 disableBody(); 1919 disableBody();
1937 } 1920 }
1938 } 1921 }
1922
1939 if (d.SpaceQuery(m_targetSpace, prim_geom)) 1923 if (d.SpaceQuery(m_targetSpace, prim_geom))
1940 { 1924 {
1941 _parent_scene.waitForSpaceUnlock(m_targetSpace); 1925 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1942 d.SpaceRemove(m_targetSpace, prim_geom); 1926 d.SpaceRemove(m_targetSpace, prim_geom);
1943 } 1927 }
1928
1944 d.GeomDestroy(prim_geom); 1929 d.GeomDestroy(prim_geom);
1945 prim_geom = IntPtr.Zero; 1930 prim_geom = IntPtr.Zero;
1946 // we don't need to do space calculation because the client sends a position update also. 1931 // we don't need to do space calculation because the client sends a position update also.
@@ -1960,15 +1945,19 @@ Console.WriteLine(" JointCreateFixed");
1960 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1945 mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1961 1946
1962 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 1947 //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
1963//Console.WriteLine("changesize 1"); 1948#if SPAM
1949Console.WriteLine("changesize 1");
1950#endif
1964 CreateGeom(m_targetSpace, mesh); 1951 CreateGeom(m_targetSpace, mesh);
1965
1966
1967 } 1952 }
1968 else 1953 else
1969 { 1954 {
1970 _mesh = null; 1955 _mesh = null;
1971//Console.WriteLine("changesize 2"); 1956
1957#if SPAM
1958Console.WriteLine("changesize 2");
1959#endif
1960
1972 CreateGeom(m_targetSpace, _mesh); 1961 CreateGeom(m_targetSpace, _mesh);
1973 } 1962 }
1974 1963
@@ -2004,8 +1993,6 @@ Console.WriteLine(" JointCreateFixed");
2004 m_taintsize = _size; 1993 m_taintsize = _size;
2005 } 1994 }
2006 1995
2007
2008
2009 public void changefloatonwater(float timestep) 1996 public void changefloatonwater(float timestep)
2010 { 1997 {
2011 m_collidesWater = m_taintCollidesWater; 1998 m_collidesWater = m_taintCollidesWater;
@@ -2053,6 +2040,7 @@ Console.WriteLine(" JointCreateFixed");
2053 prim_geom = IntPtr.Zero; 2040 prim_geom = IntPtr.Zero;
2054 m_log.ErrorFormat("[PHYSICS]: PrimGeom dead for {0}", Name); 2041 m_log.ErrorFormat("[PHYSICS]: PrimGeom dead for {0}", Name);
2055 } 2042 }
2043
2056 prim_geom = IntPtr.Zero; 2044 prim_geom = IntPtr.Zero;
2057 // we don't need to do space calculation because the client sends a position update also. 2045 // we don't need to do space calculation because the client sends a position update also.
2058 if (_size.X <= 0) _size.X = 0.01f; 2046 if (_size.X <= 0) _size.X = 0.01f;
@@ -2062,7 +2050,7 @@ Console.WriteLine(" JointCreateFixed");
2062 2050
2063 if (_parent_scene.needsMeshing(_pbs)) 2051 if (_parent_scene.needsMeshing(_pbs))
2064 { 2052 {
2065 // Don't need to re-enable body.. it's done in SetMesh 2053 // Don't need to re-enable body.. it's done in CreateMesh
2066 float meshlod = _parent_scene.meshSculptLOD; 2054 float meshlod = _parent_scene.meshSculptLOD;
2067 2055
2068 if (IsPhysical) 2056 if (IsPhysical)
@@ -2070,12 +2058,18 @@ Console.WriteLine(" JointCreateFixed");
2070 2058
2071 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); 2059 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
2072 // createmesh returns null when it doesn't mesh. 2060 // createmesh returns null when it doesn't mesh.
2061#if SPAM
2062Console.WriteLine("changeshape needed meshing");
2063#endif
2073 CreateGeom(m_targetSpace, mesh); 2064 CreateGeom(m_targetSpace, mesh);
2074 } 2065 }
2075 else 2066 else
2076 { 2067 {
2077 _mesh = null; 2068 _mesh = null;
2078//Console.WriteLine("changeshape"); 2069
2070#if SPAM
2071Console.WriteLine("changeshape not need meshing");
2072#endif
2079 CreateGeom(m_targetSpace, null); 2073 CreateGeom(m_targetSpace, null);
2080 } 2074 }
2081 2075
@@ -2110,6 +2104,7 @@ Console.WriteLine(" JointCreateFixed");
2110 parent.ChildSetGeom(this); 2104 parent.ChildSetGeom(this);
2111 } 2105 }
2112 } 2106 }
2107
2113 resetCollisionAccounting(); 2108 resetCollisionAccounting();
2114 m_taintshape = false; 2109 m_taintshape = false;
2115 } 2110 }
@@ -2160,11 +2155,8 @@ Console.WriteLine(" JointCreateFixed");
2160 } 2155 }
2161 2156
2162 m_taintforce = false; 2157 m_taintforce = false;
2163
2164 } 2158 }
2165 2159
2166
2167
2168 public void changeSetTorque(float timestamp) 2160 public void changeSetTorque(float timestamp)
2169 { 2161 {
2170 if (!m_isSelected) 2162 if (!m_isSelected)
@@ -2352,7 +2344,7 @@ Console.WriteLine(" JointCreateFixed");
2352 { 2344 {
2353 lock (_parent_scene.OdeLock) 2345 lock (_parent_scene.OdeLock)
2354 { 2346 {
2355 m_isVolumeDetect = (param!=0); 2347 m_isVolumeDetect = (param != 0);
2356 } 2348 }
2357 } 2349 }
2358 2350
@@ -2833,7 +2825,6 @@ Console.WriteLine(" JointCreateFixed");
2833 2825
2834 public override float APIDDamping{ set { return; } } 2826 public override float APIDDamping{ set { return; } }
2835 2827
2836
2837 private void createAMotor(Vector3 axis) 2828 private void createAMotor(Vector3 axis)
2838 { 2829 {
2839 if (Body == IntPtr.Zero) 2830 if (Body == IntPtr.Zero)
@@ -2953,7 +2944,6 @@ Console.WriteLine(" JointCreateFixed");
2953 //d.JointSetAMotorParam(Amotor, (int) dParam.Vel, 9000f); 2944 //d.JointSetAMotorParam(Amotor, (int) dParam.Vel, 9000f);
2954 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); 2945 d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
2955 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, Mass * 50f);// 2946 d.JointSetAMotorParam(Amotor, (int)dParam.FMax, Mass * 50f);//
2956
2957 } 2947 }
2958 2948
2959 public Matrix4 FromDMass(d.Mass pMass) 2949 public Matrix4 FromDMass(d.Mass pMass)
@@ -3038,8 +3028,6 @@ Console.WriteLine(" JointCreateFixed");
3038 return Matrix4.Identity; // should probably throw an error. singluar matrix inverse not possible 3028 return Matrix4.Identity; // should probably throw an error. singluar matrix inverse not possible
3039 } 3029 }
3040 3030
3041
3042
3043 return (Adjoint(pMat) / determinant3x3(pMat)); 3031 return (Adjoint(pMat) / determinant3x3(pMat));
3044 } 3032 }
3045 3033
@@ -3076,6 +3064,7 @@ Console.WriteLine(" JointCreateFixed");
3076 } 3064 }
3077 m++; 3065 m++;
3078 } 3066 }
3067
3079 return minor; 3068 return minor;
3080 } 3069 }
3081 3070
@@ -3178,7 +3167,6 @@ Console.WriteLine(" JointCreateFixed");
3178 3167
3179 det = diag1 + diag2 + diag3 - (diag4 + diag5 + diag6); 3168 det = diag1 + diag2 + diag3 - (diag4 + diag5 + diag6);
3180 return det; 3169 return det;
3181
3182 } 3170 }
3183 3171
3184 private static void DMassCopy(ref d.Mass src, ref d.Mass dst) 3172 private static void DMassCopy(ref d.Mass src, ref d.Mass dst)
@@ -3203,6 +3191,5 @@ Console.WriteLine(" JointCreateFixed");
3203 { 3191 {
3204 m_material = pMaterial; 3192 m_material = pMaterial;
3205 } 3193 }
3206
3207 } 3194 }
3208} 3195}