aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-13 23:14:41 +0000
committerTeravus Ovares2008-02-13 23:14:41 +0000
commit3588d89b2cba36415991c46c300b1f9c94f109bf (patch)
tree985987f9e0a2e60815134f05a4d69c658aef4ed4 /OpenSim/Region
parent* Fixed another bug in avatarpicker ('surname'/'lastname' mixup) (diff)
downloadopensim-SC-3588d89b2cba36415991c46c300b1f9c94f109bf.zip
opensim-SC-3588d89b2cba36415991c46c300b1f9c94f109bf.tar.gz
opensim-SC-3588d89b2cba36415991c46c300b1f9c94f109bf.tar.bz2
opensim-SC-3588d89b2cba36415991c46c300b1f9c94f109bf.tar.xz
* Bigish ODE stability Update. Run Prebuild
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1GridServices.cs131
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs4
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs5
-rw-r--r--OpenSim/Region/Physics/Manager/CollisionLocker.cs46
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs7
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs12
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs238
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs96
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs8
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs8
10 files changed, 380 insertions, 175 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index f8ab9ef..1953140 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -825,77 +825,92 @@ namespace OpenSim.Region.Communications.OGS1
825 /// <returns></returns> 825 /// <returns></returns>
826 public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData) 826 public bool InformRegionOfPrimCrossing(ulong regionHandle, LLUUID primID, string objData)
827 { 827 {
828 RegionInfo regInfo = null; 828 int failures = 0;
829 try 829 lock (m_deadRegionCache)
830 { 830 {
831 if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData)) 831 if (m_deadRegionCache.ContainsKey(regionHandle))
832 { 832 {
833 return true; 833 failures = m_deadRegionCache[regionHandle];
834 } 834 }
835 835 }
836 regInfo = RequestNeighbourInfo(regionHandle); 836 if (failures <= 3)
837 if (regInfo != null) 837 {
838 RegionInfo regInfo = null;
839 try
838 { 840 {
839 //don't want to be creating a new link to the remote instance every time like we are here 841 if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData))
840 bool retValue = false;
841
842
843 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject(
844 typeof (OGS1InterRegionRemoting),
845 "tcp://" + regInfo.RemotingAddress +
846 ":" + regInfo.RemotingPort +
847 "/InterRegions");
848
849 if (remObject != null)
850 { 842 {
851 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.UUID, objData); 843 return true;
852 } 844 }
853 else 845
846 regInfo = RequestNeighbourInfo(regionHandle);
847 if (regInfo != null)
854 { 848 {
855 Console.WriteLine("remoting object not found"); 849 //don't want to be creating a new link to the remote instance every time like we are here
856 } 850 bool retValue = false;
857 remObject = null;
858 851
859 852
860 return retValue; 853 OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
854 typeof(OGS1InterRegionRemoting),
855 "tcp://" + regInfo.RemotingAddress +
856 ":" + regInfo.RemotingPort +
857 "/InterRegions");
858
859 if (remObject != null)
860 {
861 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.UUID, objData);
862 }
863 else
864 {
865 Console.WriteLine("remoting object not found");
866 }
867 remObject = null;
868
869
870 return retValue;
871 }
872 NoteDeadRegion(regionHandle);
873 return false;
861 } 874 }
862 NoteDeadRegion(regionHandle); 875 catch (RemotingException e)
863 return false; 876 {
864 } 877 NoteDeadRegion(regionHandle);
865 catch (RemotingException e) 878 m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
866 { 879 m_log.Debug(e.ToString());
867 NoteDeadRegion(regionHandle); 880 return false;
868 m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle); 881 }
869 m_log.Debug(e.ToString()); 882 catch (SocketException e)
870 return false; 883 {
871 } 884 NoteDeadRegion(regionHandle);
872 catch (SocketException e) 885 m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle);
873 { 886 m_log.Debug(e.ToString());
874 NoteDeadRegion(regionHandle); 887 return false;
875 m_log.Warn("Remoting Error: Unable to connect to adjacent region: " + regionHandle); 888 }
876 m_log.Debug(e.ToString()); 889 catch (InvalidCredentialException e)
877 return false; 890 {
878 } 891 NoteDeadRegion(regionHandle);
879 catch (InvalidCredentialException e) 892 m_log.Warn("Invalid Credential Exception: Invalid Credentials : " + regionHandle);
880 { 893 m_log.Debug(e.ToString());
881 NoteDeadRegion(regionHandle); 894 return false;
882 m_log.Warn("Invalid Credential Exception: Invalid Credentials : " + regionHandle); 895 }
883 m_log.Debug(e.ToString()); 896 catch (AuthenticationException e)
884 return false; 897 {
885 } 898 NoteDeadRegion(regionHandle);
886 catch (AuthenticationException e) 899 m_log.Warn("Authentication exception: Unable to connect to adjacent region: " + regionHandle);
887 {
888 NoteDeadRegion(regionHandle);
889 m_log.Warn("Authentication exception: Unable to connect to adjacent region: " + regionHandle);
890 900
891 m_log.Debug(e.ToString()); 901 m_log.Debug(e.ToString());
892 return false; 902 return false;
903 }
904 catch (Exception e)
905 {
906 NoteDeadRegion(regionHandle);
907 m_log.Warn("Unknown exception: Unable to connect to adjacent region: " + regionHandle);
908 m_log.Debug(e.ToString());
909 return false;
910 }
893 } 911 }
894 catch (Exception e) 912 else
895 { 913 {
896 NoteDeadRegion(regionHandle);
897 m_log.Warn("Unknown exception: Unable to connect to adjacent region: " + regionHandle);
898 m_log.Debug(e.ToString());
899 return false; 914 return false;
900 } 915 }
901 } 916 }
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index b7ed417..a32bca5 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -351,5 +351,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
351 public override void SetMomentum(PhysicsVector momentum) 351 public override void SetMomentum(PhysicsVector momentum)
352 { 352 {
353 } 353 }
354 public override void CrossingFailure()
355 {
356
357 }
354 } 358 }
355} \ No newline at end of file 359} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 1080aa4..5a8589c 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -986,6 +986,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
986 } 986 }
987 987
988 #endregion 988 #endregion
989
990 public override void CrossingFailure()
991 {
992
993 }
989 } 994 }
990 995
991 /// <summary> 996 /// <summary>
diff --git a/OpenSim/Region/Physics/Manager/CollisionLocker.cs b/OpenSim/Region/Physics/Manager/CollisionLocker.cs
new file mode 100644
index 0000000..7a11720
--- /dev/null
+++ b/OpenSim/Region/Physics/Manager/CollisionLocker.cs
@@ -0,0 +1,46 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.Physics.Manager
6{
7 public class CollisionLocker
8 {
9
10 private bool locked = false;
11 private List<IntPtr> worldlock = new List<IntPtr>();
12 public CollisionLocker()
13 {
14
15 }
16 public void dlock(IntPtr world)
17 {
18 lock (worldlock)
19 {
20 worldlock.Add(world);
21 }
22
23 }
24 public void dunlock(IntPtr world)
25 {
26 lock (worldlock)
27 {
28 worldlock.Remove(world);
29 }
30 }
31 public bool lockquery()
32 {
33 return (worldlock.Count > 0);
34 }
35 public void drelease(IntPtr world)
36 {
37 lock (worldlock)
38 {
39 if (worldlock.Contains(world))
40 worldlock.Remove(world);
41 }
42 }
43
44 }
45
46}
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 7741687..97eccba 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -126,6 +126,8 @@ namespace OpenSim.Region.Physics.Manager
126 126
127 public abstract bool Selected { set; } 127 public abstract bool Selected { set; }
128 128
129 public abstract void CrossingFailure();
130
129 public virtual void RequestPhysicsterseUpdate() 131 public virtual void RequestPhysicsterseUpdate()
130 { 132 {
131 // Make a temporary copy of the event to avoid possibility of 133 // Make a temporary copy of the event to avoid possibility of
@@ -279,6 +281,11 @@ namespace OpenSim.Region.Physics.Manager
279 get { return 0f; } 281 get { return 0f; }
280 } 282 }
281 283
284 public override void CrossingFailure()
285 {
286
287 }
288
282 289
283 public override Quaternion Orientation 290 public override Quaternion Orientation
284 { 291 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 80c2a48..75d62cc 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -16,7 +16,7 @@
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMEd. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -35,7 +35,7 @@ using OpenSim.Region.Physics.Manager;
35namespace OpenSim.Region.Physics.OdePlugin 35namespace OpenSim.Region.Physics.OdePlugin
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. 38 /// Various properties that ODE uses for AMotors but isn't exposed in d.NET so we must define them ourselves.
39 /// </summary> 39 /// </summary>
40 40
41 public enum dParam : int 41 public enum dParam : int
@@ -87,6 +87,7 @@ namespace OpenSim.Region.Physics.OdePlugin
87 private bool m_hackSentFall = false; 87 private bool m_hackSentFall = false;
88 private bool m_hackSentFly = false; 88 private bool m_hackSentFly = false;
89 private bool m_foundDebian = false; 89 private bool m_foundDebian = false;
90 private CollisionLocker ode;
90 91
91 private string m_name = String.Empty; 92 private string m_name = String.Empty;
92 93
@@ -103,8 +104,9 @@ namespace OpenSim.Region.Physics.OdePlugin
103 public d.Mass ShellMass; 104 public d.Mass ShellMass;
104 public bool collidelock = false; 105 public bool collidelock = false;
105 106
106 public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos) 107 public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode)
107 { 108 {
109 ode = dode;
108 _velocity = new PhysicsVector(); 110 _velocity = new PhysicsVector();
109 _target_velocity = new PhysicsVector(); 111 _target_velocity = new PhysicsVector();
110 _position = pos; 112 _position = pos;
@@ -801,5 +803,9 @@ namespace OpenSim.Region.Physics.OdePlugin
801 d.BodyDestroy(Body); 803 d.BodyDestroy(Body);
802 } 804 }
803 } 805 }
806 public override void CrossingFailure()
807 {
808
809 }
804 } 810 }
805} 811}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 6103320..527a5cc 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -16,7 +16,7 @@
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMEd. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -56,6 +56,8 @@ namespace OpenSim.Region.Physics.OdePlugin
56 public bool m_taintremove = false; 56 public bool m_taintremove = false;
57 public bool m_taintdisable = false; 57 public bool m_taintdisable = false;
58 public bool m_disabled = false; 58 public bool m_disabled = false;
59 public bool m_taintadd = false;
60 private CollisionLocker ode;
59 61
60 private bool m_taintforce = false; 62 private bool m_taintforce = false;
61 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 63 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>();
@@ -74,6 +76,7 @@ namespace OpenSim.Region.Physics.OdePlugin
74 public int m_interpenetrationcount = 0; 76 public int m_interpenetrationcount = 0;
75 public int m_collisionscore = 0; 77 public int m_collisionscore = 0;
76 public int m_roundsUnderMotionThreshold = 0; 78 public int m_roundsUnderMotionThreshold = 0;
79 private int m_crossingfailures = 0;
77 80
78 public bool outofBounds = false; 81 public bool outofBounds = false;
79 private float m_density = 10.000006836f; // Aluminum g/cm3; 82 private float m_density = 10.000006836f; // Aluminum g/cm3;
@@ -90,9 +93,9 @@ namespace OpenSim.Region.Physics.OdePlugin
90 private int debugcounter = 0; 93 private int debugcounter = 0;
91 94
92 public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, 95 public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size,
93 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) 96 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
94 { 97 {
95 98 ode = dode;
96 _velocity = new PhysicsVector(); 99 _velocity = new PhysicsVector();
97 _position = pos; 100 _position = pos;
98 m_taintposition = pos; 101 m_taintposition = pos;
@@ -136,86 +139,11 @@ namespace OpenSim.Region.Physics.OdePlugin
136 m_targetSpace = _parent_scene.space; 139 m_targetSpace = _parent_scene.space;
137 } 140 }
138 m_primName = primName; 141 m_primName = primName;
139 if (mesh != null) 142 m_taintadd = true;
140 { 143 _parent_scene.AddPhysicsActorTaint(this);
141 } 144 // don't do .add() here; old geoms get recycled with the same hash
142 else 145 parent_scene.geom_name_map[prim_geom] = primName;
143 { 146 parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this;
144 if (_parent_scene.needsMeshing(_pbs))
145 {
146 // Don't need to re-enable body.. it's done in SetMesh
147 mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size);
148 // createmesh returns null when it's a shape that isn't a cube.
149 }
150 }
151
152 lock (OdeScene.OdeLock)
153 {
154 if (mesh != null)
155 {
156 setMesh(parent_scene, mesh);
157 }
158 else
159 {
160 if (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1)
161 {
162 if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
163 {
164 if (((_size.X / 2f) > 0f))
165 {
166
167
168 _parent_scene.waitForSpaceUnlock(m_targetSpace);
169 prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
170 }
171 else
172 {
173 _parent_scene.waitForSpaceUnlock(m_targetSpace);
174 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
175 }
176 }
177 else
178 {
179 _parent_scene.waitForSpaceUnlock(m_targetSpace);
180 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
181 }
182 }
183 //else if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
184 //{
185 //Cyllinder
186 //if (_size.X == _size.Y)
187 //{
188 //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z);
189 //}
190 //else
191 //{
192 //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
193 //}
194 //}
195 else
196 {
197 _parent_scene.waitForSpaceUnlock(m_targetSpace);
198 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
199 }
200 }
201
202 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
203 d.Quaternion myrot = new d.Quaternion();
204 myrot.W = rotation.w;
205 myrot.X = rotation.x;
206 myrot.Y = rotation.y;
207 myrot.Z = rotation.z;
208 d.GeomSetQuaternion(prim_geom, ref myrot);
209
210
211 if (m_isphysical && Body == (IntPtr) 0)
212 {
213 enableBody();
214 }
215 parent_scene.geom_name_map[prim_geom] = primName;
216 parent_scene.actor_name_map[prim_geom] = (PhysicsActor) this;
217 // don't do .add() here; old geoms get recycled with the same hash
218 }
219 } 147 }
220 148
221 /// <summary> 149 /// <summary>
@@ -399,15 +327,18 @@ namespace OpenSim.Region.Physics.OdePlugin
399 327
400 public void setMesh(OdeScene parent_scene, IMesh mesh) 328 public void setMesh(OdeScene parent_scene, IMesh mesh)
401 { 329 {
330 // This sleeper is there to moderate how long it takes between
331 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
332
333 System.Threading.Thread.Sleep(10);
334
402 //Kill Body so that mesh can re-make the geom 335 //Kill Body so that mesh can re-make the geom
403 if (IsPhysical && Body != (IntPtr) 0) 336 if (IsPhysical && Body != (IntPtr) 0)
404 { 337 {
405 disableBody(); 338 disableBody();
406 } 339 }
407 340
408 // This sleeper is there to moderate how long it takes between 341
409 // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object
410 System.Threading.Thread.Sleep(10);
411 342
412 343
413 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory 344 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
@@ -448,6 +379,10 @@ namespace OpenSim.Region.Physics.OdePlugin
448 public void ProcessTaints(float timestep) 379 public void ProcessTaints(float timestep)
449 { 380 {
450 System.Threading.Thread.Sleep(5); 381 System.Threading.Thread.Sleep(5);
382
383 if (m_taintadd)
384 changeadd(timestep);
385
451 if (m_taintposition != _position) 386 if (m_taintposition != _position)
452 Move(timestep); 387 Move(timestep);
453 388
@@ -477,8 +412,124 @@ namespace OpenSim.Region.Physics.OdePlugin
477 changevelocity(timestep); 412 changevelocity(timestep);
478 } 413 }
479 414
480
481 415
416 public void changeadd(float timestep)
417 {
418 if (_mesh != null)
419 {
420 }
421 else
422 {
423 if (_parent_scene.needsMeshing(_pbs))
424 {
425 // Don't need to re-enable body.. it's done in SetMesh
426 _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size);
427 // createmesh returns null when it's a shape that isn't a cube.
428 }
429 }
430
431 lock (OdeScene.OdeLock)
432 {
433 if (_mesh != null)
434 {
435 setMesh(_parent_scene, _mesh);
436 }
437 else
438 {
439 if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
440 {
441 if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
442 {
443 if (((_size.X / 2f) > 0f))
444 {
445
446
447 _parent_scene.waitForSpaceUnlock(m_targetSpace);
448 try
449 {
450 prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2);
451 }
452 catch (System.AccessViolationException)
453 {
454 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
455 return;
456 }
457 }
458 else
459 {
460 _parent_scene.waitForSpaceUnlock(m_targetSpace);
461 try
462 {
463 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
464 }
465 catch (System.AccessViolationException)
466 {
467 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
468 return;
469 }
470 }
471 }
472 else
473 {
474 _parent_scene.waitForSpaceUnlock(m_targetSpace);
475 try
476 {
477 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
478 }
479 catch (System.AccessViolationException)
480 {
481 return;
482 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
483 }
484 }
485 }
486 //else if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
487 //{
488 //Cyllinder
489 //if (_size.X == _size.Y)
490 //{
491 //prim_geom = d.CreateCylinder(m_targetSpace, _size.X / 2, _size.Z);
492 //}
493 //else
494 //{
495 //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
496 //}
497 //}
498 else
499 {
500 _parent_scene.waitForSpaceUnlock(m_targetSpace);
501 try
502 {
503 prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
504 }
505 catch (System.AccessViolationException)
506 {
507 m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
508 return;
509 }
510 }
511 }
512
513 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
514 d.Quaternion myrot = new d.Quaternion();
515 myrot.W = _orientation.w;
516 myrot.X = _orientation.x;
517 myrot.Y = _orientation.y;
518 myrot.Z = _orientation.z;
519 d.GeomSetQuaternion(prim_geom, ref myrot);
520
521
522 if (m_isphysical && Body == (IntPtr)0)
523 {
524 enableBody();
525 }
526
527
528 }
529 m_taintadd = false;
530
531
532 }
482 public void Move(float timestep) 533 public void Move(float timestep)
483 { 534 {
484 if (m_isphysical) 535 if (m_isphysical)
@@ -941,7 +992,15 @@ namespace OpenSim.Region.Physics.OdePlugin
941 } 992 }
942 set { m_rotationalVelocity = value; } 993 set { m_rotationalVelocity = value; }
943 } 994 }
995 public override void CrossingFailure()
996 {
997 m_crossingfailures++;
998 if (m_crossingfailures >= 5)
999 {
1000 m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName);
944 1001
1002 }
1003 }
945 public void UpdatePositionAndVelocity() 1004 public void UpdatePositionAndVelocity()
946 { 1005 {
947 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1006 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
@@ -969,7 +1028,10 @@ namespace OpenSim.Region.Physics.OdePlugin
969 1028
970 if (l_position.X > 257f || l_position.X < -1f || l_position.Y > 257f || l_position.Y < -1f) 1029 if (l_position.X > 257f || l_position.X < -1f || l_position.Y > 257f || l_position.Y < -1f)
971 { 1030 {
972 base.RequestPhysicsterseUpdate(); 1031 if (m_crossingfailures < 5)
1032 {
1033 base.RequestPhysicsterseUpdate();
1034 }
973 } 1035 }
974 1036
975 if (l_position.Z < 0) 1037 if (l_position.Z < 0)
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 1c16cfb..66af095 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -16,7 +16,7 @@
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMEd. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -46,10 +46,12 @@ namespace OpenSim.Region.Physics.OdePlugin
46 { 46 {
47 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private CollisionLocker ode;
49 private OdeScene _mScene; 50 private OdeScene _mScene;
50 51
51 public OdePlugin() 52 public OdePlugin()
52 { 53 {
54 ode = new CollisionLocker();
53 } 55 }
54 56
55 public bool Init() 57 public bool Init()
@@ -61,7 +63,7 @@ namespace OpenSim.Region.Physics.OdePlugin
61 { 63 {
62 if (_mScene == null) 64 if (_mScene == null)
63 { 65 {
64 _mScene = new OdeScene(); 66 _mScene = new OdeScene(ode);
65 } 67 }
66 return (_mScene); 68 return (_mScene);
67 } 69 }
@@ -74,7 +76,7 @@ namespace OpenSim.Region.Physics.OdePlugin
74 public void Dispose() 76 public void Dispose()
75 { 77 {
76 78
77 d.CloseODE(); 79
78 } 80 }
79 } 81 }
80 82
@@ -82,6 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin
82 { 84 {
83 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 85 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
84 86
87 CollisionLocker ode;
85 // TODO: this should be hard-coded in some common place 88 // TODO: this should be hard-coded in some common place
86 private const uint m_regionWidth = 256; 89 private const uint m_regionWidth = 256;
87 private const uint m_regionHeight = 256; 90 private const uint m_regionHeight = 256;
@@ -137,8 +140,9 @@ namespace OpenSim.Region.Physics.OdePlugin
137 /// Sets many properties that ODE requires to be stable 140 /// Sets many properties that ODE requires to be stable
138 /// These settings need to be tweaked 'exactly' right or weird stuff happens. 141 /// These settings need to be tweaked 'exactly' right or weird stuff happens.
139 /// </summary> 142 /// </summary>
140 public OdeScene() 143 public OdeScene(CollisionLocker dode)
141 { 144 {
145 ode = dode;
142 nearCallback = near; 146 nearCallback = near;
143 triCallback = TriCallback; 147 triCallback = TriCallback;
144 triArrayCallback = TriArrayCallback; 148 triArrayCallback = TriArrayCallback;
@@ -178,6 +182,7 @@ namespace OpenSim.Region.Physics.OdePlugin
178 182
179 lock (OdeLock) 183 lock (OdeLock)
180 { 184 {
185
181 // Creat the world and the first space 186 // Creat the world and the first space
182 world = d.WorldCreate(); 187 world = d.WorldCreate();
183 space = d.HashSpaceCreate(IntPtr.Zero); 188 space = d.HashSpaceCreate(IntPtr.Zero);
@@ -268,8 +273,14 @@ namespace OpenSim.Region.Physics.OdePlugin
268 // We'll be calling near recursivly if one 273 // We'll be calling near recursivly if one
269 // of them is a space to find all of the 274 // of them is a space to find all of the
270 // contact points in the space 275 // contact points in the space
271 276 try
272 d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback); 277 {
278 d.SpaceCollide2(g1, g2, IntPtr.Zero, nearCallback);
279 }
280 catch (System.AccessViolationException)
281 {
282 m_log.Warn("[PHYSICS]: Unable to collide test a space");
283 }
273 //Colliding a space or a geom with a space or a geom. so drill down 284 //Colliding a space or a geom with a space or a geom. so drill down
274 285
275 //Collide all geoms in each space.. 286 //Collide all geoms in each space..
@@ -304,7 +315,7 @@ namespace OpenSim.Region.Physics.OdePlugin
304 name2 = "null"; 315 name2 = "null";
305 } 316 }
306 317
307 //if (id == d.GeomClassID.TriMeshClass) 318 //if (id == d.GeomClassId.TriMeshClass)
308 //{ 319 //{
309 // m_log.Info("near: A collision was detected between {1} and {2}", 0, name1, name2); 320 // m_log.Info("near: A collision was detected between {1} and {2}", 0, name1, name2);
310 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); 321 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2);
@@ -321,6 +332,10 @@ namespace OpenSim.Region.Physics.OdePlugin
321 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); 332 m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim.");
322 base.TriggerPhysicsBasedRestart(); 333 base.TriggerPhysicsBasedRestart();
323 } 334 }
335 catch (System.AccessViolationException)
336 {
337 m_log.Warn("[PHYSICS]: Unable to collide test an object");
338 }
324 339
325 PhysicsActor p1; 340 PhysicsActor p1;
326 PhysicsActor p2; 341 PhysicsActor p2;
@@ -438,7 +453,7 @@ namespace OpenSim.Region.Physics.OdePlugin
438 453
439 if (contacts[i].depth >= 0.25f) 454 if (contacts[i].depth >= 0.25f)
440 { 455 {
441 // Don't collide, one or both prim will explode. 456 // Don't collide, one or both prim will expld.
442 457
443 458
444 op1.m_interpenetrationcount++; 459 op1.m_interpenetrationcount++;
@@ -596,8 +611,14 @@ namespace OpenSim.Region.Physics.OdePlugin
596 // And we'll run this again against the avatar and the space segment 611 // And we'll run this again against the avatar and the space segment
597 // This will return with a bunch of possible objects in the space segment 612 // This will return with a bunch of possible objects in the space segment
598 // and we'll run it again on all of them. 613 // and we'll run it again on all of them.
599 614 try
600 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); 615 {
616 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
617 }
618 catch (AccessViolationException)
619 {
620 m_log.Warn("[PHYSICS]: Unable to space collide");
621 }
601 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); 622 //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
602 //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10) 623 //if (chr.Position.Z + (chr.Velocity.Z * timeStep) < terrainheight + 10)
603 //{ 624 //{
@@ -616,8 +637,14 @@ namespace OpenSim.Region.Physics.OdePlugin
616 // This if may not need to be there.. it might be skipped anyway. 637 // This if may not need to be there.. it might be skipped anyway.
617 if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) 638 if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
618 { 639 {
619 640 try
620 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback); 641 {
642 d.SpaceCollide2(space, chr.prim_geom, IntPtr.Zero, nearCallback);
643 }
644 catch (AccessViolationException)
645 {
646 m_log.Warn("[PHYSICS]: Unable to space collide");
647 }
621 //calculateSpaceForGeom(chr.Position) 648 //calculateSpaceForGeom(chr.Position)
622 //foreach (OdePrim ch2 in _prims) 649 //foreach (OdePrim ch2 in _prims)
623 /// should be a separate space -- lots of avatars will be N**2 slow 650 /// should be a separate space -- lots of avatars will be N**2 slow
@@ -634,7 +661,14 @@ namespace OpenSim.Region.Physics.OdePlugin
634 //} 661 //}
635 //} 662 //}
636 } 663 }
637 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback); 664 try
665 {
666 d.SpaceCollide2(LandGeom, chr.prim_geom, IntPtr.Zero, nearCallback);
667 }
668 catch (AccessViolationException)
669 {
670 m_log.Warn("[PHYSICS]: Unable to space collide");
671 }
638 } 672 }
639 } 673 }
640 else 674 else
@@ -663,7 +697,7 @@ namespace OpenSim.Region.Physics.OdePlugin
663 pos.X = position.X; 697 pos.X = position.X;
664 pos.Y = position.Y; 698 pos.Y = position.Y;
665 pos.Z = position.Z; 699 pos.Z = position.Z;
666 OdeCharacter newAv = new OdeCharacter(avName, this, pos); 700 OdeCharacter newAv = new OdeCharacter(avName, this, pos, ode);
667 _characters.Add(newAv); 701 _characters.Add(newAv);
668 return newAv; 702 return newAv;
669 } 703 }
@@ -1007,7 +1041,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1007 OdePrim newPrim; 1041 OdePrim newPrim;
1008 lock (OdeLock) 1042 lock (OdeLock)
1009 { 1043 {
1010 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical); 1044 newPrim = new OdePrim(name, this, targetspace, pos, siz, rot, mesh, pbs, isphysical, ode);
1011 1045
1012 _prims.Add(newPrim); 1046 _prims.Add(newPrim);
1013 } 1047 }
@@ -1203,8 +1237,15 @@ namespace OpenSim.Region.Physics.OdePlugin
1203 actor.Move(timeStep); 1237 actor.Move(timeStep);
1204 actor.collidelock = true; 1238 actor.collidelock = true;
1205 } 1239 }
1240
1241 ode.dlock(world);
1206 1242
1207 collision_optimized(timeStep); 1243 collision_optimized(timeStep);
1244
1245
1246
1247 ode.dunlock(world);
1248
1208 try 1249 try
1209 { 1250 {
1210 d.WorldQuickStep(world, ODE_STEPSIZE); 1251 d.WorldQuickStep(world, ODE_STEPSIZE);
@@ -1228,25 +1269,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1228 actor.UpdatePositionAndVelocity(); 1269 actor.UpdatePositionAndVelocity();
1229 } 1270 }
1230 1271
1231 bool processedtaints = false; 1272 if (!ode.lockquery())
1232 foreach (OdePrim prim in _taintedPrim)
1233 { 1273 {
1234 prim.ProcessTaints(timeStep); 1274 bool processedtaints = false;
1235 if (prim.m_taintremove) 1275 foreach (OdePrim prim in _taintedPrim)
1236 { 1276 {
1237 RemovePrimThreadLocked(prim); 1277 prim.ProcessTaints(timeStep);
1238 } 1278 if (prim.m_taintremove)
1239 processedtaints = true; 1279 {
1240 prim.m_collisionscore = 0; 1280 RemovePrimThreadLocked(prim);
1281 }
1282 processedtaints = true;
1283 prim.m_collisionscore = 0;
1284 }
1285 if (processedtaints)
1286 _taintedPrim = new List<OdePrim>();
1241 } 1287 }
1242
1243 foreach (OdePrim prim in _activeprims) 1288 foreach (OdePrim prim in _activeprims)
1244 { 1289 {
1245 prim.m_collisionscore = 0; 1290 prim.m_collisionscore = 0;
1246 } 1291 }
1247 1292
1248 if (processedtaints) 1293
1249 _taintedPrim = new List<OdePrim>();
1250 1294
1251 if (timeStep < 0.2f) 1295 if (timeStep < 0.2f)
1252 { 1296 {
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index 5b132cf..7652934 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -480,6 +480,10 @@ namespace OpenSim.Region.Physics.POSPlugin
480 public override void SetMomentum(PhysicsVector momentum) 480 public override void SetMomentum(PhysicsVector momentum)
481 { 481 {
482 } 482 }
483 public override void CrossingFailure()
484 {
485
486 }
483 } 487 }
484 488
485 public class POSPrim : PhysicsActor 489 public class POSPrim : PhysicsActor
@@ -640,6 +644,10 @@ namespace OpenSim.Region.Physics.POSPlugin
640 { 644 {
641 set { return; } 645 set { return; }
642 } 646 }
647 public override void CrossingFailure()
648 {
649
650 }
643 651
644 } 652 }
645} \ No newline at end of file 653} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index ad18507..4a0467c 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -393,6 +393,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin
393 _position.Y = vec.Y; 393 _position.Y = vec.Y;
394 _position.Z = vec.Z; 394 _position.Z = vec.Z;
395 } 395 }
396 public override void CrossingFailure()
397 {
398
399 }
396 } 400 }
397 401
398 402
@@ -577,5 +581,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
577 { 581 {
578 get { return PhysicsVector.Zero; } 582 get { return PhysicsVector.Zero; }
579 } 583 }
584 public override void CrossingFailure()
585 {
586
587 }
580 } 588 }
581} \ No newline at end of file 589} \ No newline at end of file