diff options
Applied danx0r's ODE patch [mantis number 340].
Corrected a few out dated things in the ExtensionsScriptModule.
Diffstat (limited to 'OpenSim')
3 files changed, 106 insertions, 88 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index 7da3d55..c3cbbdc 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs | |||
@@ -47,8 +47,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp | |||
47 | compilerParams.GenerateExecutable = false; | 47 | compilerParams.GenerateExecutable = false; |
48 | compilerParams.GenerateInMemory = true; | 48 | compilerParams.GenerateInMemory = true; |
49 | compilerParams.IncludeDebugInformation = false; | 49 | compilerParams.IncludeDebugInformation = false; |
50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | 50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); |
51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); | 51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); |
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); | ||
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | 53 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); |
53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | 54 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); |
54 | compilerParams.ReferencedAssemblies.Add("System.dll"); | 55 | compilerParams.ReferencedAssemblies.Add("System.dll"); |
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 8efbdc2..a7779b7 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs | |||
@@ -47,8 +47,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript | |||
47 | compilerParams.GenerateExecutable = false; | 47 | compilerParams.GenerateExecutable = false; |
48 | compilerParams.GenerateInMemory = true; | 48 | compilerParams.GenerateInMemory = true; |
49 | compilerParams.IncludeDebugInformation = false; | 49 | compilerParams.IncludeDebugInformation = false; |
50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll"); | 50 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll"); |
51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); | 51 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll"); |
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll"); | ||
52 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); | 53 | compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll"); |
53 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); | 54 | compilerParams.ReferencedAssemblies.Add("libsecondlife.dll"); |
54 | compilerParams.ReferencedAssemblies.Add("System.dll"); | 55 | compilerParams.ReferencedAssemblies.Add("System.dll"); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 04ef1a3..3cc690d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
84 | private List<OdePrim> _prims = new List<OdePrim>(); | 84 | private List<OdePrim> _prims = new List<OdePrim>(); |
85 | private static d.ContactGeom[] contacts = new d.ContactGeom[30]; | 85 | private static d.ContactGeom[] contacts = new d.ContactGeom[30]; |
86 | private static d.Contact contact; | 86 | private static d.Contact contact; |
87 | public static Object OdeLock = new Object(); | ||
87 | public OdeScene() | 88 | public OdeScene() |
88 | { | 89 | { |
89 | contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP; | 90 | contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP; |
@@ -92,14 +93,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
92 | contact.surface.soft_erp = 0.005f; | 93 | contact.surface.soft_erp = 0.005f; |
93 | contact.surface.soft_cfm = 0.00003f; | 94 | contact.surface.soft_cfm = 0.00003f; |
94 | 95 | ||
95 | Monitor.Enter(typeof(OdeScene)); | 96 | lock (OdeLock) |
96 | world = d.WorldCreate(); | 97 | { |
97 | space = d.HashSpaceCreate(IntPtr.Zero); | 98 | world = d.WorldCreate(); |
98 | contactgroup = d.JointGroupCreate(0); | 99 | space = d.HashSpaceCreate(IntPtr.Zero); |
99 | d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); | 100 | contactgroup = d.JointGroupCreate(0); |
100 | d.WorldSetAutoDisableFlag(world, false); | 101 | d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); |
101 | d.WorldSetContactSurfaceLayer(world, 0.001f); | 102 | d.WorldSetAutoDisableFlag(world, false); |
102 | Monitor.Exit(typeof(OdeScene)); | 103 | d.WorldSetContactSurfaceLayer(world, 0.001f); |
104 | } | ||
103 | 105 | ||
104 | this._heightmap = new double[65536]; | 106 | this._heightmap = new double[65536]; |
105 | } | 107 | } |
@@ -128,7 +130,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
128 | PhysicsVector pos = new PhysicsVector(); | 130 | PhysicsVector pos = new PhysicsVector(); |
129 | pos.X = position.X; | 131 | pos.X = position.X; |
130 | pos.Y = position.Y; | 132 | pos.Y = position.Y; |
131 | pos.Z = position.Z + 20; | 133 | pos.Z = position.Z; |
132 | OdeCharacter newAv = new OdeCharacter(this, pos); | 134 | OdeCharacter newAv = new OdeCharacter(this, pos); |
133 | this._characters.Add(newAv); | 135 | this._characters.Add(newAv); |
134 | return newAv; | 136 | return newAv; |
@@ -136,7 +138,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
136 | 138 | ||
137 | public override void RemoveAvatar(PhysicsActor actor) | 139 | public override void RemoveAvatar(PhysicsActor actor) |
138 | { | 140 | { |
139 | |||
140 | } | 141 | } |
141 | 142 | ||
142 | public override void RemovePrim(PhysicsActor prim) | 143 | public override void RemovePrim(PhysicsActor prim) |
@@ -150,7 +151,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
150 | 151 | ||
151 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) | 152 | public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) |
152 | { | 153 | { |
153 | //Console.WriteLine("+++++++++++++++++++++++++++++++++AddPrim pos: " + position + " size: " + size + " quat: " + rotation); | ||
154 | PhysicsVector pos = new PhysicsVector(); | 154 | PhysicsVector pos = new PhysicsVector(); |
155 | pos.X = position.X; | 155 | pos.X = position.X; |
156 | pos.Y = position.Y; | 156 | pos.Y = position.Y; |
@@ -165,7 +165,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
165 | rot.y = rotation.y; | 165 | rot.y = rotation.y; |
166 | rot.z = rotation.z; | 166 | rot.z = rotation.z; |
167 | OdePrim newPrim; | 167 | OdePrim newPrim; |
168 | lock(typeof(OdeScene)) { | 168 | lock (OdeLock) |
169 | { | ||
169 | newPrim = new OdePrim(this, pos, siz, rot); | 170 | newPrim = new OdePrim(this, pos, siz, rot); |
170 | } | 171 | } |
171 | this._prims.Add(newPrim); | 172 | this._prims.Add(newPrim); |
@@ -174,27 +175,27 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
174 | 175 | ||
175 | public override void Simulate(float timeStep) | 176 | public override void Simulate(float timeStep) |
176 | { | 177 | { |
177 | Monitor.Enter(typeof(OdeScene)); | 178 | lock (OdeLock) |
178 | foreach (OdePrim p in _prims) | ||
179 | { | ||
180 | // Console.WriteLine("+++ prim: " + p.Position); | ||
181 | } | ||
182 | foreach (OdeCharacter actor in _characters) | ||
183 | { | ||
184 | actor.Move(timeStep); | ||
185 | } | ||
186 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); | ||
187 | for (int i = 0; i < 50; i++) | ||
188 | { | 179 | { |
189 | d.WorldQuickStep(world, timeStep * 0.02f); | 180 | foreach (OdePrim p in _prims) |
190 | } | 181 | { |
182 | } | ||
183 | foreach (OdeCharacter actor in _characters) | ||
184 | { | ||
185 | actor.Move(timeStep); | ||
186 | } | ||
187 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); | ||
188 | for (int i = 0; i < 50; i++) | ||
189 | { | ||
190 | d.WorldQuickStep(world, timeStep * 0.02f); | ||
191 | } | ||
191 | 192 | ||
192 | d.JointGroupEmpty(contactgroup); | 193 | d.JointGroupEmpty(contactgroup); |
193 | foreach (OdeCharacter actor in _characters) | 194 | foreach (OdeCharacter actor in _characters) |
194 | { | 195 | { |
195 | actor.UpdatePosition(); | 196 | actor.UpdatePosition(); |
197 | } | ||
196 | } | 198 | } |
197 | Monitor.Exit(typeof(OdeScene)); | ||
198 | } | 199 | } |
199 | 200 | ||
200 | public override void GetResults() | 201 | public override void GetResults() |
@@ -222,26 +223,27 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
222 | } | 223 | } |
223 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 224 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
224 | 225 | ||
225 | Monitor.Enter(typeof(OdeScene)); | 226 | lock (OdeLock) |
226 | d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); | 227 | { |
227 | d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); | 228 | d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 256, 256, 256, 256, 1.0f, 0.0f, 2.0f, 0); |
228 | LandGeom = d.CreateHeightfield(space, HeightmapData, 1); | 229 | d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); |
229 | d.Matrix3 R = new d.Matrix3(); | 230 | LandGeom = d.CreateHeightfield(space, HeightmapData, 1); |
230 | 231 | d.Matrix3 R = new d.Matrix3(); | |
231 | Quaternion q1 =Quaternion.FromAngleAxis(1.5707f, new Vector3(1,0,0)); | 232 | |
232 | Quaternion q2 =Quaternion.FromAngleAxis(1.5707f, new Vector3(0,1,0)); | 233 | Quaternion q1 = Quaternion.FromAngleAxis(1.5707f, new Vector3(1, 0, 0)); |
233 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | 234 | Quaternion q2 = Quaternion.FromAngleAxis(1.5707f, new Vector3(0, 1, 0)); |
234 | 235 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | |
235 | q1 = q1 * q2; | 236 | |
236 | //q1 = q1 * q3; | 237 | q1 = q1 * q2; |
237 | Vector3 v3 = new Vector3(); | 238 | //q1 = q1 * q3; |
238 | float angle = 0; | 239 | Vector3 v3 = new Vector3(); |
239 | q1.ToAngleAxis(ref angle, ref v3); | 240 | float angle = 0; |
240 | 241 | q1.ToAngleAxis(ref angle, ref v3); | |
241 | d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); | 242 | |
242 | d.GeomSetRotation(LandGeom, ref R); | 243 | d.RFromAxisAndAngle(out R, v3.x, v3.y, v3.z, angle); |
243 | d.GeomSetPosition(LandGeom, 128, 128, 0); | 244 | d.GeomSetRotation(LandGeom, ref R); |
244 | Monitor.Exit(typeof(OdeScene)); | 245 | d.GeomSetPosition(LandGeom, 128, 128, 0); |
246 | } | ||
245 | } | 247 | } |
246 | 248 | ||
247 | public override void DeleteTerrain() | 249 | public override void DeleteTerrain() |
@@ -260,20 +262,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
260 | private IntPtr BoundingCapsule; | 262 | private IntPtr BoundingCapsule; |
261 | IntPtr capsule_geom; | 263 | IntPtr capsule_geom; |
262 | d.Mass capsule_mass; | 264 | d.Mass capsule_mass; |
265 | private OdeScene _parent_scene; | ||
263 | 266 | ||
264 | public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) | 267 | public OdeCharacter(OdeScene parent_scene, PhysicsVector pos) |
265 | { | 268 | { |
266 | _velocity = new PhysicsVector(); | 269 | _velocity = new PhysicsVector(); |
267 | _position = pos; | 270 | _position = pos; |
268 | _acceleration = new PhysicsVector(); | 271 | _acceleration = new PhysicsVector(); |
269 | Monitor.Enter(typeof(OdeScene)); | 272 | _parent_scene = parent_scene; |
270 | d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f); | 273 | lock (OdeScene.OdeLock) |
271 | capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble | 274 | { |
272 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); | 275 | d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f); |
273 | d.BodySetMass(BoundingCapsule, ref capsule_mass); | 276 | capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble |
274 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); | 277 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); |
275 | d.GeomSetBody(capsule_geom, BoundingCapsule); | 278 | d.BodySetMass(BoundingCapsule, ref capsule_mass); |
276 | Monitor.Exit(typeof(OdeScene)); | 279 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); |
280 | d.GeomSetBody(capsule_geom, BoundingCapsule); | ||
281 | } | ||
277 | } | 282 | } |
278 | 283 | ||
279 | public override bool Flying | 284 | public override bool Flying |
@@ -296,7 +301,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
296 | } | 301 | } |
297 | set | 302 | set |
298 | { | 303 | { |
299 | _position = value; | 304 | lock (OdeScene.OdeLock) |
305 | { | ||
306 | d.BodySetPosition(BoundingCapsule, value.X, value.Y, value.Z); | ||
307 | _position = value; | ||
308 | } | ||
300 | } | 309 | } |
301 | } | 310 | } |
302 | 311 | ||
@@ -389,6 +398,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
389 | { | 398 | { |
390 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 399 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! |
391 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); | 400 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); |
401 | |||
402 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) | ||
403 | if (vec.X < 0.0f) vec.X = 0.0f; | ||
404 | if (vec.Y < 0.0f) vec.Y = 0.0f; | ||
405 | if (vec.X > 255.95f) vec.X = 255.95f; | ||
406 | if (vec.Y > 255.95f) vec.Y = 255.95f; | ||
407 | |||
392 | this._position.X = vec.X; | 408 | this._position.X = vec.X; |
393 | this._position.Y = vec.Y; | 409 | this._position.Y = vec.Y; |
394 | this._position.Z = vec.Z; | 410 | this._position.Z = vec.Z; |
@@ -412,15 +428,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
412 | _acceleration = new PhysicsVector(); | 428 | _acceleration = new PhysicsVector(); |
413 | _orientation = rotation; | 429 | _orientation = rotation; |
414 | prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z); | 430 | prim_geom = d.CreateBox(OdeScene.space, _size.X, _size.Y, _size.Z); |
415 | Monitor.Enter(typeof(OdeScene)); | 431 | lock (OdeScene.OdeLock) |
416 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 432 | { |
417 | d.Quaternion myrot = new d.Quaternion(); | 433 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
418 | myrot.W = rotation.w; | 434 | d.Quaternion myrot = new d.Quaternion(); |
419 | myrot.X = rotation.x; | 435 | myrot.W = rotation.w; |
420 | myrot.Y = rotation.y; | 436 | myrot.X = rotation.x; |
421 | myrot.Z = rotation.z; | 437 | myrot.Y = rotation.y; |
422 | d.GeomSetQuaternion(prim_geom, ref myrot); | 438 | myrot.Z = rotation.z; |
423 | Monitor.Exit(typeof(OdeScene)); | 439 | d.GeomSetQuaternion(prim_geom, ref myrot); |
440 | } | ||
424 | } | 441 | } |
425 | 442 | ||
426 | public override bool Flying | 443 | public override bool Flying |
@@ -442,12 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
442 | } | 459 | } |
443 | set | 460 | set |
444 | { | 461 | { |
445 | //Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting pos: " + value); | ||
446 | _position = value; | 462 | _position = value; |
447 | Monitor.Enter(typeof(OdeScene)); | 463 | lock (OdeScene.OdeLock) |
448 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 464 | { |
449 | Monitor.Exit(typeof(OdeScene)); | 465 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
450 | 466 | } | |
451 | } | 467 | } |
452 | } | 468 | } |
453 | 469 | ||
@@ -459,11 +475,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
459 | } | 475 | } |
460 | set | 476 | set |
461 | { | 477 | { |
462 | //Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting size: " + value); | ||
463 | _size = value; | 478 | _size = value; |
464 | Monitor.Enter(typeof(OdeScene)); | 479 | lock (OdeScene.OdeLock) |
465 | d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); | 480 | { |
466 | Monitor.Exit(typeof(OdeScene)); | 481 | d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); |
482 | } | ||
467 | } | 483 | } |
468 | } | 484 | } |
469 | 485 | ||
@@ -498,16 +514,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
498 | } | 514 | } |
499 | set | 515 | set |
500 | { | 516 | { |
501 | //Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++ setting Orientation"); | ||
502 | _orientation = value; | 517 | _orientation = value; |
503 | Monitor.Enter(typeof(OdeScene)); | 518 | lock (OdeScene.OdeLock) |
504 | d.Quaternion myrot = new d.Quaternion(); | 519 | { |
505 | myrot.W = _orientation.w; | 520 | d.Quaternion myrot = new d.Quaternion(); |
506 | myrot.X = _orientation.x; | 521 | myrot.W = _orientation.w; |
507 | myrot.Y = _orientation.y; | 522 | myrot.X = _orientation.x; |
508 | myrot.Z = _orientation.z; | 523 | myrot.Y = _orientation.y; |
509 | d.GeomSetQuaternion(prim_geom, ref myrot); | 524 | myrot.Z = _orientation.z; |
510 | Monitor.Exit(typeof(OdeScene)); | 525 | d.GeomSetQuaternion(prim_geom, ref myrot); |
526 | } | ||
511 | } | 527 | } |
512 | } | 528 | } |
513 | 529 | ||