Merge branch 'ubitwork' into avination

avinationmerge
Melanie 2012-07-10 17:14:42 +02:00
commit b346e36016
7 changed files with 144 additions and 44 deletions

View File

@ -959,7 +959,15 @@ namespace OpenSim.Region.Framework.Scenes
} }
return m_angularVelocity; 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;
}
}
} }
/// <summary></summary> /// <summary></summary>
@ -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) public void SetVelocity(Vector3 pVel, bool localGlobalTF)
{ {
if (ParentGroup == null || ParentGroup.IsDeleted) if (ParentGroup == null || ParentGroup.IsDeleted)
@ -1871,6 +1879,33 @@ namespace OpenSim.Region.Framework.Scenes
ParentGroup.Velocity = pVel; 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;
}
/// <summary> /// <summary>

View File

@ -583,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (value.IsFinite()) if (value.IsFinite())
{ {
AddChange(changes.Velocity, value); AddChange(changes.Velocity, value);
// _velocity = value;
} }
else else
{ {
@ -676,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (value.IsFinite()) if (value.IsFinite())
{ {
m_rotationalVelocity = value; AddChange(changes.AngVelocity, value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
} }
else else
{ {
@ -687,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override float Buoyancy public override float Buoyancy
{ {
get { return m_buoyancy; } get { return m_buoyancy; }
@ -1737,17 +1732,14 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableFlag(Body, true);
d.BodySetAutoDisableSteps(Body, body_autodisable_frames); d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
// d.BodySetLinearDampingThreshold(Body, 0.01f); d.BodySetDamping(Body, .005f, .005f);
// 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);
}
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) if (childrenPrim.Count == 0)
{ {
@ -3296,6 +3288,13 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changevelocity(Vector3 newVel) 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 (!m_isSelected)
{ {
if (Body != IntPtr.Zero) if (Body != IntPtr.Zero)
@ -3312,6 +3311,33 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity = newVel; _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) private void changeVolumedetetion(bool newVolDtc)
{ {
m_isVolumeDetect = newVolDtc; m_isVolumeDetect = newVolDtc;
@ -3948,9 +3974,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// case changes.Acceleration: // case changes.Acceleration:
// changeacceleration((Vector3)arg); // changeacceleration((Vector3)arg);
// break; // break;
// case changes.AngVelocity:
// changeangvelocity((Vector3)arg); case changes.AngVelocity:
// break; changeangvelocity((Vector3)arg);
break;
case changes.Force: case changes.Force:
changeForce((Vector3)arg); changeForce((Vector3)arg);

View File

@ -1312,7 +1312,14 @@ namespace OdeAPI
public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback); public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback);
[DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity] [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] [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity]
public static extern IntPtr HashSpaceCreate(IntPtr space); public static extern IntPtr HashSpaceCreate(IntPtr space);

View File

@ -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 d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
const float MaxERP = 0.8f; const float MaxERP = 0.8f;
const float minERP = 0.1f; const float minERP = 0.2f;
const float comumContactCFM = 0.0001f; const float comumContactCFM = 0.0001f;
float frictionMovementMult = 0.8f; float frictionMovementMult = 0.8f;
@ -268,7 +268,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public ContactData[] m_materialContactsData = new ContactData[8]; public ContactData[] m_materialContactsData = new ContactData[8];
private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); private readonly Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>(); private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
@ -408,8 +408,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// checkThread(); // checkThread();
mesher = meshmerizer; mesher = meshmerizer;
m_config = config; m_config = config;
/*
string ode_config = d.GetConfiguration("ODE"); string ode_config = d.GetConfiguration();
if (ode_config != null && ode_config != "") if (ode_config != null && ode_config != "")
{ {
m_log.WarnFormat("ODE configuration: {0}", ode_config); m_log.WarnFormat("ODE configuration: {0}", ode_config);
@ -419,7 +419,7 @@ namespace OpenSim.Region.Physics.OdePlugin
OdeUbitLib = true; OdeUbitLib = true;
} }
} }
*/
/* /*
if (region != null) if (region != null)
{ {
@ -921,6 +921,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm; cfm = 0.0001f / cfm;
if (cfm > 0.01f) if (cfm > 0.01f)
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)) if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
mu *= frictionMovementMult; mu *= frictionMovementMult;
@ -947,6 +949,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm; cfm = 0.0001f / cfm;
if (cfm > 0.01f) if (cfm > 0.01f)
cfm = 0.01f; cfm = 0.01f;
else if (cfm < 0.0001f)
cfm = 0.0001f;
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
{ {
@ -1892,18 +1896,22 @@ namespace OpenSim.Region.Physics.OdePlugin
lock (SimulationLock) lock (SimulationLock)
lock(OdeLock) lock(OdeLock)
{ {
if (world == IntPtr.Zero)
return 0;
// adjust number of iterations per step // adjust number of iterations per step
try
{ // try
// {
d.WorldSetQuickStepNumIterations(world, curphysiteractions); d.WorldSetQuickStepNumIterations(world, curphysiteractions);
} /* }
catch (StackOverflowException) catch (StackOverflowException)
{ {
m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
// ode.drelease(world); // ode.drelease(world);
base.TriggerPhysicsBasedRestart(); base.TriggerPhysicsBasedRestart();
} }
*/
while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
{ {
try try
@ -2383,11 +2391,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
d.GeomSetRotation(GroundGeom, ref R); d.GeomSetRotation(GroundGeom, ref R);
d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); RegionTerrain.Add(pOffset, GroundGeom);
// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 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"; geom_name_map[GroundGeom] = "Terrain";
d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); RegionTerrain.Add(pOffset, GroundGeom);
// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
} }
@ -2649,19 +2654,42 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void Dispose() public override void Dispose()
{ {
m_rayCastManager.Dispose();
m_rayCastManager = null;
lock (OdeLock) lock (OdeLock)
{ {
m_rayCastManager.Dispose();
m_rayCastManager = null;
lock (_prims) lock (_prims)
{ {
ChangesQueue.Clear();
foreach (OdePrim prm in _prims) 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) if (TerrainHeightFieldHeightsHandlers.Count > 0)
{ {
foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
@ -2671,6 +2699,9 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
TerrainHeightFieldHeightsHandlers.Clear();
TerrainHeightFieldHeights.Clear();
if (WaterGeom != IntPtr.Zero) if (WaterGeom != IntPtr.Zero)
{ {
d.GeomDestroy(WaterGeom); d.GeomDestroy(WaterGeom);
@ -2691,6 +2722,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.WorldDestroy(world); d.WorldDestroy(world);
world = IntPtr.Zero;
//d.CloseODE(); //d.CloseODE();
} }
} }

View File

@ -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); return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
} }
public void llSetAngularVelocity(LSL_Vector avel, int local) public void llSetAngularVelocity(LSL_Vector avel, int local)
{ {
m_host.AddScriptLPS(1); 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() 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) 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))); part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)));
} }

BIN
bin/lib32/libode.so Normal file → Executable file

Binary file not shown.

Binary file not shown.