diff options
author | Jeff Ames | 2008-05-16 01:22:11 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-16 01:22:11 +0000 |
commit | 65c5efe43b68700bad94076d4cd421160203c5de (patch) | |
tree | 589b56649ed02f4942671fd6e51c6dc43f682e0d /OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |
parent | Thank you very much, mjm for : (diff) | |
download | opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.zip opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.gz opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.bz2 opensim-SC-65c5efe43b68700bad94076d4cd421160203c5de.tar.xz |
Formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 208 |
1 files changed, 68 insertions, 140 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index d795e45..c663fb0 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -42,7 +42,7 @@ using OpenSim.Region.Physics.Manager; | |||
42 | namespace OpenSim.Region.Physics.OdePlugin | 42 | namespace OpenSim.Region.Physics.OdePlugin |
43 | { | 43 | { |
44 | /// <summary> | 44 | /// <summary> |
45 | /// ODE plugin | 45 | /// ODE plugin |
46 | /// </summary> | 46 | /// </summary> |
47 | public class OdePlugin : IPhysicsPlugin | 47 | public class OdePlugin : IPhysicsPlugin |
48 | { | 48 | { |
@@ -51,7 +51,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
51 | private CollisionLocker ode; | 51 | private CollisionLocker ode; |
52 | private OdeScene _mScene; | 52 | private OdeScene _mScene; |
53 | 53 | ||
54 | |||
55 | public OdePlugin() | 54 | public OdePlugin() |
56 | { | 55 | { |
57 | ode = new CollisionLocker(); | 56 | ode = new CollisionLocker(); |
@@ -81,15 +80,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
81 | } | 80 | } |
82 | } | 81 | } |
83 | 82 | ||
84 | 83 | public enum StatusIndicators : int | |
85 | public enum StatusIndicators : int | ||
86 | { | 84 | { |
87 | Generic = 0, | 85 | Generic = 0, |
88 | Start = 1, | 86 | Start = 1, |
89 | End = 2 | 87 | End = 2 |
90 | } | 88 | } |
91 | 89 | ||
92 | |||
93 | public struct sCollisionData | 90 | public struct sCollisionData |
94 | { | 91 | { |
95 | public uint ColliderLocalId; | 92 | public uint ColliderLocalId; |
@@ -165,7 +162,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
165 | private float mAvatarObjectContactFriction = 75f; | 162 | private float mAvatarObjectContactFriction = 75f; |
166 | private float mAvatarObjectContactBounce = 0.1f; | 163 | private float mAvatarObjectContactBounce = 0.1f; |
167 | 164 | ||
168 | |||
169 | private float avPIDD = 3200f; | 165 | private float avPIDD = 3200f; |
170 | private float avPIDP = 1400f; | 166 | private float avPIDP = 1400f; |
171 | private float avCapRadius = 0.37f; | 167 | private float avCapRadius = 0.37f; |
@@ -175,13 +171,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
175 | private float avMovementDivisorWalk = 1.3f; | 171 | private float avMovementDivisorWalk = 1.3f; |
176 | private float avMovementDivisorRun = 0.8f; | 172 | private float avMovementDivisorRun = 0.8f; |
177 | 173 | ||
178 | |||
179 | private float[] _heightmap; | 174 | private float[] _heightmap; |
180 | 175 | ||
181 | private float[] _watermap; | 176 | private float[] _watermap; |
182 | 177 | ||
183 | private float[] _origheightmap; | 178 | private float[] _origheightmap; |
184 | 179 | ||
185 | private d.NearCallback nearCallback; | 180 | private d.NearCallback nearCallback; |
186 | public d.TriCallback triCallback; | 181 | public d.TriCallback triCallback; |
187 | public d.TriArrayCallback triArrayCallback; | 182 | public d.TriArrayCallback triArrayCallback; |
@@ -200,7 +195,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
200 | private d.Contact AvatarMovementTerrainContact; | 195 | private d.Contact AvatarMovementTerrainContact; |
201 | private d.Contact WaterContact; | 196 | private d.Contact WaterContact; |
202 | 197 | ||
203 | |||
204 | //Ckrinke: Comment out until used. We declare it, initialize it, but do not use it | 198 | //Ckrinke: Comment out until used. We declare it, initialize it, but do not use it |
205 | //Ckrinke private int m_randomizeWater = 200; | 199 | //Ckrinke private int m_randomizeWater = 200; |
206 | private int m_physicsiterations = 10; | 200 | private int m_physicsiterations = 10; |
@@ -233,7 +227,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
233 | 227 | ||
234 | private IConfigSource m_config; | 228 | private IConfigSource m_config; |
235 | 229 | ||
236 | |||
237 | /// <summary> | 230 | /// <summary> |
238 | /// Initiailizes the scene | 231 | /// Initiailizes the scene |
239 | /// Sets many properties that ODE requires to be stable | 232 | /// Sets many properties that ODE requires to be stable |
@@ -245,44 +238,34 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
245 | nearCallback = near; | 238 | nearCallback = near; |
246 | triCallback = TriCallback; | 239 | triCallback = TriCallback; |
247 | triArrayCallback = TriArrayCallback; | 240 | triArrayCallback = TriArrayCallback; |
248 | |||
249 | |||
250 | |||
251 | 241 | ||
252 | lock (OdeLock) | 242 | lock (OdeLock) |
253 | { | 243 | { |
254 | 244 | // Create the world and the first space | |
255 | // Creat the world and the first space | ||
256 | world = d.WorldCreate(); | 245 | world = d.WorldCreate(); |
257 | space = d.HashSpaceCreate(IntPtr.Zero); | 246 | space = d.HashSpaceCreate(IntPtr.Zero); |
258 | 247 | ||
259 | contactgroup = d.JointGroupCreate(0); | 248 | contactgroup = d.JointGroupCreate(0); |
260 | //contactgroup | 249 | //contactgroup |
261 | 250 | ||
262 | |||
263 | |||
264 | |||
265 | d.WorldSetAutoDisableFlag(world, false); | 251 | d.WorldSetAutoDisableFlag(world, false); |
266 | |||
267 | } | 252 | } |
268 | 253 | ||
269 | // zero out a heightmap array float array (single dimention [flattened])) | 254 | // zero out a heightmap array float array (single dimention [flattened])) |
270 | _heightmap = new float[514*514]; | 255 | _heightmap = new float[514*514]; |
271 | _watermap = new float[258 * 258]; | 256 | _watermap = new float[258 * 258]; |
272 | 257 | ||
273 | // Zero out the prim spaces array (we split our space into smaller spaces so | 258 | // Zero out the prim spaces array (we split our space into smaller spaces so |
274 | // we can hit test less. | 259 | // we can hit test less. |
275 | |||
276 | } | 260 | } |
277 | 261 | ||
278 | |||
279 | // Initialize the mesh plugin | 262 | // Initialize the mesh plugin |
280 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 263 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
281 | { | 264 | { |
282 | mesher = meshmerizer; | 265 | mesher = meshmerizer; |
283 | m_config = config; | 266 | m_config = config; |
284 | // Defaults | 267 | // Defaults |
285 | 268 | ||
286 | if (Environment.OSVersion.Platform == PlatformID.Unix) | 269 | if (Environment.OSVersion.Platform == PlatformID.Unix) |
287 | { | 270 | { |
288 | avPIDD = 3200.0f; | 271 | avPIDD = 3200.0f; |
@@ -349,10 +332,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
349 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); | 332 | avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); |
350 | avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); | 333 | avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); |
351 | } | 334 | } |
352 | |||
353 | |||
354 | } | 335 | } |
355 | |||
356 | } | 336 | } |
357 | 337 | ||
358 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 338 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; |
@@ -361,8 +341,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
361 | contact.surface.mu = nmAvatarObjectContactFriction; | 341 | contact.surface.mu = nmAvatarObjectContactFriction; |
362 | contact.surface.bounce = nmAvatarObjectContactBounce; | 342 | contact.surface.bounce = nmAvatarObjectContactBounce; |
363 | 343 | ||
364 | // Terrain contact friction and Bounce | 344 | // Terrain contact friction and Bounce |
365 | // This is the *non* moving version. Use this when an avatar | 345 | // This is the *non* moving version. Use this when an avatar |
366 | // isn't moving to keep it in place better | 346 | // isn't moving to keep it in place better |
367 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; | 347 | TerrainContact.surface.mode |= d.ContactFlags.SoftERP; |
368 | TerrainContact.surface.mu = nmTerrainContactFriction; | 348 | TerrainContact.surface.mu = nmTerrainContactFriction; |
@@ -376,7 +356,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
376 | WaterContact.surface.soft_erp = 0.010f; | 356 | WaterContact.surface.soft_erp = 0.010f; |
377 | 357 | ||
378 | // Prim contact friction and bounce | 358 | // Prim contact friction and bounce |
379 | // THis is the *non* moving version of friction and bounce | 359 | // THis is the *non* moving version of friction and bounce |
380 | // Use this when an avatar comes in contact with a prim | 360 | // Use this when an avatar comes in contact with a prim |
381 | // and is moving | 361 | // and is moving |
382 | AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction; | 362 | AvatarMovementprimContact.surface.mu = mAvatarObjectContactFriction; |
@@ -409,7 +389,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
409 | staticPrimspace[i, j] = IntPtr.Zero; | 389 | staticPrimspace[i, j] = IntPtr.Zero; |
410 | } | 390 | } |
411 | } | 391 | } |
412 | |||
413 | } | 392 | } |
414 | 393 | ||
415 | internal void waitForSpaceUnlock(IntPtr space) | 394 | internal void waitForSpaceUnlock(IntPtr space) |
@@ -439,17 +418,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
439 | private void near(IntPtr space, IntPtr g1, IntPtr g2) | 418 | private void near(IntPtr space, IntPtr g1, IntPtr g2) |
440 | { | 419 | { |
441 | // no lock here! It's invoked from within Simulate(), which is thread-locked | 420 | // no lock here! It's invoked from within Simulate(), which is thread-locked |
442 | 421 | ||
443 | // Test if we're collidng a geom with a space. | 422 | // Test if we're colliding a geom with a space. |
444 | // If so we have to drill down into the space recursively | 423 | // If so we have to drill down into the space recursively |
445 | 424 | ||
446 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) | 425 | if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) |
447 | { | 426 | { |
448 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) | 427 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) |
449 | return; | 428 | return; |
450 | // Separating static prim geometry spaces. | 429 | // Separating static prim geometry spaces. |
451 | // We'll be calling near recursivly if one | 430 | // We'll be calling near recursivly if one |
452 | // of them is a space to find all of the | 431 | // of them is a space to find all of the |
453 | // contact points in the space | 432 | // contact points in the space |
454 | try | 433 | try |
455 | { | 434 | { |
@@ -462,13 +441,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
462 | } | 441 | } |
463 | //Colliding a space or a geom with a space or a geom. so drill down | 442 | //Colliding a space or a geom with a space or a geom. so drill down |
464 | 443 | ||
465 | //Collide all geoms in each space.. | 444 | //Collide all geoms in each space.. |
466 | //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); | 445 | //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); |
467 | //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); | 446 | //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); |
468 | return; | 447 | return; |
469 | } | 448 | } |
470 | 449 | ||
471 | |||
472 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) | 450 | if (g1 == (IntPtr)0 || g2 == (IntPtr)0) |
473 | return; | 451 | return; |
474 | 452 | ||
@@ -499,23 +477,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
499 | int count = 0; | 477 | int count = 0; |
500 | try | 478 | try |
501 | { | 479 | { |
502 | |||
503 | // Colliding Geom To Geom | 480 | // Colliding Geom To Geom |
504 | // This portion of the function 'was' blatantly ripped off from BoxStack.cs | 481 | // This portion of the function 'was' blatantly ripped off from BoxStack.cs |
505 | |||
506 | |||
507 | |||
508 | 482 | ||
509 | if (g1 == g2) | 483 | if (g1 == g2) |
510 | return; // Can't collide with yourself | 484 | return; // Can't collide with yourself |
511 | 485 | ||
512 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) | 486 | if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) |
513 | return; | 487 | return; |
514 | 488 | ||
515 | lock (contacts) | 489 | lock (contacts) |
516 | { | 490 | { |
517 | |||
518 | |||
519 | count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); | 491 | count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf); |
520 | } | 492 | } |
521 | } | 493 | } |
@@ -527,7 +499,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
527 | } | 499 | } |
528 | catch (AccessViolationException) | 500 | catch (AccessViolationException) |
529 | { | 501 | { |
530 | 502 | ||
531 | m_log.Warn("[PHYSICS]: Unable to collide test an object"); | 503 | m_log.Warn("[PHYSICS]: Unable to collide test an object"); |
532 | return; | 504 | return; |
533 | } | 505 | } |
@@ -539,6 +511,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
539 | { | 511 | { |
540 | p1 = PANull; | 512 | p1 = PANull; |
541 | } | 513 | } |
514 | |||
542 | if (!actor_name_map.TryGetValue(g2, out p2)) | 515 | if (!actor_name_map.TryGetValue(g2, out p2)) |
543 | { | 516 | { |
544 | p2 = PANull; | 517 | p2 = PANull; |
@@ -554,14 +527,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
554 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. | 527 | // If we're colliding with terrain, use 'TerrainContact' instead of contact. |
555 | // allows us to have different settings | 528 | // allows us to have different settings |
556 | 529 | ||
557 | |||
558 | |||
559 | // We only need to test p2 for 'jump crouch purposes' | 530 | // We only need to test p2 for 'jump crouch purposes' |
560 | p2.IsColliding = true; | 531 | p2.IsColliding = true; |
561 | 532 | ||
562 | //if ((framecount % m_returncollisions) == 0) | 533 | //if ((framecount % m_returncollisions) == 0) |
563 | |||
564 | |||
565 | 534 | ||
566 | switch (p1.PhysicsActorType) | 535 | switch (p1.PhysicsActorType) |
567 | { | 536 | { |
@@ -588,41 +557,39 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
588 | { | 557 | { |
589 | //This is disabled at the moment only because it needs more tweaking | 558 | //This is disabled at the moment only because it needs more tweaking |
590 | //It will eventually be uncommented | 559 | //It will eventually be uncommented |
591 | 560 | ||
592 | if (contacts[i].depth >= 1.00f) | 561 | if (contacts[i].depth >= 1.00f) |
593 | { | 562 | { |
594 | //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); | 563 | //m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString()); |
595 | } | 564 | } |
596 | 565 | ||
597 | //If you interpenetrate a prim with an agent | 566 | //If you interpenetrate a prim with an agent |
598 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && | 567 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent && |
599 | p1.PhysicsActorType == (int) ActorTypes.Prim) || | 568 | p1.PhysicsActorType == (int) ActorTypes.Prim) || |
600 | (p1.PhysicsActorType == (int) ActorTypes.Agent && | 569 | (p1.PhysicsActorType == (int) ActorTypes.Agent && |
601 | p2.PhysicsActorType == (int) ActorTypes.Prim)) | 570 | p2.PhysicsActorType == (int) ActorTypes.Prim)) |
602 | { | 571 | { |
603 | |||
604 | |||
605 | # region disabled code1 | 572 | # region disabled code1 |
606 | //contacts[i].depth = contacts[i].depth * 4.15f; | 573 | //contacts[i].depth = contacts[i].depth * 4.15f; |
607 | /* | 574 | /* |
608 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) | 575 | if (p2.PhysicsActorType == (int) ActorTypes.Agent) |
609 | { | 576 | { |
610 | p2.CollidingObj = true; | 577 | p2.CollidingObj = true; |
611 | contacts[i].depth = 0.003f; | 578 | contacts[i].depth = 0.003f; |
612 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); | 579 | p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f); |
613 | OdeCharacter character = (OdeCharacter) p2; | 580 | OdeCharacter character = (OdeCharacter) p2; |
614 | character.SetPidStatus(true); | 581 | character.SetPidStatus(true); |
615 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); | 582 | contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2)); |
616 | 583 | ||
617 | } | 584 | } |
618 | else | 585 | else |
619 | { | 586 | { |
620 | 587 | ||
621 | //contacts[i].depth = 0.0000000f; | 588 | //contacts[i].depth = 0.0000000f; |
622 | } | 589 | } |
623 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) | 590 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) |
624 | { | 591 | { |
625 | 592 | ||
626 | p1.CollidingObj = true; | 593 | p1.CollidingObj = true; |
627 | contacts[i].depth = 0.003f; | 594 | contacts[i].depth = 0.003f; |
628 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); | 595 | p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f); |
@@ -632,14 +599,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
632 | } | 599 | } |
633 | else | 600 | else |
634 | { | 601 | { |
635 | 602 | ||
636 | //contacts[i].depth = 0.0000000f; | 603 | //contacts[i].depth = 0.0000000f; |
637 | } | 604 | } |
638 | */ | 605 | */ |
639 | #endregion | 606 | #endregion |
640 | |||
641 | } | 607 | } |
642 | |||
643 | 608 | ||
644 | // If you interpenetrate a prim with another prim | 609 | // If you interpenetrate a prim with another prim |
645 | if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) | 610 | if (p1.PhysicsActorType == (int) ActorTypes.Prim && p2.PhysicsActorType == (int) ActorTypes.Prim) |
@@ -649,7 +614,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
649 | //OdePrim op2 = (OdePrim)p2; | 614 | //OdePrim op2 = (OdePrim)p2; |
650 | //op1.m_collisionscore++; | 615 | //op1.m_collisionscore++; |
651 | //op2.m_collisionscore++; | 616 | //op2.m_collisionscore++; |
652 | |||
653 | 617 | ||
654 | //if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000) | 618 | //if (op1.m_collisionscore > 8000 || op2.m_collisionscore > 8000) |
655 | //{ | 619 | //{ |
@@ -658,11 +622,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
658 | //op2.m_taintdisable = true; | 622 | //op2.m_taintdisable = true; |
659 | //AddPhysicsActorTaint(p2); | 623 | //AddPhysicsActorTaint(p2); |
660 | //} | 624 | //} |
661 | 625 | ||
662 | //if (contacts[i].depth >= 0.25f) | 626 | //if (contacts[i].depth >= 0.25f) |
663 | //{ | 627 | //{ |
664 | // Don't collide, one or both prim will expld. | 628 | // Don't collide, one or both prim will expld. |
665 | |||
666 | 629 | ||
667 | //op1.m_interpenetrationcount++; | 630 | //op1.m_interpenetrationcount++; |
668 | //op2.m_interpenetrationcount++; | 631 | //op2.m_interpenetrationcount++; |
@@ -678,17 +641,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
678 | //AddPhysicsActorTaint(p2); | 641 | //AddPhysicsActorTaint(p2); |
679 | //} | 642 | //} |
680 | 643 | ||
681 | |||
682 | //contacts[i].depth = contacts[i].depth / 8f; | 644 | //contacts[i].depth = contacts[i].depth / 8f; |
683 | //contacts[i].normal = new d.Vector3(0, 0, 1); | 645 | //contacts[i].normal = new d.Vector3(0, 0, 1); |
684 | //} | 646 | //} |
685 | //if (op1.m_disabled || op2.m_disabled) | 647 | //if (op1.m_disabled || op2.m_disabled) |
686 | //{ | 648 | //{ |
687 | //Manually disabled objects stay disabled | 649 | //Manually disabled objects stay disabled |
688 | //contacts[i].depth = 0f; | 650 | //contacts[i].depth = 0f; |
689 | //} | 651 | //} |
690 | #endregion | 652 | #endregion |
691 | } | 653 | } |
654 | |||
692 | if (contacts[i].depth >= 1.00f) | 655 | if (contacts[i].depth >= 1.00f) |
693 | { | 656 | { |
694 | //m_log.Info("[P]: " + contacts[i].depth.ToString()); | 657 | //m_log.Info("[P]: " + contacts[i].depth.ToString()); |
@@ -713,6 +676,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
713 | else | 676 | else |
714 | { | 677 | { |
715 | } | 678 | } |
679 | |||
716 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) | 680 | if (p1.PhysicsActorType == (int) ActorTypes.Agent) |
717 | { | 681 | { |
718 | OdeCharacter character = (OdeCharacter)p1; | 682 | OdeCharacter character = (OdeCharacter)p1; |
@@ -738,7 +702,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
738 | 702 | ||
739 | if (contacts[i].depth >= 0f) | 703 | if (contacts[i].depth >= 0f) |
740 | { | 704 | { |
741 | // If we're collidng against terrain | 705 | // If we're colliding against terrain |
742 | if (name1 == "Terrain" || name2 == "Terrain") | 706 | if (name1 == "Terrain" || name2 == "Terrain") |
743 | { | 707 | { |
744 | // If we're moving | 708 | // If we're moving |
@@ -760,12 +724,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
760 | { | 724 | { |
761 | if ((p2.PhysicsActorType == (int)ActorTypes.Prim)) | 725 | if ((p2.PhysicsActorType == (int)ActorTypes.Prim)) |
762 | { | 726 | { |
763 | |||
764 | } | 727 | } |
765 | else | 728 | else |
766 | { | 729 | { |
767 | |||
768 | } | 730 | } |
731 | |||
769 | //WaterContact.surface.soft_cfm = 0.0000f; | 732 | //WaterContact.surface.soft_cfm = 0.0000f; |
770 | //WaterContact.surface.soft_erp = 0.00000f; | 733 | //WaterContact.surface.soft_erp = 0.00000f; |
771 | if (contacts[i].depth > 0.1f) | 734 | if (contacts[i].depth > 0.1f) |
@@ -775,7 +738,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
775 | //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); | 738 | //contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f); |
776 | } | 739 | } |
777 | WaterContact.geom = contacts[i]; | 740 | WaterContact.geom = contacts[i]; |
778 | 741 | ||
779 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); | 742 | joint = d.JointCreateContact(world, contactgroup, ref WaterContact); |
780 | 743 | ||
781 | //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); | 744 | //m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth); |
@@ -806,7 +769,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
806 | { | 769 | { |
807 | // If there are more then 3 contact points, it's likely | 770 | // If there are more then 3 contact points, it's likely |
808 | // that we've got a pile of objects | 771 | // that we've got a pile of objects |
809 | // | 772 | // |
810 | // We don't want to send out hundreds of terse updates over and over again | 773 | // We don't want to send out hundreds of terse updates over and over again |
811 | // so lets throttle them and send them again after it's somewhat sorted out. | 774 | // so lets throttle them and send them again after it's somewhat sorted out. |
812 | p2.ThrottleUpdates = true; | 775 | p2.ThrottleUpdates = true; |
@@ -814,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
814 | //System.Console.WriteLine(count.ToString()); | 777 | //System.Console.WriteLine(count.ToString()); |
815 | //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); | 778 | //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); |
816 | } | 779 | } |
817 | |||
818 | } | 780 | } |
819 | 781 | ||
820 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) | 782 | private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth) |
@@ -831,7 +793,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
831 | { | 793 | { |
832 | case ActorTypes.Agent: | 794 | case ActorTypes.Agent: |
833 | cc2 = (OdeCharacter)p2; | 795 | cc2 = (OdeCharacter)p2; |
834 | 796 | ||
835 | obj1LocalID = cc2.m_localID; | 797 | obj1LocalID = cc2.m_localID; |
836 | switch ((ActorTypes)p1.PhysicsActorType) | 798 | switch ((ActorTypes)p1.PhysicsActorType) |
837 | { | 799 | { |
@@ -840,7 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
840 | obj2LocalID = cc1.m_localID; | 802 | obj2LocalID = cc1.m_localID; |
841 | cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); | 803 | cc1.AddCollisionEvent(cc2.m_localID, collisiondepth); |
842 | //ctype = (int)CollisionCategories.Character; | 804 | //ctype = (int)CollisionCategories.Character; |
843 | 805 | ||
844 | //if (cc1.CollidingObj) | 806 | //if (cc1.CollidingObj) |
845 | //cStartStop = (int)StatusIndicators.Generic; | 807 | //cStartStop = (int)StatusIndicators.Generic; |
846 | //else | 808 | //else |
@@ -858,7 +820,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
858 | //cStartStop = (int)StatusIndicators.Generic; | 820 | //cStartStop = (int)StatusIndicators.Generic; |
859 | //else | 821 | //else |
860 | //cStartStop = (int)StatusIndicators.Start; | 822 | //cStartStop = (int)StatusIndicators.Start; |
861 | 823 | ||
862 | //returncollisions = true; | 824 | //returncollisions = true; |
863 | break; | 825 | break; |
864 | 826 | ||
@@ -869,14 +831,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
869 | //returncollisions = true; | 831 | //returncollisions = true; |
870 | break; | 832 | break; |
871 | } | 833 | } |
872 | |||
873 | 834 | ||
874 | |||
875 | cc2.AddCollisionEvent(obj2LocalID, collisiondepth); | 835 | cc2.AddCollisionEvent(obj2LocalID, collisiondepth); |
876 | break; | 836 | break; |
877 | case ActorTypes.Prim: | 837 | case ActorTypes.Prim: |
878 | cp2 = (OdePrim)p2; | 838 | cp2 = (OdePrim)p2; |
879 | 839 | ||
880 | obj1LocalID = cp2.m_localID; | 840 | obj1LocalID = cp2.m_localID; |
881 | switch ((ActorTypes)p1.PhysicsActorType) | 841 | switch ((ActorTypes)p1.PhysicsActorType) |
882 | { | 842 | { |
@@ -891,7 +851,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
891 | //else | 851 | //else |
892 | //cStartStop = (int)StatusIndicators.Start; | 852 | //cStartStop = (int)StatusIndicators.Start; |
893 | //returncollisions = true; | 853 | //returncollisions = true; |
894 | 854 | ||
895 | break; | 855 | break; |
896 | case ActorTypes.Prim: | 856 | case ActorTypes.Prim: |
897 | cp1 = (OdePrim)p1; | 857 | cp1 = (OdePrim)p1; |
@@ -903,7 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
903 | //cStartStop = (int)StatusIndicators.Generic; | 863 | //cStartStop = (int)StatusIndicators.Generic; |
904 | //else | 864 | //else |
905 | //cStartStop = (int)StatusIndicators.Start; | 865 | //cStartStop = (int)StatusIndicators.Start; |
906 | 866 | ||
907 | //returncollisions = true; | 867 | //returncollisions = true; |
908 | break; | 868 | break; |
909 | 869 | ||
@@ -911,11 +871,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
911 | case ActorTypes.Unknown: | 871 | case ActorTypes.Unknown: |
912 | obj2LocalID = 0; | 872 | obj2LocalID = 0; |
913 | //ctype = (int)CollisionCategories.Land; | 873 | //ctype = (int)CollisionCategories.Land; |
914 | 874 | ||
915 | //returncollisions = true; | 875 | //returncollisions = true; |
916 | break; | 876 | break; |
917 | } | 877 | } |
918 | 878 | ||
919 | cp2.AddCollisionEvent(obj2LocalID, collisiondepth); | 879 | cp2.AddCollisionEvent(obj2LocalID, collisiondepth); |
920 | break; | 880 | break; |
921 | } | 881 | } |
@@ -999,7 +959,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
999 | /// <param name="timeStep"></param> | 959 | /// <param name="timeStep"></param> |
1000 | private void collision_optimized(float timeStep) | 960 | private void collision_optimized(float timeStep) |
1001 | { | 961 | { |
1002 | 962 | ||
1003 | foreach (OdeCharacter chr in _characters) | 963 | foreach (OdeCharacter chr in _characters) |
1004 | { | 964 | { |
1005 | // Reset the collision values to false | 965 | // Reset the collision values to false |
@@ -1008,7 +968,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1008 | chr.IsColliding = false; | 968 | chr.IsColliding = false; |
1009 | chr.CollidingGround = false; | 969 | chr.CollidingGround = false; |
1010 | chr.CollidingObj = false; | 970 | chr.CollidingObj = false; |
1011 | 971 | ||
1012 | // test the avatar's geometry for collision with the space | 972 | // test the avatar's geometry for collision with the space |
1013 | // This will return near and the space that they are the closest to | 973 | // This will return near and the space that they are the closest to |
1014 | // And we'll run this again against the avatar and the space segment | 974 | // And we'll run this again against the avatar and the space segment |
@@ -1029,15 +989,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1029 | //forcedZ = true; | 989 | //forcedZ = true; |
1030 | //} | 990 | //} |
1031 | } | 991 | } |
1032 | |||
1033 | 992 | ||
1034 | |||
1035 | lock (_activeprims) | 993 | lock (_activeprims) |
1036 | { | 994 | { |
1037 | |||
1038 | foreach (OdePrim chr in _activeprims) | 995 | foreach (OdePrim chr in _activeprims) |
1039 | { | 996 | { |
1040 | |||
1041 | if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) | 997 | if (d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) |
1042 | { | 998 | { |
1043 | try | 999 | try |
@@ -1049,18 +1005,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1049 | else | 1005 | else |
1050 | m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed"); | 1006 | m_log.Debug("[PHYSICS]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed"); |
1051 | } | 1007 | } |
1052 | |||
1053 | } | 1008 | } |
1054 | catch (AccessViolationException) | 1009 | catch (AccessViolationException) |
1055 | { | 1010 | { |
1056 | m_log.Warn("[PHYSICS]: Unable to space collide"); | 1011 | m_log.Warn("[PHYSICS]: Unable to space collide"); |
1057 | } | 1012 | } |
1058 | |||
1059 | } | 1013 | } |
1060 | |||
1061 | } | 1014 | } |
1062 | } | 1015 | } |
1063 | |||
1064 | } | 1016 | } |
1065 | 1017 | ||
1066 | #endregion | 1018 | #endregion |
@@ -1077,7 +1029,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1077 | { | 1029 | { |
1078 | if (!_collisionEventPrim.Contains(obj)) | 1030 | if (!_collisionEventPrim.Contains(obj)) |
1079 | _collisionEventPrim.Add(obj); | 1031 | _collisionEventPrim.Add(obj); |
1080 | |||
1081 | } | 1032 | } |
1082 | } | 1033 | } |
1083 | 1034 | ||
@@ -1090,7 +1041,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1090 | } | 1041 | } |
1091 | } | 1042 | } |
1092 | 1043 | ||
1093 | |||
1094 | #region Add/Remove Entities | 1044 | #region Add/Remove Entities |
1095 | 1045 | ||
1096 | public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size) | 1046 | public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size) |
@@ -1131,8 +1081,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1131 | rot.y = rotation.y; | 1081 | rot.y = rotation.y; |
1132 | rot.z = rotation.z; | 1082 | rot.z = rotation.z; |
1133 | 1083 | ||
1134 | |||
1135 | |||
1136 | OdePrim newPrim; | 1084 | OdePrim newPrim; |
1137 | lock (OdeLock) | 1085 | lock (OdeLock) |
1138 | { | 1086 | { |
@@ -1141,7 +1089,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1141 | _prims.Add(newPrim); | 1089 | _prims.Add(newPrim); |
1142 | } | 1090 | } |
1143 | 1091 | ||
1144 | |||
1145 | return newPrim; | 1092 | return newPrim; |
1146 | } | 1093 | } |
1147 | 1094 | ||
@@ -1178,11 +1125,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1178 | 1125 | ||
1179 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); | 1126 | result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); |
1180 | 1127 | ||
1181 | |||
1182 | return result; | 1128 | return result; |
1183 | } | 1129 | } |
1184 | 1130 | ||
1185 | |||
1186 | public void remActivePrim(OdePrim deactivatePrim) | 1131 | public void remActivePrim(OdePrim deactivatePrim) |
1187 | { | 1132 | { |
1188 | lock (_activeprims) | 1133 | lock (_activeprims) |
@@ -1210,8 +1155,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1210 | /// This is called from within simulate but outside the locked portion | 1155 | /// This is called from within simulate but outside the locked portion |
1211 | /// We need to do our own locking here | 1156 | /// We need to do our own locking here |
1212 | /// Essentially, we need to remove the prim from our space segment, whatever segment it's in. | 1157 | /// Essentially, we need to remove the prim from our space segment, whatever segment it's in. |
1213 | /// | 1158 | /// |
1214 | /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory | 1159 | /// If there are no more prim in the segment, we need to empty (spacedestroy)the segment and reclaim memory |
1215 | /// that the space was using. | 1160 | /// that the space was using. |
1216 | /// </summary> | 1161 | /// </summary> |
1217 | /// <param name="prim"></param> | 1162 | /// <param name="prim"></param> |
@@ -1226,7 +1171,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1226 | { | 1171 | { |
1227 | prim.ResetTaints(); | 1172 | prim.ResetTaints(); |
1228 | 1173 | ||
1229 | |||
1230 | if (prim.IsPhysical) | 1174 | if (prim.IsPhysical) |
1231 | { | 1175 | { |
1232 | prim.disableBody(); | 1176 | prim.disableBody(); |
@@ -1267,7 +1211,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1267 | { | 1211 | { |
1268 | m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); | 1212 | m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); |
1269 | } | 1213 | } |
1270 | |||
1271 | } | 1214 | } |
1272 | catch (AccessViolationException) | 1215 | catch (AccessViolationException) |
1273 | { | 1216 | { |
@@ -1297,8 +1240,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1297 | //} | 1240 | //} |
1298 | //} | 1241 | //} |
1299 | } | 1242 | } |
1300 | |||
1301 | |||
1302 | } | 1243 | } |
1303 | } | 1244 | } |
1304 | } | 1245 | } |
@@ -1337,12 +1278,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1337 | /// <returns>a pointer to the new space it's in</returns> | 1278 | /// <returns>a pointer to the new space it's in</returns> |
1338 | public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) | 1279 | public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) |
1339 | { | 1280 | { |
1340 | 1281 | // Called from setting the Position and Size of an ODEPrim so | |
1341 | // Called from setting the Position and Size of an ODEPrim so | ||
1342 | // it's already in locked space. | 1282 | // it's already in locked space. |
1343 | 1283 | ||
1344 | // we don't want to remove the main space | 1284 | // we don't want to remove the main space |
1345 | // we don't need to test physical here because this function should | 1285 | // we don't need to test physical here because this function should |
1346 | // never be called if the prim is physical(active) | 1286 | // never be called if the prim is physical(active) |
1347 | 1287 | ||
1348 | // All physical prim end up in the root space | 1288 | // All physical prim end up in the root space |
@@ -1399,7 +1339,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1399 | waitForSpaceUnlock(space); | 1339 | waitForSpaceUnlock(space); |
1400 | d.SpaceRemove(space, currentspace); | 1340 | d.SpaceRemove(space, currentspace); |
1401 | // free up memory used by the space. | 1341 | // free up memory used by the space. |
1402 | 1342 | ||
1403 | //d.SpaceDestroy(currentspace); | 1343 | //d.SpaceDestroy(currentspace); |
1404 | resetSpaceArrayItemToZero(currentspace); | 1344 | resetSpaceArrayItemToZero(currentspace); |
1405 | } | 1345 | } |
@@ -1418,7 +1358,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1418 | { | 1358 | { |
1419 | if (d.SpaceQuery(currentspace, geom)) | 1359 | if (d.SpaceQuery(currentspace, geom)) |
1420 | { | 1360 | { |
1421 | |||
1422 | if (d.GeomIsSpace(currentspace)) | 1361 | if (d.GeomIsSpace(currentspace)) |
1423 | { | 1362 | { |
1424 | waitForSpaceUnlock(currentspace); | 1363 | waitForSpaceUnlock(currentspace); |
@@ -1453,8 +1392,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1453 | } | 1392 | } |
1454 | } | 1393 | } |
1455 | 1394 | ||
1456 | // The routines in the Position and Size sections do the 'inserting' into the space, | 1395 | // The routines in the Position and Size sections do the 'inserting' into the space, |
1457 | // so all we have to do is make sure that the space that we're putting the prim into | 1396 | // so all we have to do is make sure that the space that we're putting the prim into |
1458 | // is in the 'main' space. | 1397 | // is in the 'main' space. |
1459 | int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); | 1398 | int[] iprimspaceArrItem = calculateSpaceArrayItemFromPos(pos); |
1460 | IntPtr newspace = calculateSpaceForGeom(pos); | 1399 | IntPtr newspace = calculateSpaceForGeom(pos); |
@@ -1492,11 +1431,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1492 | public IntPtr calculateSpaceForGeom(PhysicsVector pos) | 1431 | public IntPtr calculateSpaceForGeom(PhysicsVector pos) |
1493 | { | 1432 | { |
1494 | IntPtr locationbasedspace =IntPtr.Zero; | 1433 | IntPtr locationbasedspace =IntPtr.Zero; |
1495 | 1434 | ||
1496 | int[] xyspace = calculateSpaceArrayItemFromPos(pos); | 1435 | int[] xyspace = calculateSpaceArrayItemFromPos(pos); |
1497 | //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); | 1436 | //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); |
1498 | locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; | 1437 | locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; |
1499 | 1438 | ||
1500 | //locationbasedspace = space; | 1439 | //locationbasedspace = space; |
1501 | return locationbasedspace; | 1440 | return locationbasedspace; |
1502 | } | 1441 | } |
@@ -1523,13 +1462,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1523 | if (returnint[1] < 0) | 1462 | if (returnint[1] < 0) |
1524 | returnint[1] = 0; | 1463 | returnint[1] = 0; |
1525 | 1464 | ||
1526 | |||
1527 | return returnint; | 1465 | return returnint; |
1528 | } | 1466 | } |
1529 | #endregion | ||
1530 | |||
1531 | |||
1532 | 1467 | ||
1468 | #endregion | ||
1533 | 1469 | ||
1534 | /// <summary> | 1470 | /// <summary> |
1535 | /// Routine to figure out if we need to mesh this prim with our mesher | 1471 | /// Routine to figure out if we need to mesh this prim with our mesher |
@@ -1564,7 +1500,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1564 | return false; | 1500 | return false; |
1565 | } | 1501 | } |
1566 | 1502 | ||
1567 | |||
1568 | /// <summary> | 1503 | /// <summary> |
1569 | /// Called after our prim properties are set Scale, position etc. | 1504 | /// Called after our prim properties are set Scale, position etc. |
1570 | /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex | 1505 | /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex |
@@ -1586,7 +1521,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1586 | 1521 | ||
1587 | /// <summary> | 1522 | /// <summary> |
1588 | /// This is our main simulate loop | 1523 | /// This is our main simulate loop |
1589 | /// It's thread locked by a Mutex in the scene. | 1524 | /// It's thread locked by a Mutex in the scene. |
1590 | /// It holds Collisions, it instructs ODE to step through the physical reactions | 1525 | /// It holds Collisions, it instructs ODE to step through the physical reactions |
1591 | /// It moves the objects around in memory | 1526 | /// It moves the objects around in memory |
1592 | /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup) | 1527 | /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup) |
@@ -1597,7 +1532,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1597 | { | 1532 | { |
1598 | if (framecount >= int.MaxValue) | 1533 | if (framecount >= int.MaxValue) |
1599 | framecount = 0; | 1534 | framecount = 0; |
1600 | 1535 | ||
1601 | framecount++; | 1536 | framecount++; |
1602 | 1537 | ||
1603 | float fps = 0; | 1538 | float fps = 0; |
@@ -1605,12 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1605 | step_time += timeStep; | 1540 | step_time += timeStep; |
1606 | 1541 | ||
1607 | 1542 | ||
1608 | // If We're loaded down by something else, | 1543 | // If We're loaded down by something else, |
1609 | // or debugging with the Visual Studio project on pause | 1544 | // or debugging with the Visual Studio project on pause |
1610 | // skip a few frames to catch up gracefully. | 1545 | // skip a few frames to catch up gracefully. |
1611 | // without shooting the physicsactors all over the place | 1546 | // without shooting the physicsactors all over the place |
1612 | 1547 | ||
1613 | |||
1614 | if (step_time >= m_SkipFramesAtms) | 1548 | if (step_time >= m_SkipFramesAtms) |
1615 | { | 1549 | { |
1616 | // Instead of trying to catch up, it'll do 5 physics frames only | 1550 | // Instead of trying to catch up, it'll do 5 physics frames only |
@@ -1623,7 +1557,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1623 | } | 1557 | } |
1624 | lock (OdeLock) | 1558 | lock (OdeLock) |
1625 | { | 1559 | { |
1626 | // Process 10 frames if the sim is running normal.. | 1560 | // Process 10 frames if the sim is running normal.. |
1627 | // process 5 frames if the sim is running slow | 1561 | // process 5 frames if the sim is running slow |
1628 | //try | 1562 | //try |
1629 | //{ | 1563 | //{ |
@@ -1642,13 +1576,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1642 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size | 1576 | //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size |
1643 | step_time = 0.09375f; | 1577 | step_time = 0.09375f; |
1644 | fps = (step_time/ODE_STEPSIZE) * 1000; | 1578 | fps = (step_time/ODE_STEPSIZE) * 1000; |
1645 | 1579 | ||
1646 | while (step_time > 0.0f) | 1580 | while (step_time > 0.0f) |
1647 | { | 1581 | { |
1648 | //lock (ode) | 1582 | //lock (ode) |
1649 | //{ | 1583 | //{ |
1650 | //if (!ode.lockquery()) | 1584 | //if (!ode.lockquery()) |
1651 | //{ | 1585 | //{ |
1652 | // ode.dlock(world); | 1586 | // ode.dlock(world); |
1653 | try | 1587 | try |
1654 | { | 1588 | { |
@@ -1661,9 +1595,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1661 | } | 1595 | } |
1662 | } | 1596 | } |
1663 | 1597 | ||
1664 | |||
1665 | bool processedtaints = false; | 1598 | bool processedtaints = false; |
1666 | 1599 | ||
1667 | lock (_taintedPrim) | 1600 | lock (_taintedPrim) |
1668 | { | 1601 | { |
1669 | foreach (OdePrim prim in _taintedPrim) | 1602 | foreach (OdePrim prim in _taintedPrim) |
@@ -1679,10 +1612,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1679 | processedtaints = true; | 1612 | processedtaints = true; |
1680 | prim.m_collisionscore = 0; | 1613 | prim.m_collisionscore = 0; |
1681 | } | 1614 | } |
1682 | 1615 | ||
1683 | if (processedtaints) | 1616 | if (processedtaints) |
1684 | _taintedPrim = new List<OdePrim>(); | 1617 | _taintedPrim = new List<OdePrim>(); |
1685 | |||
1686 | } | 1618 | } |
1687 | 1619 | ||
1688 | lock (_activeprims) | 1620 | lock (_activeprims) |
@@ -1696,7 +1628,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1696 | 1628 | ||
1697 | //if ((framecount % m_randomizeWater) == 0) | 1629 | //if ((framecount % m_randomizeWater) == 0) |
1698 | // randomizeWater(waterlevel); | 1630 | // randomizeWater(waterlevel); |
1699 | |||
1700 | 1631 | ||
1701 | collision_optimized(timeStep); | 1632 | collision_optimized(timeStep); |
1702 | 1633 | ||
@@ -1718,7 +1649,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1718 | pobj.SendCollisions(); | 1649 | pobj.SendCollisions(); |
1719 | break; | 1650 | break; |
1720 | } | 1651 | } |
1721 | |||
1722 | } | 1652 | } |
1723 | } | 1653 | } |
1724 | 1654 | ||
@@ -1726,13 +1656,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1726 | 1656 | ||
1727 | d.JointGroupEmpty(contactgroup); | 1657 | d.JointGroupEmpty(contactgroup); |
1728 | //ode.dunlock(world); | 1658 | //ode.dunlock(world); |
1729 | } | 1659 | } |
1730 | catch (Exception e) | 1660 | catch (Exception e) |
1731 | { | 1661 | { |
1732 | m_log.Error("[PHYSICS]: " + e.Message.ToString() + e.TargetSite.ToString()); | 1662 | m_log.Error("[PHYSICS]: " + e.Message.ToString() + e.TargetSite.ToString()); |
1733 | ode.dunlock(world); | 1663 | ode.dunlock(world); |
1734 | } | 1664 | } |
1735 | 1665 | ||
1736 | step_time -= ODE_STEPSIZE; | 1666 | step_time -= ODE_STEPSIZE; |
1737 | i++; | 1667 | i++; |
1738 | //} | 1668 | //} |
@@ -1765,7 +1695,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1765 | } | 1695 | } |
1766 | } | 1696 | } |
1767 | } | 1697 | } |
1768 | |||
1769 | } | 1698 | } |
1770 | return fps; | 1699 | return fps; |
1771 | } | 1700 | } |
@@ -1780,7 +1709,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1780 | get { return (false); } | 1709 | get { return (false); } |
1781 | } | 1710 | } |
1782 | 1711 | ||
1783 | #region ODE Specific Terrain Fixes | 1712 | #region ODE Specific Terrain Fixes |
1784 | public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) | 1713 | public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) |
1785 | { | 1714 | { |
1786 | float[] returnarr = new float[262144]; | 1715 | float[] returnarr = new float[262144]; |
@@ -1800,7 +1729,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1800 | // This particular way is quick but it only works on a multiple of the original | 1729 | // This particular way is quick but it only works on a multiple of the original |
1801 | 1730 | ||
1802 | // The idea behind this method can be described with the following diagrams | 1731 | // The idea behind this method can be described with the following diagrams |
1803 | // second pass and third pass happen in the same loop really.. just separated | 1732 | // second pass and third pass happen in the same loop really.. just separated |
1804 | // them to show what this does. | 1733 | // them to show what this does. |
1805 | 1734 | ||
1806 | // First Pass | 1735 | // First Pass |
@@ -1893,6 +1822,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1893 | 1822 | ||
1894 | return returnarr; | 1823 | return returnarr; |
1895 | } | 1824 | } |
1825 | |||
1896 | public float[] ResizeTerrain512Interpolation(float[] heightMap) | 1826 | public float[] ResizeTerrain512Interpolation(float[] heightMap) |
1897 | { | 1827 | { |
1898 | float[] returnarr = new float[262144]; | 1828 | float[] returnarr = new float[262144]; |
@@ -1912,7 +1842,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1912 | // This particular way is quick but it only works on a multiple of the original | 1842 | // This particular way is quick but it only works on a multiple of the original |
1913 | 1843 | ||
1914 | // The idea behind this method can be described with the following diagrams | 1844 | // The idea behind this method can be described with the following diagrams |
1915 | // second pass and third pass happen in the same loop really.. just separated | 1845 | // second pass and third pass happen in the same loop really.. just separated |
1916 | // them to show what this does. | 1846 | // them to show what this does. |
1917 | 1847 | ||
1918 | // First Pass | 1848 | // First Pass |
@@ -2139,7 +2069,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2139 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); | 2069 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); |
2140 | } | 2070 | } |
2141 | 2071 | ||
2142 | |||
2143 | lock (OdeLock) | 2072 | lock (OdeLock) |
2144 | { | 2073 | { |
2145 | if (!(WaterGeom == (IntPtr)0)) | 2074 | if (!(WaterGeom == (IntPtr)0)) |
@@ -2183,7 +2112,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2183 | { | 2112 | { |
2184 | lock (OdeLock) | 2113 | lock (OdeLock) |
2185 | { | 2114 | { |
2186 | |||
2187 | foreach (OdePrim prm in _prims) | 2115 | foreach (OdePrim prm in _prims) |
2188 | { | 2116 | { |
2189 | RemovePrim(prm); | 2117 | RemovePrim(prm); |