diff options
author | Robert Adams | 2012-09-13 08:11:54 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-15 15:31:29 -0700 |
commit | 2c5ff9399063080276a23bcd06fb696d653bef2e (patch) | |
tree | 3428eaff2697b562880c75f5f83eafcbb855c93e /OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |
parent | Add basic asset connector tests to check behaviour for normal, local and temp... (diff) | |
download | opensim-SC-2c5ff9399063080276a23bcd06fb696d653bef2e.zip opensim-SC-2c5ff9399063080276a23bcd06fb696d653bef2e.tar.gz opensim-SC-2c5ff9399063080276a23bcd06fb696d653bef2e.tar.bz2 opensim-SC-2c5ff9399063080276a23bcd06fb696d653bef2e.tar.xz |
BulletSim: Way too many changes in one commit.
Many changes to BSDynamic for readability and commentary.
Linkset hacking for vehicles: don't over mass the root prim.
Add parameter for link constraint solver iterations.
Correct uses of timestep in timescale calculations for vehicles.
Reorganize code/logic for making objects static and dynamic for readability
and use of API2.
Changed most calls in BSPrim to use API2 calls (the new way).
Avatars do not generate default Bullet collision events but do call up
to the simulator for every avatar. Reduces overhead.
Objects added to collision list only if they are processing collisions.
Reduces overhead especially for large numbers of avatars.
Generalize call for water height to GetWaterHeightAtXYZ().
Catch and correct exception getting terrain height when out of bounds.
Correct race condition in Terrain Manager where creation wasn't at taint-time.
Add API calls for constructing compound shapes.
Move NeedsMeshing() logic into object class.
Reorganize logic for object meshing to reduce rebuilding of meshs/hulls.
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 47d7199..d48462e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -154,27 +154,31 @@ public class BSTerrainManager | |||
154 | 154 | ||
155 | // The simulator wants to set a new heightmap for the terrain. | 155 | // The simulator wants to set a new heightmap for the terrain. |
156 | public void SetTerrain(float[] heightMap) { | 156 | public void SetTerrain(float[] heightMap) { |
157 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) | 157 | float[] localHeightMap = heightMap; |
158 | m_physicsScene.TaintedObject("TerrainManager.SetTerrain", delegate() | ||
158 | { | 159 | { |
159 | // If a child of a mega-region, we shouldn't have any terrain allocated for us | 160 | if (m_worldOffset != Vector3.Zero && m_parentScene != null) |
160 | ReleaseGroundPlaneAndTerrain(); | ||
161 | // If doing the mega-prim stuff and we are the child of the zero region, | ||
162 | // the terrain is added to our parent | ||
163 | if (m_parentScene is BSScene) | ||
164 | { | 161 | { |
165 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", | 162 | // If a child of a mega-region, we shouldn't have any terrain allocated for us |
166 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); | 163 | ReleaseGroundPlaneAndTerrain(); |
167 | ((BSScene)m_parentScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID, | 164 | // If doing the mega-prim stuff and we are the child of the zero region, |
168 | heightMap, m_worldOffset, m_worldOffset+DefaultRegionSize, false); | 165 | // the terrain is added to our parent |
166 | if (m_parentScene is BSScene) | ||
167 | { | ||
168 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", | ||
169 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); | ||
170 | ((BSScene)m_parentScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID, | ||
171 | localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); | ||
172 | } | ||
169 | } | 173 | } |
170 | } | 174 | else |
171 | else | 175 | { |
172 | { | 176 | // If not doing the mega-prim thing, just change the terrain |
173 | // If not doing the mega-prim thing, just change the terrain | 177 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); |
174 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); | ||
175 | 178 | ||
176 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, heightMap, m_worldOffset, m_worldOffset+DefaultRegionSize, false); | 179 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); |
177 | } | 180 | } |
181 | }); | ||
178 | } | 182 | } |
179 | 183 | ||
180 | // If called with no mapInfo for the terrain, this will create a new mapInfo and terrain | 184 | // If called with no mapInfo for the terrain, this will create a new mapInfo and terrain |
@@ -319,6 +323,8 @@ public class BSTerrainManager | |||
319 | 323 | ||
320 | // Make sure the new shape is processed. | 324 | // Make sure the new shape is processed. |
321 | BulletSimAPI.Activate2(mapInfo.terrainBody.Ptr, true); | 325 | BulletSimAPI.Activate2(mapInfo.terrainBody.Ptr, true); |
326 | |||
327 | m_terrainModified = true; | ||
322 | }; | 328 | }; |
323 | 329 | ||
324 | // There is the option to do the changes now (we're already in 'taint time'), or | 330 | // There is the option to do the changes now (we're already in 'taint time'), or |
@@ -357,6 +363,8 @@ public class BSTerrainManager | |||
357 | m_heightMaps.Add(terrainRegionBase, mapInfo); | 363 | m_heightMaps.Add(terrainRegionBase, mapInfo); |
358 | // Build the terrain | 364 | // Build the terrain |
359 | UpdateOrCreateTerrain(newTerrainID, heightMap, minCoords, maxCoords, true); | 365 | UpdateOrCreateTerrain(newTerrainID, heightMap, minCoords, maxCoords, true); |
366 | |||
367 | m_terrainModified = true; | ||
360 | }; | 368 | }; |
361 | 369 | ||
362 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. | 370 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. |
@@ -383,7 +391,7 @@ public class BSTerrainManager | |||
383 | private float lastHeightTX = 999999f; | 391 | private float lastHeightTX = 999999f; |
384 | private float lastHeightTY = 999999f; | 392 | private float lastHeightTY = 999999f; |
385 | private float lastHeight = HEIGHT_INITIAL_LASTHEIGHT; | 393 | private float lastHeight = HEIGHT_INITIAL_LASTHEIGHT; |
386 | public float GetTerrainHeightAtXY(float tX, float tY) | 394 | private float GetTerrainHeightAtXY(float tX, float tY) |
387 | { | 395 | { |
388 | // You'd be surprized at the number of times this routine is called | 396 | // You'd be surprized at the number of times this routine is called |
389 | // with the same parameters as last time. | 397 | // with the same parameters as last time. |
@@ -403,11 +411,18 @@ public class BSTerrainManager | |||
403 | { | 411 | { |
404 | float regionX = tX - offsetX; | 412 | float regionX = tX - offsetX; |
405 | float regionY = tY - offsetY; | 413 | float regionY = tY - offsetY; |
406 | if (regionX >= mapInfo.sizeX || regionX < 0f) regionX = 0; | ||
407 | if (regionY >= mapInfo.sizeY || regionY < 0f) regionY = 0; | ||
408 | int mapIndex = (int)regionY * (int)mapInfo.sizeY + (int)regionX; | 414 | int mapIndex = (int)regionY * (int)mapInfo.sizeY + (int)regionX; |
409 | ret = mapInfo.heightMap[mapIndex]; | 415 | try |
410 | m_terrainModified = false; | 416 | { |
417 | ret = mapInfo.heightMap[mapIndex]; | ||
418 | } | ||
419 | catch | ||
420 | { | ||
421 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. | ||
422 | m_physicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, x={2}, y={3}", | ||
423 | LogHeader, terrainBaseXY, regionX, regionY); | ||
424 | ret = HEIGHT_GETHEIGHT_RET; | ||
425 | } | ||
411 | // DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXY,bX={1},baseY={2},szX={3},szY={4},regX={5},regY={6},index={7},ht={8}", | 426 | // DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXY,bX={1},baseY={2},szX={3},szY={4},regX={5},regY={6},index={7},ht={8}", |
412 | // BSScene.DetailLogZero, offsetX, offsetY, mapInfo.sizeX, mapInfo.sizeY, regionX, regionY, mapIndex, ret); | 427 | // BSScene.DetailLogZero, offsetX, offsetY, mapInfo.sizeX, mapInfo.sizeY, regionX, regionY, mapIndex, ret); |
413 | } | 428 | } |
@@ -416,6 +431,7 @@ public class BSTerrainManager | |||
416 | m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}", | 431 | m_physicsScene.Logger.ErrorFormat("{0} GetTerrainHeightAtXY: terrain not found: region={1}, x={2}, y={3}", |
417 | LogHeader, m_physicsScene.RegionName, tX, tY); | 432 | LogHeader, m_physicsScene.RegionName, tX, tY); |
418 | } | 433 | } |
434 | m_terrainModified = false; | ||
419 | lastHeight = ret; | 435 | lastHeight = ret; |
420 | return ret; | 436 | return ret; |
421 | } | 437 | } |