diff options
author | Dan Lake | 2011-07-20 15:01:32 -0700 |
---|---|---|
committer | Dan Lake | 2011-07-20 15:01:32 -0700 |
commit | 2c11f7fc38ba14e041ed0e648088d574dadaaffe (patch) | |
tree | d593e3d1130e78ec74a11650d413f451a9a844da /OpenSim/Region/Physics | |
parent | Merge branch 'master' into bulletsim (diff) | |
parent | Removed unused AddPrimShape methods in PhysicsScene caused by merge conflicts (diff) | |
download | opensim-SC-2c11f7fc38ba14e041ed0e648088d574dadaaffe.zip opensim-SC-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.gz opensim-SC-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.bz2 opensim-SC-2c11f7fc38ba14e041ed0e648088d574dadaaffe.tar.xz |
Merge branch 'master' into bulletsim
Diffstat (limited to 'OpenSim/Region/Physics')
11 files changed, 176 insertions, 114 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index b6e1cb4..6c9d9ab 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | |||
@@ -84,13 +84,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
84 | */ | 84 | */ |
85 | 85 | ||
86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 86 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
87 | Vector3 size, Quaternion rotation) | 87 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
88 | { | ||
89 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
90 | } | ||
91 | |||
92 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
93 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
94 | { | 88 | { |
95 | return null; | 89 | return null; |
96 | } | 90 | } |
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs index 6df213d..0d1bd82 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs | |||
@@ -213,12 +213,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin | |||
213 | return newPrim; | 213 | return newPrim; |
214 | } | 214 | } |
215 | 215 | ||
216 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation) | 216 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
217 | { | ||
218 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
219 | } | ||
220 | |||
221 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical) | ||
222 | { | 217 | { |
223 | PhysicsActor result; | 218 | PhysicsActor result; |
224 | IMesh mesh = null; | 219 | IMesh mesh = null; |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index e2a6a2e..df62dbc 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -626,13 +626,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
626 | } | 626 | } |
627 | 627 | ||
628 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position, | 628 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position, |
629 | OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation) | 629 | OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical, uint localid) |
630 | { | ||
631 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
632 | } | ||
633 | |||
634 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position, | ||
635 | OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical) | ||
636 | { | 630 | { |
637 | PhysicsActor result; | 631 | PhysicsActor result; |
638 | 632 | ||
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 13ea084..3870411 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs | |||
@@ -37,6 +37,18 @@ namespace OpenSim.Region.Physics.Manager | |||
37 | public delegate void physicsCrash(); | 37 | public delegate void physicsCrash(); |
38 | 38 | ||
39 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); | 39 | public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); |
40 | public delegate void RayCallback(List<ContactResult> list); | ||
41 | |||
42 | /// <summary> | ||
43 | /// Contact result from a raycast. | ||
44 | /// </summary> | ||
45 | public struct ContactResult | ||
46 | { | ||
47 | public Vector3 Pos; | ||
48 | public float Depth; | ||
49 | public uint ConsumerID; | ||
50 | public Vector3 Normal; | ||
51 | } | ||
40 | 52 | ||
41 | public abstract class PhysicsScene | 53 | public abstract class PhysicsScene |
42 | { | 54 | { |
@@ -61,7 +73,6 @@ namespace OpenSim.Region.Physics.Manager | |||
61 | } | 73 | } |
62 | } | 74 | } |
63 | 75 | ||
64 | |||
65 | public abstract void Initialise(IMesher meshmerizer, IConfigSource config); | 76 | public abstract void Initialise(IMesher meshmerizer, IConfigSource config); |
66 | 77 | ||
67 | public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); | 78 | public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); |
@@ -78,20 +89,7 @@ namespace OpenSim.Region.Physics.Manager | |||
78 | public abstract void RemovePrim(PhysicsActor prim); | 89 | public abstract void RemovePrim(PhysicsActor prim); |
79 | 90 | ||
80 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 91 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
81 | Vector3 size, Quaternion rotation); //To be removed | 92 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid); |
82 | public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
83 | Vector3 size, Quaternion rotation, bool isPhysical); | ||
84 | |||
85 | public virtual PhysicsActor AddPrimShape(uint localID, string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
86 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
87 | { | ||
88 | PhysicsActor ret = AddPrimShape(primName, pbs, position, size, rotation, isPhysical); | ||
89 | |||
90 | if (ret != null) | ||
91 | ret.LocalID = localID; | ||
92 | |||
93 | return ret; | ||
94 | } | ||
95 | 93 | ||
96 | public virtual float TimeDilation | 94 | public virtual float TimeDilation |
97 | { | 95 | { |
@@ -225,6 +223,17 @@ namespace OpenSim.Region.Physics.Manager | |||
225 | retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); | 223 | retMethod(false, Vector3.Zero, 0, 999999999999f, Vector3.Zero); |
226 | } | 224 | } |
227 | 225 | ||
226 | public virtual void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) | ||
227 | { | ||
228 | if (retMethod != null) | ||
229 | retMethod(new List<ContactResult>()); | ||
230 | } | ||
231 | |||
232 | public virtual List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) | ||
233 | { | ||
234 | return new List<ContactResult>(); | ||
235 | } | ||
236 | |||
228 | private class NullPhysicsScene : PhysicsScene | 237 | private class NullPhysicsScene : PhysicsScene |
229 | { | 238 | { |
230 | private static int m_workIndicator; | 239 | private static int m_workIndicator; |
@@ -262,13 +271,7 @@ namespace OpenSim.Region.Physics.Manager | |||
262 | */ | 271 | */ |
263 | 272 | ||
264 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 273 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
265 | Vector3 size, Quaternion rotation) //To be removed | 274 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
266 | { | ||
267 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
268 | } | ||
269 | |||
270 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
271 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
272 | { | 275 | { |
273 | m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); | 276 | m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); |
274 | return PhysicsActor.Null; | 277 | return PhysicsActor.Null; |
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 5ca5f20..5413aa8 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -303,6 +303,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
303 | 303 | ||
304 | private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod) | 304 | private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod) |
305 | { | 305 | { |
306 | // m_log.DebugFormat( | ||
307 | // "[MESH]: Creating physics proxy for {0}, shape {1}", | ||
308 | // primName, (OpenMetaverse.SculptType)primShape.SculptType); | ||
309 | |||
306 | PrimMesh primMesh; | 310 | PrimMesh primMesh; |
307 | PrimMesher.SculptMesh sculptMesh; | 311 | PrimMesher.SculptMesh sculptMesh; |
308 | 312 | ||
@@ -668,7 +672,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
668 | 672 | ||
669 | // If this mesh has been created already, return it instead of creating another copy | 673 | // If this mesh has been created already, return it instead of creating another copy |
670 | // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory | 674 | // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory |
671 | |||
672 | key = GetMeshKey(primShape, size, lod); | 675 | key = GetMeshKey(primShape, size, lod); |
673 | if (m_uniqueMeshes.TryGetValue(key, out mesh)) | 676 | if (m_uniqueMeshes.TryGetValue(key, out mesh)) |
674 | return mesh; | 677 | return mesh; |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 123c8ff..b3045bd 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -638,7 +638,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
638 | float profileEnd; | 638 | float profileEnd; |
639 | 639 | ||
640 | if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) | 640 | if (_pbs.PathCurve == (byte)Extrusion.Straight || _pbs.PathCurve == (byte)Extrusion.Flexible) |
641 | { | 641 | { |
642 | taperX1 = _pbs.PathScaleX * 0.01f; | 642 | taperX1 = _pbs.PathScaleX * 0.01f; |
643 | if (taperX1 > 1.0f) | 643 | if (taperX1 > 1.0f) |
644 | taperX1 = 2.0f - taperX1; | 644 | taperX1 = 2.0f - taperX1; |
@@ -648,9 +648,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
648 | if (taperY1 > 1.0f) | 648 | if (taperY1 > 1.0f) |
649 | taperY1 = 2.0f - taperY1; | 649 | taperY1 = 2.0f - taperY1; |
650 | taperY = 1.0f - taperY1; | 650 | taperY = 1.0f - taperY1; |
651 | } | 651 | } |
652 | else | 652 | else |
653 | { | 653 | { |
654 | taperX = _pbs.PathTaperX * 0.01f; | 654 | taperX = _pbs.PathTaperX * 0.01f; |
655 | if (taperX < 0.0f) | 655 | if (taperX < 0.0f) |
656 | taperX = -taperX; | 656 | taperX = -taperX; |
@@ -660,9 +660,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
660 | if (taperY < 0.0f) | 660 | if (taperY < 0.0f) |
661 | taperY = -taperY; | 661 | taperY = -taperY; |
662 | taperY1 = 1.0f - taperY; | 662 | taperY1 = 1.0f - taperY; |
663 | 663 | } | |
664 | } | ||
665 | |||
666 | 664 | ||
667 | volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); | 665 | volume *= (taperX1 * taperY1 + 0.5f * (taperX1 * taperY + taperX * taperY1) + 0.3333333333f * taperX * taperY); |
668 | 666 | ||
@@ -846,7 +844,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
846 | return; | 844 | return; |
847 | } | 845 | } |
848 | 846 | ||
849 | |||
850 | // if (IsPhysical && Body == (IntPtr) 0) | 847 | // if (IsPhysical && Body == (IntPtr) 0) |
851 | // { | 848 | // { |
852 | // Recreate the body | 849 | // Recreate the body |
@@ -859,7 +856,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
859 | 856 | ||
860 | public void ProcessTaints(float timestep) | 857 | public void ProcessTaints(float timestep) |
861 | { | 858 | { |
862 | //Console.WriteLine("ProcessTaints for " + Name); | 859 | #if SPAM |
860 | Console.WriteLine("ZProcessTaints for " + Name); | ||
861 | #endif | ||
863 | if (m_taintadd) | 862 | if (m_taintadd) |
864 | { | 863 | { |
865 | changeadd(timestep); | 864 | changeadd(timestep); |
@@ -1323,7 +1322,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1323 | 1322 | ||
1324 | public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) | 1323 | public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) |
1325 | { | 1324 | { |
1326 | //Console.WriteLine("CreateGeom:"); | 1325 | #if SPAM |
1326 | Console.WriteLine("CreateGeom:"); | ||
1327 | #endif | ||
1327 | if (_mesh != null) | 1328 | if (_mesh != null) |
1328 | { | 1329 | { |
1329 | setMesh(_parent_scene, _mesh); | 1330 | setMesh(_parent_scene, _mesh); |
@@ -1944,7 +1945,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
1944 | if (_parent_scene.needsMeshing(_pbs)) | 1945 | if (_parent_scene.needsMeshing(_pbs)) |
1945 | mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | 1946 | mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); |
1946 | 1947 | ||
1947 | //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | ||
1948 | #if SPAM | 1948 | #if SPAM |
1949 | Console.WriteLine("changesize 1"); | 1949 | Console.WriteLine("changesize 1"); |
1950 | #endif | 1950 | #endif |
@@ -2056,8 +2056,8 @@ Console.WriteLine("changesize 2"); | |||
2056 | if (IsPhysical) | 2056 | if (IsPhysical) |
2057 | meshlod = _parent_scene.MeshSculptphysicalLOD; | 2057 | meshlod = _parent_scene.MeshSculptphysicalLOD; |
2058 | 2058 | ||
2059 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | ||
2060 | // createmesh returns null when it doesn't mesh. | 2059 | // createmesh returns null when it doesn't mesh. |
2060 | IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); | ||
2061 | #if SPAM | 2061 | #if SPAM |
2062 | Console.WriteLine("changeshape needed meshing"); | 2062 | Console.WriteLine("changeshape needed meshing"); |
2063 | #endif | 2063 | #endif |
@@ -2284,6 +2284,7 @@ Console.WriteLine("changeshape not need meshing"); | |||
2284 | if (value.IsFinite()) | 2284 | if (value.IsFinite()) |
2285 | { | 2285 | { |
2286 | _size = value; | 2286 | _size = value; |
2287 | // m_log.DebugFormat("[PHYSICS]: Set size on {0} to {1}", Name, value); | ||
2287 | } | 2288 | } |
2288 | else | 2289 | else |
2289 | { | 2290 | { |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs index ba77dae..6c2bdde 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs | |||
@@ -45,11 +45,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
45 | public class ODERayCastRequestManager | 45 | public class ODERayCastRequestManager |
46 | { | 46 | { |
47 | /// <summary> | 47 | /// <summary> |
48 | /// Pending Raycast Requests | 48 | /// Pending raycast requests |
49 | /// </summary> | 49 | /// </summary> |
50 | protected List<ODERayCastRequest> m_PendingRequests = new List<ODERayCastRequest>(); | 50 | protected List<ODERayCastRequest> m_PendingRequests = new List<ODERayCastRequest>(); |
51 | 51 | ||
52 | /// <summary> | 52 | /// <summary> |
53 | /// Pending ray requests | ||
54 | /// </summary> | ||
55 | protected List<ODERayRequest> m_PendingRayRequests = new List<ODERayRequest>(); | ||
56 | |||
57 | /// <summary> | ||
53 | /// Scene that created this object. | 58 | /// Scene that created this object. |
54 | /// </summary> | 59 | /// </summary> |
55 | private OdeScene m_scene; | 60 | private OdeScene m_scene; |
@@ -96,6 +101,29 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
96 | } | 101 | } |
97 | 102 | ||
98 | /// <summary> | 103 | /// <summary> |
104 | /// Queues a raycast | ||
105 | /// </summary> | ||
106 | /// <param name="position">Origin of Ray</param> | ||
107 | /// <param name="direction">Ray normal</param> | ||
108 | /// <param name="length">Ray length</param> | ||
109 | /// <param name="count"></param> | ||
110 | /// <param name="retMethod">Return method to send the results</param> | ||
111 | public void QueueRequest(Vector3 position, Vector3 direction, float length, int count, RayCallback retMethod) | ||
112 | { | ||
113 | lock (m_PendingRequests) | ||
114 | { | ||
115 | ODERayRequest req = new ODERayRequest(); | ||
116 | req.callbackMethod = retMethod; | ||
117 | req.length = length; | ||
118 | req.Normal = direction; | ||
119 | req.Origin = position; | ||
120 | req.Count = count; | ||
121 | |||
122 | m_PendingRayRequests.Add(req); | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
99 | /// Process all queued raycast requests | 127 | /// Process all queued raycast requests |
100 | /// </summary> | 128 | /// </summary> |
101 | /// <returns>Time in MS the raycasts took to process.</returns> | 129 | /// <returns>Time in MS the raycasts took to process.</returns> |
@@ -112,15 +140,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
112 | if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast | 140 | if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast |
113 | RayCast(reqs[i]); // if there isn't anyone to send results | 141 | RayCast(reqs[i]); // if there isn't anyone to send results |
114 | } | 142 | } |
115 | /* | 143 | |
116 | foreach (ODERayCastRequest req in m_PendingRequests) | 144 | m_PendingRequests.Clear(); |
145 | } | ||
146 | } | ||
147 | |||
148 | lock (m_PendingRayRequests) | ||
149 | { | ||
150 | if (m_PendingRayRequests.Count > 0) | ||
151 | { | ||
152 | ODERayRequest[] reqs = m_PendingRayRequests.ToArray(); | ||
153 | for (int i = 0; i < reqs.Length; i++) | ||
117 | { | 154 | { |
118 | if (req.callbackMethod != null) // quick optimization here, don't raycast | 155 | if (reqs[i].callbackMethod != null) // quick optimization here, don't raycast |
119 | RayCast(req); // if there isn't anyone to send results to | 156 | RayCast(reqs[i]); // if there isn't anyone to send results |
120 | |||
121 | } | 157 | } |
122 | */ | 158 | |
123 | m_PendingRequests.Clear(); | 159 | m_PendingRayRequests.Clear(); |
124 | } | 160 | } |
125 | } | 161 | } |
126 | 162 | ||
@@ -146,7 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
146 | // Remove Ray | 182 | // Remove Ray |
147 | d.GeomDestroy(ray); | 183 | d.GeomDestroy(ray); |
148 | 184 | ||
149 | |||
150 | // Define default results | 185 | // Define default results |
151 | bool hitYN = false; | 186 | bool hitYN = false; |
152 | uint hitConsumerID = 0; | 187 | uint hitConsumerID = 0; |
@@ -177,6 +212,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
177 | req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal); | 212 | req.callbackMethod(hitYN, closestcontact, hitConsumerID, distance, snormal); |
178 | } | 213 | } |
179 | 214 | ||
215 | /// <summary> | ||
216 | /// Method that actually initiates the raycast | ||
217 | /// </summary> | ||
218 | /// <param name="req"></param> | ||
219 | private void RayCast(ODERayRequest req) | ||
220 | { | ||
221 | // Create the ray | ||
222 | IntPtr ray = d.CreateRay(m_scene.space, req.length); | ||
223 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); | ||
224 | |||
225 | // Collide test | ||
226 | d.SpaceCollide2(m_scene.space, ray, IntPtr.Zero, nearCallback); | ||
227 | |||
228 | // Remove Ray | ||
229 | d.GeomDestroy(ray); | ||
230 | |||
231 | // Find closest contact and object. | ||
232 | lock (m_contactResults) | ||
233 | { | ||
234 | // Return results | ||
235 | if (req.callbackMethod != null) | ||
236 | req.callbackMethod(m_contactResults); | ||
237 | } | ||
238 | } | ||
239 | |||
180 | // This is the standard Near. Uses space AABBs to speed up detection. | 240 | // This is the standard Near. Uses space AABBs to speed up detection. |
181 | private void near(IntPtr space, IntPtr g1, IntPtr g2) | 241 | private void near(IntPtr space, IntPtr g1, IntPtr g2) |
182 | { | 242 | { |
@@ -342,10 +402,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
342 | m_contactResults.Add(collisionresult); | 402 | m_contactResults.Add(collisionresult); |
343 | } | 403 | } |
344 | } | 404 | } |
345 | |||
346 | |||
347 | } | 405 | } |
348 | |||
349 | } | 406 | } |
350 | 407 | ||
351 | /// <summary> | 408 | /// <summary> |
@@ -365,11 +422,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
365 | public RaycastCallback callbackMethod; | 422 | public RaycastCallback callbackMethod; |
366 | } | 423 | } |
367 | 424 | ||
368 | public struct ContactResult | 425 | public struct ODERayRequest |
369 | { | 426 | { |
370 | public Vector3 Pos; | 427 | public Vector3 Origin; |
371 | public float Depth; | ||
372 | public uint ConsumerID; | ||
373 | public Vector3 Normal; | 428 | public Vector3 Normal; |
429 | public int Count; | ||
430 | public float length; | ||
431 | public RayCallback callbackMethod; | ||
374 | } | 432 | } |
375 | } | 433 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 99392cc..a307469 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -1677,7 +1677,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, | 1679 | private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, |
1680 | IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) | 1680 | IMesh mesh, PrimitiveBaseShape pbs, bool isphysical, uint localID) |
1681 | { | 1681 | { |
1682 | Vector3 pos = position; | 1682 | Vector3 pos = position; |
1683 | Vector3 siz = size; | 1683 | Vector3 siz = size; |
@@ -1691,7 +1691,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1691 | lock (_prims) | 1691 | lock (_prims) |
1692 | _prims.Add(newPrim); | 1692 | _prims.Add(newPrim); |
1693 | } | 1693 | } |
1694 | 1694 | newPrim.LocalID = localID; | |
1695 | return newPrim; | 1695 | return newPrim; |
1696 | } | 1696 | } |
1697 | 1697 | ||
@@ -1708,13 +1708,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1708 | } | 1708 | } |
1709 | 1709 | ||
1710 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 1710 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
1711 | Vector3 size, Quaternion rotation) //To be removed | 1711 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
1712 | { | ||
1713 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
1714 | } | ||
1715 | |||
1716 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
1717 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
1718 | { | 1712 | { |
1719 | #if SPAM | 1713 | #if SPAM |
1720 | m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName); | 1714 | m_log.DebugFormat("[PHYSICS]: Adding physics actor to {0}", primName); |
@@ -1723,22 +1717,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1723 | PhysicsActor result; | 1717 | PhysicsActor result; |
1724 | IMesh mesh = null; | 1718 | IMesh mesh = null; |
1725 | 1719 | ||
1726 | if (needsMeshing(pbs)) | 1720 | // Don't create the mesh here - wait until the mesh data is loaded from the asset store. |
1727 | { | 1721 | // if (needsMeshing(pbs)) |
1728 | try | 1722 | // { |
1729 | { | 1723 | // try |
1730 | mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); | 1724 | // { |
1731 | } | 1725 | // mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); |
1732 | catch(Exception e) | 1726 | // } |
1733 | { | 1727 | // catch(Exception e) |
1734 | m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName); | 1728 | // { |
1735 | m_log.Debug(e.ToString()); | 1729 | // m_log.ErrorFormat("[PHYSICS]: Exception while meshing prim {0}.", primName); |
1736 | mesh = null; | 1730 | // m_log.Debug(e.ToString()); |
1737 | return null; | 1731 | // mesh = null; |
1738 | } | 1732 | // return null; |
1739 | } | 1733 | // } |
1740 | 1734 | // } | |
1741 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); | 1735 | |
1736 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical, localid); | ||
1742 | 1737 | ||
1743 | return result; | 1738 | return result; |
1744 | } | 1739 | } |
@@ -2590,7 +2585,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2590 | { | 2585 | { |
2591 | if (!(_taintedPrimH.Contains(taintedprim))) | 2586 | if (!(_taintedPrimH.Contains(taintedprim))) |
2592 | { | 2587 | { |
2593 | //Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.m_primName); | 2588 | #if SPAM |
2589 | Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); | ||
2590 | #endif | ||
2594 | _taintedPrimH.Add(taintedprim); // HashSet for searching | 2591 | _taintedPrimH.Add(taintedprim); // HashSet for searching |
2595 | _taintedPrimL.Add(taintedprim); // List for ordered readout | 2592 | _taintedPrimL.Add(taintedprim); // List for ordered readout |
2596 | } | 2593 | } |
@@ -3733,6 +3730,34 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3733 | } | 3730 | } |
3734 | } | 3731 | } |
3735 | 3732 | ||
3733 | public override void RaycastWorld(Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) | ||
3734 | { | ||
3735 | if (retMethod != null) | ||
3736 | { | ||
3737 | m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod); | ||
3738 | } | ||
3739 | } | ||
3740 | |||
3741 | public override List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) | ||
3742 | { | ||
3743 | ContactResult[] ourResults = null; | ||
3744 | RayCallback retMethod = delegate(List<ContactResult> results) | ||
3745 | { | ||
3746 | ourResults = new ContactResult[results.Count]; | ||
3747 | results.CopyTo(ourResults, 0); | ||
3748 | }; | ||
3749 | int waitTime = 0; | ||
3750 | m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod); | ||
3751 | while (ourResults == null && waitTime < 1000) | ||
3752 | { | ||
3753 | Thread.Sleep(1); | ||
3754 | waitTime++; | ||
3755 | } | ||
3756 | if (ourResults == null) | ||
3757 | return new List<ContactResult> (); | ||
3758 | return new List<ContactResult>(ourResults); | ||
3759 | } | ||
3760 | |||
3736 | #if USE_DRAWSTUFF | 3761 | #if USE_DRAWSTUFF |
3737 | // Keyboard callback | 3762 | // Keyboard callback |
3738 | public void command(int cmd) | 3763 | public void command(int cmd) |
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs index a7f8baa..2ea810f 100644 --- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs +++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs | |||
@@ -31,17 +31,18 @@ using NUnit.Framework; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Physics.Manager; | 33 | using OpenSim.Region.Physics.Manager; |
34 | using OpenSim.Region.Physics.OdePlugin; | ||
34 | using log4net; | 35 | using log4net; |
35 | using System.Reflection; | 36 | using System.Reflection; |
36 | 37 | ||
37 | namespace OpenSim.Region.Physics.OdePlugin | 38 | namespace OpenSim.Region.Physics.OdePlugin.Tests |
38 | { | 39 | { |
39 | [TestFixture] | 40 | [TestFixture] |
40 | public class ODETestClass | 41 | public class ODETestClass |
41 | { | 42 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 44 | ||
44 | private OdePlugin cbt; | 45 | private OpenSim.Region.Physics.OdePlugin.OdePlugin cbt; |
45 | private PhysicsScene ps; | 46 | private PhysicsScene ps; |
46 | private IMeshingPlugin imp; | 47 | private IMeshingPlugin imp; |
47 | 48 | ||
@@ -83,7 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
83 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); | 84 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); |
84 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); | 85 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); |
85 | Quaternion rot = Quaternion.Identity; | 86 | Quaternion rot = Quaternion.Identity; |
86 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); | 87 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); |
87 | OdePrim oprim = (OdePrim)prim; | 88 | OdePrim oprim = (OdePrim)prim; |
88 | OdeScene pscene = (OdeScene) ps; | 89 | OdeScene pscene = (OdeScene) ps; |
89 | 90 | ||
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs index c3f5040..2f24a50 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs | |||
@@ -91,13 +91,7 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
91 | */ | 91 | */ |
92 | 92 | ||
93 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 93 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
94 | Vector3 size, Quaternion rotation) | 94 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
95 | { | ||
96 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
97 | } | ||
98 | |||
99 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
100 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
101 | { | 95 | { |
102 | POSPrim prim = new POSPrim(); | 96 | POSPrim prim = new POSPrim(); |
103 | prim.Position = position; | 97 | prim.Position = position; |
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs index 4de4b01..beb3404 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs | |||
@@ -108,13 +108,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
108 | } | 108 | } |
109 | 109 | ||
110 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | 110 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, |
111 | Vector3 size, Quaternion rotation) //To be removed | 111 | Vector3 size, Quaternion rotation, bool isPhysical, uint localid) |
112 | { | ||
113 | return AddPrimShape(primName, pbs, position, size, rotation, false); | ||
114 | } | ||
115 | |||
116 | public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, | ||
117 | Vector3 size, Quaternion rotation, bool isPhysical) | ||
118 | { | 112 | { |
119 | return AddPrim(position, size, rotation); | 113 | return AddPrim(position, size, rotation); |
120 | } | 114 | } |