aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs9
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs29
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs2
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs10
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs14
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs14
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs187
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs12
9 files changed, 255 insertions, 35 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 81c0b73..bcc02ea 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -429,12 +429,17 @@ namespace OpenSim.Region.Environment.Scenes
429 group.AbsolutePosition = pos; 429 group.AbsolutePosition = pos;
430 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 430 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
431 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 431 if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
432 rootPart.PhysActor = phyScene.AddPrim( 432 {
433 PrimitiveBaseShape pbs = rootPart.Shape;
434 rootPart.PhysActor = phyScene.AddPrimShape(
435 rootPart.Name,
436 pbs,
433 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 437 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
434 rootPart.AbsolutePosition.Z), 438 rootPart.AbsolutePosition.Z),
435 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 439 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
436 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, 440 new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
437 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z)); 441 rootPart.RotationOffset.Y, rootPart.RotationOffset.Z));
442 }
438 } 443 }
439 } 444 }
440} \ No newline at end of file 445}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 8ad8147..579ec90 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -531,7 +531,9 @@ namespace OpenSim.Region.Environment.Scenes
531 AddEntityFromStorage(prim); 531 AddEntityFromStorage(prim);
532 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID); 532 SceneObjectPart rootPart = prim.GetChildPart(prim.UUID);
533 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 533 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
534 rootPart.PhysActor = phyScene.AddPrim( 534 rootPart.PhysActor = phyScene.AddPrimShape(
535 rootPart.Name,
536 rootPart.Shape,
535 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 537 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
536 rootPart.AbsolutePosition.Z), 538 rootPart.AbsolutePosition.Z),
537 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 539 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
@@ -579,7 +581,10 @@ namespace OpenSim.Region.Environment.Scenes
579 // if not phantom, add to physics 581 // if not phantom, add to physics
580 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 582 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
581 rootPart.PhysActor = 583 rootPart.PhysActor =
582 phyScene.AddPrim(new PhysicsVector(pos.X, pos.Y, pos.Z), 584 phyScene.AddPrimShape(
585 rootPart.Name,
586 rootPart.Shape,
587 new PhysicsVector(pos.X, pos.Y, pos.Z),
583 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), 588 new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z),
584 new Quaternion()); 589 new Quaternion());
585 } 590 }
@@ -662,7 +667,9 @@ namespace OpenSim.Region.Environment.Scenes
662 667
663 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID); 668 SceneObjectPart rootPart = obj.GetChildPart(obj.UUID);
664 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0) 669 if ((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) == 0)
665 rootPart.PhysActor = phyScene.AddPrim( 670 rootPart.PhysActor = phyScene.AddPrimShape(
671 rootPart.Name,
672 rootPart.Shape,
666 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, 673 new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
667 rootPart.AbsolutePosition.Z), 674 rootPart.AbsolutePosition.Z),
668 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), 675 new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 890008d..da9f366 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -314,12 +314,16 @@ namespace OpenSim.Region.Environment.Scenes
314 /// may need to create a new Physics actor. 314 /// may need to create a new Physics actor.
315 if (dupe.RootPart.PhysActor != null) 315 if (dupe.RootPart.PhysActor != null)
316 { 316 {
317 dupe.RootPart.PhysActor = m_scene.PhysScene.AddPrim( 317 PrimitiveBaseShape pbs = dupe.RootPart.Shape;
318 new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, 318
319 dupe.RootPart.AbsolutePosition.Z), 319 dupe.RootPart.PhysActor = m_scene.PhysScene.AddPrimShape(
320 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), 320 dupe.RootPart.Name,
321 new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, 321 pbs,
322 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z)); 322 new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z),
323 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z),
324 new Axiom.Math.Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X,
325 dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z));
326
323 } 327 }
324 328
325 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values); 329 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.Values);
@@ -838,6 +842,17 @@ namespace OpenSim.Region.Environment.Scenes
838 { 842 {
839 part.UpdateShape(shapeBlock); 843 part.UpdateShape(shapeBlock);
840 } 844 }
845 if (m_rootPart.PhysActor != null)
846 {
847 this.m_scene.PhysScene.RemovePrim(m_rootPart.PhysActor);
848 m_rootPart.PhysActor = m_scene.PhysScene.AddPrimShape(
849 m_rootPart.Name,
850 m_rootPart.Shape,
851 new PhysicsVector(m_rootPart.AbsolutePosition.X, m_rootPart.AbsolutePosition.Y, m_rootPart.AbsolutePosition.Z),
852 new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z),
853 new Axiom.Math.Quaternion(m_rootPart.RotationOffset.W, m_rootPart.RotationOffset.X,
854 m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z));
855 }
841 } 856 }
842 857
843 #endregion 858 #endregion
@@ -1252,4 +1267,4 @@ namespace OpenSim.Region.Environment.Scenes
1252 Text = text; 1267 Text = text;
1253 } 1268 }
1254 } 1269 }
1255} \ No newline at end of file 1270}
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 0338572..428b771 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -914,7 +914,7 @@ namespace OpenSim.Region.Environment.Scenes
914 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, 914 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
915 AbsolutePosition.Z); 915 AbsolutePosition.Z);
916 916
917 m_physicsActor = scene.AddAvatar(pVec); 917 m_physicsActor = scene.AddAvatar(this.Firstname+"."+this.Lastname, pVec);
918 } 918 }
919 919
920 internal void Close() 920 internal void Close()
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 31861b4..85d9ff6 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System.Collections.Generic; 28using System.Collections.Generic;
29using Axiom.Math; 29using Axiom.Math;
30using OpenSim.Framework.Types;
30using OpenSim.Region.Physics.Manager; 31using OpenSim.Region.Physics.Manager;
31 32
32namespace OpenSim.Region.Physics.BasicPhysicsPlugin 33namespace OpenSim.Region.Physics.BasicPhysicsPlugin
@@ -72,7 +73,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
72 73
73 } 74 }
74 75
75 public override PhysicsActor AddAvatar(PhysicsVector position) 76 public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
76 { 77 {
77 BasicActor act = new BasicActor(); 78 BasicActor act = new BasicActor();
78 act.Position = position; 79 act.Position = position;
@@ -95,10 +96,17 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
95 96
96 } 97 }
97 98
99/*
98 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 100 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
99 { 101 {
100 return null; 102 return null;
101 } 103 }
104*/
105 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
106 {
107 return null;
108 }
109
102 110
103 public override void Simulate(float timeStep) 111 public override void Simulate(float timeStep)
104 { 112 {
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 6d8e1a8..af13d02 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -30,6 +30,7 @@
30#region References 30#region References
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using OpenSim.Framework.Types;
33using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Physics.Manager;
34using Axiom.Math; 35using Axiom.Math;
35using AxiomQuaternion = Axiom.Math.Quaternion; 36using AxiomQuaternion = Axiom.Math.Quaternion;
@@ -252,7 +253,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
252 253
253 this._heightmap = new float[65536]; 254 this._heightmap = new float[65536];
254 } 255 }
255 public override PhysicsActor AddAvatar(PhysicsVector position) 256 public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
256 { 257 {
257 PhysicsVector pos = new PhysicsVector(); 258 PhysicsVector pos = new PhysicsVector();
258 pos.X = position.X; 259 pos.X = position.X;
@@ -276,7 +277,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
276 } 277 }
277 } 278 }
278 } 279 }
279 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation) 280 PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation)
280 { 281 {
281 BulletXPrim newPrim = null; 282 BulletXPrim newPrim = null;
282 lock (BulletXLock) 283 lock (BulletXLock)
@@ -286,6 +287,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin
286 } 287 }
287 return newPrim; 288 return newPrim;
288 } 289 }
290 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, AxiomQuaternion rotation)
291 {
292 return AddPrim(position, size, rotation);
293 }
294
289 public override void RemovePrim(PhysicsActor prim) 295 public override void RemovePrim(PhysicsActor prim)
290 { 296 {
291 if (prim is BulletXPrim) 297 if (prim is BulletXPrim)
@@ -709,7 +715,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
709 { 715 {
710 _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(pos); 716 _startTransform.Translation = BulletXMaths.PhysicsVectorToXnaVector3(pos);
711 //For now all prims are boxes 717 //For now all prims are boxes
712 CollisionShape _collisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size) / 2.0f); 718 CollisionShape _collisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_size) / 2.0f);
713 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset); 719 DefaultMotionState _motionState = new DefaultMotionState(_startTransform, _centerOfMassOffset);
714 MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3(); 720 MonoXnaCompactMaths.Vector3 _localInertia = new MonoXnaCompactMaths.Vector3();
715 _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0 721 _collisionShape.CalculateLocalInertia(Mass, out _localInertia); //Always when mass > 0
@@ -912,7 +918,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
912 MonoXnaCompactMaths.Vector3 _newsize; 918 MonoXnaCompactMaths.Vector3 _newsize;
913 _newsize = BulletXMaths.PhysicsVectorToXnaVector3(_newSize); 919 _newsize = BulletXMaths.PhysicsVectorToXnaVector3(_newSize);
914 //For now all prims are Boxes 920 //For now all prims are Boxes
915 rigidBody.CollisionShape = new BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize) / 2.0f); 921 rigidBody.CollisionShape = new XnaDevRu.BulletX.BoxShape(BulletXMaths.PhysicsVectorToXnaVector3(_newSize) / 2.0f);
916 } 922 }
917 private void ReOrient() 923 private void ReOrient()
918 { 924 {
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 9e3f6ea..bd06fa1 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -25,6 +25,7 @@
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using OpenSim.Framework.Types;
28using OpenSim.Framework.Console; 29using OpenSim.Framework.Console;
29using Axiom.Math; 30using Axiom.Math;
30 31
@@ -40,13 +41,13 @@ namespace OpenSim.Region.Physics.Manager
40 } 41 }
41 } 42 }
42 43
43 public abstract PhysicsActor AddAvatar(PhysicsVector position); 44 public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position);
44 45
45 public abstract void RemoveAvatar(PhysicsActor actor); 46 public abstract void RemoveAvatar(PhysicsActor actor);
46 47
47 public abstract void RemovePrim(PhysicsActor prim); 48 public abstract void RemovePrim(PhysicsActor prim);
48 49
49 public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation); 50 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation);
50 51
51 public abstract void Simulate(float timeStep); 52 public abstract void Simulate(float timeStep);
52 53
@@ -65,7 +66,7 @@ namespace OpenSim.Region.Physics.Manager
65 { 66 {
66 private static int m_workIndicator; 67 private static int m_workIndicator;
67 68
68 public override PhysicsActor AddAvatar(PhysicsVector position) 69 public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
69 { 70 {
70 MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position); 71 MainLog.Instance.Verbose("NullPhysicsScene : AddAvatar({0})", position);
71 return PhysicsActor.Null; 72 return PhysicsActor.Null;
@@ -81,11 +82,18 @@ namespace OpenSim.Region.Physics.Manager
81 82
82 } 83 }
83 84
85/*
84 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 86 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
85 { 87 {
86 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size); 88 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size);
87 return PhysicsActor.Null; 89 return PhysicsActor.Null;
88 } 90 }
91*/
92 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
93 {
94 MainLog.Instance.Verbose("NullPhysicsScene : AddPrim({0},{1})", position, size);
95 return PhysicsActor.Null;
96 }
89 97
90 public override void Simulate(float timeStep) 98 public override void Simulate(float timeStep)
91 { 99 {
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 8d142ab..e7592fb 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -28,10 +28,17 @@
28using System; 28using System;
29using System.Threading; 29using System.Threading;
30using System.Collections.Generic; 30using System.Collections.Generic;
31
32using libsecondlife;
33using libsecondlife.Utilities;
34
31using Axiom.Math; 35using Axiom.Math;
32using Ode.NET; 36using Ode.NET;
37using OpenSim.Framework.Types;
38using OpenSim.Framework.Console;
33using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
34 40
41
35namespace OpenSim.Region.Physics.OdePlugin 42namespace OpenSim.Region.Physics.OdePlugin
36{ 43{
37 /// <summary> 44 /// <summary>
@@ -77,8 +84,11 @@ namespace OpenSim.Region.Physics.OdePlugin
77 private IntPtr LandGeom; 84 private IntPtr LandGeom;
78 private double[] _heightmap; 85 private double[] _heightmap;
79 private d.NearCallback nearCallback; 86 private d.NearCallback nearCallback;
87 public d.TriCallback triCallback;
88 public d.TriArrayCallback triArrayCallback;
80 private List<OdeCharacter> _characters = new List<OdeCharacter>(); 89 private List<OdeCharacter> _characters = new List<OdeCharacter>();
81 private List<OdePrim> _prims = new List<OdePrim>(); 90 private List<OdePrim> _prims = new List<OdePrim>();
91 public Dictionary<IntPtr, String> geom_name_map=new Dictionary<IntPtr, String>();
82 private d.ContactGeom[] contacts = new d.ContactGeom[30]; 92 private d.ContactGeom[] contacts = new d.ContactGeom[30];
83 private d.Contact contact; 93 private d.Contact contact;
84 94
@@ -89,6 +99,8 @@ namespace OpenSim.Region.Physics.OdePlugin
89 public OdeScene() 99 public OdeScene()
90 { 100 {
91 nearCallback = near; 101 nearCallback = near;
102 triCallback = TriCallback;
103 triArrayCallback = TriArrayCallback;
92 contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP; 104 contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP;
93 contact.surface.mu = 10.0f; 105 contact.surface.mu = 10.0f;
94 contact.surface.bounce = 0.9f; 106 contact.surface.bounce = 0.9f;
@@ -112,12 +124,33 @@ namespace OpenSim.Region.Physics.OdePlugin
112 private void near(IntPtr space, IntPtr g1, IntPtr g2) 124 private void near(IntPtr space, IntPtr g1, IntPtr g2)
113 { 125 {
114 // no lock here! It's invoked from within Simulate(), which is thread-locked 126 // no lock here! It's invoked from within Simulate(), which is thread-locked
127 if (g1 == g2)
128 return; // Can't collide with yourself
129
115 IntPtr b1 = d.GeomGetBody(g1); 130 IntPtr b1 = d.GeomGetBody(g1);
116 IntPtr b2 = d.GeomGetBody(g2); 131 IntPtr b2 = d.GeomGetBody(g2);
132
117 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 133 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
118 return; 134 return;
119 135
120 int count = d.Collide(g1, g2, 500, contacts, d.ContactGeom.SizeOf); 136 d.GeomClassID id = d.GeomGetClass(g1);
137 if (id==d.GeomClassID.TriMeshClass)
138 {
139 String name1 = null;
140 String name2 = null;
141 if (!geom_name_map.TryGetValue(g1, out name1))
142 {
143 name1 = "null";
144 }
145 if (!geom_name_map.TryGetValue(g2, out name2))
146 {
147 name2 = "null";
148 }
149
150// MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2);
151 }
152
153 int count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
121 for (int i = 0; i < count; i++) 154 for (int i = 0; i < count; i++)
122 { 155 {
123 contact.geom = contacts[i]; 156 contact.geom = contacts[i];
@@ -139,21 +172,24 @@ namespace OpenSim.Region.Physics.OdePlugin
139 } 172 }
140 } 173 }
141 174
142 public override PhysicsActor AddAvatar(PhysicsVector position) 175 public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
143 { 176 {
144 PhysicsVector pos = new PhysicsVector(); 177 PhysicsVector pos = new PhysicsVector();
145 pos.X = position.X; 178 pos.X = position.X;
146 pos.Y = position.Y; 179 pos.Y = position.Y;
147 pos.Z = position.Z; 180 pos.Z = position.Z;
148 OdeCharacter newAv = new OdeCharacter(this, pos); 181 OdeCharacter newAv = new OdeCharacter(avName, this, pos);
149 _characters.Add(newAv); 182 _characters.Add(newAv);
150 return newAv; 183 return newAv;
151 } 184 }
152 185
153 public override void RemoveAvatar(PhysicsActor actor) 186 public override void RemoveAvatar(PhysicsActor actor)
154 { 187 {
155 ((OdeCharacter)actor).Destroy(); 188 lock (OdeLock)
156 _characters.Remove((OdeCharacter)actor); 189 {
190 ((OdeCharacter)actor).Destroy();
191 _characters.Remove((OdeCharacter)actor);
192 }
157 } 193 }
158 194
159 public override void RemovePrim(PhysicsActor prim) 195 public override void RemovePrim(PhysicsActor prim)
@@ -168,7 +204,7 @@ namespace OpenSim.Region.Physics.OdePlugin
168 } 204 }
169 } 205 }
170 206
171 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 207 PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
172 { 208 {
173 PhysicsVector pos = new PhysicsVector(); 209 PhysicsVector pos = new PhysicsVector();
174 pos.X = position.X; 210 pos.X = position.X;
@@ -186,12 +222,91 @@ namespace OpenSim.Region.Physics.OdePlugin
186 OdePrim newPrim; 222 OdePrim newPrim;
187 lock (OdeLock) 223 lock (OdeLock)
188 { 224 {
189 newPrim = new OdePrim(this, pos, siz, rot); 225 newPrim = new OdePrim(name, this, pos, siz, rot, mesh, pbs);
190 } 226 }
191 _prims.Add(newPrim); 227 _prims.Add(newPrim);
192 return newPrim; 228 return newPrim;
193 } 229 }
194 230
231
232 public int TriArrayCallback(System.IntPtr trimesh, System.IntPtr refObject, int[] triangleIndex, int triCount)
233 {
234/* String name1 = null;
235 String name2 = null;
236
237 if (!geom_name_map.TryGetValue(trimesh, out name1))
238 {
239 name1 = "null";
240 }
241 if (!geom_name_map.TryGetValue(refObject, out name2))
242 {
243 name2 = "null";
244 }
245
246 MainLog.Instance.Verbose("TriArrayCallback: A collision was detected between {1} and {2}", 0, name1, name2);
247*/
248 return 1;
249 }
250
251 public int TriCallback(System.IntPtr trimesh, System.IntPtr refObject, int triangleIndex)
252 {
253
254 String name1 = null;
255 String name2 = null;
256
257 if (!geom_name_map.TryGetValue(trimesh, out name1))
258 {
259 Console.WriteLine("+++ nulling " + name1);
260 name1 = "null";
261 }
262 if (!geom_name_map.TryGetValue(refObject, out name2))
263 {
264 Console.WriteLine("+++ nulling " + name2);
265 name2 = "null";
266 }
267
268// MainLog.Instance.Verbose("TriCallback: A collision was detected between {1} and {2}. Index was {3}", 0, name1, name2, triangleIndex);
269
270 d.Vector3 v0 = new d.Vector3();
271 d.Vector3 v1 = new d.Vector3();
272 d.Vector3 v2 = new d.Vector3();
273
274 d.GeomTriMeshGetTriangle(trimesh, 0, ref v0, ref v1, ref v2);
275 MainLog.Instance.Debug("Triangle {0} is <{1},{2},{3}>, <{4},{5},{6}>, <{7},{8},{9}>", triangleIndex, v0.X, v0.Y, v0.Z, v1.X, v1.Y, v1.Z, v2.X, v2.Y, v2.Z);
276
277 return 1;
278 }
279
280
281 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
282 {
283 PhysicsActor result;
284
285 switch(pbs.ProfileShape)
286 {
287 case ProfileShape.Square:
288 /// support simple box & hollow box now; later, more shapes
289 if (pbs.ProfileHollow == 0)
290 {
291 result = AddPrim(primName, position, size, rotation, null, null);
292 }
293 else
294 {
295 Mesh mesh = Meshmerizer.CreateMesh(pbs, size);
296 result = AddPrim(primName, position, size, rotation, mesh, pbs);
297 }
298 break;
299
300 default:
301 result = AddPrim(primName, position, size, rotation, null, null);
302 break;
303 }
304
305 return result;
306 }
307
308
309
195 public override void Simulate(float timeStep) 310 public override void Simulate(float timeStep)
196 { 311 {
197 lock (OdeLock) 312 lock (OdeLock)
@@ -247,6 +362,8 @@ namespace OpenSim.Region.Physics.OdePlugin
247 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); 362 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0);
248 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); 363 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256);
249 LandGeom = d.CreateHeightfield(space, HeightmapData, 1); 364 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
365 this.geom_name_map[LandGeom]="Terrain";
366
250 d.Matrix3 R = new d.Matrix3(); 367 d.Matrix3 R = new d.Matrix3();
251 368
252 Quaternion q1 = Quaternion.FromAngleAxis(1.5707f, new Vector3(1, 0, 0)); 369 Quaternion q1 = Quaternion.FromAngleAxis(1.5707f, new Vector3(1, 0, 0));
@@ -285,7 +402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
285 public IntPtr capsule_geom; 402 public IntPtr capsule_geom;
286 public d.Mass capsule_mass; 403 public d.Mass capsule_mass;
287 404
288 public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) 405 public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos)
289 { 406 {
290 _velocity = new PhysicsVector(); 407 _velocity = new PhysicsVector();
291 _position = pos; 408 _position = pos;
@@ -300,6 +417,8 @@ namespace OpenSim.Region.Physics.OdePlugin
300 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); 417 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
301 d.GeomSetBody(capsule_geom, BoundingCapsule); 418 d.GeomSetBody(capsule_geom, BoundingCapsule);
302 } 419 }
420 parent_scene.geom_name_map[capsule_geom]=avName;
421
303 } 422 }
304 423
305 public override bool Flying 424 public override bool Flying
@@ -454,6 +573,8 @@ namespace OpenSim.Region.Physics.OdePlugin
454 lock (OdeScene.OdeLock) 573 lock (OdeScene.OdeLock)
455 { 574 {
456 d.GeomDestroy(this.capsule_geom); 575 d.GeomDestroy(this.capsule_geom);
576 Console.WriteLine("+++ removing geom");
577 this._parent_scene.geom_name_map.Remove(this.capsule_geom);
457 d.BodyDestroy(this.BoundingCapsule); 578 d.BodyDestroy(this.BoundingCapsule);
458 } 579 }
459 } 580 }
@@ -466,18 +587,35 @@ namespace OpenSim.Region.Physics.OdePlugin
466 private PhysicsVector _size; 587 private PhysicsVector _size;
467 private PhysicsVector _acceleration; 588 private PhysicsVector _acceleration;
468 private Quaternion _orientation; 589 private Quaternion _orientation;
590 private Mesh _mesh;
591 private PrimitiveBaseShape _pbs;
592 private OdeScene _parent_scene;
469 public IntPtr prim_geom; 593 public IntPtr prim_geom;
594 public IntPtr _triMeshData;
470 595
471 public OdePrim(OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, Quaternion rotation) 596 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
597 Quaternion rotation, Mesh mesh, PrimitiveBaseShape pbs)
472 { 598 {
473 _velocity = new PhysicsVector(); 599 _velocity = new PhysicsVector();
474 _position = pos; 600 _position = pos;
475 _size = size; 601 _size = size;
476 _acceleration = new PhysicsVector(); 602 _acceleration = new PhysicsVector();
477 _orientation = rotation; 603 _orientation = rotation;
604 _mesh = mesh;
605 _pbs = pbs;
606 _parent_scene = parent_scene;
607
478 lock (OdeScene.OdeLock) 608 lock (OdeScene.OdeLock)
479 { 609 {
480 prim_geom = d.CreateBox(parent_scene.space, _size.X, _size.Y, _size.Z); 610 if (mesh!=null)
611 {
612 setMesh(parent_scene, mesh);
613 }
614 else
615 {
616 prim_geom = d.CreateBox(parent_scene.space, _size.X, _size.Y, _size.Z);
617 }
618
481 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 619 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
482 d.Quaternion myrot = new d.Quaternion(); 620 d.Quaternion myrot = new d.Quaternion();
483 myrot.W = rotation.w; 621 myrot.W = rotation.w;
@@ -485,9 +623,25 @@ namespace OpenSim.Region.Physics.OdePlugin
485 myrot.Y = rotation.y; 623 myrot.Y = rotation.y;
486 myrot.Z = rotation.z; 624 myrot.Z = rotation.z;
487 d.GeomSetQuaternion(prim_geom, ref myrot); 625 d.GeomSetQuaternion(prim_geom, ref myrot);
626 parent_scene.geom_name_map[prim_geom] = primName; // don't do .add() here; old geoms get recycled with the same hash
488 } 627 }
489 } 628 }
490 629
630 public void setMesh(OdeScene parent_scene, Mesh mesh)
631 {
632 float[] vertexList = mesh.getVertexListAsFloat(); // Note, that vertextList is pinned in memory
633 int[] indexList = mesh.getIndexListAsInt(); // Also pinned, needs release after usage
634 int VertexCount = vertexList.GetLength(0) / 3;
635 int IndexCount = indexList.GetLength(0);
636
637 _triMeshData = d.GeomTriMeshDataCreate();
638
639 d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, 3 * sizeof(int));
640 d.GeomTriMeshDataPreprocess(_triMeshData);
641
642 prim_geom = d.CreateTriMesh(parent_scene.space, _triMeshData, parent_scene.triCallback, parent_scene.triArrayCallback, null);
643 }
644
491 public override bool Flying 645 public override bool Flying
492 { 646 {
493 get 647 get
@@ -526,7 +680,18 @@ namespace OpenSim.Region.Physics.OdePlugin
526 _size = value; 680 _size = value;
527 lock (OdeScene.OdeLock) 681 lock (OdeScene.OdeLock)
528 { 682 {
529 d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 683 if (_mesh != null) // We deal with a mesh here
684 {
685 string oldname = _parent_scene.geom_name_map[prim_geom];
686 d.GeomDestroy(prim_geom);
687 Mesh mesh = Meshmerizer.CreateMesh(_pbs, _size);
688 setMesh(_parent_scene, mesh);
689 _parent_scene.geom_name_map[prim_geom] = oldname;
690 }
691 else
692 {
693 d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
694 }
530 } 695 }
531 } 696 }
532 } 697 }
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index ba9fe36..d45bfd1 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Framework.Types;
30using OpenSim.Region.Physics.Manager; 31using OpenSim.Region.Physics.Manager;
31using PhysXWrapper; 32using PhysXWrapper;
32using Quaternion=Axiom.Math.Quaternion; 33using Quaternion=Axiom.Math.Quaternion;
@@ -86,14 +87,14 @@ namespace OpenSim.Region.Physics.PhysXPlugin
86 87
87 } 88 }
88 89
89 public override PhysicsActor AddAvatar(PhysicsVector position) 90 public override PhysicsActor AddAvatar(string avName, PhysicsVector position)
90 { 91 {
91 Vec3 pos = new Vec3(); 92 Vec3 pos = new Vec3();
92 pos.X = position.X; 93 pos.X = position.X;
93 pos.Y = position.Y; 94 pos.Y = position.Y;
94 pos.Z = position.Z; 95 pos.Z = position.Z;
95 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos)); 96 PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
96 act.Position = position; 97 act.Position = position;
97 _characters.Add(act); 98 _characters.Add(act);
98 return act; 99 return act;
99 } 100 }
@@ -108,7 +109,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
108 109
109 } 110 }
110 111
111 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 112 PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation)
112 { 113 {
113 Vec3 pos = new Vec3(); 114 Vec3 pos = new Vec3();
114 pos.X = position.X; 115 pos.X = position.X;
@@ -122,6 +123,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
122 _prims.Add(act); 123 _prims.Add(act);
123 return act; 124 return act;
124 } 125 }
126 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation)
127 {
128 return AddPrim(position, size, rotation);
129 }
130
125 public override void Simulate(float timeStep) 131 public override void Simulate(float timeStep)
126 { 132 {
127 try 133 try