aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs108
1 files changed, 62 insertions, 46 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index b7030f1..f97b49b 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -311,6 +311,9 @@ namespace OpenSim.Region.Physics.OdePlugin
311 311
312 private volatile int m_global_contactcount = 0; 312 private volatile int m_global_contactcount = 0;
313 313
314 private Vector3 m_worldOffset = Vector3.Zero;
315 public Vector2 WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize);
316
314 private ODERayCastRequestManager m_rayCastManager; 317 private ODERayCastRequestManager m_rayCastManager;
315 318
316 /// <summary> 319 /// <summary>
@@ -348,10 +351,10 @@ namespace OpenSim.Region.Physics.OdePlugin
348 } 351 }
349 352
350 // zero out a heightmap array float array (single dimension [flattened])) 353 // zero out a heightmap array float array (single dimension [flattened]))
351 if ((int)Constants.RegionSize == 256) 354 if ((int)WorldExtents.X == 256 && (int)m_worldOffset.Y == 256)
352 _heightmap = new float[514*514]; 355 _heightmap = new float[514*514];
353 else 356 else
354 _heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))]; 357 _heightmap = new float[(((int)WorldExtents.Y + 2) * ((int)WorldExtents.X + 2))];
355 _watermap = new float[258 * 258]; 358 _watermap = new float[258 * 258];
356 359
357 // Zero out the prim spaces array (we split our space into smaller spaces so 360 // Zero out the prim spaces array (we split our space into smaller spaces so
@@ -1556,7 +1559,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1556 } 1559 }
1557 1560
1558 #endregion 1561 #endregion
1559 1562
1563 public override void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents)
1564 {
1565 m_worldOffset = offset;
1566 WorldExtents = new Vector2(extents.X, extents.Y);
1567 }
1560// Recovered for use by fly height. Kitto Flora 1568// Recovered for use by fly height. Kitto Flora
1561 public float GetTerrainHeightAtXY(float x, float y) 1569 public float GetTerrainHeightAtXY(float x, float y)
1562 { 1570 {
@@ -1568,14 +1576,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1568 // Is there any reason that we don't do this in ScenePresence? 1576 // Is there any reason that we don't do this in ScenePresence?
1569 // The only physics engine that benefits from it in the physics plugin is this one 1577 // The only physics engine that benefits from it in the physics plugin is this one
1570 1578
1571 if ((int)x > Constants.RegionSize || (int)y > Constants.RegionSize || 1579 if ((int)x > WorldExtents.X || (int)y > WorldExtents.Y ||
1572 (int)x < 0.001f || (int)y < 0.001f) 1580 (int)x < 0.001f || (int)y < 0.001f)
1573 return 0; 1581 return 0;
1574 1582
1575 index = (int) ((int)y * Constants.RegionSize + (int)x); 1583 index = (int)((int)y * WorldExtents.Y + (int)x);
1576 1584
1577 if (index < _origheightmap.Length) 1585 if (index < _origheightmap.Length)
1578 return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; 1586 return (float)_origheightmap[(int)y * (int)WorldExtents.Y + (int)x];
1579 else 1587 else
1580 return 0; 1588 return 0;
1581 } 1589 }
@@ -1646,6 +1654,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1646 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 1654 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation,
1647 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1655 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
1648 { 1656 {
1657
1649 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 1658 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z);
1650 //pos.X = position.X; 1659 //pos.X = position.X;
1651 //pos.Y = position.Y; 1660 //pos.Y = position.Y;
@@ -2548,6 +2557,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2548 if (framecount >= int.MaxValue) 2557 if (framecount >= int.MaxValue)
2549 framecount = 0; 2558 framecount = 0;
2550 2559
2560 if (m_worldOffset != Vector3.Zero)
2561 return 0;
2562
2551 framecount++; 2563 framecount++;
2552 2564
2553 float fps = 0; 2565 float fps = 0;
@@ -3006,14 +3018,14 @@ namespace OpenSim.Region.Physics.OdePlugin
3006 public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) 3018 public float[] ResizeTerrain512NearestNeighbour(float[] heightMap)
3007 { 3019 {
3008 float[] returnarr = new float[262144]; 3020 float[] returnarr = new float[262144];
3009 float[,] resultarr = new float[m_regionWidth, m_regionHeight]; 3021 float[,] resultarr = new float[(int)WorldExtents.X, (int)WorldExtents.Y];
3010 3022
3011 // Filling out the array into its multi-dimensional components 3023 // Filling out the array into its multi-dimensional components
3012 for (int y = 0; y < m_regionHeight; y++) 3024 for (int y = 0; y < WorldExtents.Y; y++)
3013 { 3025 {
3014 for (int x = 0; x < m_regionWidth; x++) 3026 for (int x = 0; x < WorldExtents.X; x++)
3015 { 3027 {
3016 resultarr[y, x] = heightMap[y * m_regionWidth + x]; 3028 resultarr[y, x] = heightMap[y * (int)WorldExtents.Y + x];
3017 } 3029 }
3018 } 3030 }
3019 3031
@@ -3077,21 +3089,21 @@ namespace OpenSim.Region.Physics.OdePlugin
3077 // on single loop. 3089 // on single loop.
3078 3090
3079 float[,] resultarr2 = new float[512, 512]; 3091 float[,] resultarr2 = new float[512, 512];
3080 for (int y = 0; y < m_regionHeight; y++) 3092 for (int y = 0; y < WorldExtents.Y; y++)
3081 { 3093 {
3082 for (int x = 0; x < m_regionWidth; x++) 3094 for (int x = 0; x < WorldExtents.X; x++)
3083 { 3095 {
3084 resultarr2[y * 2, x * 2] = resultarr[y, x]; 3096 resultarr2[y * 2, x * 2] = resultarr[y, x];
3085 3097
3086 if (y < m_regionHeight) 3098 if (y < WorldExtents.Y)
3087 { 3099 {
3088 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; 3100 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x];
3089 } 3101 }
3090 if (x < m_regionWidth) 3102 if (x < WorldExtents.X)
3091 { 3103 {
3092 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; 3104 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x];
3093 } 3105 }
3094 if (x < m_regionWidth && y < m_regionHeight) 3106 if (x < WorldExtents.X && y < WorldExtents.Y)
3095 { 3107 {
3096 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x]; 3108 resultarr2[(y * 2) + 1, (x * 2) + 1] = resultarr[y, x];
3097 } 3109 }
@@ -3119,14 +3131,14 @@ namespace OpenSim.Region.Physics.OdePlugin
3119 public float[] ResizeTerrain512Interpolation(float[] heightMap) 3131 public float[] ResizeTerrain512Interpolation(float[] heightMap)
3120 { 3132 {
3121 float[] returnarr = new float[262144]; 3133 float[] returnarr = new float[262144];
3122 float[,] resultarr = new float[m_regionWidth,m_regionHeight]; 3134 float[,] resultarr = new float[(int)WorldExtents.X,(int)WorldExtents.Y];
3123 3135
3124 // Filling out the array into its multi-dimensional components 3136 // Filling out the array into its multi-dimensional components
3125 for (int y = 0; y < m_regionHeight; y++) 3137 for (int y = 0; y < WorldExtents.Y; y++)
3126 { 3138 {
3127 for (int x = 0; x < m_regionWidth; x++) 3139 for (int x = 0; x < WorldExtents.X; x++)
3128 { 3140 {
3129 resultarr[y, x] = heightMap[y*m_regionWidth + x]; 3141 resultarr[y, x] = heightMap[y*(int)WorldExtents.Y + x];
3130 } 3142 }
3131 } 3143 }
3132 3144
@@ -3190,17 +3202,17 @@ namespace OpenSim.Region.Physics.OdePlugin
3190 // on single loop. 3202 // on single loop.
3191 3203
3192 float[,] resultarr2 = new float[512,512]; 3204 float[,] resultarr2 = new float[512,512];
3193 for (int y = 0; y < m_regionHeight; y++) 3205 for (int y = 0; y < WorldExtents.Y; y++)
3194 { 3206 {
3195 for (int x = 0; x < m_regionWidth; x++) 3207 for (int x = 0; x < WorldExtents.X; x++)
3196 { 3208 {
3197 resultarr2[y*2, x*2] = resultarr[y, x]; 3209 resultarr2[y*2, x*2] = resultarr[y, x];
3198 3210
3199 if (y < m_regionHeight) 3211 if (y < WorldExtents.Y)
3200 { 3212 {
3201 if (y + 1 < m_regionHeight) 3213 if (y + 1 < WorldExtents.Y)
3202 { 3214 {
3203 if (x + 1 < m_regionWidth) 3215 if (x + 1 < WorldExtents.X)
3204 { 3216 {
3205 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] + 3217 resultarr2[(y*2) + 1, x*2] = ((resultarr[y, x] + resultarr[y + 1, x] +
3206 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3218 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3215,11 +3227,11 @@ namespace OpenSim.Region.Physics.OdePlugin
3215 resultarr2[(y*2) + 1, x*2] = resultarr[y, x]; 3227 resultarr2[(y*2) + 1, x*2] = resultarr[y, x];
3216 } 3228 }
3217 } 3229 }
3218 if (x < m_regionWidth) 3230 if (x < WorldExtents.X)
3219 { 3231 {
3220 if (x + 1 < m_regionWidth) 3232 if (x + 1 < WorldExtents.X)
3221 { 3233 {
3222 if (y + 1 < m_regionHeight) 3234 if (y + 1 < WorldExtents.Y)
3223 { 3235 {
3224 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + 3236 resultarr2[y*2, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
3225 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3237 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3234,9 +3246,9 @@ namespace OpenSim.Region.Physics.OdePlugin
3234 resultarr2[y*2, (x*2) + 1] = resultarr[y, x]; 3246 resultarr2[y*2, (x*2) + 1] = resultarr[y, x];
3235 } 3247 }
3236 } 3248 }
3237 if (x < m_regionWidth && y < m_regionHeight) 3249 if (x < WorldExtents.X && y < WorldExtents.Y)
3238 { 3250 {
3239 if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight)) 3251 if ((x + 1 < WorldExtents.X) && (y + 1 < WorldExtents.Y))
3240 { 3252 {
3241 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + 3253 resultarr2[(y*2) + 1, (x*2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] +
3242 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4); 3254 resultarr[y, x + 1] + resultarr[y + 1, x + 1])/4);
@@ -3274,24 +3286,26 @@ namespace OpenSim.Region.Physics.OdePlugin
3274 // this._heightmap[i] = (double)heightMap[i]; 3286 // this._heightmap[i] = (double)heightMap[i];
3275 // dbm (danx0r) -- creating a buffer zone of one extra sample all around 3287 // dbm (danx0r) -- creating a buffer zone of one extra sample all around
3276 _origheightmap = heightMap; // Used for Fly height. Kitto Flora 3288 _origheightmap = heightMap; // Used for Fly height. Kitto Flora
3277 uint heightmapWidth = m_regionWidth + 1; 3289 uint heightmapWidth = (uint)WorldExtents.X + 1;
3278 uint heightmapHeight = m_regionHeight + 1; 3290 uint heightmapHeight = (uint)WorldExtents.Y + 1;
3279 3291
3280 uint heightmapWidthSamples; 3292 uint heightmapWidthSamples;
3281 3293
3282 uint heightmapHeightSamples; 3294 uint heightmapHeightSamples;
3283 if (((int)Constants.RegionSize) == 256) 3295 /*
3296 if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3284 { 3297 {
3285 heightmapWidthSamples = 2*m_regionWidth + 2; 3298 heightmapWidthSamples = 2 * (uint)m_worldExtents.X + 2;
3286 heightmapHeightSamples = 2*m_regionHeight + 2; 3299 heightmapHeightSamples = 2*(uint)m_worldExtents.Y + 2;
3287 heightmapWidth++; 3300 heightmapWidth++;
3288 heightmapHeight++; 3301 heightmapHeight++;
3289 } 3302 }
3290 else 3303 else
3291 { 3304 {
3292 heightmapWidthSamples = m_regionWidth + 1; 3305 */
3293 heightmapHeightSamples = m_regionHeight + 1; 3306 heightmapWidthSamples = (uint)WorldExtents.X + 1;
3294 } 3307 heightmapHeightSamples = (uint)WorldExtents.Y + 1;
3308 //}
3295 3309
3296 const float scale = 1.0f; 3310 const float scale = 1.0f;
3297 const float offset = 0.0f; 3311 const float offset = 0.0f;
@@ -3300,12 +3314,12 @@ namespace OpenSim.Region.Physics.OdePlugin
3300 3314
3301 3315
3302 //Double resolution 3316 //Double resolution
3303 if (((int)Constants.RegionSize) == 256) 3317 //if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3304 heightMap = ResizeTerrain512Interpolation(heightMap); 3318 // heightMap = ResizeTerrain512Interpolation(heightMap);
3305 3319
3306 int regionsize = (int)Constants.RegionSize; 3320
3307 if (regionsize == 256) 3321 //if (((int)m_worldExtents.X) == 256 && (int)m_worldExtents.Y == 256)
3308 regionsize = 512; 3322 // regionsize = 512;
3309 3323
3310 float hfmin = 2000; 3324 float hfmin = 2000;
3311 float hfmax = -2000; 3325 float hfmax = -2000;
@@ -3313,10 +3327,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3313 { 3327 {
3314 for (int y = 0; y < heightmapHeightSamples; y++) 3328 for (int y = 0; y < heightmapHeightSamples; y++)
3315 { 3329 {
3316 int xx = Util.Clip(x - 1, 0, regionsize - 1); 3330 int xx = Util.Clip(x - 1, 0, (int)WorldExtents.X - 1);
3317 int yy = Util.Clip(y - 1, 0, regionsize - 1); 3331 int yy = Util.Clip(y - 1, 0, (int)WorldExtents.Y - 1);
3318 3332
3319 float val = heightMap[yy*regionsize + xx]; 3333 float val = heightMap[yy*(int)WorldExtents.Y + xx];
3320 _heightmap[x*heightmapHeightSamples + y] = val; 3334 _heightmap[x*heightmapHeightSamples + y] = val;
3321 hfmin = (val < hfmin) ? val : hfmin; 3335 hfmin = (val < hfmin) ? val : hfmin;
3322 hfmax = (val > hfmax) ? val : hfmax; 3336 hfmax = (val > hfmax) ? val : hfmax;
@@ -3357,7 +3371,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3357 3371
3358 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 3372 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
3359 d.GeomSetRotation(LandGeom, ref R); 3373 d.GeomSetRotation(LandGeom, ref R);
3360 d.GeomSetPosition(LandGeom, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, 0); 3374 d.GeomSetPosition(LandGeom, (int)WorldExtents.X * 0.5f, (int)WorldExtents.Y * 0.5f, 0);
3361 } 3375 }
3362 } 3376 }
3363 3377
@@ -3370,6 +3384,8 @@ namespace OpenSim.Region.Physics.OdePlugin
3370 return waterlevel; 3384 return waterlevel;
3371 } 3385 }
3372 3386
3387
3388
3373 public override void SetWaterLevel(float baseheight) 3389 public override void SetWaterLevel(float baseheight)
3374 { 3390 {
3375 waterlevel = baseheight; 3391 waterlevel = baseheight;