diff options
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 171 |
1 files changed, 135 insertions, 36 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 12da6a7..4c041a1 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Runtime.InteropServices; | ||
31 | using Axiom.Math; | 32 | using Axiom.Math; |
32 | using Ode.NET; | 33 | using Ode.NET; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -57,6 +58,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
57 | public bool m_taintdisable = false; | 58 | public bool m_taintdisable = false; |
58 | public bool m_disabled = false; | 59 | public bool m_disabled = false; |
59 | public bool m_taintadd = false; | 60 | public bool m_taintadd = false; |
61 | public GCHandle gc; | ||
60 | private CollisionLocker ode; | 62 | private CollisionLocker ode; |
61 | 63 | ||
62 | private bool m_taintforce = false; | 64 | private bool m_taintforce = false; |
@@ -67,6 +69,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
67 | private OdeScene _parent_scene; | 69 | private OdeScene _parent_scene; |
68 | public IntPtr m_targetSpace = (IntPtr) 0; | 70 | public IntPtr m_targetSpace = (IntPtr) 0; |
69 | public IntPtr prim_geom; | 71 | public IntPtr prim_geom; |
72 | public IntPtr prev_geom; | ||
70 | public IntPtr _triMeshData; | 73 | public IntPtr _triMeshData; |
71 | 74 | ||
72 | private bool iscolliding = false; | 75 | private bool iscolliding = false; |
@@ -95,6 +98,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
95 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, | 98 | public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, |
96 | Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) | 99 | Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) |
97 | { | 100 | { |
101 | |||
102 | |||
103 | gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); | ||
98 | ode = dode; | 104 | ode = dode; |
99 | _velocity = new PhysicsVector(); | 105 | _velocity = new PhysicsVector(); |
100 | _position = pos; | 106 | _position = pos; |
@@ -116,6 +122,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
116 | _position.Y = 0; | 122 | _position.Y = 0; |
117 | } | 123 | } |
118 | 124 | ||
125 | prim_geom = (IntPtr)0; | ||
126 | prev_geom = (IntPtr)0; | ||
127 | |||
119 | _size = size; | 128 | _size = size; |
120 | m_taintsize = _size; | 129 | m_taintsize = _size; |
121 | _acceleration = new PhysicsVector(); | 130 | _acceleration = new PhysicsVector(); |
@@ -173,6 +182,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
173 | set { return; } | 182 | set { return; } |
174 | } | 183 | } |
175 | 184 | ||
185 | public void SetGeom(IntPtr geom) | ||
186 | { | ||
187 | prev_geom = prim_geom; | ||
188 | prim_geom = geom; | ||
189 | m_log.Warn("Setting Geom to: " + prim_geom); | ||
190 | |||
191 | } | ||
176 | 192 | ||
177 | public void enableBody() | 193 | public void enableBody() |
178 | { | 194 | { |
@@ -337,9 +353,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
337 | disableBody(); | 353 | disableBody(); |
338 | } | 354 | } |
339 | 355 | ||
340 | |||
341 | |||
342 | |||
343 | float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory | 356 | float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory |
344 | int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage | 357 | int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage |
345 | int VertexCount = vertexList.GetLength(0)/3; | 358 | int VertexCount = vertexList.GetLength(0)/3; |
@@ -356,7 +369,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
356 | 369 | ||
357 | try | 370 | try |
358 | { | 371 | { |
359 | prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); | 372 | if (prim_geom == (IntPtr)0) |
373 | { | ||
374 | SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); | ||
375 | } | ||
360 | } | 376 | } |
361 | catch (System.AccessViolationException) | 377 | catch (System.AccessViolationException) |
362 | { | 378 | { |
@@ -377,10 +393,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
377 | 393 | ||
378 | public void ProcessTaints(float timestep) | 394 | public void ProcessTaints(float timestep) |
379 | { | 395 | { |
380 | 396 | ||
381 | 397 | ||
382 | if (m_taintadd) | 398 | if (m_taintadd) |
399 | { | ||
383 | changeadd(timestep); | 400 | changeadd(timestep); |
401 | } | ||
384 | 402 | ||
385 | if (m_taintposition != _position) | 403 | if (m_taintposition != _position) |
386 | Move(timestep); | 404 | Move(timestep); |
@@ -433,6 +451,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
433 | } | 451 | } |
434 | public void changeadd(float timestep) | 452 | public void changeadd(float timestep) |
435 | { | 453 | { |
454 | while (ode.lockquery()) | ||
455 | { | ||
456 | } | ||
457 | ode.dlock(_parent_scene.world); | ||
458 | |||
436 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | 459 | int[] iprimspaceArrItem = _parent_scene.calculateSpaceArrayItemFromPos(_position); |
437 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); | 460 | IntPtr targetspace = _parent_scene.calculateSpaceForGeom(_position); |
438 | 461 | ||
@@ -441,6 +464,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
441 | 464 | ||
442 | m_targetSpace = targetspace; | 465 | m_targetSpace = targetspace; |
443 | 466 | ||
467 | if (m_targetSpace != (IntPtr)0) | ||
468 | { | ||
469 | m_log.Warn("[PHYSICS]: target: " + m_targetSpace.ToString()); | ||
470 | } | ||
471 | |||
444 | if (_mesh != null) | 472 | if (_mesh != null) |
445 | { | 473 | { |
446 | } | 474 | } |
@@ -473,11 +501,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
473 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 501 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
474 | try | 502 | try |
475 | { | 503 | { |
476 | prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); | 504 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); |
477 | } | 505 | } |
478 | catch (System.AccessViolationException) | 506 | catch (System.AccessViolationException) |
479 | { | 507 | { |
480 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | 508 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); |
509 | ode.dunlock(_parent_scene.world); | ||
481 | return; | 510 | return; |
482 | } | 511 | } |
483 | } | 512 | } |
@@ -486,11 +515,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
486 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 515 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
487 | try | 516 | try |
488 | { | 517 | { |
489 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 518 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
490 | } | 519 | } |
491 | catch (System.AccessViolationException) | 520 | catch (System.AccessViolationException) |
492 | { | 521 | { |
493 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | 522 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); |
523 | ode.dunlock(_parent_scene.world); | ||
494 | return; | 524 | return; |
495 | } | 525 | } |
496 | } | 526 | } |
@@ -500,12 +530,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
500 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 530 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
501 | try | 531 | try |
502 | { | 532 | { |
503 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 533 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
504 | } | 534 | } |
505 | catch (System.AccessViolationException) | 535 | catch (System.AccessViolationException) |
506 | { | 536 | { |
507 | return; | ||
508 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | 537 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); |
538 | ode.dunlock(_parent_scene.world); | ||
539 | return; | ||
509 | } | 540 | } |
510 | } | 541 | } |
511 | } | 542 | } |
@@ -526,23 +557,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
526 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 557 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
527 | try | 558 | try |
528 | { | 559 | { |
529 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 560 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
530 | } | 561 | } |
531 | catch (System.AccessViolationException) | 562 | catch (System.AccessViolationException) |
532 | { | 563 | { |
533 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); | 564 | m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); |
565 | ode.dunlock(_parent_scene.world); | ||
534 | return; | 566 | return; |
535 | } | 567 | } |
536 | } | 568 | } |
537 | } | 569 | } |
538 | 570 | if (prim_geom != (IntPtr) 0) | |
539 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 571 | { |
540 | d.Quaternion myrot = new d.Quaternion(); | 572 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
541 | myrot.W = _orientation.w; | 573 | d.Quaternion myrot = new d.Quaternion(); |
542 | myrot.X = _orientation.x; | 574 | myrot.W = _orientation.w; |
543 | myrot.Y = _orientation.y; | 575 | myrot.X = _orientation.x; |
544 | myrot.Z = _orientation.z; | 576 | myrot.Y = _orientation.y; |
545 | d.GeomSetQuaternion(prim_geom, ref myrot); | 577 | myrot.Z = _orientation.z; |
578 | d.GeomSetQuaternion(prim_geom, ref myrot); | ||
579 | } | ||
546 | 580 | ||
547 | 581 | ||
548 | if (m_isphysical && Body == (IntPtr)0) | 582 | if (m_isphysical && Body == (IntPtr)0) |
@@ -551,7 +585,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
551 | } | 585 | } |
552 | 586 | ||
553 | 587 | ||
554 | } | 588 | } |
589 | ode.dunlock(_parent_scene.world); | ||
555 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; | 590 | _parent_scene.geom_name_map[prim_geom] = this.m_primName; |
556 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; | 591 | _parent_scene.actor_name_map[prim_geom] = (PhysicsActor)this; |
557 | m_taintadd = false; | 592 | m_taintadd = false; |
@@ -560,32 +595,55 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
560 | } | 595 | } |
561 | public void Move(float timestep) | 596 | public void Move(float timestep) |
562 | { | 597 | { |
598 | while (ode.lockquery()) | ||
599 | { | ||
600 | } | ||
601 | ode.dlock(_parent_scene.world); | ||
602 | |||
603 | |||
563 | if (m_isphysical) | 604 | if (m_isphysical) |
564 | { | 605 | { |
565 | // This is a fallback.. May no longer be necessary. | 606 | // This is a fallback.. May no longer be necessary. |
566 | if (Body == (IntPtr) 0) | 607 | if (Body == (IntPtr) 0) |
567 | enableBody(); | 608 | enableBody(); |
568 | //Prim auto disable after 20 frames, | 609 | //Prim auto disable after 20 frames, |
569 | ///if you move it, re-enable the prim manually. | 610 | //if you move it, re-enable the prim manually. |
570 | d.BodyEnable(Body); | 611 | |
571 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | 612 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); |
613 | d.BodyEnable(Body); | ||
614 | |||
572 | } | 615 | } |
573 | else | 616 | else |
574 | { | 617 | { |
575 | string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); | 618 | string primScenAvatarIn = _parent_scene.whichspaceamIin(_position); |
576 | int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); | 619 | int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); |
577 | m_targetSpace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); | 620 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
578 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 621 | |
622 | IntPtr tempspace = _parent_scene.recalculateSpaceForGeom(prim_geom, _position, m_targetSpace); | ||
623 | m_targetSpace = tempspace; | ||
579 | 624 | ||
580 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 625 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
581 | d.SpaceAdd(m_targetSpace, prim_geom); | 626 | if (prim_geom != (IntPtr) 0) |
627 | { | ||
628 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | ||
629 | |||
630 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | ||
631 | d.SpaceAdd(m_targetSpace, prim_geom); | ||
632 | } | ||
582 | } | 633 | } |
634 | ode.dunlock(_parent_scene.world); | ||
635 | |||
583 | resetCollisionAccounting(); | 636 | resetCollisionAccounting(); |
584 | m_taintposition = _position; | 637 | m_taintposition = _position; |
585 | } | 638 | } |
586 | 639 | ||
587 | public void rotate(float timestep) | 640 | public void rotate(float timestep) |
588 | { | 641 | { |
642 | while (ode.lockquery()) | ||
643 | { | ||
644 | } | ||
645 | ode.dlock(_parent_scene.world); | ||
646 | |||
589 | d.Quaternion myrot = new d.Quaternion(); | 647 | d.Quaternion myrot = new d.Quaternion(); |
590 | myrot.W = _orientation.w; | 648 | myrot.W = _orientation.w; |
591 | myrot.X = _orientation.x; | 649 | myrot.X = _orientation.x; |
@@ -596,6 +654,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
596 | { | 654 | { |
597 | d.BodySetQuaternion(Body, ref myrot); | 655 | d.BodySetQuaternion(Body, ref myrot); |
598 | } | 656 | } |
657 | |||
658 | ode.dunlock(_parent_scene.world); | ||
659 | |||
599 | resetCollisionAccounting(); | 660 | resetCollisionAccounting(); |
600 | m_taintrot = _orientation; | 661 | m_taintrot = _orientation; |
601 | } | 662 | } |
@@ -608,11 +669,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
608 | } | 669 | } |
609 | 670 | ||
610 | public void changedisable(float timestep) | 671 | public void changedisable(float timestep) |
611 | { | 672 | { |
673 | while (ode.lockquery()) | ||
674 | { | ||
675 | } | ||
676 | ode.dlock(_parent_scene.world); | ||
612 | m_disabled = true; | 677 | m_disabled = true; |
613 | if (Body != (IntPtr) 0) | 678 | if (Body != (IntPtr) 0) |
614 | d.BodyDisable(Body); | 679 | d.BodyDisable(Body); |
615 | 680 | ||
681 | ode.dunlock(_parent_scene.world); | ||
682 | |||
616 | m_taintdisable = false; | 683 | m_taintdisable = false; |
617 | } | 684 | } |
618 | 685 | ||
@@ -638,6 +705,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
638 | 705 | ||
639 | public void changesize(float timestamp) | 706 | public void changesize(float timestamp) |
640 | { | 707 | { |
708 | while (ode.lockquery()) | ||
709 | { | ||
710 | } | ||
711 | ode.dlock(_parent_scene.world); | ||
641 | //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) | 712 | //if (!_parent_scene.geom_name_map.ContainsKey(prim_geom)) |
642 | //{ | 713 | //{ |
643 | // m_taintsize = _size; | 714 | // m_taintsize = _size; |
@@ -684,20 +755,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
684 | if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) | 755 | if (((_size.X / 2f) > 0f) && ((_size.X / 2f) < 1000)) |
685 | { | 756 | { |
686 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 757 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
687 | prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); | 758 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); |
688 | } | 759 | } |
689 | else | 760 | else |
690 | { | 761 | { |
691 | m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); | 762 | m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); |
692 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 763 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
693 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 764 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
694 | } | 765 | } |
695 | 766 | ||
696 | } | 767 | } |
697 | else | 768 | else |
698 | { | 769 | { |
699 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 770 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
700 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 771 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
701 | } | 772 | } |
702 | } | 773 | } |
703 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | 774 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) |
@@ -715,7 +786,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
715 | else | 786 | else |
716 | { | 787 | { |
717 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 788 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
718 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 789 | SetGeom(prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
719 | } | 790 | } |
720 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 791 | //prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); |
721 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 792 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
@@ -734,12 +805,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
734 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | 805 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) |
735 | { | 806 | { |
736 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 807 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
737 | prim_geom = d.CreateSphere(m_targetSpace, _size.X / 2); | 808 | SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); |
738 | } | 809 | } |
739 | else | 810 | else |
740 | { | 811 | { |
741 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 812 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
742 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 813 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
743 | } | 814 | } |
744 | } | 815 | } |
745 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) | 816 | //else if (_pbs.ProfileShape == ProfileShape.Circle && _pbs.PathCurve == (byte)Extrusion.Straight) |
@@ -757,7 +828,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
757 | else | 828 | else |
758 | { | 829 | { |
759 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 830 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
760 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 831 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
761 | } | 832 | } |
762 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); | 833 | d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); |
763 | d.Quaternion myrot = new d.Quaternion(); | 834 | d.Quaternion myrot = new d.Quaternion(); |
@@ -779,12 +850,21 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
779 | } | 850 | } |
780 | 851 | ||
781 | _parent_scene.geom_name_map[prim_geom] = oldname; | 852 | _parent_scene.geom_name_map[prim_geom] = oldname; |
853 | |||
854 | ode.dunlock(_parent_scene.world); | ||
855 | |||
782 | resetCollisionAccounting(); | 856 | resetCollisionAccounting(); |
783 | m_taintsize = _size; | 857 | m_taintsize = _size; |
784 | } | 858 | } |
785 | 859 | ||
786 | public void changeshape(float timestamp) | 860 | public void changeshape(float timestamp) |
787 | { | 861 | { |
862 | while (ode.lockquery()) | ||
863 | { | ||
864 | } | ||
865 | ode.dlock(_parent_scene.world); | ||
866 | |||
867 | |||
788 | string oldname = _parent_scene.geom_name_map[prim_geom]; | 868 | string oldname = _parent_scene.geom_name_map[prim_geom]; |
789 | 869 | ||
790 | // Cleanup of old prim geometry and Bodies | 870 | // Cleanup of old prim geometry and Bodies |
@@ -809,13 +889,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
809 | else | 889 | else |
810 | { | 890 | { |
811 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 891 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
812 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 892 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
813 | } | 893 | } |
814 | } | 894 | } |
815 | else | 895 | else |
816 | { | 896 | { |
817 | _parent_scene.waitForSpaceUnlock(m_targetSpace); | 897 | _parent_scene.waitForSpaceUnlock(m_targetSpace); |
818 | prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); | 898 | SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z)); |
819 | } | 899 | } |
820 | if (IsPhysical && Body == (IntPtr) 0) | 900 | if (IsPhysical && Body == (IntPtr) 0) |
821 | { | 901 | { |
@@ -833,12 +913,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
833 | d.GeomSetQuaternion(prim_geom, ref myrot); | 913 | d.GeomSetQuaternion(prim_geom, ref myrot); |
834 | } | 914 | } |
835 | _parent_scene.geom_name_map[prim_geom] = oldname; | 915 | _parent_scene.geom_name_map[prim_geom] = oldname; |
916 | |||
917 | ode.dunlock(_parent_scene.world); | ||
918 | |||
836 | resetCollisionAccounting(); | 919 | resetCollisionAccounting(); |
837 | m_taintshape = false; | 920 | m_taintshape = false; |
838 | } | 921 | } |
839 | 922 | ||
840 | public void changeAddForce(float timestamp) | 923 | public void changeAddForce(float timestamp) |
841 | { | 924 | { |
925 | while (ode.lockquery()) | ||
926 | { | ||
927 | } | ||
928 | ode.dlock(_parent_scene.world); | ||
929 | |||
842 | System.Threading.Thread.Sleep(2); | 930 | System.Threading.Thread.Sleep(2); |
843 | lock (m_forcelist) | 931 | lock (m_forcelist) |
844 | { | 932 | { |
@@ -855,6 +943,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
855 | } | 943 | } |
856 | m_forcelist.Clear(); | 944 | m_forcelist.Clear(); |
857 | } | 945 | } |
946 | |||
947 | ode.dunlock(_parent_scene.world); | ||
948 | |||
858 | m_collisionscore = 0; | 949 | m_collisionscore = 0; |
859 | m_interpenetrationcount = 0; | 950 | m_interpenetrationcount = 0; |
860 | m_taintforce = false; | 951 | m_taintforce = false; |
@@ -862,6 +953,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
862 | } | 953 | } |
863 | private void changevelocity(float timestep) | 954 | private void changevelocity(float timestep) |
864 | { | 955 | { |
956 | while (ode.lockquery()) | ||
957 | { | ||
958 | } | ||
959 | ode.dlock(_parent_scene.world); | ||
960 | |||
865 | System.Threading.Thread.Sleep(20); | 961 | System.Threading.Thread.Sleep(20); |
866 | if (IsPhysical) | 962 | if (IsPhysical) |
867 | { | 963 | { |
@@ -870,7 +966,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
870 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); | 966 | d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); |
871 | } | 967 | } |
872 | } | 968 | } |
873 | resetCollisionAccounting(); | 969 | |
970 | ode.dunlock(_parent_scene.world); | ||
971 | |||
972 | //resetCollisionAccounting(); | ||
874 | m_taintVelocity = PhysicsVector.Zero; | 973 | m_taintVelocity = PhysicsVector.Zero; |
875 | } | 974 | } |
876 | public override bool IsPhysical | 975 | public override bool IsPhysical |