Merge branch 'ubitwork' into avination
commit
b346e36016
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (ParentGroup == null || ParentGroup.IsDeleted)
|
||||
|
@ -1872,6 +1880,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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// hook to the physics scene to apply angular impulse
|
||||
|
|
|
@ -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,9 +1732,7 @@ 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);
|
||||
d.BodySetDamping(Body, .005f, .005f);
|
||||
|
||||
if (m_targetSpace != IntPtr.Zero)
|
||||
{
|
||||
|
@ -1748,7 +1741,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
d.SpaceRemove(m_targetSpace, prim_geom);
|
||||
}
|
||||
|
||||
|
||||
if (childrenPrim.Count == 0)
|
||||
{
|
||||
collide_geom = prim_geom;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<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, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -2648,20 +2653,43 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
lock (OdeLock)
|
||||
{
|
||||
m_rayCastManager.Dispose();
|
||||
m_rayCastManager = null;
|
||||
|
||||
lock (OdeLock)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue