ubitode: create and use 4 off world collision spaces for offworld static prims

avinationmerge
UbitUmarov 2012-06-30 08:49:07 +01:00
parent 38cdf77cef
commit ec7c7fe5f8
1 changed files with 38 additions and 11 deletions

View File

@ -302,6 +302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// split static geometry collision into a grid as before // split static geometry collision into a grid as before
private IntPtr[,] staticPrimspace; private IntPtr[,] staticPrimspace;
private IntPtr[] staticPrimspaceOffRegion;
public Object OdeLock; public Object OdeLock;
private static Object SimulationLock; private static Object SimulationLock;
@ -551,6 +552,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// create all spaces now // create all spaces now
int i, j; int i, j;
IntPtr newspace; IntPtr newspace;
for (i = 0; i < spaceGridMaxX; i++) for (i = 0; i < spaceGridMaxX; i++)
for (j = 0; j < spaceGridMaxY; j++) for (j = 0; j < spaceGridMaxY; j++)
{ {
@ -573,6 +575,29 @@ namespace OpenSim.Region.Physics.OdePlugin
// let this now be real maximum values // let this now be real maximum values
spaceGridMaxX--; spaceGridMaxX--;
spaceGridMaxY--; 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 = DateTime.UtcNow; m_lastframe = DateTime.UtcNow;
} }
@ -1650,20 +1675,22 @@ namespace OpenSim.Region.Physics.OdePlugin
public IntPtr calculateSpaceForGeom(Vector3 pos) public IntPtr calculateSpaceForGeom(Vector3 pos)
{ {
int x, y; int x, y;
if (pos.X < 0)
return staticPrimspaceOffRegion[0];
if (pos.Y < 0)
return staticPrimspaceOffRegion[2];
x = (int)(pos.X * spacesPerMeter); x = (int)(pos.X * spacesPerMeter);
if (x < 0) if (x > spaceGridMaxX)
x = 0; return staticPrimspaceOffRegion[1];
else if (x > spaceGridMaxX)
x = spaceGridMaxX;
y = (int)(pos.Y * spacesPerMeter); y = (int)(pos.Y * spacesPerMeter);
if (y < 0) if (y > spaceGridMaxY)
y = 0; return staticPrimspaceOffRegion[3];
else if (y >spaceGridMaxY)
y = spaceGridMaxY;
IntPtr tmpSpace = staticPrimspace[x, y]; return staticPrimspace[x, y];
return tmpSpace;
} }
#endregion #endregion