ubOde: hashSpaces aren't that nice
parent
ca493a1beb
commit
0ac81f6a09
|
@ -751,8 +751,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
m_parent_scene.waitForSpaceUnlock(m_parent_scene.CharsSpace);
|
m_parent_scene.waitForSpaceUnlock(m_parent_scene.CharsSpace);
|
||||||
|
|
||||||
collider = d.HashSpaceCreate(m_parent_scene.CharsSpace);
|
collider = d.SimpleSpaceCreate(m_parent_scene.CharsSpace);
|
||||||
d.HashSpaceSetLevels(collider, -4, 3);
|
|
||||||
d.SpaceSetSublevel(collider, 3);
|
d.SpaceSetSublevel(collider, 3);
|
||||||
d.SpaceSetCleanup(collider, false);
|
d.SpaceSetCleanup(collider, false);
|
||||||
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
|
d.GeomSetCategoryBits(collider, (uint)m_collisionCategories);
|
||||||
|
|
|
@ -196,8 +196,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
private int m_eventsubscription;
|
private int m_eventsubscription;
|
||||||
private int m_cureventsubscription;
|
private int m_cureventsubscription;
|
||||||
private CollisionEventUpdate CollisionEventsThisFrame = null;
|
private CollisionEventUpdate CollisionEvents = null;
|
||||||
private CollisionEventUpdate CollisionVDTCEventsThisFrame = null;
|
private CollisionEventUpdate CollisionVDTCEvents = null;
|
||||||
private bool SentEmptyCollisionsEvent;
|
private bool SentEmptyCollisionsEvent;
|
||||||
|
|
||||||
public volatile bool childPrim;
|
public volatile bool childPrim;
|
||||||
|
@ -1138,24 +1138,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
{
|
{
|
||||||
m_eventsubscription = ms;
|
m_eventsubscription = ms;
|
||||||
m_cureventsubscription = 0;
|
m_cureventsubscription = 0;
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEvents == null)
|
||||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
CollisionEvents = new CollisionEventUpdate();
|
||||||
if (CollisionVDTCEventsThisFrame == null)
|
if (CollisionVDTCEvents == null)
|
||||||
CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
|
CollisionVDTCEvents = new CollisionEventUpdate();
|
||||||
SentEmptyCollisionsEvent = false;
|
SentEmptyCollisionsEvent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UnSubscribeEvents()
|
public override void UnSubscribeEvents()
|
||||||
{
|
{
|
||||||
if (CollisionVDTCEventsThisFrame != null)
|
if (CollisionVDTCEvents != null)
|
||||||
{
|
{
|
||||||
CollisionVDTCEventsThisFrame.Clear();
|
CollisionVDTCEvents.Clear();
|
||||||
CollisionVDTCEventsThisFrame = null;
|
CollisionVDTCEvents = null;
|
||||||
}
|
}
|
||||||
if (CollisionEventsThisFrame != null)
|
if (CollisionEvents != null)
|
||||||
{
|
{
|
||||||
CollisionEventsThisFrame.Clear();
|
CollisionEvents.Clear();
|
||||||
CollisionEventsThisFrame = null;
|
CollisionEvents = null;
|
||||||
}
|
}
|
||||||
m_eventsubscription = 0;
|
m_eventsubscription = 0;
|
||||||
_parent_scene.RemoveCollisionEventReporting(this);
|
_parent_scene.RemoveCollisionEventReporting(this);
|
||||||
|
@ -1163,27 +1163,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||||
{
|
{
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEvents == null)
|
||||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
CollisionEvents = new CollisionEventUpdate();
|
||||||
|
|
||||||
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
|
CollisionEvents.AddCollider(CollidedWith, contact);
|
||||||
_parent_scene.AddCollisionEventReporting(this);
|
_parent_scene.AddCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact)
|
public override void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||||
{
|
{
|
||||||
if (CollisionVDTCEventsThisFrame == null)
|
if (CollisionVDTCEvents == null)
|
||||||
CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
|
CollisionVDTCEvents = new CollisionEventUpdate();
|
||||||
|
|
||||||
CollisionVDTCEventsThisFrame.AddCollider(CollidedWith, contact);
|
CollisionVDTCEvents.AddCollider(CollidedWith, contact);
|
||||||
_parent_scene.AddCollisionEventReporting(this);
|
_parent_scene.AddCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SleeperAddCollisionEvents()
|
internal void SleeperAddCollisionEvents()
|
||||||
{
|
{
|
||||||
if(CollisionEventsThisFrame != null && CollisionEventsThisFrame.m_objCollisionList.Count != 0)
|
if(CollisionEvents != null && CollisionEvents.m_objCollisionList.Count != 0)
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList)
|
foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEvents.m_objCollisionList)
|
||||||
{
|
{
|
||||||
if(kvp.Key == 0)
|
if(kvp.Key == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1196,9 +1196,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
other.AddCollisionEvent(ParentActor.LocalID,cp);
|
other.AddCollisionEvent(ParentActor.LocalID,cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CollisionVDTCEventsThisFrame != null && CollisionVDTCEventsThisFrame.m_objCollisionList.Count != 0)
|
if(CollisionVDTCEvents != null && CollisionVDTCEvents.m_objCollisionList.Count != 0)
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionVDTCEventsThisFrame.m_objCollisionList)
|
foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionVDTCEvents.m_objCollisionList)
|
||||||
{
|
{
|
||||||
OdePrim other = _parent_scene.getPrim(kvp.Key);
|
OdePrim other = _parent_scene.getPrim(kvp.Key);
|
||||||
if(other == null)
|
if(other == null)
|
||||||
|
@ -1213,8 +1213,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
internal void clearSleeperCollisions()
|
internal void clearSleeperCollisions()
|
||||||
{
|
{
|
||||||
if(CollisionVDTCEventsThisFrame != null && CollisionVDTCEventsThisFrame.Count >0 )
|
if(CollisionVDTCEvents != null && CollisionVDTCEvents.Count >0 )
|
||||||
CollisionVDTCEventsThisFrame.Clear();
|
CollisionVDTCEvents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendCollisions(int timestep)
|
public void SendCollisions(int timestep)
|
||||||
|
@ -1226,14 +1226,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
if (m_cureventsubscription < m_eventsubscription)
|
if (m_cureventsubscription < m_eventsubscription)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEvents == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
|
int ncolisions = CollisionEvents.m_objCollisionList.Count;
|
||||||
|
|
||||||
if (!SentEmptyCollisionsEvent || ncolisions > 0)
|
if (!SentEmptyCollisionsEvent || ncolisions > 0)
|
||||||
{
|
{
|
||||||
base.SendCollisionUpdate(CollisionEventsThisFrame);
|
base.SendCollisionUpdate(CollisionEvents);
|
||||||
m_cureventsubscription = 0;
|
m_cureventsubscription = 0;
|
||||||
|
|
||||||
if (ncolisions == 0)
|
if (ncolisions == 0)
|
||||||
|
@ -1244,7 +1244,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
else if(Body == IntPtr.Zero || (d.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 ))
|
else if(Body == IntPtr.Zero || (d.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 ))
|
||||||
{
|
{
|
||||||
SentEmptyCollisionsEvent = false;
|
SentEmptyCollisionsEvent = false;
|
||||||
CollisionEventsThisFrame.Clear();
|
CollisionEvents.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1832,7 +1832,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
// should only be called for non physical prims unless they are becoming non physical
|
// should only be called for non physical prims unless they are becoming non physical
|
||||||
private void SetInStaticSpace(OdePrim prim)
|
private void SetInStaticSpace(OdePrim prim)
|
||||||
{
|
{
|
||||||
IntPtr targetSpace = _parent_scene.MoveGeomToStaticSpace(prim.prim_geom, prim._position, prim.m_targetSpace);
|
IntPtr targetSpace = _parent_scene.MoveGeomToStaticSpace(prim.prim_geom, prim.m_targetSpace);
|
||||||
prim.m_targetSpace = targetSpace;
|
prim.m_targetSpace = targetSpace;
|
||||||
collide_geom = IntPtr.Zero;
|
collide_geom = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
@ -2069,8 +2069,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_targetSpace = d.HashSpaceCreate(_parent_scene.ActiveSpace);
|
m_targetSpace = d.SimpleSpaceCreate(_parent_scene.ActiveSpace);
|
||||||
d.HashSpaceSetLevels(m_targetSpace, -2, 8);
|
|
||||||
d.SpaceSetSublevel(m_targetSpace, 3);
|
d.SpaceSetSublevel(m_targetSpace, 3);
|
||||||
d.SpaceSetCleanup(m_targetSpace, false);
|
d.SpaceSetCleanup(m_targetSpace, false);
|
||||||
|
|
||||||
|
@ -2964,7 +2963,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
|
d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
|
||||||
_position = newPos;
|
_position = newPos;
|
||||||
|
|
||||||
m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, _position, m_targetSpace);
|
m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, m_targetSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3103,7 +3102,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
|
d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
|
||||||
_position = newPos;
|
_position = newPos;
|
||||||
|
|
||||||
m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, _position, m_targetSpace);
|
m_targetSpace = _parent_scene.MoveGeomToStaticSpace(prim_geom, m_targetSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
public float ODE_STEPSIZE = 0.020f;
|
public float ODE_STEPSIZE = 0.020f;
|
||||||
public float HalfOdeStep = 0.01f;
|
public float HalfOdeStep = 0.01f;
|
||||||
public int odetimestepMS = 20; // rounded
|
public int odetimestepMS = 20; // rounded
|
||||||
private float metersInSpace = 25.6f;
|
|
||||||
private float m_timeDilation = 1.0f;
|
private float m_timeDilation = 1.0f;
|
||||||
|
|
||||||
private double m_lastframe;
|
private double m_lastframe;
|
||||||
|
@ -284,16 +283,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
public IntPtr StaticSpace; // space for the static things around
|
public IntPtr StaticSpace; // space for the static things around
|
||||||
public IntPtr GroundSpace; // space for ground
|
public IntPtr GroundSpace; // space for ground
|
||||||
|
|
||||||
// some speedup variables
|
|
||||||
private int spaceGridMaxX;
|
|
||||||
private int spaceGridMaxY;
|
|
||||||
private float spacesPerMeterX;
|
|
||||||
private float spacesPerMeterY;
|
|
||||||
|
|
||||||
// split static geometry collision into a grid as before
|
|
||||||
private IntPtr[,] staticPrimspace;
|
|
||||||
private IntPtr[] staticPrimspaceOffRegion;
|
|
||||||
|
|
||||||
public Object OdeLock;
|
public Object OdeLock;
|
||||||
public static Object SimulationLock;
|
public static Object SimulationLock;
|
||||||
|
|
||||||
|
@ -386,13 +375,23 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
world = d.WorldCreate();
|
world = d.WorldCreate();
|
||||||
TopSpace = d.HashSpaceCreate(IntPtr.Zero);
|
TopSpace = d.SimpleSpaceCreate(IntPtr.Zero);
|
||||||
|
ActiveSpace = d.SimpleSpaceCreate(TopSpace);
|
||||||
// now the major subspaces
|
CharsSpace = d.SimpleSpaceCreate(TopSpace);
|
||||||
ActiveSpace = d.HashSpaceCreate(TopSpace);
|
GroundSpace = d.SimpleSpaceCreate(TopSpace);
|
||||||
CharsSpace = d.HashSpaceCreate(TopSpace);
|
float sx = WorldExtents.X + 16;
|
||||||
StaticSpace = d.HashSpaceCreate(TopSpace);
|
float sy = WorldExtents.Y + 16;
|
||||||
GroundSpace = d.HashSpaceCreate(TopSpace);
|
d.Vector3 ex =new d.Vector3(sx, sy, 0);
|
||||||
|
d.Vector3 px =new d.Vector3(sx * 0.5f, sx * 0.5f, 0);
|
||||||
|
if(sx < sy)
|
||||||
|
sx = sy;
|
||||||
|
sx = (float)Math.Log(sx) * 1.442695f + 0.5f;
|
||||||
|
int dp = (int)sx - 2;
|
||||||
|
if(dp > 8)
|
||||||
|
dp = 8;
|
||||||
|
else if(dp < 4)
|
||||||
|
dp = 4;
|
||||||
|
StaticSpace = d.QuadTreeSpaceCreate(TopSpace, ref px, ref ex, dp);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -400,12 +399,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
// i did!
|
// i did!
|
||||||
}
|
}
|
||||||
|
|
||||||
d.HashSpaceSetLevels(TopSpace, -5, 12);
|
|
||||||
d.HashSpaceSetLevels(ActiveSpace, -5, 10);
|
|
||||||
d.HashSpaceSetLevels(CharsSpace, -4, 3);
|
|
||||||
d.HashSpaceSetLevels(StaticSpace, -5, 12);
|
|
||||||
d.HashSpaceSetLevels(GroundSpace, 0, 8);
|
|
||||||
|
|
||||||
// demote to second level
|
// demote to second level
|
||||||
d.SpaceSetSublevel(ActiveSpace, 1);
|
d.SpaceSetSublevel(ActiveSpace, 1);
|
||||||
d.SpaceSetSublevel(CharsSpace, 1);
|
d.SpaceSetSublevel(CharsSpace, 1);
|
||||||
|
@ -469,8 +462,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
gravityy = physicsconfig.GetFloat("world_gravityy", gravityy);
|
gravityy = physicsconfig.GetFloat("world_gravityy", gravityy);
|
||||||
gravityz = physicsconfig.GetFloat("world_gravityz", gravityz);
|
gravityz = physicsconfig.GetFloat("world_gravityz", gravityz);
|
||||||
|
|
||||||
metersInSpace = physicsconfig.GetFloat("meters_in_small_space", metersInSpace);
|
|
||||||
|
|
||||||
// contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer);
|
// contactsurfacelayer = physicsconfig.GetFloat("world_contact_surface_layer", contactsurfacelayer);
|
||||||
|
|
||||||
ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE);
|
ODE_STEPSIZE = physicsconfig.GetFloat("world_stepsize", ODE_STEPSIZE);
|
||||||
|
@ -560,76 +551,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
m_materialContactsData[(int)Material.light].mu = 0.0f;
|
m_materialContactsData[(int)Material.light].mu = 0.0f;
|
||||||
m_materialContactsData[(int)Material.light].bounce = 0.0f;
|
m_materialContactsData[(int)Material.light].bounce = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
spacesPerMeterX = 1.0f / metersInSpace;
|
|
||||||
spacesPerMeterY = spacesPerMeterX;
|
|
||||||
spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeterX);
|
|
||||||
spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeterY);
|
|
||||||
|
|
||||||
if (spaceGridMaxX > 24)
|
|
||||||
{
|
|
||||||
spaceGridMaxX = 24;
|
|
||||||
spacesPerMeterX = spaceGridMaxX / WorldExtents.X;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spaceGridMaxY > 24)
|
|
||||||
{
|
|
||||||
spaceGridMaxY = 24;
|
|
||||||
spacesPerMeterY = spaceGridMaxY / WorldExtents.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY];
|
|
||||||
|
|
||||||
// create all spaces now
|
|
||||||
int i, j;
|
|
||||||
IntPtr newspace;
|
|
||||||
|
|
||||||
for (i = 0; i < spaceGridMaxX; i++)
|
|
||||||
for (j = 0; j < spaceGridMaxY; j++)
|
|
||||||
{
|
|
||||||
newspace = d.HashSpaceCreate(StaticSpace);
|
|
||||||
d.GeomSetCategoryBits(newspace, (int)CollisionCategories.Space);
|
|
||||||
waitForSpaceUnlock(newspace);
|
|
||||||
d.SpaceSetSublevel(newspace, 2);
|
|
||||||
d.HashSpaceSetLevels(newspace, -2, 8);
|
|
||||||
d.GeomSetCategoryBits(newspace, (uint)(CollisionCategories.Space |
|
|
||||||
CollisionCategories.Geom |
|
|
||||||
CollisionCategories.Land |
|
|
||||||
CollisionCategories.Water |
|
|
||||||
CollisionCategories.Phantom |
|
|
||||||
CollisionCategories.VolumeDtc
|
|
||||||
));
|
|
||||||
d.GeomSetCollideBits(newspace, 0);
|
|
||||||
|
|
||||||
staticPrimspace[i, j] = newspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let this now be index limit
|
|
||||||
spaceGridMaxX--;
|
|
||||||
spaceGridMaxY--;
|
|
||||||
|
|
||||||
// create 4 off world spaces (x<0,x>max,y<0,y>max)
|
|
||||||
staticPrimspaceOffRegion = new IntPtr[4];
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
newspace = d.HashSpaceCreate(StaticSpace);
|
|
||||||
d.GeomSetCategoryBits(newspace, (int)CollisionCategories.Space);
|
|
||||||
waitForSpaceUnlock(newspace);
|
|
||||||
d.SpaceSetSublevel(newspace, 2);
|
|
||||||
d.HashSpaceSetLevels(newspace, -2, 8);
|
|
||||||
d.GeomSetCategoryBits(newspace, (uint)(CollisionCategories.Space |
|
|
||||||
CollisionCategories.Geom |
|
|
||||||
CollisionCategories.Land |
|
|
||||||
CollisionCategories.Water |
|
|
||||||
CollisionCategories.Phantom |
|
|
||||||
CollisionCategories.VolumeDtc
|
|
||||||
));
|
|
||||||
d.GeomSetCollideBits(newspace, 0);
|
|
||||||
|
|
||||||
staticPrimspaceOffRegion[i] = newspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lastframe = Util.GetTimeStamp();
|
m_lastframe = Util.GetTimeStamp();
|
||||||
m_lastMeshExpire = m_lastframe;
|
m_lastMeshExpire = m_lastframe;
|
||||||
step_time = -1;
|
step_time = -1;
|
||||||
|
@ -758,7 +679,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
//
|
//
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
|
if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
|
||||||
d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
|
d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc)
|
||||||
{
|
{
|
||||||
|
@ -1307,6 +1227,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
public override void RemoveAvatar(PhysicsActor actor)
|
public override void RemoveAvatar(PhysicsActor actor)
|
||||||
{
|
{
|
||||||
//m_log.Debug("[PHYSICS]:ODELOCK");
|
//m_log.Debug("[PHYSICS]:ODELOCK");
|
||||||
|
if (world == IntPtr.Zero)
|
||||||
|
return;
|
||||||
|
|
||||||
lock (OdeLock)
|
lock (OdeLock)
|
||||||
{
|
{
|
||||||
d.AllocateODEDataForThread(0);
|
d.AllocateODEDataForThread(0);
|
||||||
|
@ -1461,27 +1384,23 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a static prim moves or becomes static
|
/// Called when a static prim moves or becomes static
|
||||||
/// Places the prim in a space one the static sub-spaces grid
|
/// Places the prim in a space one the static space
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="geom">the pointer to the geom that moved</param>
|
/// <param name="geom">the pointer to the geom that moved</param>
|
||||||
/// <param name="pos">the position that the geom moved to</param>
|
|
||||||
/// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
|
/// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
|
||||||
/// <returns>a pointer to the new space it's in</returns>
|
/// <returns>a pointer to the new space it's in</returns>
|
||||||
public IntPtr MoveGeomToStaticSpace(IntPtr geom, Vector3 pos, IntPtr currentspace)
|
public IntPtr MoveGeomToStaticSpace(IntPtr geom, IntPtr currentspace)
|
||||||
{
|
{
|
||||||
// moves a prim into another static sub-space or from another space into a static sub-space
|
// moves a prim into static sub-space
|
||||||
|
|
||||||
// Called ODEPrim so
|
// Called ODEPrim so
|
||||||
// it's already in locked space.
|
// it's already in locked space.
|
||||||
|
|
||||||
if (geom == IntPtr.Zero) // shouldn't happen
|
if (geom == IntPtr.Zero) // shouldn't happen
|
||||||
return IntPtr.Zero;
|
return IntPtr.Zero;
|
||||||
|
|
||||||
// get the static sub-space for current position
|
if (StaticSpace == currentspace) // if we are there all done
|
||||||
IntPtr newspace = calculateSpaceForGeom(pos);
|
return StaticSpace;
|
||||||
|
|
||||||
if (newspace == currentspace) // if we are there all done
|
|
||||||
return newspace;
|
|
||||||
|
|
||||||
// else remove it from its current space
|
// else remove it from its current space
|
||||||
if (currentspace != IntPtr.Zero && d.SpaceQuery(currentspace, geom))
|
if (currentspace != IntPtr.Zero && d.SpaceQuery(currentspace, geom))
|
||||||
|
@ -1516,44 +1435,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
{
|
{
|
||||||
d.SpaceDestroy(currentspace);
|
d.SpaceDestroy(currentspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// put the geom in the newspace
|
// put the geom in the newspace
|
||||||
waitForSpaceUnlock(newspace);
|
waitForSpaceUnlock(StaticSpace);
|
||||||
d.SpaceAdd(newspace, geom);
|
d.SpaceAdd(StaticSpace, geom);
|
||||||
|
|
||||||
// let caller know this newspace
|
return StaticSpace;
|
||||||
return newspace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calculates the space the prim should be in by its position
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
/// <returns>a pointer to the space. This could be a new space or reused space.</returns>
|
|
||||||
public IntPtr calculateSpaceForGeom(Vector3 pos)
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
if (pos.X < 0)
|
|
||||||
return staticPrimspaceOffRegion[0];
|
|
||||||
|
|
||||||
if (pos.Y < 0)
|
|
||||||
return staticPrimspaceOffRegion[2];
|
|
||||||
|
|
||||||
x = (int)(pos.X * spacesPerMeterX);
|
|
||||||
if (x > spaceGridMaxX)
|
|
||||||
return staticPrimspaceOffRegion[1];
|
|
||||||
|
|
||||||
y = (int)(pos.Y * spacesPerMeterY);
|
|
||||||
if (y > spaceGridMaxY)
|
|
||||||
return staticPrimspaceOffRegion[3];
|
|
||||||
|
|
||||||
return staticPrimspace[x, y];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -1642,6 +1534,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override float Simulate(float reqTimeStep)
|
public override float Simulate(float reqTimeStep)
|
||||||
{
|
{
|
||||||
|
if (world == IntPtr.Zero)
|
||||||
|
return 0;
|
||||||
|
|
||||||
double now = Util.GetTimeStamp();
|
double now = Util.GetTimeStamp();
|
||||||
double timeStep = now - m_lastframe;
|
double timeStep = now - m_lastframe;
|
||||||
m_lastframe = now;
|
m_lastframe = now;
|
||||||
|
@ -1680,9 +1575,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
double maxChangestime = (int)(reqTimeStep * 500f); // half the time
|
double maxChangestime = (int)(reqTimeStep * 500f); // half the time
|
||||||
double maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time
|
double maxLoopTime = (int)(reqTimeStep * 1200f); // 1.2 the time
|
||||||
|
|
||||||
// double collisionTime = 0;
|
|
||||||
// double qstepTIme = 0;
|
double collisionTime = 0;
|
||||||
// double tmpTime = 0;
|
double qstepTIme = 0;
|
||||||
|
double tmpTime = 0;
|
||||||
|
double changestot = 0;
|
||||||
|
double collisonRepo = 0;
|
||||||
|
double updatesTime = 0;
|
||||||
|
double moveTime = 0;
|
||||||
|
double rayTime = 0;
|
||||||
|
|
||||||
d.AllocateODEDataForThread(~0U);
|
d.AllocateODEDataForThread(~0U);
|
||||||
|
|
||||||
|
@ -1720,6 +1621,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
m_global_contactcount = 0;
|
m_global_contactcount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
tmpTime = Util.GetTimeStampMS();
|
||||||
|
|
||||||
// Move characters
|
// Move characters
|
||||||
lock (_characters)
|
lock (_characters)
|
||||||
{
|
{
|
||||||
|
@ -1747,13 +1650,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
aprim.Move();
|
aprim.Move();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
moveTime += Util.GetTimeStampMS() - tmpTime;
|
||||||
|
|
||||||
|
tmpTime = Util.GetTimeStampMS();
|
||||||
m_rayCastManager.ProcessQueuedRequests();
|
m_rayCastManager.ProcessQueuedRequests();
|
||||||
|
rayTime += Util.GetTimeStampMS() - tmpTime;
|
||||||
|
|
||||||
// tmpTime = Util.GetTimeStampMS();
|
tmpTime = Util.GetTimeStampMS();
|
||||||
collision_optimized();
|
collision_optimized();
|
||||||
// collisionTime += Util.GetTimeStampMS() - tmpTime;
|
collisionTime += Util.GetTimeStampMS() - tmpTime;
|
||||||
|
|
||||||
|
tmpTime = Util.GetTimeStampMS();
|
||||||
lock(_collisionEventPrimRemove)
|
lock(_collisionEventPrimRemove)
|
||||||
{
|
{
|
||||||
foreach (PhysicsActor obj in _collisionEventPrimRemove)
|
foreach (PhysicsActor obj in _collisionEventPrimRemove)
|
||||||
|
@ -1792,12 +1699,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
foreach(OdePrim prm in sleepers)
|
foreach(OdePrim prm in sleepers)
|
||||||
prm.SleeperAddCollisionEvents();
|
prm.SleeperAddCollisionEvents();
|
||||||
sleepers.Clear();
|
sleepers.Clear();
|
||||||
|
collisonRepo += Util.GetTimeStampMS() - tmpTime;
|
||||||
|
|
||||||
|
|
||||||
// do a ode simulation step
|
// do a ode simulation step
|
||||||
// tmpTime = Util.GetTimeStampMS();
|
tmpTime = Util.GetTimeStampMS();
|
||||||
d.WorldQuickStep(world, ODE_STEPSIZE);
|
d.WorldQuickStep(world, ODE_STEPSIZE);
|
||||||
d.JointGroupEmpty(contactgroup);
|
d.JointGroupEmpty(contactgroup);
|
||||||
// qstepTIme += Util.GetTimeStampMS() - tmpTime;
|
qstepTIme += Util.GetTimeStampMS() - tmpTime;
|
||||||
|
|
||||||
// update managed ideia of physical data and do updates to core
|
// update managed ideia of physical data and do updates to core
|
||||||
/*
|
/*
|
||||||
|
@ -1815,7 +1724,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
// tmpTime = Util.GetTimeStampMS();
|
||||||
lock (_activegroups)
|
lock (_activegroups)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -1828,6 +1737,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// updatesTime += Util.GetTimeStampMS() - tmpTime;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1835,10 +1745,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
// ode.dunlock(world);
|
// ode.dunlock(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
step_time -= ODE_STEPSIZE;
|
step_time -= ODE_STEPSIZE;
|
||||||
nodeframes++;
|
nodeframes++;
|
||||||
|
|
||||||
looptimeMS = Util.GetTimeStampMS() - loopstartMS;
|
looptimeMS = Util.GetTimeStampMS() - loopstartMS;
|
||||||
|
|
||||||
if (looptimeMS > maxLoopTime)
|
if (looptimeMS > maxLoopTime)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1855,9 +1767,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
_badCharacter.Clear();
|
_badCharacter.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// information block for in debug breakpoint only
|
|
||||||
/*
|
/*
|
||||||
|
// information block for in debug breakpoint only
|
||||||
|
|
||||||
int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
|
int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
|
||||||
int ntopstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
|
int ntopstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
|
||||||
int ngroundgeoms = d.SpaceGetNumGeoms(GroundSpace);
|
int ngroundgeoms = d.SpaceGetNumGeoms(GroundSpace);
|
||||||
|
@ -1899,14 +1811,23 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
int nbodies = d.NTotalBodies;
|
int nbodies = d.NTotalBodies;
|
||||||
int ngeoms = d.NTotalGeoms;
|
int ngeoms = d.NTotalGeoms;
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
|
|
||||||
looptimeMS /= nodeframes;
|
looptimeMS /= nodeframes;
|
||||||
if(looptimeMS > 0.080)
|
collisionTime /= nodeframes;
|
||||||
|
qstepTIme /= nodeframes;
|
||||||
|
changestot /= nodeframes;
|
||||||
|
collisonRepo /= nodeframes;
|
||||||
|
updatesTime /= nodeframes;
|
||||||
|
moveTime /= nodeframes;
|
||||||
|
rayTime /= nodeframes;
|
||||||
|
|
||||||
|
if(looptimeMS > .05)
|
||||||
{
|
{
|
||||||
collisionTime /= nodeframes;
|
|
||||||
qstepTIme /= nodeframes;
|
|
||||||
}
|
}
|
||||||
*/
|
/*
|
||||||
// Finished with all sim stepping. If requested, dump world state to file for debugging.
|
// Finished with all sim stepping. If requested, dump world state to file for debugging.
|
||||||
// TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
|
// TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
|
||||||
// TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
|
// TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
|
||||||
|
@ -1925,7 +1846,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
|
d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fps = (float)nodeframes * ODE_STEPSIZE / reqTimeStep;
|
fps = (float)nodeframes * ODE_STEPSIZE / reqTimeStep;
|
||||||
|
|
||||||
if(step_time < HalfOdeStep)
|
if(step_time < HalfOdeStep)
|
||||||
|
|
Loading…
Reference in New Issue