diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs (renamed from OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs) | 6 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODECharacter.cs) | 64 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments (renamed from OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments) | 0 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs) | 4 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODEPrim.cs) | 40 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs (renamed from OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs) | 11 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs) | 6 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/OdeScene.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdeScene.cs) | 686 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs (renamed from OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs) | 67 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/drawstuff.cs (renamed from OpenSim/Region/Physics/OdePlugin/drawstuff.cs) | 0 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdePlugin.cs) | 74 |
11 files changed, 391 insertions, 567 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs index 3c4f06a..7869739 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/PhysicsModules/Ode/AssemblyInfo.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using System.Runtime.InteropServices; | 29 | using System.Runtime.InteropServices; |
30 | using Mono.Addins; | ||
30 | 31 | ||
31 | // Information about this assembly is defined by the following | 32 | // Information about this assembly is defined by the following |
32 | // attributes. | 33 | // attributes. |
@@ -55,4 +56,7 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 56 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 57 | // numbers with the '*' character (the default): |
57 | 58 | ||
58 | [assembly : AssemblyVersion("0.7.5.*")] | 59 | [assembly : AssemblyVersion("0.8.2.*")] |
60 | |||
61 | [assembly: Addin("OpenSim.Region.PhysicsModule.ODE", OpenSim.VersionInfo.VersionNumber)] | ||
62 | [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs index 319f6ab..b35c299 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs | |||
@@ -31,10 +31,10 @@ using System.Reflection; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using Ode.NET; | 32 | using Ode.NET; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Physics.Manager; | 34 | using OpenSim.Region.PhysicsModules.SharedBase; |
35 | using log4net; | 35 | using log4net; |
36 | 36 | ||
37 | namespace OpenSim.Region.Physics.OdePlugin | 37 | namespace OpenSim.Region.PhysicsModule.ODE |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. | 40 | /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. |
@@ -167,6 +167,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
167 | /// <param name="avName"></param> | 167 | /// <param name="avName"></param> |
168 | /// <param name="parent_scene"></param> | 168 | /// <param name="parent_scene"></param> |
169 | /// <param name="pos"></param> | 169 | /// <param name="pos"></param> |
170 | /// <param name="vel"></param> | ||
170 | /// <param name="size"></param> | 171 | /// <param name="size"></param> |
171 | /// <param name="pid_d"></param> | 172 | /// <param name="pid_d"></param> |
172 | /// <param name="pid_p"></param> | 173 | /// <param name="pid_p"></param> |
@@ -178,7 +179,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
178 | /// <param name="walk_divisor"></param> | 179 | /// <param name="walk_divisor"></param> |
179 | /// <param name="rundivisor"></param> | 180 | /// <param name="rundivisor"></param> |
180 | public OdeCharacter( | 181 | public OdeCharacter( |
181 | String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, | 182 | String avName, OdeScene parent_scene, Vector3 pos, Vector3 vel, Vector3 size, float pid_d, float pid_p, |
182 | float capsule_radius, float tensor, float density, | 183 | float capsule_radius, float tensor, float density, |
183 | float walk_divisor, float rundivisor) | 184 | float walk_divisor, float rundivisor) |
184 | { | 185 | { |
@@ -210,6 +211,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
210 | m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName); | 211 | m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName); |
211 | } | 212 | } |
212 | 213 | ||
214 | _velocity = vel; | ||
215 | m_taintTargetVelocity = vel; | ||
216 | |||
213 | _parent_scene = parent_scene; | 217 | _parent_scene = parent_scene; |
214 | 218 | ||
215 | PID_D = pid_d; | 219 | PID_D = pid_d; |
@@ -500,12 +504,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
500 | { | 504 | { |
501 | m_pidControllerActive = true; | 505 | m_pidControllerActive = true; |
502 | 506 | ||
503 | m_tainted_CAPSULE_LENGTH = (size.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; | 507 | m_tainted_CAPSULE_LENGTH = size.Z - CAPSULE_RADIUS * 2.0f; |
504 | // m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH); | 508 | |
509 | // m_log.InfoFormat("[ODE CHARACTER]: Size = {0}, Capsule Length = {1} (Capsule Radius = {2})", | ||
510 | // size, m_tainted_CAPSULE_LENGTH, CAPSULE_RADIUS); | ||
505 | } | 511 | } |
506 | else | 512 | else |
507 | { | 513 | { |
508 | m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.Name); | 514 | m_log.WarnFormat("[ODE CHARACTER]: Got a NaN Size for {0} in {1}", Name, _parent_scene.PhysicsSceneName); |
509 | } | 515 | } |
510 | } | 516 | } |
511 | 517 | ||
@@ -890,42 +896,30 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
890 | // vec, _target_velocity, movementdivisor, vel); | 896 | // vec, _target_velocity, movementdivisor, vel); |
891 | } | 897 | } |
892 | 898 | ||
893 | if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) | 899 | if (flying) |
894 | { | 900 | { |
895 | // We're colliding with something and we're not flying but we're moving | 901 | // This also acts as anti-gravity so that we hover when flying rather than fall. |
896 | // This means we're walking or running. | 902 | vec.Z = (_target_velocity.Z - vel.Z) * (PID_D); |
897 | d.Vector3 pos = d.BodyGetPosition(Body); | ||
898 | vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P; | ||
899 | if (_target_velocity.X > 0) | ||
900 | { | ||
901 | vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; | ||
902 | } | ||
903 | if (_target_velocity.Y > 0) | ||
904 | { | ||
905 | vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; | ||
906 | } | ||
907 | } | 903 | } |
908 | else if (!m_iscolliding && !flying) | 904 | else |
909 | { | 905 | { |
910 | // we're not colliding and we're not flying so that means we're falling! | 906 | if (m_iscolliding && _target_velocity.Z > 0.0f) |
911 | // m_iscolliding includes collisions with the ground. | ||
912 | |||
913 | // d.Vector3 pos = d.BodyGetPosition(Body); | ||
914 | if (_target_velocity.X > 0) | ||
915 | { | 907 | { |
908 | // We're colliding with something and we're not flying but we're moving | ||
909 | // This means we're walking or running. | ||
910 | d.Vector3 pos = d.BodyGetPosition(Body); | ||
911 | vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; | ||
916 | vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; | 912 | vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; |
913 | vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; | ||
917 | } | 914 | } |
918 | if (_target_velocity.Y > 0) | 915 | else if (!m_iscolliding) |
919 | { | 916 | { |
917 | // we're not colliding and we're not flying so that means we're falling! | ||
918 | // m_iscolliding includes collisions with the ground. | ||
919 | vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; | ||
920 | vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; | 920 | vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; |
921 | } | 921 | } |
922 | } | 922 | } |
923 | |||
924 | if (flying) | ||
925 | { | ||
926 | // This also acts as anti-gravity so that we hover when flying rather than fall. | ||
927 | vec.Z = (_target_velocity.Z - vel.Z) * (PID_D); | ||
928 | } | ||
929 | } | 923 | } |
930 | 924 | ||
931 | if (flying) | 925 | if (flying) |
@@ -1255,7 +1249,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1255 | } | 1249 | } |
1256 | 1250 | ||
1257 | public override Vector3 PIDTarget { set { return; } } | 1251 | public override Vector3 PIDTarget { set { return; } } |
1258 | public override bool PIDActive { set { return; } } | 1252 | public override bool PIDActive |
1253 | { | ||
1254 | get { return false; } | ||
1255 | set { return; } | ||
1256 | } | ||
1259 | public override float PIDTau { set { return; } } | 1257 | public override float PIDTau { set { return; } } |
1260 | 1258 | ||
1261 | public override float PIDHoverHeight { set { return; } } | 1259 | public override float PIDHoverHeight { set { return; } } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments index 1060aa6..1060aa6 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.c_comments +++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.c_comments | |||
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs index 2342bfa..8f8e2bd 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs | |||
@@ -46,9 +46,9 @@ using log4net; | |||
46 | using OpenMetaverse; | 46 | using OpenMetaverse; |
47 | using Ode.NET; | 47 | using Ode.NET; |
48 | using OpenSim.Framework; | 48 | using OpenSim.Framework; |
49 | using OpenSim.Region.Physics.Manager; | 49 | using OpenSim.Region.PhysicsModules.SharedBase; |
50 | 50 | ||
51 | namespace OpenSim.Region.Physics.OdePlugin | 51 | namespace OpenSim.Region.PhysicsModule.ODE |
52 | { | 52 | { |
53 | public class ODEDynamics | 53 | public class ODEDynamics |
54 | { | 54 | { |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs index 0d66496..0b9c45f 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs | |||
@@ -50,9 +50,9 @@ using log4net; | |||
50 | using OpenMetaverse; | 50 | using OpenMetaverse; |
51 | using Ode.NET; | 51 | using Ode.NET; |
52 | using OpenSim.Framework; | 52 | using OpenSim.Framework; |
53 | using OpenSim.Region.Physics.Manager; | 53 | using OpenSim.Region.PhysicsModules.SharedBase; |
54 | 54 | ||
55 | namespace OpenSim.Region.Physics.OdePlugin | 55 | namespace OpenSim.Region.PhysicsModule.ODE |
56 | { | 56 | { |
57 | /// <summary> | 57 | /// <summary> |
58 | /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. | 58 | /// Various properties that ODE uses for AMotors but isn't exposed in ODE.NET so we must define them ourselves. |
@@ -108,14 +108,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
108 | private Vector3 m_taintAngularLock = Vector3.One; | 108 | private Vector3 m_taintAngularLock = Vector3.One; |
109 | private IntPtr Amotor = IntPtr.Zero; | 109 | private IntPtr Amotor = IntPtr.Zero; |
110 | 110 | ||
111 | private object m_assetsLock = new object(); | ||
112 | private bool m_assetFailed = false; | 111 | private bool m_assetFailed = false; |
113 | 112 | ||
114 | private Vector3 m_PIDTarget; | 113 | private Vector3 m_PIDTarget; |
115 | private float m_PIDTau; | 114 | private float m_PIDTau; |
116 | private float PID_D = 35f; | 115 | private float PID_D = 35f; |
117 | private float PID_G = 25f; | 116 | private float PID_G = 25f; |
118 | private bool m_usePID; | ||
119 | 117 | ||
120 | // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), | 118 | // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), |
121 | // and are for non-VEHICLES only. | 119 | // and are for non-VEHICLES only. |
@@ -447,7 +445,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
447 | m_disabled = false; | 445 | m_disabled = false; |
448 | 446 | ||
449 | // The body doesn't already have a finite rotation mode set here | 447 | // The body doesn't already have a finite rotation mode set here |
450 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null) | 448 | if ((!m_angularlock.ApproxEquals(Vector3.One, 0.0f)) && _parent == null) |
451 | { | 449 | { |
452 | createAMotor(m_angularlock); | 450 | createAMotor(m_angularlock); |
453 | } | 451 | } |
@@ -787,6 +785,14 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
787 | } | 785 | } |
788 | } | 786 | } |
789 | 787 | ||
788 | private void setAngularVelocity(float x, float y, float z) | ||
789 | { | ||
790 | if (Body != (IntPtr)0) | ||
791 | { | ||
792 | d.BodySetAngularVel(Body, x, y, z); | ||
793 | } | ||
794 | } | ||
795 | |||
790 | /// <summary> | 796 | /// <summary> |
791 | /// Stop a prim from being subject to physics. | 797 | /// Stop a prim from being subject to physics. |
792 | /// </summary> | 798 | /// </summary> |
@@ -1115,7 +1121,7 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1115 | { | 1121 | { |
1116 | d.Mass m2; | 1122 | d.Mass m2; |
1117 | d.MassSetZero(out m2); | 1123 | d.MassSetZero(out m2); |
1118 | d.MassSetBoxTotal(out m2, prim.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); | 1124 | d.MassSetBoxTotal(out m2, prm.CalculateMass(), prm._size.X, prm._size.Y, prm._size.Z); |
1119 | 1125 | ||
1120 | d.Quaternion quat = new d.Quaternion(); | 1126 | d.Quaternion quat = new d.Quaternion(); |
1121 | quat.W = prm._orientation.W; | 1127 | quat.W = prm._orientation.W; |
@@ -1178,11 +1184,6 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1178 | prm.m_collisionscore = 0; | 1184 | prm.m_collisionscore = 0; |
1179 | prm.m_disabled = false; | 1185 | prm.m_disabled = false; |
1180 | 1186 | ||
1181 | // The body doesn't already have a finite rotation mode set here | ||
1182 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) | ||
1183 | { | ||
1184 | prm.createAMotor(m_angularlock); | ||
1185 | } | ||
1186 | prm.Body = Body; | 1187 | prm.Body = Body; |
1187 | _parent_scene.ActivatePrim(prm); | 1188 | _parent_scene.ActivatePrim(prm); |
1188 | } | 1189 | } |
@@ -1229,7 +1230,7 @@ Console.WriteLine("ZProcessTaints for " + Name); | |||
1229 | m_disabled = false; | 1230 | m_disabled = false; |
1230 | 1231 | ||
1231 | // The body doesn't already have a finite rotation mode set here | 1232 | // The body doesn't already have a finite rotation mode set here |
1232 | if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) | 1233 | if ((!m_angularlock.ApproxEquals(Vector3.One, 0f)) && _parent == null) |
1233 | { | 1234 | { |
1234 | createAMotor(m_angularlock); | 1235 | createAMotor(m_angularlock); |
1235 | } | 1236 | } |
@@ -1724,7 +1725,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
1724 | // gravityz multiplier = 1 - m_buoyancy | 1725 | // gravityz multiplier = 1 - m_buoyancy |
1725 | fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; | 1726 | fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; |
1726 | 1727 | ||
1727 | if (m_usePID) | 1728 | if (PIDActive) |
1728 | { | 1729 | { |
1729 | //Console.WriteLine("PID " + Name); | 1730 | //Console.WriteLine("PID " + Name); |
1730 | // KF - this is for object move? eg. llSetPos() ? | 1731 | // KF - this is for object move? eg. llSetPos() ? |
@@ -1793,10 +1794,10 @@ Console.WriteLine(" JointCreateFixed"); | |||
1793 | 1794 | ||
1794 | fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); | 1795 | fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); |
1795 | } | 1796 | } |
1796 | } // end if (m_usePID) | 1797 | } // end if (PIDActive) |
1797 | 1798 | ||
1798 | // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller | 1799 | // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller |
1799 | if (m_useHoverPID && !m_usePID) | 1800 | if (m_useHoverPID && !PIDActive) |
1800 | { | 1801 | { |
1801 | //Console.WriteLine("Hover " + Name); | 1802 | //Console.WriteLine("Hover " + Name); |
1802 | 1803 | ||
@@ -2647,6 +2648,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2647 | if (value.IsFinite()) | 2648 | if (value.IsFinite()) |
2648 | { | 2649 | { |
2649 | m_rotationalVelocity = value; | 2650 | m_rotationalVelocity = value; |
2651 | setAngularVelocity(value.X, value.Y, value.Z); | ||
2650 | } | 2652 | } |
2651 | else | 2653 | else |
2652 | { | 2654 | { |
@@ -2867,7 +2869,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2867 | // it does make sense to do this for tiny little instabilities with physical prim, however 0.5m/frame is fairly large. | 2869 | // it does make sense to do this for tiny little instabilities with physical prim, however 0.5m/frame is fairly large. |
2868 | // reducing this to 0.02m/frame seems to help the angular rubberbanding quite a bit, however, to make sure it doesn't affect elevators and vehicles | 2870 | // reducing this to 0.02m/frame seems to help the angular rubberbanding quite a bit, however, to make sure it doesn't affect elevators and vehicles |
2869 | // adding these logical exclusion situations to maintain this where I think it was intended to be. | 2871 | // adding these logical exclusion situations to maintain this where I think it was intended to be. |
2870 | if (m_throttleUpdates || m_usePID || (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) || (Amotor != IntPtr.Zero)) | 2872 | if (m_throttleUpdates || PIDActive || (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) || (Amotor != IntPtr.Zero)) |
2871 | { | 2873 | { |
2872 | m_minvelocity = 0.5f; | 2874 | m_minvelocity = 0.5f; |
2873 | } | 2875 | } |
@@ -2948,7 +2950,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
2948 | m_log.WarnFormat("[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name); | 2950 | m_log.WarnFormat("[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name); |
2949 | } | 2951 | } |
2950 | } | 2952 | } |
2951 | public override bool PIDActive { set { m_usePID = value; } } | 2953 | public override bool PIDActive { get; set; } |
2952 | public override float PIDTau { set { m_PIDTau = value; } } | 2954 | public override float PIDTau { set { m_PIDTau = value; } } |
2953 | 2955 | ||
2954 | public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } | 2956 | public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } |
@@ -3345,7 +3347,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
3345 | RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; | 3347 | RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; |
3346 | if (assetProvider != null) | 3348 | if (assetProvider != null) |
3347 | assetProvider(_pbs.SculptTexture, MeshAssetReceived); | 3349 | assetProvider(_pbs.SculptTexture, MeshAssetReceived); |
3348 | }); | 3350 | }, null, "ODEPrim.CheckMeshAsset"); |
3349 | } | 3351 | } |
3350 | } | 3352 | } |
3351 | 3353 | ||
@@ -3373,7 +3375,7 @@ Console.WriteLine(" JointCreateFixed"); | |||
3373 | { | 3375 | { |
3374 | m_log.WarnFormat( | 3376 | m_log.WarnFormat( |
3375 | "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", | 3377 | "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", |
3376 | _pbs.SculptTexture, Name, _position, _parent_scene.Name); | 3378 | _pbs.SculptTexture, Name, _position, _parent_scene.PhysicsSceneName); |
3377 | } | 3379 | } |
3378 | } | 3380 | } |
3379 | } | 3381 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs index 8d7d3b3..8d610f7 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODERayCastRequestManager.cs | |||
@@ -31,11 +31,11 @@ using System.Reflection; | |||
31 | using System.Runtime.InteropServices; | 31 | using System.Runtime.InteropServices; |
32 | using System.Text; | 32 | using System.Text; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Region.Physics.Manager; | 34 | using OpenSim.Region.PhysicsModules.SharedBase; |
35 | using Ode.NET; | 35 | using Ode.NET; |
36 | using log4net; | 36 | using log4net; |
37 | 37 | ||
38 | namespace OpenSim.Region.Physics.OdePlugin | 38 | namespace OpenSim.Region.PhysicsModule.ODE |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// Processes raycast requests as ODE is in a state to be able to do them. | 41 | /// Processes raycast requests as ODE is in a state to be able to do them. |
@@ -172,6 +172,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
172 | /// <param name="req"></param> | 172 | /// <param name="req"></param> |
173 | private void RayCast(ODERayCastRequest req) | 173 | private void RayCast(ODERayCastRequest req) |
174 | { | 174 | { |
175 | // NOTE: limit ray length or collisions will take all avaiable stack space | ||
176 | // this value may still be too large, depending on machine configuration | ||
177 | // of maximum stack | ||
178 | float len = req.length; | ||
179 | if (len > 250f) | ||
180 | len = 250f; | ||
181 | |||
175 | // Create the ray | 182 | // Create the ray |
176 | IntPtr ray = d.CreateRay(m_scene.space, req.length); | 183 | IntPtr ray = d.CreateRay(m_scene.space, req.length); |
177 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); | 184 | d.GeomRaySet(ray, req.Origin.X, req.Origin.Y, req.Origin.Z, req.Normal.X, req.Normal.Y, req.Normal.Z); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs b/OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs index b4a3c48..2eb7ba6 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePhysicsJoint.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdePhysicsJoint.cs | |||
@@ -29,10 +29,10 @@ using System; | |||
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using Ode.NET; | 30 | using Ode.NET; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Physics.Manager; | 32 | using OpenSim.Region.PhysicsModules.SharedBase; |
33 | using OpenSim.Region.Physics.OdePlugin; | 33 | using OpenSim.Region.PhysicsModule.ODE; |
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.OdePlugin | 35 | namespace OpenSim.Region.PhysicsModule.ODE |
36 | { | 36 | { |
37 | class OdePhysicsJoint : PhysicsJoint | 37 | class OdePhysicsJoint : PhysicsJoint |
38 | { | 38 | { |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs index d53bd90..8cc7f28 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/PhysicsModules/Ode/OdeScene.cs | |||
@@ -25,6 +25,12 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | // changes for varsize regions | ||
29 | // note that raycasts need to have limited range | ||
30 | // (even in normal regions) | ||
31 | // or application thread stack may just blowup | ||
32 | // see RayCast(ODERayCastRequest req) | ||
33 | |||
28 | //#define USE_DRAWSTUFF | 34 | //#define USE_DRAWSTUFF |
29 | //#define SPAM | 35 | //#define SPAM |
30 | 36 | ||
@@ -38,15 +44,19 @@ using System.Runtime.InteropServices; | |||
38 | using System.Threading; | 44 | using System.Threading; |
39 | using log4net; | 45 | using log4net; |
40 | using Nini.Config; | 46 | using Nini.Config; |
47 | using Mono.Addins; | ||
41 | using Ode.NET; | 48 | using Ode.NET; |
42 | using OpenMetaverse; | 49 | using OpenMetaverse; |
43 | #if USE_DRAWSTUFF | 50 | #if USE_DRAWSTUFF |
44 | using Drawstuff.NET; | 51 | using Drawstuff.NET; |
45 | #endif | 52 | #endif |
46 | using OpenSim.Framework; | 53 | using OpenSim.Framework; |
47 | using OpenSim.Region.Physics.Manager; | 54 | using OpenSim.Region.PhysicsModules.SharedBase; |
55 | using OpenSim.Region.Framework.Scenes; | ||
56 | using OpenSim.Region.Framework.Interfaces; | ||
57 | |||
48 | 58 | ||
49 | namespace OpenSim.Region.Physics.OdePlugin | 59 | namespace OpenSim.Region.PhysicsModule.ODE |
50 | { | 60 | { |
51 | public enum StatusIndicators : int | 61 | public enum StatusIndicators : int |
52 | { | 62 | { |
@@ -101,9 +111,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
101 | Rubber = 6 | 111 | Rubber = 6 |
102 | } | 112 | } |
103 | 113 | ||
104 | public class OdeScene : PhysicsScene | 114 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ODEPhysicsScene")] |
115 | public class OdeScene : PhysicsScene, INonSharedRegionModule | ||
105 | { | 116 | { |
106 | private readonly ILog m_log; | 117 | private readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString()); |
118 | private bool m_Enabled = false; | ||
119 | |||
107 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); | 120 | // private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>(); |
108 | 121 | ||
109 | /// <summary> | 122 | /// <summary> |
@@ -263,8 +276,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
263 | 276 | ||
264 | private Random fluidRandomizer = new Random(Environment.TickCount); | 277 | private Random fluidRandomizer = new Random(Environment.TickCount); |
265 | 278 | ||
266 | private const uint m_regionWidth = Constants.RegionSize; | 279 | public bool m_suportCombine = true; |
267 | private const uint m_regionHeight = Constants.RegionSize; | 280 | |
281 | private uint m_regionWidth = Constants.RegionSize; | ||
282 | private uint m_regionHeight = Constants.RegionSize; | ||
268 | 283 | ||
269 | private float ODE_STEPSIZE = 0.0178f; | 284 | private float ODE_STEPSIZE = 0.0178f; |
270 | private float metersInSpace = 29.9f; | 285 | private float metersInSpace = 29.9f; |
@@ -288,9 +303,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
288 | private int framecount = 0; | 303 | private int framecount = 0; |
289 | //private int m_returncollisions = 10; | 304 | //private int m_returncollisions = 10; |
290 | 305 | ||
291 | private readonly IntPtr contactgroup; | 306 | private IntPtr contactgroup; |
292 | 307 | ||
293 | internal IntPtr WaterGeom; | 308 | // internal IntPtr WaterGeom; |
294 | 309 | ||
295 | private float nmTerrainContactFriction = 255.0f; | 310 | private float nmTerrainContactFriction = 255.0f; |
296 | private float nmTerrainContactBounce = 0.1f; | 311 | private float nmTerrainContactBounce = 0.1f; |
@@ -507,31 +522,116 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
507 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); | 522 | public d.Vector3 xyz = new d.Vector3(128.1640f, 128.3079f, 25.7600f); |
508 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); | 523 | public d.Vector3 hpr = new d.Vector3(125.5000f, -17.0000f, 0.0000f); |
509 | 524 | ||
510 | // TODO: unused: private uint heightmapWidth = m_regionWidth + 1; | ||
511 | // TODO: unused: private uint heightmapHeight = m_regionHeight + 1; | ||
512 | // TODO: unused: private uint heightmapWidthSamples; | ||
513 | // TODO: unused: private uint heightmapHeightSamples; | ||
514 | |||
515 | private volatile int m_global_contactcount = 0; | 525 | private volatile int m_global_contactcount = 0; |
516 | 526 | ||
517 | private Vector3 m_worldOffset = Vector3.Zero; | 527 | private Vector3 m_worldOffset = Vector3.Zero; |
518 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | 528 | public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); |
519 | private PhysicsScene m_parentScene = null; | 529 | private PhysicsScene m_parentScene = null; |
520 | 530 | ||
531 | float spacesPerMeterX; | ||
532 | float spacesPerMeterY; | ||
533 | int spaceGridMaxX; | ||
534 | int spaceGridMaxY; | ||
535 | |||
521 | private ODERayCastRequestManager m_rayCastManager; | 536 | private ODERayCastRequestManager m_rayCastManager; |
522 | 537 | ||
538 | |||
539 | #region INonSharedRegionModule | ||
540 | public string Name | ||
541 | { | ||
542 | get { return "OpenDynamicsEngine"; } | ||
543 | } | ||
544 | |||
545 | public Type ReplaceableInterface | ||
546 | { | ||
547 | get { return null; } | ||
548 | } | ||
549 | |||
550 | public void Initialise(IConfigSource source) | ||
551 | { | ||
552 | // TODO: Move this out of Startup | ||
553 | IConfig config = source.Configs["Startup"]; | ||
554 | if (config != null) | ||
555 | { | ||
556 | string physics = config.GetString("physics", string.Empty); | ||
557 | if (physics == Name) | ||
558 | { | ||
559 | m_Enabled = true; | ||
560 | m_config = source; | ||
561 | |||
562 | // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether | ||
563 | // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports | ||
564 | // will find it already loaded later on. | ||
565 | // | ||
566 | // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be | ||
567 | // controlled in Ode.NET.dll.config | ||
568 | if (Util.IsWindows()) | ||
569 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
570 | |||
571 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | ||
572 | // http://opensimulator.org/mantis/view.php?id=2750). | ||
573 | d.InitODE(); | ||
574 | |||
575 | } | ||
576 | } | ||
577 | |||
578 | } | ||
579 | |||
580 | public void Close() | ||
581 | { | ||
582 | } | ||
583 | |||
584 | public void AddRegion(Scene scene) | ||
585 | { | ||
586 | if (!m_Enabled) | ||
587 | return; | ||
588 | |||
589 | EngineType = Name; | ||
590 | PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName; | ||
591 | |||
592 | scene.RegisterModuleInterface<PhysicsScene>(this); | ||
593 | Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ); | ||
594 | Initialise(extent); | ||
595 | InitialiseFromConfig(m_config); | ||
596 | |||
597 | // This may not be that good since terrain may not be avaiable at this point | ||
598 | base.Initialise(scene.PhysicsRequestAsset, | ||
599 | (scene.Heightmap != null ? scene.Heightmap.GetFloatsSerialised() : new float[(int)(extent.X * extent.Y)]), | ||
600 | (float)scene.RegionInfo.RegionSettings.WaterHeight); | ||
601 | |||
602 | } | ||
603 | |||
604 | public void RemoveRegion(Scene scene) | ||
605 | { | ||
606 | if (!m_Enabled) | ||
607 | return; | ||
608 | } | ||
609 | |||
610 | public void RegionLoaded(Scene scene) | ||
611 | { | ||
612 | if (!m_Enabled) | ||
613 | return; | ||
614 | |||
615 | mesher = scene.RequestModuleInterface<IMesher>(); | ||
616 | if (mesher == null) | ||
617 | m_log.WarnFormat("[ODE SCENE]: No mesher in {0}. Things will not work well.", PhysicsSceneName); | ||
618 | } | ||
619 | #endregion | ||
620 | |||
523 | /// <summary> | 621 | /// <summary> |
524 | /// Initiailizes the scene | 622 | /// Initiailizes the scene |
525 | /// Sets many properties that ODE requires to be stable | 623 | /// Sets many properties that ODE requires to be stable |
526 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. | 624 | /// These settings need to be tweaked 'exactly' right or weird stuff happens. |
527 | /// </summary> | 625 | /// </summary> |
528 | /// <param value="name">Name of the scene. Useful in debug messages.</param> | 626 | private void Initialise(Vector3 regionExtent) |
529 | public OdeScene(string name) | ||
530 | { | 627 | { |
531 | m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name); | 628 | WorldExtents.X = regionExtent.X; |
532 | 629 | m_regionWidth = (uint)regionExtent.X; | |
533 | Name = name; | 630 | WorldExtents.Y = regionExtent.Y; |
534 | 631 | m_regionHeight = (uint)regionExtent.Y; | |
632 | |||
633 | m_suportCombine = false; | ||
634 | |||
535 | nearCallback = near; | 635 | nearCallback = near; |
536 | triCallback = TriCallback; | 636 | triCallback = TriCallback; |
537 | triArrayCallback = TriArrayCallback; | 637 | triArrayCallback = TriArrayCallback; |
@@ -550,7 +650,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
550 | viewthread.Start(); | 650 | viewthread.Start(); |
551 | #endif | 651 | #endif |
552 | 652 | ||
553 | _watermap = new float[258 * 258]; | 653 | // _watermap = new float[258 * 258]; |
554 | 654 | ||
555 | // Zero out the prim spaces array (we split our space into smaller spaces so | 655 | // Zero out the prim spaces array (we split our space into smaller spaces so |
556 | // we can hit test less. | 656 | // we can hit test less. |
@@ -571,12 +671,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
571 | } | 671 | } |
572 | #endif | 672 | #endif |
573 | 673 | ||
574 | // Initialize the mesh plugin | 674 | // Initialize from configs |
575 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 675 | private void InitialiseFromConfig(IConfigSource config) |
576 | { | 676 | { |
577 | InitializeExtraStats(); | 677 | InitializeExtraStats(); |
578 | 678 | ||
579 | mesher = meshmerizer; | ||
580 | m_config = config; | 679 | m_config = config; |
581 | // Defaults | 680 | // Defaults |
582 | 681 | ||
@@ -698,7 +797,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
698 | 797 | ||
699 | contacts = new d.ContactGeom[contactsPerCollision]; | 798 | contacts = new d.ContactGeom[contactsPerCollision]; |
700 | 799 | ||
701 | staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; | 800 | spacesPerMeterX = 1.0f / metersInSpace; |
801 | spacesPerMeterY = 1.0f / metersInSpace; | ||
802 | |||
803 | spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX); | ||
804 | spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY); | ||
805 | |||
806 | // note: limit number of spaces | ||
807 | if (spaceGridMaxX > 24) | ||
808 | { | ||
809 | spaceGridMaxX = 24; | ||
810 | spacesPerMeterX = spaceGridMaxX / WorldExtents.X; | ||
811 | } | ||
812 | if (spaceGridMaxY > 24) | ||
813 | { | ||
814 | spaceGridMaxY = 24; | ||
815 | spacesPerMeterY = spaceGridMaxY / WorldExtents.Y ; | ||
816 | } | ||
817 | |||
818 | staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY]; | ||
819 | |||
820 | // make this index limits | ||
821 | spaceGridMaxX--; | ||
822 | spaceGridMaxY--; | ||
823 | |||
824 | |||
702 | 825 | ||
703 | // Centeral contact friction and bounce | 826 | // Centeral contact friction and bounce |
704 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why | 827 | // ckrinke 11/10/08 Enabling soft_erp but not soft_cfm until I figure out why |
@@ -1817,7 +1940,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1817 | } | 1940 | } |
1818 | catch (AccessViolationException) | 1941 | catch (AccessViolationException) |
1819 | { | 1942 | { |
1820 | m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name); | 1943 | m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", PhysicsSceneName); |
1821 | } | 1944 | } |
1822 | 1945 | ||
1823 | //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); | 1946 | //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); |
@@ -1882,6 +2005,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1882 | 2005 | ||
1883 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) | 2006 | public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) |
1884 | { | 2007 | { |
2008 | if (!m_suportCombine) | ||
2009 | return; | ||
1885 | m_worldOffset = offset; | 2010 | m_worldOffset = offset; |
1886 | WorldExtents = new Vector2(extents.X, extents.Y); | 2011 | WorldExtents = new Vector2(extents.X, extents.Y); |
1887 | m_parentScene = pScene; | 2012 | m_parentScene = pScene; |
@@ -1890,12 +2015,17 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1890 | // Recovered for use by fly height. Kitto Flora | 2015 | // Recovered for use by fly height. Kitto Flora |
1891 | internal float GetTerrainHeightAtXY(float x, float y) | 2016 | internal float GetTerrainHeightAtXY(float x, float y) |
1892 | { | 2017 | { |
1893 | int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1894 | int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
1895 | |||
1896 | IntPtr heightFieldGeom = IntPtr.Zero; | 2018 | IntPtr heightFieldGeom = IntPtr.Zero; |
2019 | int offsetX = 0; | ||
2020 | int offsetY = 0; | ||
2021 | |||
2022 | if (m_suportCombine) | ||
2023 | { | ||
2024 | offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2025 | offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize; | ||
2026 | } | ||
1897 | 2027 | ||
1898 | if (RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) | 2028 | if(RegionTerrain.TryGetValue(new Vector3(offsetX,offsetY,0), out heightFieldGeom)) |
1899 | { | 2029 | { |
1900 | if (heightFieldGeom != IntPtr.Zero) | 2030 | if (heightFieldGeom != IntPtr.Zero) |
1901 | { | 2031 | { |
@@ -1909,10 +2039,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1909 | (int)x < 0.001f || (int)y < 0.001f) | 2039 | (int)x < 0.001f || (int)y < 0.001f) |
1910 | return 0; | 2040 | return 0; |
1911 | 2041 | ||
1912 | x = x - offsetX; | 2042 | x = x - offsetX + 1f; |
1913 | y = y - offsetY; | 2043 | y = y - offsetY + 1f; |
1914 | 2044 | ||
1915 | index = (int)((int)x * ((int)Constants.RegionSize + 2) + (int)y); | 2045 | index = (int)((int)x * ((int)m_regionHeight +3) + (int)y); |
1916 | 2046 | ||
1917 | if (index < TerrainHeightFieldHeights[heightFieldGeom].Length) | 2047 | if (index < TerrainHeightFieldHeights[heightFieldGeom].Length) |
1918 | { | 2048 | { |
@@ -1968,16 +2098,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1968 | 2098 | ||
1969 | #region Add/Remove Entities | 2099 | #region Add/Remove Entities |
1970 | 2100 | ||
1971 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) | 2101 | public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) |
1972 | { | 2102 | { |
1973 | Vector3 pos; | ||
1974 | pos.X = position.X; | ||
1975 | pos.Y = position.Y; | ||
1976 | pos.Z = position.Z; | ||
1977 | |||
1978 | OdeCharacter newAv | 2103 | OdeCharacter newAv |
1979 | = new OdeCharacter( | 2104 | = new OdeCharacter( |
1980 | avName, this, pos, size, avPIDD, avPIDP, | 2105 | avName, this, position, velocity, size, avPIDD, avPIDP, |
1981 | avCapRadius, avStandupTensor, avDensity, | 2106 | avCapRadius, avStandupTensor, avDensity, |
1982 | avMovementDivisorWalk, avMovementDivisorRun); | 2107 | avMovementDivisorWalk, avMovementDivisorRun); |
1983 | 2108 | ||
@@ -2751,16 +2876,16 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2751 | { | 2876 | { |
2752 | int[] returnint = new int[2]; | 2877 | int[] returnint = new int[2]; |
2753 | 2878 | ||
2754 | returnint[0] = (int) (pos.X/metersInSpace); | 2879 | returnint[0] = (int) (pos.X * spacesPerMeterX); |
2755 | 2880 | ||
2756 | if (returnint[0] > ((int) (259f/metersInSpace))) | 2881 | if (returnint[0] > spaceGridMaxX) |
2757 | returnint[0] = ((int) (259f/metersInSpace)); | 2882 | returnint[0] = spaceGridMaxX; |
2758 | if (returnint[0] < 0) | 2883 | if (returnint[0] < 0) |
2759 | returnint[0] = 0; | 2884 | returnint[0] = 0; |
2760 | 2885 | ||
2761 | returnint[1] = (int) (pos.Y/metersInSpace); | 2886 | returnint[1] = (int)(pos.Y * spacesPerMeterY); |
2762 | if (returnint[1] > ((int) (259f/metersInSpace))) | 2887 | if (returnint[1] > spaceGridMaxY) |
2763 | returnint[1] = ((int) (259f/metersInSpace)); | 2888 | returnint[1] = spaceGridMaxY; |
2764 | if (returnint[1] < 0) | 2889 | if (returnint[1] < 0) |
2765 | returnint[1] = 0; | 2890 | returnint[1] = 0; |
2766 | 2891 | ||
@@ -3086,7 +3211,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3086 | { | 3211 | { |
3087 | m_log.ErrorFormat( | 3212 | m_log.ErrorFormat( |
3088 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving", | 3213 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when moving", |
3089 | actor.Name, actor.LocalID, Name); | 3214 | actor.Name, actor.LocalID, PhysicsSceneName); |
3090 | 3215 | ||
3091 | RemoveCharacter(actor); | 3216 | RemoveCharacter(actor); |
3092 | actor.DestroyOdeStructures(); | 3217 | actor.DestroyOdeStructures(); |
@@ -3202,7 +3327,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3202 | { | 3327 | { |
3203 | m_log.ErrorFormat( | 3328 | m_log.ErrorFormat( |
3204 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity", | 3329 | "[ODE SCENE]: Removing physics character {0} {1} from physics scene {2} due to defect found when updating position and velocity", |
3205 | actor.Name, actor.LocalID, Name); | 3330 | actor.Name, actor.LocalID, PhysicsSceneName); |
3206 | 3331 | ||
3207 | RemoveCharacter(actor); | 3332 | RemoveCharacter(actor); |
3208 | actor.DestroyOdeStructures(); | 3333 | actor.DestroyOdeStructures(); |
@@ -3514,273 +3639,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3514 | get { return false; } | 3639 | get { return false; } |
3515 | } | 3640 | } |
3516 | 3641 | ||
3517 | #region ODE Specific Terrain Fixes | ||
3518 | private float[] ResizeTerrain512NearestNeighbour(float[] heightMap) | ||
3519 | { | ||
3520 | float[] returnarr = new float[262144]; | ||
3521 | float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y]; | ||
3522 | |||
3523 | // Filling out the array into its multi-dimensional components | ||
3524 | for (int y = 0; y < WorldExtents.Y; y++) | ||
3525 | { | ||
3526 | for (int x = 0; x < WorldExtents.X; x++) | ||
3527 | { | ||
3528 | resultarr[y, x] = heightMap[y * (int)WorldExtents.Y + x]; | ||
3529 | } | ||
3530 | } | ||
3531 | |||
3532 | // Resize using Nearest Neighbour | ||
3533 | |||
3534 | // This particular way is quick but it only works on a multiple of the original | ||
3535 | |||
3536 | // The idea behind this method can be described with the following diagrams | ||
3537 | // second pass and third pass happen in the same loop really.. just separated | ||
3538 | // them to show what this does. | ||
3539 | |||
3540 | // First Pass | ||
3541 | // ResultArr: | ||
3542 | // 1,1,1,1,1,1 | ||
3543 | // 1,1,1,1,1,1 | ||
3544 | // 1,1,1,1,1,1 | ||
3545 | // 1,1,1,1,1,1 | ||
3546 | // 1,1,1,1,1,1 | ||
3547 | // 1,1,1,1,1,1 | ||
3548 | |||
3549 | // Second Pass | ||
3550 | // ResultArr2: | ||
3551 | // 1,,1,,1,,1,,1,,1, | ||
3552 | // ,,,,,,,,,, | ||
3553 | // 1,,1,,1,,1,,1,,1, | ||
3554 | // ,,,,,,,,,, | ||
3555 | // 1,,1,,1,,1,,1,,1, | ||
3556 | // ,,,,,,,,,, | ||
3557 | // 1,,1,,1,,1,,1,,1, | ||
3558 | // ,,,,,,,,,, | ||
3559 | // 1,,1,,1,,1,,1,,1, | ||
3560 | // ,,,,,,,,,, | ||
3561 | // 1,,1,,1,,1,,1,,1, | ||
3562 | |||
3563 | // Third pass fills in the blanks | ||
3564 | // ResultArr2: | ||
3565 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3566 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3567 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3568 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3569 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3570 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3571 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3572 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3573 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3574 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3575 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3576 | |||
3577 | // X,Y = . | ||
3578 | // X+1,y = ^ | ||
3579 | // X,Y+1 = * | ||
3580 | // X+1,Y+1 = # | ||
3581 | |||
3582 | // Filling in like this; | ||
3583 | // .* | ||
3584 | // ^# | ||
3585 | // 1st . | ||
3586 | // 2nd * | ||
3587 | // 3rd ^ | ||
3588 | // 4th # | ||
3589 | // on single loop. | ||
3590 | |||
3591 | float[,] resultarr2 = new float[512, 512]; | ||
3592 | for (int y = 0; y < WorldExtents.Y; y++) | ||
3593 | { | ||
3594 | for (int x = 0; x < WorldExtents.X; x++) | ||
3595 | { | ||
3596 | resultarr2[y * 2, x * 2] = resultarr[y, x]; | ||
3597 | |||
3598 | if (y < WorldExtents.Y) | ||
3599 | { | ||
3600 | resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; | ||
3601 | } | ||
3602 | if (x < WorldExtents.X) | ||
3603 | { | ||
3604 | resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; | ||
3605 | } | ||
3606 | if (x < WorldExtents.X && y < WorldExtents.Y) | ||
3607 | { | ||
3608 | resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; | ||
3609 | } | ||
3610 | } | ||
3611 | } | ||
3612 | |||
3613 | //Flatten out the array | ||
3614 | int i = 0; | ||
3615 | for (int y = 0; y < 512; y++) | ||
3616 | { | ||
3617 | for (int x = 0; x < 512; x++) | ||
3618 | { | ||
3619 | if (resultarr2[y, x] <= 0) | ||
3620 | returnarr[i] = 0.0000001f; | ||
3621 | else | ||
3622 | returnarr[i] = resultarr2[y, x]; | ||
3623 | |||
3624 | i++; | ||
3625 | } | ||
3626 | } | ||
3627 | |||
3628 | return returnarr; | ||
3629 | } | ||
3630 | |||
3631 | private float[] ResizeTerrain512Interpolation(float[] heightMap) | ||
3632 | { | ||
3633 | float[] returnarr = new float[262144]; | ||
3634 | float[,] resultarr = new float[512,512]; | ||
3635 | |||
3636 | // Filling out the array into its multi-dimensional components | ||
3637 | for (int y = 0; y < 256; y++) | ||
3638 | { | ||
3639 | for (int x = 0; x < 256; x++) | ||
3640 | { | ||
3641 | resultarr[y, x] = heightMap[y * 256 + x]; | ||
3642 | } | ||
3643 | } | ||
3644 | |||
3645 | // Resize using interpolation | ||
3646 | |||
3647 | // This particular way is quick but it only works on a multiple of the original | ||
3648 | |||
3649 | // The idea behind this method can be described with the following diagrams | ||
3650 | // second pass and third pass happen in the same loop really.. just separated | ||
3651 | // them to show what this does. | ||
3652 | |||
3653 | // First Pass | ||
3654 | // ResultArr: | ||
3655 | // 1,1,1,1,1,1 | ||
3656 | // 1,1,1,1,1,1 | ||
3657 | // 1,1,1,1,1,1 | ||
3658 | // 1,1,1,1,1,1 | ||
3659 | // 1,1,1,1,1,1 | ||
3660 | // 1,1,1,1,1,1 | ||
3661 | |||
3662 | // Second Pass | ||
3663 | // ResultArr2: | ||
3664 | // 1,,1,,1,,1,,1,,1, | ||
3665 | // ,,,,,,,,,, | ||
3666 | // 1,,1,,1,,1,,1,,1, | ||
3667 | // ,,,,,,,,,, | ||
3668 | // 1,,1,,1,,1,,1,,1, | ||
3669 | // ,,,,,,,,,, | ||
3670 | // 1,,1,,1,,1,,1,,1, | ||
3671 | // ,,,,,,,,,, | ||
3672 | // 1,,1,,1,,1,,1,,1, | ||
3673 | // ,,,,,,,,,, | ||
3674 | // 1,,1,,1,,1,,1,,1, | ||
3675 | |||
3676 | // Third pass fills in the blanks | ||
3677 | // ResultArr2: | ||
3678 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3679 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3680 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3681 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3682 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3683 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3684 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3685 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3686 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3687 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3688 | // 1,1,1,1,1,1,1,1,1,1,1,1 | ||
3689 | |||
3690 | // X,Y = . | ||
3691 | // X+1,y = ^ | ||
3692 | // X,Y+1 = * | ||
3693 | // X+1,Y+1 = # | ||
3694 | |||
3695 | // Filling in like this; | ||
3696 | // .* | ||
3697 | // ^# | ||
3698 | // 1st . | ||
3699 | // 2nd * | ||
3700 | // 3rd ^ | ||
3701 | // 4th # | ||
3702 | // on single loop. | ||
3703 | |||
3704 | float[,] resultarr2 = new float[512,512]; | ||
3705 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
3706 | { | ||
3707 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
3708 | { | ||
3709 | resultarr2[y*2, x*2] = resultarr[y, x]; | ||
3710 | |||
3711 | if (y < (int)Constants.RegionSize) | ||
3712 | { | ||
3713 | if (y + 1 < (int)Constants.RegionSize) | ||
3714 | { | ||
3715 | if (x + 1 < (int)Constants.RegionSize) | ||
3716 | { | ||
3717 | resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] + | ||
3718 | resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); | ||
3719 | } | ||
3720 | else | ||
3721 | { | ||
3722 | resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x])/2); | ||
3723 | } | ||
3724 | } | ||
3725 | else | ||
3726 | { | ||
3727 | resultarr2[(y*2) + 1, x*2] = resultarr[y, x]; | ||
3728 | } | ||
3729 | } | ||
3730 | if (x < (int)Constants.RegionSize) | ||
3731 | { | ||
3732 | if (x + 1 < (int)Constants.RegionSize) | ||
3733 | { | ||
3734 | if (y + 1 < (int)Constants.RegionSize) | ||
3735 | { | ||
3736 | resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + | ||
3737 | resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); | ||
3738 | } | ||
3739 | else | ||
3740 | { | ||
3741 | resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y, x + 1])/2); | ||
3742 | } | ||
3743 | } | ||
3744 | else | ||
3745 | { | ||
3746 | resultarr2[y*2, (x*2) + 1] = resultarr[y, x]; | ||
3747 | } | ||
3748 | } | ||
3749 | if (x < (int)Constants.RegionSize && y < (int)Constants.RegionSize) | ||
3750 | { | ||
3751 | if ((x + 1 < (int)Constants.RegionSize) && (y + 1 < (int)Constants.RegionSize)) | ||
3752 | { | ||
3753 | resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + | ||
3754 | resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); | ||
3755 | } | ||
3756 | else | ||
3757 | { | ||
3758 | resultarr2[(y*2) + 1, (x*2) + 1] = resultarr[y, x]; | ||
3759 | } | ||
3760 | } | ||
3761 | } | ||
3762 | } | ||
3763 | //Flatten out the array | ||
3764 | int i = 0; | ||
3765 | for (int y = 0; y < 512; y++) | ||
3766 | { | ||
3767 | for (int x = 0; x < 512; x++) | ||
3768 | { | ||
3769 | if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x])) | ||
3770 | { | ||
3771 | m_log.Warn("[ODE SCENE]: Non finite heightfield element detected. Setting it to 0"); | ||
3772 | resultarr2[y, x] = 0; | ||
3773 | } | ||
3774 | returnarr[i] = resultarr2[y, x]; | ||
3775 | i++; | ||
3776 | } | ||
3777 | } | ||
3778 | |||
3779 | return returnarr; | ||
3780 | } | ||
3781 | |||
3782 | #endregion | ||
3783 | |||
3784 | public override void SetTerrain(float[] heightMap) | 3642 | public override void SetTerrain(float[] heightMap) |
3785 | { | 3643 | { |
3786 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 3644 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) |
@@ -3799,73 +3657,67 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3799 | private void SetTerrain(float[] heightMap, Vector3 pOffset) | 3657 | private void SetTerrain(float[] heightMap, Vector3 pOffset) |
3800 | { | 3658 | { |
3801 | int startTime = Util.EnvironmentTickCount(); | 3659 | int startTime = Util.EnvironmentTickCount(); |
3802 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", Name, pOffset); | 3660 | m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0} with offset {1}", PhysicsSceneName, pOffset); |
3803 | 3661 | ||
3804 | // this._heightmap[i] = (double)heightMap[i]; | 3662 | |
3805 | // dbm (danx0r) -- creating a buffer zone of one extra sample all around | ||
3806 | //_origheightmap = heightMap; | ||
3807 | |||
3808 | float[] _heightmap; | 3663 | float[] _heightmap; |
3809 | 3664 | ||
3810 | // zero out a heightmap array float array (single dimension [flattened])) | 3665 | // ok im lasy this are just a aliases |
3811 | //if ((int)Constants.RegionSize == 256) | 3666 | uint regionsizeX = m_regionWidth; |
3812 | // _heightmap = new float[514 * 514]; | 3667 | uint regionsizeY = m_regionHeight; |
3813 | //else | ||
3814 | 3668 | ||
3815 | _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; | 3669 | // map is rotated |
3670 | uint heightmapWidth = regionsizeY + 2; | ||
3671 | uint heightmapHeight = regionsizeX + 2; | ||
3816 | 3672 | ||
3817 | uint heightmapWidth = Constants.RegionSize + 1; | 3673 | uint heightmapWidthSamples = heightmapWidth + 1; |
3818 | uint heightmapHeight = Constants.RegionSize + 1; | 3674 | uint heightmapHeightSamples = heightmapHeight + 1; |
3819 | 3675 | ||
3820 | uint heightmapWidthSamples; | 3676 | _heightmap = new float[heightmapWidthSamples * heightmapHeightSamples]; |
3821 | 3677 | ||
3822 | uint heightmapHeightSamples; | ||
3823 | |||
3824 | //if (((int)Constants.RegionSize) == 256) | ||
3825 | //{ | ||
3826 | // heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3827 | // heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2; | ||
3828 | // heightmapWidth++; | ||
3829 | // heightmapHeight++; | ||
3830 | //} | ||
3831 | //else | ||
3832 | //{ | ||
3833 | |||
3834 | heightmapWidthSamples = (uint)Constants.RegionSize + 1; | ||
3835 | heightmapHeightSamples = (uint)Constants.RegionSize + 1; | ||
3836 | //} | ||
3837 | 3678 | ||
3838 | const float scale = 1.0f; | 3679 | const float scale = 1.0f; |
3839 | const float offset = 0.0f; | 3680 | const float offset = 0.0f; |
3840 | const float thickness = 0.2f; | 3681 | const float thickness = 10f; |
3841 | const int wrap = 0; | 3682 | const int wrap = 0; |
3842 | 3683 | ||
3843 | int regionsize = (int) Constants.RegionSize + 2; | ||
3844 | //Double resolution | ||
3845 | //if (((int)Constants.RegionSize) == 256) | ||
3846 | // heightMap = ResizeTerrain512Interpolation(heightMap); | ||
3847 | 3684 | ||
3685 | float hfmin = float.MaxValue; | ||
3686 | float hfmax = float.MinValue; | ||
3687 | float val; | ||
3688 | uint xx; | ||
3689 | uint yy; | ||
3848 | 3690 | ||
3849 | // if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256) | 3691 | uint maxXX = regionsizeX - 1; |
3850 | // regionsize = 512; | 3692 | uint maxYY = regionsizeY - 1; |
3851 | 3693 | ||
3852 | float hfmin = 2000; | 3694 | // flipping map adding one margin all around so things don't fall in edges |
3853 | float hfmax = -2000; | 3695 | |
3854 | 3696 | uint xt = 0; | |
3855 | for (int x = 0; x < heightmapWidthSamples; x++) | 3697 | xx = 0; |
3698 | |||
3699 | |||
3700 | for (uint x = 0; x < heightmapWidthSamples; x++) | ||
3856 | { | 3701 | { |
3857 | for (int y = 0; y < heightmapHeightSamples; y++) | 3702 | if (x > 1 && xx < maxXX) |
3703 | xx++; | ||
3704 | yy = 0; | ||
3705 | for (uint y = 0; y < heightmapHeightSamples; y++) | ||
3858 | { | 3706 | { |
3859 | int xx = Util.Clip(x - 1, 0, regionsize - 1); | 3707 | if (y > 1 && y < maxYY) |
3860 | int yy = Util.Clip(y - 1, 0, regionsize - 1); | 3708 | yy += regionsizeX; |
3861 | 3709 | ||
3862 | 3710 | val = heightMap[yy + xx]; | |
3863 | float val= heightMap[yy * (int)Constants.RegionSize + xx]; | 3711 | if (val < 0.0f) |
3864 | _heightmap[x * ((int)Constants.RegionSize + 2) + y] = val; | 3712 | val = 0.0f; |
3865 | 3713 | _heightmap[xt + y] = val; | |
3866 | hfmin = (val < hfmin) ? val : hfmin; | 3714 | |
3867 | hfmax = (val > hfmax) ? val : hfmax; | 3715 | if (hfmin > val) |
3716 | hfmin = val; | ||
3717 | if (hfmax < val) | ||
3718 | hfmax = val; | ||
3868 | } | 3719 | } |
3720 | xt += heightmapHeightSamples; | ||
3869 | } | 3721 | } |
3870 | 3722 | ||
3871 | lock (OdeLock) | 3723 | lock (OdeLock) |
@@ -3886,9 +3738,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3886 | 3738 | ||
3887 | } | 3739 | } |
3888 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 3740 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
3889 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, heightmapWidth + 1, heightmapHeight + 1, | 3741 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _heightmap, 0, |
3890 | (int)heightmapWidthSamples + 1, (int)heightmapHeightSamples + 1, scale, | 3742 | heightmapWidth, heightmapHeight, |
3891 | offset, thickness, wrap); | 3743 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, |
3744 | scale, offset, thickness, wrap); | ||
3745 | |||
3892 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); | 3746 | d.GeomHeightfieldDataSetBounds(HeightmapData, hfmin - 1, hfmax + 1); |
3893 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); | 3747 | GroundGeom = d.CreateHeightfield(space, HeightmapData, 1); |
3894 | if (GroundGeom != IntPtr.Zero) | 3748 | if (GroundGeom != IntPtr.Zero) |
@@ -3903,17 +3757,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3903 | 3757 | ||
3904 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); | 3758 | Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); |
3905 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); | 3759 | Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); |
3906 | //Axiom.Math.Quaternion q3 = Axiom.Math.Quaternion.FromAngleAxis(3.14f, new Axiom.Math.Vector3(0, 0, 1)); | ||
3907 | 3760 | ||
3908 | q1 = q1 * q2; | 3761 | q1 = q1 * q2; |
3909 | //q1 = q1 * q3; | ||
3910 | Vector3 v3; | 3762 | Vector3 v3; |
3911 | float angle; | 3763 | float angle; |
3912 | q1.GetAxisAngle(out v3, out angle); | 3764 | q1.GetAxisAngle(out v3, out angle); |
3913 | 3765 | ||
3914 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); | 3766 | d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); |
3915 | d.GeomSetRotation(GroundGeom, ref R); | 3767 | d.GeomSetRotation(GroundGeom, ref R); |
3916 | d.GeomSetPosition(GroundGeom, (pOffset.X + ((int)Constants.RegionSize * 0.5f)), (pOffset.Y + ((int)Constants.RegionSize * 0.5f)), 0); | 3768 | d.GeomSetPosition(GroundGeom, pOffset.X + regionsizeX * 0.5f, pOffset.Y + regionsizeY * 0.5f, 0f); |
3917 | IntPtr testGround = IntPtr.Zero; | 3769 | IntPtr testGround = IntPtr.Zero; |
3918 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) | 3770 | if (RegionTerrain.TryGetValue(pOffset, out testGround)) |
3919 | { | 3771 | { |
@@ -3924,7 +3776,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3924 | } | 3776 | } |
3925 | 3777 | ||
3926 | m_log.DebugFormat( | 3778 | m_log.DebugFormat( |
3927 | "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); | 3779 | "[ODE SCENE]: Setting terrain for {0} took {1}ms", PhysicsSceneName, Util.EnvironmentTickCountSubtract(startTime)); |
3928 | } | 3780 | } |
3929 | 3781 | ||
3930 | public override void DeleteTerrain() | 3782 | public override void DeleteTerrain() |
@@ -3938,89 +3790,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3938 | 3790 | ||
3939 | public override bool SupportsCombining() | 3791 | public override bool SupportsCombining() |
3940 | { | 3792 | { |
3941 | return true; | 3793 | return m_suportCombine; |
3942 | } | 3794 | } |
3943 | 3795 | ||
3944 | // public override void UnCombine(PhysicsScene pScene) | ||
3945 | // { | ||
3946 | // IntPtr localGround = IntPtr.Zero; | ||
3947 | //// float[] localHeightfield; | ||
3948 | // bool proceed = false; | ||
3949 | // List<IntPtr> geomDestroyList = new List<IntPtr>(); | ||
3950 | // | ||
3951 | // lock (OdeLock) | ||
3952 | // { | ||
3953 | // if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) | ||
3954 | // { | ||
3955 | // foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) | ||
3956 | // { | ||
3957 | // if (geom == localGround) | ||
3958 | // { | ||
3959 | //// localHeightfield = TerrainHeightFieldHeights[geom]; | ||
3960 | // proceed = true; | ||
3961 | // } | ||
3962 | // else | ||
3963 | // { | ||
3964 | // geomDestroyList.Add(geom); | ||
3965 | // } | ||
3966 | // } | ||
3967 | // | ||
3968 | // if (proceed) | ||
3969 | // { | ||
3970 | // m_worldOffset = Vector3.Zero; | ||
3971 | // WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); | ||
3972 | // m_parentScene = null; | ||
3973 | // | ||
3974 | // foreach (IntPtr g in geomDestroyList) | ||
3975 | // { | ||
3976 | // // removingHeightField needs to be done or the garbage collector will | ||
3977 | // // collect the terrain data before we tell ODE to destroy it causing | ||
3978 | // // memory corruption | ||
3979 | // if (TerrainHeightFieldHeights.ContainsKey(g)) | ||
3980 | // { | ||
3981 | //// float[] removingHeightField = TerrainHeightFieldHeights[g]; | ||
3982 | // TerrainHeightFieldHeights.Remove(g); | ||
3983 | // | ||
3984 | // if (RegionTerrain.ContainsKey(g)) | ||
3985 | // { | ||
3986 | // RegionTerrain.Remove(g); | ||
3987 | // } | ||
3988 | // | ||
3989 | // d.GeomDestroy(g); | ||
3990 | // //removingHeightField = new float[0]; | ||
3991 | // } | ||
3992 | // } | ||
3993 | // | ||
3994 | // } | ||
3995 | // else | ||
3996 | // { | ||
3997 | // m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); | ||
3998 | // } | ||
3999 | // } | ||
4000 | // } | ||
4001 | // } | ||
4002 | |||
4003 | public override void SetWaterLevel(float baseheight) | 3796 | public override void SetWaterLevel(float baseheight) |
4004 | { | 3797 | { |
4005 | waterlevel = baseheight; | 3798 | waterlevel = baseheight; |
4006 | randomizeWater(waterlevel); | 3799 | // randomizeWater(waterlevel); |
4007 | } | 3800 | } |
4008 | 3801 | ||
3802 | /* | ||
4009 | private void randomizeWater(float baseheight) | 3803 | private void randomizeWater(float baseheight) |
4010 | { | 3804 | { |
4011 | const uint heightmapWidth = m_regionWidth + 2; | 3805 | uint heightmapWidth = m_regionWidth + 2; |
4012 | const uint heightmapHeight = m_regionHeight + 2; | 3806 | uint heightmapHeight = m_regionHeight + 2; |
4013 | const uint heightmapWidthSamples = m_regionWidth + 2; | 3807 | uint heightmapWidthSamples = m_regionWidth + 2; |
4014 | const uint heightmapHeightSamples = m_regionHeight + 2; | 3808 | uint heightmapHeightSamples = m_regionHeight + 2; |
4015 | const float scale = 1.0f; | 3809 | float scale = 1.0f; |
4016 | const float offset = 0.0f; | 3810 | float offset = 0.0f; |
4017 | const float thickness = 2.9f; | 3811 | float thickness = 2.9f; |
4018 | const int wrap = 0; | 3812 | int wrap = 0; |
4019 | 3813 | ||
4020 | for (int i = 0; i < (258 * 258); i++) | 3814 | for (int i = 0; i < (258 * 258); i++) |
4021 | { | 3815 | { |
4022 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); | 3816 | _watermap[i] = (baseheight-0.1f) + ((float)fluidRandomizer.Next(1,9) / 10f); |
4023 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); | 3817 | // m_log.Info((baseheight - 0.1f) + ((float)fluidRandomizer.Next(1, 9) / 10f)); |
4024 | } | 3818 | } |
4025 | 3819 | ||
4026 | lock (OdeLock) | 3820 | lock (OdeLock) |
@@ -4031,8 +3825,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4031 | } | 3825 | } |
4032 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); | 3826 | IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); |
4033 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, | 3827 | d.GeomHeightfieldDataBuildSingle(HeightmapData, _watermap, 0, heightmapWidth, heightmapHeight, |
4034 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, | 3828 | (int)heightmapWidthSamples, (int)heightmapHeightSamples, scale, |
4035 | offset, thickness, wrap); | 3829 | offset, thickness, wrap); |
4036 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); | 3830 | d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight); |
4037 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); | 3831 | WaterGeom = d.CreateHeightfield(space, HeightmapData, 1); |
4038 | if (WaterGeom != IntPtr.Zero) | 3832 | if (WaterGeom != IntPtr.Zero) |
@@ -4060,7 +3854,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4060 | d.GeomSetPosition(WaterGeom, 128, 128, 0); | 3854 | d.GeomSetPosition(WaterGeom, 128, 128, 0); |
4061 | } | 3855 | } |
4062 | } | 3856 | } |
4063 | 3857 | */ | |
4064 | public override void Dispose() | 3858 | public override void Dispose() |
4065 | { | 3859 | { |
4066 | _worldInitialized = false; | 3860 | _worldInitialized = false; |
@@ -4095,8 +3889,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4095 | lock (_prims) | 3889 | lock (_prims) |
4096 | { | 3890 | { |
4097 | List<OdePrim> orderedPrims = new List<OdePrim>(_prims); | 3891 | List<OdePrim> orderedPrims = new List<OdePrim>(_prims); |
4098 | orderedPrims.OrderByDescending(p => p.CollisionScore).Take(25); | 3892 | orderedPrims.OrderByDescending(p => p.CollisionScore); |
4099 | topColliders = orderedPrims.ToDictionary(p => p.LocalID, p => p.CollisionScore); | 3893 | topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore); |
4100 | 3894 | ||
4101 | foreach (OdePrim p in _prims) | 3895 | foreach (OdePrim p in _prims) |
4102 | p.CollisionScore = 0; | 3896 | p.CollisionScore = 0; |
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs index 16404c6..6dc22bd 100644 --- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs +++ b/OpenSim/Region/PhysicsModules/Ode/Tests/ODETestClass.cs | |||
@@ -30,51 +30,74 @@ using Nini.Config; | |||
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Physics.Manager; | 33 | using OpenSim.Region.PhysicsModules.SharedBase; |
34 | using OpenSim.Region.Physics.OdePlugin; | 34 | using OpenSim.Region.PhysicsModule.ODE; |
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
36 | using log4net; | 38 | using log4net; |
37 | using System.Reflection; | 39 | using System.Reflection; |
38 | 40 | ||
39 | namespace OpenSim.Region.Physics.OdePlugin.Tests | 41 | namespace OpenSim.Region.PhysicsModule.ODE.Tests |
40 | { | 42 | { |
41 | [TestFixture] | 43 | [TestFixture] |
42 | public class ODETestClass : OpenSimTestCase | 44 | public class ODETestClass : OpenSimTestCase |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | private OpenSim.Region.Physics.OdePlugin.OdePlugin cbt; | 48 | //private OpenSim.Region.PhysicsModule.ODE.OdePlugin cbt; |
47 | private PhysicsScene ps; | 49 | private PhysicsScene pScene; |
48 | private IMeshingPlugin imp; | ||
49 | 50 | ||
50 | [SetUp] | 51 | [SetUp] |
51 | public void Initialize() | 52 | public void Initialize() |
52 | { | 53 | { |
53 | IConfigSource TopConfig = new IniConfigSource(); | 54 | IConfigSource openSimINI = new IniConfigSource(); |
54 | IConfig config = TopConfig.AddConfig("Startup"); | 55 | IConfig startupConfig = openSimINI.AddConfig("Startup"); |
55 | config.Set("DecodedSculptMapPath","j2kDecodeCache"); | 56 | startupConfig.Set("physics", "OpenDynamicsEngine"); |
57 | startupConfig.Set("DecodedSculptMapPath", "j2kDecodeCache"); | ||
58 | |||
59 | Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | ||
60 | |||
61 | //PhysicsScene pScene = physicsPluginManager.GetPhysicsScene( | ||
62 | // "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent); | ||
63 | RegionInfo info = new RegionInfo(); | ||
64 | info.RegionName = "ODETestRegion"; | ||
65 | info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize; | ||
66 | OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info); | ||
67 | |||
68 | //IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer(); | ||
69 | //INonSharedRegionModule mod = mesher as INonSharedRegionModule; | ||
70 | //mod.Initialise(openSimINI); | ||
71 | //mod.AddRegion(scene); | ||
72 | //mod.RegionLoaded(scene); | ||
73 | |||
74 | pScene = new OdeScene(); | ||
75 | Console.WriteLine("HERE " + (pScene == null ? "Null" : "Not null")); | ||
76 | INonSharedRegionModule mod = (pScene as INonSharedRegionModule); | ||
77 | Console.WriteLine("HERE " + (mod == null ? "Null" : "Not null")); | ||
78 | mod.Initialise(openSimINI); | ||
79 | mod.AddRegion(scene); | ||
80 | mod.RegionLoaded(scene); | ||
56 | 81 | ||
57 | // Loading ODEPlugin | 82 | // Loading ODEPlugin |
58 | cbt = new OdePlugin(); | 83 | //cbt = new OdePlugin(); |
59 | // Loading Zero Mesher | ||
60 | imp = new ZeroMesherPlugin(); | ||
61 | // Getting Physics Scene | 84 | // Getting Physics Scene |
62 | ps = cbt.GetScene("test"); | 85 | //ps = cbt.GetScene("test"); |
63 | // Initializing Physics Scene. | 86 | // Initializing Physics Scene. |
64 | ps.Initialise(imp.GetMesher(TopConfig),null); | 87 | //ps.Initialise(imp.GetMesher(TopConfig), null, Vector3.Zero); |
65 | float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; | 88 | float[] _heightmap = new float[(int)Constants.RegionSize * (int)Constants.RegionSize]; |
66 | for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) | 89 | for (int i = 0; i < ((int)Constants.RegionSize * (int)Constants.RegionSize); i++) |
67 | { | 90 | { |
68 | _heightmap[i] = 21f; | 91 | _heightmap[i] = 21f; |
69 | } | 92 | } |
70 | ps.SetTerrain(_heightmap); | 93 | pScene.SetTerrain(_heightmap); |
71 | } | 94 | } |
72 | 95 | ||
73 | [TearDown] | 96 | [TearDown] |
74 | public void Terminate() | 97 | public void Terminate() |
75 | { | 98 | { |
76 | ps.DeleteTerrain(); | 99 | pScene.DeleteTerrain(); |
77 | ps.Dispose(); | 100 | pScene.Dispose(); |
78 | 101 | ||
79 | } | 102 | } |
80 | 103 | ||
@@ -85,9 +108,9 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests | |||
85 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); | 108 | Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f); |
86 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); | 109 | Vector3 size = new Vector3(0.5f, 0.5f, 0.5f); |
87 | Quaternion rot = Quaternion.Identity; | 110 | Quaternion rot = Quaternion.Identity; |
88 | PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); | 111 | PhysicsActor prim = pScene.AddPrimShape("CoolShape", newcube, position, size, rot, true, 0); |
89 | OdePrim oprim = (OdePrim)prim; | 112 | OdePrim oprim = (OdePrim)prim; |
90 | OdeScene pscene = (OdeScene) ps; | 113 | OdeScene pscene = (OdeScene)pScene; |
91 | 114 | ||
92 | Assert.That(oprim.m_taintadd); | 115 | Assert.That(oprim.m_taintadd); |
93 | 116 | ||
@@ -95,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests | |||
95 | 118 | ||
96 | for (int i = 0; i < 58; i++) | 119 | for (int i = 0; i < 58; i++) |
97 | { | 120 | { |
98 | ps.Simulate(0.133f); | 121 | pScene.Simulate(0.133f); |
99 | 122 | ||
100 | Assert.That(oprim.prim_geom != (IntPtr)0); | 123 | Assert.That(oprim.prim_geom != (IntPtr)0); |
101 | 124 | ||
@@ -119,9 +142,9 @@ namespace OpenSim.Region.Physics.OdePlugin.Tests | |||
119 | // Make sure we're not somewhere above the ground | 142 | // Make sure we're not somewhere above the ground |
120 | Assert.That(prim.Position.Z < 21.5f); | 143 | Assert.That(prim.Position.Z < 21.5f); |
121 | 144 | ||
122 | ps.RemovePrim(prim); | 145 | pScene.RemovePrim(prim); |
123 | Assert.That(oprim.m_taintremove); | 146 | Assert.That(oprim.m_taintremove); |
124 | ps.Simulate(0.133f); | 147 | pScene.Simulate(0.133f); |
125 | Assert.That(oprim.Body == (IntPtr)0); | 148 | Assert.That(oprim.Body == (IntPtr)0); |
126 | } | 149 | } |
127 | } | 150 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/drawstuff.cs b/OpenSim/Region/PhysicsModules/Ode/drawstuff.cs index 87ca446..87ca446 100644 --- a/OpenSim/Region/Physics/OdePlugin/drawstuff.cs +++ b/OpenSim/Region/PhysicsModules/Ode/drawstuff.cs | |||
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs index 478dd95..1ec2046 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs | |||
@@ -25,66 +25,62 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenMetaverse; | ||
28 | using System; | 29 | using System; |
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Linq; | ||
30 | using System.Reflection; | 32 | using System.Reflection; |
31 | using System.Runtime.InteropServices; | ||
32 | using System.Threading; | 33 | using System.Threading; |
33 | using System.IO; | ||
34 | using System.Diagnostics; | ||
35 | using log4net; | 34 | using log4net; |
36 | using Nini.Config; | 35 | using pCampBot.Interfaces; |
37 | using Ode.NET; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.Physics.Manager; | ||
40 | using OpenMetaverse; | ||
41 | 36 | ||
42 | namespace OpenSim.Region.Physics.OdePlugin | 37 | namespace pCampBot |
43 | { | 38 | { |
44 | /// <summary> | 39 | /// <summary> |
45 | /// ODE plugin | 40 | /// This behavior is for the systematic study of some performance improvements made |
41 | /// for OSCC'13. | ||
42 | /// Walk around, sending AgentUpdate packets all the time. | ||
46 | /// </summary> | 43 | /// </summary> |
47 | public class OdePlugin : IPhysicsPlugin | 44 | public class PhysicsBehaviour2 : AbstractBehaviour |
48 | { | 45 | { |
49 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | |||
51 | private OdeScene m_scene; | ||
52 | 47 | ||
53 | public bool Init() | 48 | public PhysicsBehaviour2() |
54 | { | 49 | { |
55 | return true; | 50 | AbbreviatedName = "ph2"; |
51 | Name = "Physics2"; | ||
56 | } | 52 | } |
57 | 53 | ||
58 | public PhysicsScene GetScene(String sceneIdentifier) | 54 | private const int TIME_WALKING = 5 * 10; // 5 seconds |
55 | private int counter = 0; | ||
56 | |||
57 | public override void Action() | ||
59 | { | 58 | { |
60 | if (m_scene == null) | 59 | |
60 | if (counter >= TIME_WALKING) | ||
61 | { | 61 | { |
62 | // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether | 62 | counter = 0; |
63 | // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports | ||
64 | // will find it already loaded later on. | ||
65 | // | ||
66 | // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be | ||
67 | // controlled in Ode.NET.dll.config | ||
68 | if (Util.IsWindows()) | ||
69 | Util.LoadArchSpecificWindowsDll("ode.dll"); | ||
70 | 63 | ||
71 | // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to | 64 | Vector3 target = new Vector3(Bot.Random.Next(1, 254), Bot.Random.Next(1, 254), Bot.Client.Self.SimPosition.Z); |
72 | // http://opensimulator.org/mantis/view.php?id=2750). | 65 | MyTurnToward(target); |
73 | d.InitODE(); | ||
74 | |||
75 | m_scene = new OdeScene(sceneIdentifier); | ||
76 | } | ||
77 | 66 | ||
78 | return m_scene; | 67 | Bot.Client.Self.Movement.AtPos = true; |
79 | } | ||
80 | 68 | ||
81 | public string GetName() | 69 | } |
82 | { | 70 | else |
83 | return ("OpenDynamicsEngine"); | 71 | counter++; |
72 | // In any case, send an update | ||
73 | Bot.Client.Self.Movement.SendUpdate(); | ||
84 | } | 74 | } |
85 | 75 | ||
86 | public void Dispose() | 76 | private void MyTurnToward(Vector3 target) |
87 | { | 77 | { |
78 | Quaternion between = Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target - Bot.Client.Self.SimPosition)); | ||
79 | Quaternion rot = between ; | ||
80 | |||
81 | Bot.Client.Self.Movement.BodyRotation = rot; | ||
82 | Bot.Client.Self.Movement.HeadRotation = rot; | ||
83 | Bot.Client.Self.Movement.Camera.LookAt(Bot.Client.Self.SimPosition, target); | ||
88 | } | 84 | } |
89 | } | 85 | } |
90 | } \ No newline at end of file | 86 | } \ No newline at end of file |