diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index dd30a59bd1..16a85883d1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -959,7 +959,15 @@ namespace OpenSim.Region.Framework.Scenes
}
return m_angularVelocity;
}
- set { m_angularVelocity = value; }
+ set
+ {
+ m_angularVelocity = value;
+ PhysicsActor actor = PhysActor;
+ if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE)
+ {
+ actor.RotationalVelocity = m_angularVelocity;
+ }
+ }
}
///
@@ -1845,7 +1853,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
-// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
+ // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
public void SetVelocity(Vector3 pVel, bool localGlobalTF)
{
if (ParentGroup == null || ParentGroup.IsDeleted)
@@ -1871,6 +1879,33 @@ namespace OpenSim.Region.Framework.Scenes
ParentGroup.Velocity = pVel;
}
+
+ // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future
+ public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF)
+ {
+ if (ParentGroup == null || ParentGroup.IsDeleted)
+ return;
+
+ if (ParentGroup.IsAttachment)
+ return; // don't work on attachments (for now ??)
+
+ SceneObjectPart root = ParentGroup.RootPart;
+
+ if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles
+ return;
+
+ PhysicsActor pa = root.PhysActor;
+
+ if (pa == null || !pa.IsPhysical)
+ return;
+
+ if (localGlobalTF)
+ {
+ pAngVel = pAngVel * GetWorldRotation();
+ }
+
+ root.AngularVelocity = pAngVel;
+ }
///
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 3d8e6801f6..14e4272b86 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -583,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (value.IsFinite())
{
AddChange(changes.Velocity, value);
-// _velocity = value;
-
}
else
{
@@ -676,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (value.IsFinite())
{
- m_rotationalVelocity = value;
- if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
- d.BodyEnable(Body);
+ AddChange(changes.AngVelocity, value);
}
else
{
@@ -687,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
-
public override float Buoyancy
{
get { return m_buoyancy; }
@@ -1737,17 +1732,14 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
-// d.BodySetLinearDampingThreshold(Body, 0.01f);
-// d.BodySetAngularDampingThreshold(Body, 0.001f);
- d.BodySetDamping(Body, .002f, .002f);
-
- if (m_targetSpace != IntPtr.Zero)
- {
- _parent_scene.waitForSpaceUnlock(m_targetSpace);
- if (d.SpaceQuery(m_targetSpace, prim_geom))
- d.SpaceRemove(m_targetSpace, prim_geom);
- }
+ d.BodySetDamping(Body, .005f, .005f);
+ if (m_targetSpace != IntPtr.Zero)
+ {
+ _parent_scene.waitForSpaceUnlock(m_targetSpace);
+ if (d.SpaceQuery(m_targetSpace, prim_geom))
+ d.SpaceRemove(m_targetSpace, prim_geom);
+ }
if (childrenPrim.Count == 0)
{
@@ -3296,6 +3288,13 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changevelocity(Vector3 newVel)
{
+ float len = newVel.LengthSquared();
+ if (len > 100000.0f) // limit to 100m/s
+ {
+ len = 100.0f / (float)Math.Sqrt(len);
+ newVel *= len;
+ }
+
if (!m_isSelected)
{
if (Body != IntPtr.Zero)
@@ -3312,6 +3311,33 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity = newVel;
}
+
+ private void changeangvelocity(Vector3 newAngVel)
+ {
+ float len = newAngVel.LengthSquared();
+ if (len > 144.0f) // limit to 12rad/s
+ {
+ len = 12.0f / (float)Math.Sqrt(len);
+ newAngVel *= len;
+ }
+
+ if (!m_isSelected)
+ {
+ if (Body != IntPtr.Zero)
+ {
+ if (m_disabled)
+ enableBodySoft();
+ else if (!d.BodyIsEnabled(Body))
+ d.BodyEnable(Body);
+
+
+ d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
+ }
+ //resetCollisionAccounting();
+ }
+ m_rotationalVelocity = newAngVel;
+ }
+
private void changeVolumedetetion(bool newVolDtc)
{
m_isVolumeDetect = newVolDtc;
@@ -3948,9 +3974,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
-// case changes.AngVelocity:
-// changeangvelocity((Vector3)arg);
-// break;
+
+ case changes.AngVelocity:
+ changeangvelocity((Vector3)arg);
+ break;
case changes.Force:
changeForce((Vector3)arg);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index 0e4961b85a..23411868c7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -1312,7 +1312,14 @@ namespace OdeAPI
public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback);
[DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity]
- public static extern string GetConfiguration(string str);
+ public static extern IntPtr iGetConfiguration();
+
+ public static string GetConfiguration()
+ {
+ IntPtr ptr = iGetConfiguration();
+ string s = Marshal.PtrToStringAnsi(ptr);
+ return s;
+ }
[DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity]
public static extern IntPtr HashSpaceCreate(IntPtr space);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 4552f3fb2e..d5938f4ade 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Physics.OdePlugin
const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
const float MaxERP = 0.8f;
- const float minERP = 0.1f;
+ const float minERP = 0.2f;
const float comumContactCFM = 0.0001f;
float frictionMovementMult = 0.8f;
@@ -268,7 +268,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public ContactData[] m_materialContactsData = new ContactData[8];
- private readonly DoubleDictionary RegionTerrain = new DoubleDictionary();
+ private readonly Dictionary RegionTerrain = new Dictionary();
private readonly Dictionary TerrainHeightFieldHeights = new Dictionary();
private readonly Dictionary TerrainHeightFieldHeightsHandlers = new Dictionary();
@@ -408,8 +408,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// checkThread();
mesher = meshmerizer;
m_config = config;
-/*
- string ode_config = d.GetConfiguration("ODE");
+
+ string ode_config = d.GetConfiguration();
if (ode_config != null && ode_config != "")
{
m_log.WarnFormat("ODE configuration: {0}", ode_config);
@@ -419,7 +419,7 @@ namespace OpenSim.Region.Physics.OdePlugin
OdeUbitLib = true;
}
}
-*/
+
/*
if (region != null)
{
@@ -921,6 +921,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm;
if (cfm > 0.01f)
cfm = 0.01f;
+ else if (cfm < 0.0001f)
+ cfm = 0.0001f;
if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
mu *= frictionMovementMult;
@@ -947,6 +949,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm;
if (cfm > 0.01f)
cfm = 0.01f;
+ else if (cfm < 0.0001f)
+ cfm = 0.0001f;
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
{
@@ -1892,18 +1896,22 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (SimulationLock)
lock(OdeLock)
{
+ if (world == IntPtr.Zero)
+ return 0;
+
// adjust number of iterations per step
- try
- {
+
+// try
+// {
d.WorldSetQuickStepNumIterations(world, curphysiteractions);
- }
+/* }
catch (StackOverflowException)
{
m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
// ode.drelease(world);
base.TriggerPhysicsBasedRestart();
}
-
+*/
while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
{
try
@@ -2383,11 +2391,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
d.GeomSetRotation(GroundGeom, ref R);
d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
- RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
-// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
+ RegionTerrain.Add(pOffset, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
- TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
-
+ TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
}
}
@@ -2486,8 +2492,7 @@ namespace OpenSim.Region.Physics.OdePlugin
geom_name_map[GroundGeom] = "Terrain";
d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
- RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
- // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
+ RegionTerrain.Add(pOffset, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
}
@@ -2649,19 +2654,42 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void Dispose()
{
- m_rayCastManager.Dispose();
- m_rayCastManager = null;
-
lock (OdeLock)
{
+ m_rayCastManager.Dispose();
+ m_rayCastManager = null;
+
lock (_prims)
{
+ ChangesQueue.Clear();
foreach (OdePrim prm in _prims)
{
- RemovePrim(prm);
+ prm.DoAChange(changes.Remove, null);
+ _collisionEventPrim.Remove(prm);
}
+ _prims.Clear();
}
+ OdeCharacter[] chtorem;
+ lock (_characters)
+ {
+ chtorem = new OdeCharacter[_characters.Count];
+ _characters.CopyTo(chtorem);
+ }
+
+ ChangesQueue.Clear();
+ foreach (OdeCharacter ch in chtorem)
+ ch.DoAChange(changes.Remove, null);
+
+
+ foreach (IntPtr GroundGeom in RegionTerrain.Values)
+ {
+ if (GroundGeom != IntPtr.Zero)
+ d.GeomDestroy(GroundGeom);
+ }
+
+ RegionTerrain.Clear();
+
if (TerrainHeightFieldHeightsHandlers.Count > 0)
{
foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
@@ -2671,6 +2699,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
+ TerrainHeightFieldHeightsHandlers.Clear();
+ TerrainHeightFieldHeights.Clear();
+
if (WaterGeom != IntPtr.Zero)
{
d.GeomDestroy(WaterGeom);
@@ -2691,6 +2722,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.WorldDestroy(world);
+ world = IntPtr.Zero;
//d.CloseODE();
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0ee27482c7..05bb1619fb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2597,12 +2597,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
}
-
public void llSetAngularVelocity(LSL_Vector avel, int local)
{
m_host.AddScriptLPS(1);
- // Still not done !!!!
-// m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
+ m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
}
public LSL_Vector llGetOmega()
@@ -3806,6 +3804,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
{
+ spinrate *= gain;
part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)));
}
diff --git a/bin/lib32/libode.so b/bin/lib32/libode.so
old mode 100644
new mode 100755
index 6bb85fb72a..5b110ae54c
Binary files a/bin/lib32/libode.so and b/bin/lib32/libode.so differ
diff --git a/bin/lib32/ode.dll b/bin/lib32/ode.dll
index f310358693..90106cad75 100755
Binary files a/bin/lib32/ode.dll and b/bin/lib32/ode.dll differ