diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 254 |
1 files changed, 192 insertions, 62 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index d344d4d..d045b59 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -2579,7 +2579,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2579 | { | 2579 | { |
2580 | if (retMethod != null) | 2580 | if (retMethod != null) |
2581 | { | 2581 | { |
2582 | m_rayCastManager.QueueRequest(position, direction, length, retMethod); | 2582 | ODERayRequest req = new ODERayRequest(); |
2583 | req.geom = IntPtr.Zero; | ||
2584 | req.callbackMethod = retMethod; | ||
2585 | req.length = length; | ||
2586 | req.Normal = direction; | ||
2587 | req.Origin = position; | ||
2588 | req.Count = 0; | ||
2589 | req.filter = RayFilterFlags.All; | ||
2590 | |||
2591 | m_rayCastManager.QueueRequest(req); | ||
2583 | } | 2592 | } |
2584 | } | 2593 | } |
2585 | 2594 | ||
@@ -2587,29 +2596,51 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2587 | { | 2596 | { |
2588 | if (retMethod != null) | 2597 | if (retMethod != null) |
2589 | { | 2598 | { |
2590 | m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod); | 2599 | ODERayRequest req = new ODERayRequest(); |
2600 | req.geom = IntPtr.Zero; | ||
2601 | req.callbackMethod = retMethod; | ||
2602 | req.length = length; | ||
2603 | req.Normal = direction; | ||
2604 | req.Origin = position; | ||
2605 | req.Count = Count; | ||
2606 | req.filter = RayFilterFlags.All; | ||
2607 | |||
2608 | m_rayCastManager.QueueRequest(req); | ||
2591 | } | 2609 | } |
2592 | } | 2610 | } |
2593 | 2611 | ||
2594 | // don't like this | 2612 | |
2595 | public override List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) | 2613 | public override List<ContactResult> RaycastWorld(Vector3 position, Vector3 direction, float length, int Count) |
2596 | { | 2614 | { |
2597 | ContactResult[] ourResults = null; | 2615 | List<ContactResult> ourresults = new List<ContactResult>(); |
2616 | object SyncObject = new object(); | ||
2617 | |||
2598 | RayCallback retMethod = delegate(List<ContactResult> results) | 2618 | RayCallback retMethod = delegate(List<ContactResult> results) |
2599 | { | 2619 | { |
2600 | ourResults = new ContactResult[results.Count]; | 2620 | lock (SyncObject) |
2601 | results.CopyTo(ourResults, 0); | 2621 | { |
2622 | ourresults = results; | ||
2623 | Monitor.PulseAll(SyncObject); | ||
2624 | } | ||
2602 | }; | 2625 | }; |
2603 | int waitTime = 0; | 2626 | |
2604 | m_rayCastManager.QueueRequest(position, direction, length, Count, retMethod); | 2627 | ODERayRequest req = new ODERayRequest(); |
2605 | while (ourResults == null && waitTime < 1000) | 2628 | req.geom = IntPtr.Zero; |
2629 | req.callbackMethod = retMethod; | ||
2630 | req.length = length; | ||
2631 | req.Normal = direction; | ||
2632 | req.Origin = position; | ||
2633 | req.Count = Count; | ||
2634 | req.filter = RayFilterFlags.All; | ||
2635 | |||
2636 | lock (SyncObject) | ||
2606 | { | 2637 | { |
2607 | Thread.Sleep(1); | 2638 | m_rayCastManager.QueueRequest(req); |
2608 | waitTime++; | 2639 | if (!Monitor.Wait(SyncObject, 500)) |
2640 | return null; | ||
2641 | else | ||
2642 | return ourresults; | ||
2609 | } | 2643 | } |
2610 | if (ourResults == null) | ||
2611 | return new List<ContactResult>(); | ||
2612 | return new List<ContactResult>(ourResults); | ||
2613 | } | 2644 | } |
2614 | 2645 | ||
2615 | public override bool SuportsRaycastWorldFiltered() | 2646 | public override bool SuportsRaycastWorldFiltered() |
@@ -2631,9 +2662,18 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2631 | } | 2662 | } |
2632 | }; | 2663 | }; |
2633 | 2664 | ||
2665 | ODERayRequest req = new ODERayRequest(); | ||
2666 | req.geom = IntPtr.Zero; | ||
2667 | req.callbackMethod = retMethod; | ||
2668 | req.length = length; | ||
2669 | req.Normal = direction; | ||
2670 | req.Origin = position; | ||
2671 | req.Count = Count; | ||
2672 | req.filter = filter; | ||
2673 | |||
2634 | lock (SyncObject) | 2674 | lock (SyncObject) |
2635 | { | 2675 | { |
2636 | m_rayCastManager.QueueRequest(position, direction, length, Count,filter, retMethod); | 2676 | m_rayCastManager.QueueRequest(req); |
2637 | if (!Monitor.Wait(SyncObject, 500)) | 2677 | if (!Monitor.Wait(SyncObject, 500)) |
2638 | return null; | 2678 | return null; |
2639 | else | 2679 | else |
@@ -2641,73 +2681,163 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2641 | } | 2681 | } |
2642 | } | 2682 | } |
2643 | 2683 | ||
2644 | public override void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, RaycastCallback retMethod) | 2684 | public override List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags) |
2645 | { | 2685 | { |
2646 | if (retMethod != null && actor !=null) | 2686 | if (actor == null) |
2687 | return new List<ContactResult>(); | ||
2688 | |||
2689 | IntPtr geom; | ||
2690 | if (actor is OdePrim) | ||
2691 | geom = ((OdePrim)actor).prim_geom; | ||
2692 | else if (actor is OdeCharacter) | ||
2693 | geom = ((OdePrim)actor).prim_geom; | ||
2694 | else | ||
2695 | return new List<ContactResult>(); | ||
2696 | |||
2697 | if (geom == IntPtr.Zero) | ||
2698 | return new List<ContactResult>(); | ||
2699 | |||
2700 | List<ContactResult> ourResults = null; | ||
2701 | object SyncObject = new object(); | ||
2702 | |||
2703 | RayCallback retMethod = delegate(List<ContactResult> results) | ||
2647 | { | 2704 | { |
2648 | IntPtr geom; | 2705 | lock (SyncObject) |
2649 | if (actor is OdePrim) | 2706 | { |
2650 | geom = ((OdePrim)actor).prim_geom; | 2707 | ourResults = results; |
2651 | else if (actor is OdeCharacter) | 2708 | Monitor.PulseAll(SyncObject); |
2652 | geom = ((OdePrim)actor).prim_geom; | 2709 | } |
2653 | else | 2710 | }; |
2654 | return; | 2711 | |
2655 | if (geom == IntPtr.Zero) | 2712 | ODERayRequest req = new ODERayRequest(); |
2656 | return; | 2713 | req.geom = geom; |
2657 | m_rayCastManager.QueueRequest(geom, position, direction, length, retMethod); | 2714 | req.callbackMethod = retMethod; |
2715 | req.length = length; | ||
2716 | req.Normal = direction; | ||
2717 | req.Origin = position; | ||
2718 | req.Count = Count; | ||
2719 | req.filter = flags; | ||
2720 | |||
2721 | lock (SyncObject) | ||
2722 | { | ||
2723 | m_rayCastManager.QueueRequest(req); | ||
2724 | if (!Monitor.Wait(SyncObject, 500)) | ||
2725 | return new List<ContactResult>(); | ||
2658 | } | 2726 | } |
2727 | |||
2728 | if (ourResults == null) | ||
2729 | return new List<ContactResult>(); | ||
2730 | return ourResults; | ||
2659 | } | 2731 | } |
2660 | 2732 | ||
2661 | public override void RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayCallback retMethod) | 2733 | public override List<ContactResult> BoxProbe(Vector3 position, Vector3 size, Quaternion orientation, int Count, RayFilterFlags flags) |
2662 | { | 2734 | { |
2663 | if (retMethod != null && actor != null) | 2735 | List<ContactResult> ourResults = null; |
2736 | object SyncObject = new object(); | ||
2737 | |||
2738 | ProbeBoxCallback retMethod = delegate(List<ContactResult> results) | ||
2664 | { | 2739 | { |
2665 | IntPtr geom; | 2740 | lock (SyncObject) |
2666 | if (actor is OdePrim) | 2741 | { |
2667 | geom = ((OdePrim)actor).prim_geom; | 2742 | ourResults = results; |
2668 | else if (actor is OdeCharacter) | 2743 | Monitor.PulseAll(SyncObject); |
2669 | geom = ((OdePrim)actor).prim_geom; | 2744 | } |
2670 | else | 2745 | }; |
2671 | return; | 2746 | |
2672 | if (geom == IntPtr.Zero) | 2747 | ODERayRequest req = new ODERayRequest(); |
2673 | return; | 2748 | req.geom = IntPtr.Zero; |
2749 | req.callbackMethod = retMethod; | ||
2750 | req.Normal = size; | ||
2751 | req.Origin = position; | ||
2752 | req.orientation = orientation; | ||
2753 | req.Count = Count; | ||
2754 | req.filter = flags; | ||
2674 | 2755 | ||
2675 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, retMethod); | 2756 | lock (SyncObject) |
2757 | { | ||
2758 | m_rayCastManager.QueueRequest(req); | ||
2759 | if (!Monitor.Wait(SyncObject, 500)) | ||
2760 | return new List<ContactResult>(); | ||
2676 | } | 2761 | } |
2762 | |||
2763 | if (ourResults == null) | ||
2764 | return new List<ContactResult>(); | ||
2765 | return ourResults; | ||
2677 | } | 2766 | } |
2678 | 2767 | ||
2679 | public override List<ContactResult> RaycastActor(PhysicsActor actor, Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags flags) | 2768 | public override List<ContactResult> SphereProbe(Vector3 position, float radius, int Count, RayFilterFlags flags) |
2769 | { | ||
2770 | List<ContactResult> ourResults = null; | ||
2771 | object SyncObject = new object(); | ||
2772 | |||
2773 | ProbeSphereCallback retMethod = delegate(List<ContactResult> results) | ||
2774 | { | ||
2775 | ourResults = results; | ||
2776 | Monitor.PulseAll(SyncObject); | ||
2777 | }; | ||
2778 | |||
2779 | ODERayRequest req = new ODERayRequest(); | ||
2780 | req.geom = IntPtr.Zero; | ||
2781 | req.callbackMethod = retMethod; | ||
2782 | req.length = radius; | ||
2783 | req.Origin = position; | ||
2784 | req.Count = Count; | ||
2785 | req.filter = flags; | ||
2786 | |||
2787 | |||
2788 | lock (SyncObject) | ||
2789 | { | ||
2790 | m_rayCastManager.QueueRequest(req); | ||
2791 | if (!Monitor.Wait(SyncObject, 500)) | ||
2792 | return new List<ContactResult>(); | ||
2793 | } | ||
2794 | |||
2795 | if (ourResults == null) | ||
2796 | return new List<ContactResult>(); | ||
2797 | return ourResults; | ||
2798 | } | ||
2799 | |||
2800 | public override List<ContactResult> PlaneProbe(PhysicsActor actor, Vector4 plane, int Count, RayFilterFlags flags) | ||
2680 | { | 2801 | { |
2802 | IntPtr geom = IntPtr.Zero;; | ||
2803 | |||
2681 | if (actor != null) | 2804 | if (actor != null) |
2682 | { | 2805 | { |
2683 | IntPtr geom; | ||
2684 | if (actor is OdePrim) | 2806 | if (actor is OdePrim) |
2685 | geom = ((OdePrim)actor).prim_geom; | 2807 | geom = ((OdePrim)actor).prim_geom; |
2686 | else if (actor is OdeCharacter) | 2808 | else if (actor is OdeCharacter) |
2687 | geom = ((OdePrim)actor).prim_geom; | 2809 | geom = ((OdePrim)actor).prim_geom; |
2688 | else | 2810 | } |
2689 | return new List<ContactResult>(); | ||
2690 | if (geom == IntPtr.Zero) | ||
2691 | return new List<ContactResult>(); | ||
2692 | 2811 | ||
2693 | ContactResult[] ourResults = null; | 2812 | List<ContactResult> ourResults = null; |
2694 | RayCallback retMethod = delegate(List<ContactResult> results) | 2813 | object SyncObject = new object(); |
2695 | { | 2814 | |
2696 | ourResults = new ContactResult[results.Count]; | 2815 | ProbePlaneCallback retMethod = delegate(List<ContactResult> results) |
2697 | results.CopyTo(ourResults, 0); | 2816 | { |
2698 | }; | 2817 | ourResults = results; |
2699 | int waitTime = 0; | 2818 | Monitor.PulseAll(SyncObject); |
2700 | m_rayCastManager.QueueRequest(geom,position, direction, length, Count, flags, retMethod); | 2819 | }; |
2701 | while (ourResults == null && waitTime < 1000) | 2820 | |
2702 | { | 2821 | ODERayRequest req = new ODERayRequest(); |
2703 | Thread.Sleep(1); | 2822 | req.geom = geom; |
2704 | waitTime++; | 2823 | req.callbackMethod = retMethod; |
2705 | } | 2824 | req.length = plane.W; |
2706 | if (ourResults == null) | 2825 | req.Normal.X = plane.X; |
2826 | req.Normal.Y = plane.Y; | ||
2827 | req.Normal.Z = plane.Z; | ||
2828 | req.Count = Count; | ||
2829 | req.filter = flags; | ||
2830 | |||
2831 | lock (SyncObject) | ||
2832 | { | ||
2833 | m_rayCastManager.QueueRequest(req); | ||
2834 | if (!Monitor.Wait(SyncObject, 500)) | ||
2707 | return new List<ContactResult>(); | 2835 | return new List<ContactResult>(); |
2708 | return new List<ContactResult>(ourResults); | ||
2709 | } | 2836 | } |
2710 | return new List<ContactResult>(); | 2837 | |
2838 | if (ourResults == null) | ||
2839 | return new List<ContactResult>(); | ||
2840 | return ourResults; | ||
2711 | } | 2841 | } |
2712 | 2842 | ||
2713 | public override int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) | 2843 | public override int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) |