ubitode varsize ( Mega disabled till better checks )
parent
2e15ed80cd
commit
abeb2ec4b3
|
@ -170,6 +170,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
|
// private Dictionary<string, sCollisionData> m_storedCollisions = new Dictionary<string, sCollisionData>();
|
||||||
|
|
||||||
public bool OdeUbitLib = false;
|
public bool OdeUbitLib = false;
|
||||||
|
public bool m_suportCombine = false; // mega suport not tested
|
||||||
|
|
||||||
// private int threadid = 0;
|
// private int threadid = 0;
|
||||||
// private Random fluidRandomizer = new Random(Environment.TickCount);
|
// private Random fluidRandomizer = new Random(Environment.TickCount);
|
||||||
|
|
||||||
|
@ -187,8 +189,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public float AvatarFriction = 0;// 0.9f * 0.5f;
|
public float AvatarFriction = 0;// 0.9f * 0.5f;
|
||||||
|
|
||||||
private const uint m_regionWidth = Constants.RegionSize;
|
private uint m_regionWidth = Constants.RegionSize;
|
||||||
private const uint m_regionHeight = Constants.RegionSize;
|
private uint m_regionHeight = Constants.RegionSize;
|
||||||
|
|
||||||
public float ODE_STEPSIZE = 0.020f;
|
public float ODE_STEPSIZE = 0.020f;
|
||||||
public float HalfOdeStep = 0.01f;
|
public float HalfOdeStep = 0.01f;
|
||||||
|
@ -418,8 +420,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the mesh plugin
|
public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
|
||||||
// public override void Initialise(IMesher meshmerizer, IConfigSource config, RegionInfo region )
|
{
|
||||||
|
WorldExtents.X = regionExtent.X;
|
||||||
|
WorldExtents.Y = regionExtent.Y;
|
||||||
|
m_suportCombine = false;
|
||||||
|
Initialise(meshmerizer, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Initialise(IMesher meshmerizer, IConfigSource config)
|
public override void Initialise(IMesher meshmerizer, IConfigSource config)
|
||||||
{
|
{
|
||||||
// checkThread();
|
// checkThread();
|
||||||
|
@ -557,6 +566,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
|
spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
|
||||||
spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter);
|
spaceGridMaxY = (int)(WorldExtents.Y * spacesPerMeter);
|
||||||
|
|
||||||
|
if (spaceGridMaxX > 40)
|
||||||
|
spaceGridMaxX = 40;
|
||||||
|
if (spaceGridMaxY > 40)
|
||||||
|
spaceGridMaxY = 40;
|
||||||
|
|
||||||
staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY];
|
staticPrimspace = new IntPtr[spaceGridMaxX, spaceGridMaxY];
|
||||||
|
|
||||||
// create all spaces now
|
// create all spaces now
|
||||||
|
@ -1882,17 +1896,25 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public float GetTerrainHeightAtXY(float x, float y)
|
public float GetTerrainHeightAtXY(float x, float y)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
|
||||||
int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
|
||||||
|
|
||||||
|
|
||||||
IntPtr heightFieldGeom = IntPtr.Zero;
|
IntPtr heightFieldGeom = IntPtr.Zero;
|
||||||
|
|
||||||
// get region map
|
int offsetX = 0;
|
||||||
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
|
int offsetY = 0;
|
||||||
return 0f;
|
|
||||||
|
if (m_suportCombine)
|
||||||
|
{
|
||||||
|
offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
||||||
|
offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
||||||
|
// get region map
|
||||||
|
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!RegionTerrain.TryGetValue(Vector3.Zero , out heightFieldGeom))
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (heightFieldGeom == IntPtr.Zero)
|
if (heightFieldGeom == IntPtr.Zero)
|
||||||
return 0f;
|
return 0f;
|
||||||
|
@ -1917,28 +1939,30 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float dx;
|
float dx;
|
||||||
float dy;
|
float dy;
|
||||||
|
|
||||||
int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples
|
int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples
|
||||||
|
int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples
|
||||||
|
int regsize = regsizeX;
|
||||||
|
|
||||||
if (OdeUbitLib)
|
if (OdeUbitLib)
|
||||||
{
|
{
|
||||||
if (x < regsize - 1)
|
if (x < regsizeX - 1)
|
||||||
{
|
{
|
||||||
ix = (int)x;
|
ix = (int)x;
|
||||||
dx = x - (float)ix;
|
dx = x - (float)ix;
|
||||||
}
|
}
|
||||||
else // out world use external height
|
else // out world use external height
|
||||||
{
|
{
|
||||||
ix = regsize - 2;
|
ix = regsizeX - 2;
|
||||||
dx = 0;
|
dx = 0;
|
||||||
}
|
}
|
||||||
if (y < regsize - 1)
|
if (y < regsizeY - 1)
|
||||||
{
|
{
|
||||||
iy = (int)y;
|
iy = (int)y;
|
||||||
dy = y - (float)iy;
|
dy = y - (float)iy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iy = regsize - 2;
|
iy = regsizeY - 2;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1948,24 +1972,26 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// also flip x and y because of how map is done for ODE fliped axis
|
// also flip x and y because of how map is done for ODE fliped axis
|
||||||
// so ix,iy,dx and dy are inter exchanged
|
// so ix,iy,dx and dy are inter exchanged
|
||||||
|
|
||||||
if (x < regsize - 1)
|
regsize = regsizeY;
|
||||||
|
|
||||||
|
if (x < regsizeX - 1)
|
||||||
{
|
{
|
||||||
iy = (int)x;
|
iy = (int)x;
|
||||||
dy = x - (float)iy;
|
dy = x - (float)iy;
|
||||||
}
|
}
|
||||||
else // out world use external height
|
else // out world use external height
|
||||||
{
|
{
|
||||||
iy = regsize - 2;
|
iy = regsizeX - 2;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
}
|
}
|
||||||
if (y < regsize - 1)
|
if (y < regsizeY - 1)
|
||||||
{
|
{
|
||||||
ix = (int)y;
|
ix = (int)y;
|
||||||
dx = y - (float)ix;
|
dx = y - (float)ix;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ix = regsize - 2;
|
ix = regsizeY - 2;
|
||||||
dx = 0;
|
dx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2014,15 +2040,25 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public Vector3 GetTerrainNormalAtXY(float x, float y)
|
public Vector3 GetTerrainNormalAtXY(float x, float y)
|
||||||
{
|
{
|
||||||
int offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
|
||||||
int offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
|
||||||
|
|
||||||
IntPtr heightFieldGeom = IntPtr.Zero;
|
IntPtr heightFieldGeom = IntPtr.Zero;
|
||||||
Vector3 norm = new Vector3(0, 0, 1);
|
Vector3 norm = new Vector3(0, 0, 1);
|
||||||
|
|
||||||
// get region map
|
int offsetX = 0;
|
||||||
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
|
int offsetY = 0;
|
||||||
return norm;
|
|
||||||
|
if (m_suportCombine)
|
||||||
|
{
|
||||||
|
offsetX = ((int)(x / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
||||||
|
offsetY = ((int)(y / (int)Constants.RegionSize)) * (int)Constants.RegionSize;
|
||||||
|
// get region map
|
||||||
|
if (!RegionTerrain.TryGetValue(new Vector3(offsetX, offsetY, 0), out heightFieldGeom))
|
||||||
|
return norm; ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!RegionTerrain.TryGetValue(Vector3.Zero, out heightFieldGeom))
|
||||||
|
return norm; ;
|
||||||
|
}
|
||||||
|
|
||||||
if (heightFieldGeom == IntPtr.Zero)
|
if (heightFieldGeom == IntPtr.Zero)
|
||||||
return norm;
|
return norm;
|
||||||
|
@ -2047,32 +2083,34 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
float dx;
|
float dx;
|
||||||
float dy;
|
float dy;
|
||||||
|
|
||||||
|
int regsizeX = (int)WorldExtents.X + 3; // map size see setterrain number of samples
|
||||||
|
int regsizeY = (int)WorldExtents.Y + 3; // map size see setterrain number of samples
|
||||||
|
int regsize = regsizeX;
|
||||||
|
|
||||||
int regsize = (int)Constants.RegionSize + 3; // map size see setterrain number of samples
|
|
||||||
int xstep = 1;
|
int xstep = 1;
|
||||||
int ystep = regsize;
|
int ystep = regsizeX;
|
||||||
bool firstTri = false;
|
bool firstTri = false;
|
||||||
|
|
||||||
if (OdeUbitLib)
|
if (OdeUbitLib)
|
||||||
{
|
{
|
||||||
if (x < regsize - 1)
|
if (x < regsizeX - 1)
|
||||||
{
|
{
|
||||||
ix = (int)x;
|
ix = (int)x;
|
||||||
dx = x - (float)ix;
|
dx = x - (float)ix;
|
||||||
}
|
}
|
||||||
else // out world use external height
|
else // out world use external height
|
||||||
{
|
{
|
||||||
ix = regsize - 2;
|
ix = regsizeX - 2;
|
||||||
dx = 0;
|
dx = 0;
|
||||||
}
|
}
|
||||||
if (y < regsize - 1)
|
if (y < regsizeY - 1)
|
||||||
{
|
{
|
||||||
iy = (int)y;
|
iy = (int)y;
|
||||||
dy = y - (float)iy;
|
dy = y - (float)iy;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iy = regsize - 2;
|
iy = regsizeY - 2;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
}
|
}
|
||||||
firstTri = dy > dx;
|
firstTri = dy > dx;
|
||||||
|
@ -2080,29 +2118,31 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xstep = regsize;
|
xstep = regsizeY;
|
||||||
ystep = 1;
|
ystep = 1;
|
||||||
|
regsize = regsizeY;
|
||||||
|
|
||||||
// we still have square fixed size regions
|
// we still have square fixed size regions
|
||||||
// also flip x and y because of how map is done for ODE fliped axis
|
// also flip x and y because of how map is done for ODE fliped axis
|
||||||
// so ix,iy,dx and dy are inter exchanged
|
// so ix,iy,dx and dy are inter exchanged
|
||||||
if (x < regsize - 1)
|
if (x < regsizeX - 1)
|
||||||
{
|
{
|
||||||
iy = (int)x;
|
iy = (int)x;
|
||||||
dy = x - (float)iy;
|
dy = x - (float)iy;
|
||||||
}
|
}
|
||||||
else // out world use external height
|
else // out world use external height
|
||||||
{
|
{
|
||||||
iy = regsize - 2;
|
iy = regsizeX - 2;
|
||||||
dy = 0;
|
dy = 0;
|
||||||
}
|
}
|
||||||
if (y < regsize - 1)
|
if (y < regsizeY - 1)
|
||||||
{
|
{
|
||||||
ix = (int)y;
|
ix = (int)y;
|
||||||
dx = y - (float)ix;
|
dx = y - (float)ix;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ix = regsize - 2;
|
ix = regsizeY - 2;
|
||||||
dx = 0;
|
dx = 0;
|
||||||
}
|
}
|
||||||
firstTri = dx > dy;
|
firstTri = dx > dy;
|
||||||
|
@ -2175,8 +2215,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
float[] _heightmap;
|
float[] _heightmap;
|
||||||
|
|
||||||
uint heightmapWidth = Constants.RegionSize + 2;
|
uint regionsizeX = (uint)WorldExtents.X;
|
||||||
uint heightmapHeight = Constants.RegionSize + 2;
|
uint regionsizeY = (uint)WorldExtents.Y;
|
||||||
|
|
||||||
|
// map is rotated
|
||||||
|
uint heightmapWidth = regionsizeY + 2;
|
||||||
|
uint heightmapHeight = regionsizeX + 2;
|
||||||
|
|
||||||
uint heightmapWidthSamples = heightmapWidth + 1;
|
uint heightmapWidthSamples = heightmapWidth + 1;
|
||||||
uint heightmapHeightSamples = heightmapHeight + 1;
|
uint heightmapHeightSamples = heightmapHeight + 1;
|
||||||
|
@ -2188,7 +2232,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
const float thickness = 10f;
|
const float thickness = 10f;
|
||||||
const int wrap = 0;
|
const int wrap = 0;
|
||||||
|
|
||||||
uint regionsize = Constants.RegionSize;
|
|
||||||
|
|
||||||
float hfmin = float.MaxValue;
|
float hfmin = float.MaxValue;
|
||||||
float hfmax = float.MinValue;
|
float hfmax = float.MinValue;
|
||||||
|
@ -2196,7 +2239,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
uint xx;
|
uint xx;
|
||||||
uint yy;
|
uint yy;
|
||||||
|
|
||||||
uint maxXXYY = regionsize - 1;
|
uint maxXX = regionsizeX - 1;
|
||||||
|
uint maxYY = regionsizeY - 1;
|
||||||
// flipping map adding one margin all around so things don't fall in edges
|
// flipping map adding one margin all around so things don't fall in edges
|
||||||
|
|
||||||
uint xt = 0;
|
uint xt = 0;
|
||||||
|
@ -2204,13 +2248,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
for (uint x = 0; x < heightmapWidthSamples; x++)
|
for (uint x = 0; x < heightmapWidthSamples; x++)
|
||||||
{
|
{
|
||||||
if (x > 1 && xx < maxXXYY)
|
if (x > 1 && xx < maxXX)
|
||||||
xx++;
|
xx++;
|
||||||
yy = 0;
|
yy = 0;
|
||||||
for (uint y = 0; y < heightmapHeightSamples; y++)
|
for (uint y = 0; y < heightmapHeightSamples; y++)
|
||||||
{
|
{
|
||||||
if (y > 1 && y < maxXXYY)
|
if (y > 1 && y < maxYY)
|
||||||
yy += regionsize;
|
yy += regionsizeX;
|
||||||
|
|
||||||
val = heightMap[yy + xx];
|
val = heightMap[yy + xx];
|
||||||
if (val < 0.0f)
|
if (val < 0.0f)
|
||||||
|
@ -2224,6 +2268,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
}
|
}
|
||||||
xt += heightmapHeightSamples;
|
xt += heightmapHeightSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (OdeLock)
|
lock (OdeLock)
|
||||||
{
|
{
|
||||||
IntPtr GroundGeom = IntPtr.Zero;
|
IntPtr GroundGeom = IntPtr.Zero;
|
||||||
|
@ -2296,8 +2341,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
float[] _heightmap;
|
float[] _heightmap;
|
||||||
|
|
||||||
uint heightmapWidth = Constants.RegionSize + 2;
|
uint regionsizeX = (uint)WorldExtents.X;
|
||||||
uint heightmapHeight = Constants.RegionSize + 2;
|
uint regionsizeY = (uint)WorldExtents.Y;
|
||||||
|
|
||||||
|
uint heightmapWidth = regionsizeX + 2;
|
||||||
|
uint heightmapHeight = regionsizeY + 2;
|
||||||
|
|
||||||
uint heightmapWidthSamples = heightmapWidth + 1;
|
uint heightmapWidthSamples = heightmapWidth + 1;
|
||||||
uint heightmapHeightSamples = heightmapHeight + 1;
|
uint heightmapHeightSamples = heightmapHeight + 1;
|
||||||
|
@ -2305,14 +2353,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
_heightmap = new float[heightmapWidthSamples * heightmapHeightSamples];
|
_heightmap = new float[heightmapWidthSamples * heightmapHeightSamples];
|
||||||
|
|
||||||
|
|
||||||
uint regionsize = Constants.RegionSize;
|
|
||||||
|
|
||||||
float hfmin = float.MaxValue;
|
float hfmin = float.MaxValue;
|
||||||
// float hfmax = float.MinValue;
|
// float hfmax = float.MinValue;
|
||||||
float val;
|
float val;
|
||||||
|
|
||||||
|
|
||||||
uint maxXXYY = regionsize - 1;
|
uint maxXX = regionsizeX - 1;
|
||||||
|
uint maxYY = regionsizeY - 1;
|
||||||
// adding one margin all around so things don't fall in edges
|
// adding one margin all around so things don't fall in edges
|
||||||
|
|
||||||
uint xx;
|
uint xx;
|
||||||
|
@ -2321,12 +2368,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
for (uint y = 0; y < heightmapHeightSamples; y++)
|
for (uint y = 0; y < heightmapHeightSamples; y++)
|
||||||
{
|
{
|
||||||
if (y > 1 && y < maxXXYY)
|
if (y > 1 && y < maxYY)
|
||||||
yy += regionsize;
|
yy += regionsizeX;
|
||||||
xx = 0;
|
xx = 0;
|
||||||
for (uint x = 0; x < heightmapWidthSamples; x++)
|
for (uint x = 0; x < heightmapWidthSamples; x++)
|
||||||
{
|
{
|
||||||
if (x > 1 && x < maxXXYY)
|
if (x > 1 && x < maxXX)
|
||||||
xx++;
|
xx++;
|
||||||
|
|
||||||
val = heightMap[yy + xx];
|
val = heightMap[yy + xx];
|
||||||
|
@ -2409,7 +2456,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public override bool SupportsCombining()
|
public override bool SupportsCombining()
|
||||||
{
|
{
|
||||||
return true;
|
return m_suportCombine;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public override void UnCombine(PhysicsScene pScene)
|
public override void UnCombine(PhysicsScene pScene)
|
||||||
|
|
Loading…
Reference in New Issue