move characters (avatars) to own collision space, also fixing a problem

with previus code that was still assuming the avatar is g2
avinationmerge
UbitUmarov 2012-12-04 02:46:40 +00:00
parent fc1be7e41f
commit b6d29aa124
3 changed files with 47 additions and 14 deletions

View File

@ -708,21 +708,21 @@ namespace OpenSim.Region.Physics.OdePlugin
bot += midsz;
float topz = bot + topsz * 0.5f;
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
feetbox = d.CreateBox(_parent_scene.ActiveSpace, feetsx, feetsy, feetsz);
feetbox = d.CreateBox(_parent_scene.CharsSpace, feetsx, feetsy, feetsz);
d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags);
midbox = d.CreateBox(_parent_scene.ActiveSpace, midsx, midsy, midsz);
midbox = d.CreateBox(_parent_scene.CharsSpace, midsx, midsy, midsz);
d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(midbox, (uint)m_collisionFlags);
topbox = d.CreateBox(_parent_scene.ActiveSpace, topsx, topsy, topsz);
topbox = d.CreateBox(_parent_scene.CharsSpace, topsx, topsy, topsz);
d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories);
d.GeomSetCollideBits(topbox, (uint)m_collisionFlags);
bonebox = d.CreateBox(_parent_scene.ActiveSpace, bonesx, bonesy, bonesz);
bonebox = d.CreateBox(_parent_scene.CharsSpace, bonesx, bonesy, bonesz);
d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories);
d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags);
@ -828,21 +828,21 @@ namespace OpenSim.Region.Physics.OdePlugin
if (topbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(topbox);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(topbox);
topbox = IntPtr.Zero;
}
if (midbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(midbox);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(midbox);
midbox = IntPtr.Zero;
}
if (feetbox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(feetbox);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(feetbox);
feetbox = IntPtr.Zero;
}
@ -850,7 +850,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (bonebox != IntPtr.Zero)
{
_parent_scene.actor_name_map.Remove(bonebox);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
_parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace);
d.GeomDestroy(bonebox);
bonebox = IntPtr.Zero;
}

View File

@ -324,7 +324,10 @@ namespace OpenSim.Region.Physics.OdePlugin
{
// Collide tests
if ((CurrentRayFilter & FilterActiveSpace) != 0)
{
d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback);
d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback);
}
if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount))
d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback);
if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount))

View File

@ -299,6 +299,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr TopSpace; // the global space
public IntPtr ActiveSpace; // space for active prims
public IntPtr CharsSpace; // space for active prims
public IntPtr StaticSpace; // space for the static things around
public IntPtr GroundSpace; // space for ground
@ -372,21 +373,25 @@ namespace OpenSim.Region.Physics.OdePlugin
// now the major subspaces
ActiveSpace = d.HashSpaceCreate(TopSpace);
CharsSpace = d.HashSpaceCreate(TopSpace);
StaticSpace = d.HashSpaceCreate(TopSpace);
GroundSpace = d.HashSpaceCreate(TopSpace);
}
catch
{
// i must RtC#FM
// i did!
}
d.HashSpaceSetLevels(TopSpace, -2, 8);
d.HashSpaceSetLevels(ActiveSpace, -2, 8);
d.HashSpaceSetLevels(CharsSpace, -4, 3);
d.HashSpaceSetLevels(StaticSpace, -2, 8);
d.HashSpaceSetLevels(GroundSpace, 0, 8);
// demote to second level
d.SpaceSetSublevel(ActiveSpace, 1);
d.SpaceSetSublevel(CharsSpace, 1);
d.SpaceSetSublevel(StaticSpace, 1);
d.SpaceSetSublevel(GroundSpace, 1);
@ -396,11 +401,24 @@ namespace OpenSim.Region.Physics.OdePlugin
CollisionCategories.Phantom |
CollisionCategories.VolumeDtc
));
d.GeomSetCollideBits(ActiveSpace, 0);
d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom |
CollisionCategories.Character |
CollisionCategories.Phantom |
CollisionCategories.VolumeDtc
));
d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom |
CollisionCategories.Character |
CollisionCategories.Phantom |
CollisionCategories.VolumeDtc
));
d.GeomSetCollideBits(CharsSpace, 0);
d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space |
CollisionCategories.Geom |
CollisionCategories.Land |
CollisionCategories.Water |
// CollisionCategories.Land |
// CollisionCategories.Water |
CollisionCategories.Phantom |
CollisionCategories.VolumeDtc
));
@ -1271,6 +1289,9 @@ namespace OpenSim.Region.Physics.OdePlugin
d.SpaceCollide2(StaticSpace, chr.midbox, IntPtr.Zero, nearCallback);
d.SpaceCollide2(StaticSpace, chr.feetbox, IntPtr.Zero, nearCallback);
d.SpaceCollide2(StaticSpace, chr.bonebox, IntPtr.Zero, nearCallback);
// chars with chars
d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback);
// no coll with gnd
}
}
@ -1312,16 +1333,25 @@ namespace OpenSim.Region.Physics.OdePlugin
m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
}
}
// finally colide active things amoung them
// colide active amoung them
try
{
d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback);
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to collide Active with Characters space");
}
// and with chars
try
{
d.SpaceCollide2(ActiveSpace, CharsSpace,IntPtr.Zero, nearCallback);
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to collide in Active space");
}
// _perloopContact.Clear();
// _perloopContact.Clear();
}
#endregion