aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/OdeScene.cs164
1 files changed, 5 insertions, 159 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
index 4e95b7a..6f14121 100644
--- a/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs
@@ -31,9 +31,6 @@
31// or application thread stack may just blowup 31// or application thread stack may just blowup
32// see RayCast(ODERayCastRequest req) 32// see RayCast(ODERayCastRequest req)
33 33
34//#define USE_DRAWSTUFF
35//#define SPAM
36
37using System; 34using System;
38using System.Collections.Generic; 35using System.Collections.Generic;
39using System.Diagnostics; 36using System.Diagnostics;
@@ -46,17 +43,12 @@ using System.Threading;
46using log4net; 43using log4net;
47using Nini.Config; 44using Nini.Config;
48using Mono.Addins; 45using Mono.Addins;
49using Ode.NET;
50using OpenMetaverse; 46using OpenMetaverse;
51#if USE_DRAWSTUFF
52using Drawstuff.NET;
53#endif
54using OpenSim.Framework; 47using OpenSim.Framework;
55using OpenSim.Region.PhysicsModules.SharedBase; 48using OpenSim.Region.PhysicsModules.SharedBase;
56using OpenSim.Region.Framework.Scenes; 49using OpenSim.Region.Framework.Scenes;
57using OpenSim.Region.Framework.Interfaces; 50using OpenSim.Region.Framework.Interfaces;
58 51
59
60namespace OpenSim.Region.PhysicsModule.ODE 52namespace OpenSim.Region.PhysicsModule.ODE
61{ 53{
62 public enum StatusIndicators : int 54 public enum StatusIndicators : int
@@ -585,32 +577,12 @@ namespace OpenSim.Region.PhysicsModule.ODE
585 577
586 d.WorldSetAutoDisableFlag(world, false); 578 d.WorldSetAutoDisableFlag(world, false);
587 579
588 #if USE_DRAWSTUFF 580// _watermap = new float[258 * 258];
589 Thread viewthread = new Thread(new ParameterizedThreadStart(startvisualization));
590 viewthread.Start();
591 #endif
592
593 // _watermap = new float[258 * 258];
594 581
595 // Zero out the prim spaces array (we split our space into smaller spaces so 582 // Zero out the prim spaces array (we split our space into smaller spaces so
596 // we can hit test less. 583 // we can hit test less.
597 } 584 }
598 585
599#if USE_DRAWSTUFF
600 public void startvisualization(object o)
601 {
602 ds.Functions fn;
603 fn.version = ds.VERSION;
604 fn.start = new ds.CallbackFunction(start);
605 fn.step = new ds.CallbackFunction(step);
606 fn.command = new ds.CallbackFunction(command);
607 fn.stop = null;
608 fn.path_to_textures = "./textures";
609 string[] args = new string[0];
610 ds.SimulationLoop(args.Length, args, 352, 288, ref fn);
611 }
612#endif
613
614 // Initialize from configs 586 // Initialize from configs
615 private void InitialiseFromConfig(IConfigSource config) 587 private void InitialiseFromConfig(IConfigSource config)
616 { 588 {
@@ -957,7 +929,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
957 /// <param name='contactsArray'></param> 929 /// <param name='contactsArray'></param>
958 /// <param name='contactGeomSize'></param> 930 /// <param name='contactGeomSize'></param>
959 private int CollideGeoms( 931 private int CollideGeoms(
960 IntPtr geom1, IntPtr geom2, int maxContacts, Ode.NET.d.ContactGeom[] contactsArray, int contactGeomSize) 932 IntPtr geom1, IntPtr geom2, int maxContacts, d.ContactGeom[] contactsArray, int contactGeomSize)
961 { 933 {
962 int count; 934 int count;
963 935
@@ -1090,7 +1062,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
1090 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 1062 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
1091 return; 1063 return;
1092 1064
1093 count = CollideGeoms(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); 1065 count = CollideGeoms(g1, g2, contacts.Length, contacts, d.ContactGeom.unmanagedSizeOf);
1094 1066
1095 // All code after this is only relevant if we have any collisions 1067 // All code after this is only relevant if we have any collisions
1096 if (count <= 0) 1068 if (count <= 0)
@@ -2972,7 +2944,8 @@ namespace OpenSim.Region.PhysicsModule.ODE
2972 /// <returns>The number of frames simulated over that period.</returns> 2944 /// <returns>The number of frames simulated over that period.</returns>
2973 public override float Simulate(float timeStep) 2945 public override float Simulate(float timeStep)
2974 { 2946 {
2975 if (!_worldInitialized) return 11f; 2947 if (!_worldInitialized)
2948 return 1.0f;
2976 2949
2977 int startFrameTick = CollectStats ? Util.EnvironmentTickCount() : 0; 2950 int startFrameTick = CollectStats ? Util.EnvironmentTickCount() : 0;
2978 int tempTick = 0, tempTick2 = 0; 2951 int tempTick = 0, tempTick2 = 0;
@@ -3804,133 +3777,6 @@ namespace OpenSim.Region.PhysicsModule.ODE
3804 return new List<ContactResult>(ourResults); 3777 return new List<ContactResult>(ourResults);
3805 } 3778 }
3806 3779
3807#if USE_DRAWSTUFF
3808 // Keyboard callback
3809 public void command(int cmd)
3810 {
3811 IntPtr geom;
3812 d.Mass mass;
3813 d.Vector3 sides = new d.Vector3(d.RandReal() * 0.5f + 0.1f, d.RandReal() * 0.5f + 0.1f, d.RandReal() * 0.5f + 0.1f);
3814
3815
3816
3817 Char ch = Char.ToLower((Char)cmd);
3818 switch ((Char)ch)
3819 {
3820 case 'w':
3821 try
3822 {
3823 Vector3 rotate = (new Vector3(1, 0, 0) * Quaternion.CreateFromEulers(hpr.Z * Utils.DEG_TO_RAD, hpr.Y * Utils.DEG_TO_RAD, hpr.X * Utils.DEG_TO_RAD));
3824
3825 xyz.X += rotate.X; xyz.Y += rotate.Y; xyz.Z += rotate.Z;
3826 ds.SetViewpoint(ref xyz, ref hpr);
3827 }
3828 catch (ArgumentException)
3829 { hpr.X = 0; }
3830 break;
3831
3832 case 'a':
3833 hpr.X++;
3834 ds.SetViewpoint(ref xyz, ref hpr);
3835 break;
3836
3837 case 's':
3838 try
3839 {
3840 Vector3 rotate2 = (new Vector3(-1, 0, 0) * Quaternion.CreateFromEulers(hpr.Z * Utils.DEG_TO_RAD, hpr.Y * Utils.DEG_TO_RAD, hpr.X * Utils.DEG_TO_RAD));
3841
3842 xyz.X += rotate2.X; xyz.Y += rotate2.Y; xyz.Z += rotate2.Z;
3843 ds.SetViewpoint(ref xyz, ref hpr);
3844 }
3845 catch (ArgumentException)
3846 { hpr.X = 0; }
3847 break;
3848 case 'd':
3849 hpr.X--;
3850 ds.SetViewpoint(ref xyz, ref hpr);
3851 break;
3852 case 'r':
3853 xyz.Z++;
3854 ds.SetViewpoint(ref xyz, ref hpr);
3855 break;
3856 case 'f':
3857 xyz.Z--;
3858 ds.SetViewpoint(ref xyz, ref hpr);
3859 break;
3860 case 'e':
3861 xyz.Y++;
3862 ds.SetViewpoint(ref xyz, ref hpr);
3863 break;
3864 case 'q':
3865 xyz.Y--;
3866 ds.SetViewpoint(ref xyz, ref hpr);
3867 break;
3868 }
3869 }
3870
3871 public void step(int pause)
3872 {
3873
3874 ds.SetColor(1.0f, 1.0f, 0.0f);
3875 ds.SetTexture(ds.Texture.Wood);
3876 lock (_prims)
3877 {
3878 foreach (OdePrim prm in _prims)
3879 {
3880 //IntPtr body = d.GeomGetBody(prm.prim_geom);
3881 if (prm.prim_geom != IntPtr.Zero)
3882 {
3883 d.Vector3 pos;
3884 d.GeomCopyPosition(prm.prim_geom, out pos);
3885 //d.BodyCopyPosition(body, out pos);
3886
3887 d.Matrix3 R;
3888 d.GeomCopyRotation(prm.prim_geom, out R);
3889 //d.BodyCopyRotation(body, out R);
3890
3891
3892 d.Vector3 sides = new d.Vector3();
3893 sides.X = prm.Size.X;
3894 sides.Y = prm.Size.Y;
3895 sides.Z = prm.Size.Z;
3896
3897 ds.DrawBox(ref pos, ref R, ref sides);
3898 }
3899 }
3900 }
3901 ds.SetColor(1.0f, 0.0f, 0.0f);
3902
3903 foreach (OdeCharacter chr in _characters)
3904 {
3905 if (chr.Shell != IntPtr.Zero)
3906 {
3907 IntPtr body = d.GeomGetBody(chr.Shell);
3908
3909 d.Vector3 pos;
3910 d.GeomCopyPosition(chr.Shell, out pos);
3911 //d.BodyCopyPosition(body, out pos);
3912
3913 d.Matrix3 R;
3914 d.GeomCopyRotation(chr.Shell, out R);
3915 //d.BodyCopyRotation(body, out R);
3916
3917 ds.DrawCapsule(ref pos, ref R, chr.Size.Z, 0.35f);
3918 d.Vector3 sides = new d.Vector3();
3919 sides.X = 0.5f;
3920 sides.Y = 0.5f;
3921 sides.Z = 0.5f;
3922
3923 ds.DrawBox(ref pos, ref R, ref sides);
3924 }
3925 }
3926 }
3927
3928 public void start(int unused)
3929 {
3930 ds.SetViewpoint(ref xyz, ref hpr);
3931 }
3932#endif
3933
3934 public override Dictionary<string, float> GetStats() 3780 public override Dictionary<string, float> GetStats()
3935 { 3781 {
3936 if (!CollectStats) 3782 if (!CollectStats)