aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs (renamed from OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs)42
1 files changed, 20 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
index e4fecc3..42fc11b 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
@@ -30,15 +30,14 @@ using System.Text;
30 30
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework; 32using OpenSim.Region.Framework;
33using OpenSim.Region.CoreModules; 33using OpenSim.Region.PhysicsModules.SharedBase;
34using OpenSim.Region.Physics.Manager;
35 34
36using Nini.Config; 35using Nini.Config;
37using log4net; 36using log4net;
38 37
39using OpenMetaverse; 38using OpenMetaverse;
40 39
41namespace OpenSim.Region.Physics.BulletSPlugin 40namespace OpenSim.Region.PhysicsModule.BulletS
42{ 41{
43public sealed class BSTerrainHeightmap : BSTerrainPhys 42public sealed class BSTerrainHeightmap : BSTerrainPhys
44{ 43{
@@ -58,7 +57,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
58 { 57 {
59 initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; 58 initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION;
60 } 59 }
61 m_mapInfo = new BulletHMapInfo(id, initialMap); 60 m_mapInfo = new BulletHMapInfo(id, initialMap, regionSize.X, regionSize.Y);
62 m_mapInfo.minCoords = minTerrainCoords; 61 m_mapInfo.minCoords = minTerrainCoords;
63 m_mapInfo.maxCoords = maxTerrainCoords; 62 m_mapInfo.maxCoords = maxTerrainCoords;
64 m_mapInfo.terrainRegionBase = TerrainBase; 63 m_mapInfo.terrainRegionBase = TerrainBase;
@@ -68,11 +67,11 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
68 67
69 // This minCoords and maxCoords passed in give the size of the terrain (min and max Z 68 // This minCoords and maxCoords passed in give the size of the terrain (min and max Z
70 // are the high and low points of the heightmap). 69 // are the high and low points of the heightmap).
71 public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, 70 public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap,
72 Vector3 minCoords, Vector3 maxCoords) 71 Vector3 minCoords, Vector3 maxCoords)
73 : base(physicsScene, regionBase, id) 72 : base(physicsScene, regionBase, id)
74 { 73 {
75 m_mapInfo = new BulletHMapInfo(id, initialMap); 74 m_mapInfo = new BulletHMapInfo(id, initialMap, maxCoords.X - minCoords.X, maxCoords.Y - minCoords.Y);
76 m_mapInfo.minCoords = minCoords; 75 m_mapInfo.minCoords = minCoords;
77 m_mapInfo.maxCoords = maxCoords; 76 m_mapInfo.maxCoords = maxCoords;
78 m_mapInfo.minZ = minCoords.Z; 77 m_mapInfo.minZ = minCoords.Z;
@@ -92,7 +91,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
92 private void BuildHeightmapTerrain() 91 private void BuildHeightmapTerrain()
93 { 92 {
94 // Create the terrain shape from the mapInfo 93 // Create the terrain shape from the mapInfo
95 m_mapInfo.terrainShape = PhysicsScene.PE.CreateTerrainShape( m_mapInfo.ID, 94 m_mapInfo.terrainShape = m_physicsScene.PE.CreateTerrainShape( m_mapInfo.ID,
96 new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ, 95 new Vector3(m_mapInfo.sizeX, m_mapInfo.sizeY, 0), m_mapInfo.minZ, m_mapInfo.maxZ,
97 m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin); 96 m_mapInfo.heightMap, 1f, BSParam.TerrainCollisionMargin);
98 97
@@ -103,26 +102,25 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
103 centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f); 102 centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f);
104 centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f); 103 centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f);
105 104
106 m_mapInfo.terrainBody = PhysicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape, 105 m_mapInfo.terrainBody = m_physicsScene.PE.CreateBodyWithDefaultMotionState(m_mapInfo.terrainShape,
107 m_mapInfo.ID, centerPos, Quaternion.Identity); 106 m_mapInfo.ID, centerPos, Quaternion.Identity);
108 107
109 // Set current terrain attributes 108 // Set current terrain attributes
110 PhysicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction); 109 m_physicsScene.PE.SetFriction(m_mapInfo.terrainBody, BSParam.TerrainFriction);
111 PhysicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction); 110 m_physicsScene.PE.SetHitFraction(m_mapInfo.terrainBody, BSParam.TerrainHitFraction);
112 PhysicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution); 111 m_physicsScene.PE.SetRestitution(m_mapInfo.terrainBody, BSParam.TerrainRestitution);
113 PhysicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT); 112 m_physicsScene.PE.SetCollisionFlags(m_mapInfo.terrainBody, CollisionFlags.CF_STATIC_OBJECT);
113
114 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
114 115
115 // Return the new terrain to the world of physical objects 116 // Return the new terrain to the world of physical objects
116 PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, m_mapInfo.terrainBody); 117 m_physicsScene.PE.AddObjectToWorld(m_physicsScene.World, m_mapInfo.terrainBody);
117 118
118 // redo its bounding box now that it is in the world 119 // redo its bounding box now that it is in the world
119 PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, m_mapInfo.terrainBody); 120 m_physicsScene.PE.UpdateSingleAabb(m_physicsScene.World, m_mapInfo.terrainBody);
120
121 m_mapInfo.terrainBody.collisionType = CollisionType.Terrain;
122 m_mapInfo.terrainBody.ApplyCollisionMask(PhysicsScene);
123 121
124 // Make it so the terrain will not move or be considered for movement. 122 // Make it so the terrain will not move or be considered for movement.
125 PhysicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION); 123 m_physicsScene.PE.ForceActivationState(m_mapInfo.terrainBody, ActivationState.DISABLE_SIMULATION);
126 124
127 return; 125 return;
128 } 126 }
@@ -134,9 +132,9 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
134 { 132 {
135 if (m_mapInfo.terrainBody.HasPhysicalBody) 133 if (m_mapInfo.terrainBody.HasPhysicalBody)
136 { 134 {
137 PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_mapInfo.terrainBody); 135 m_physicsScene.PE.RemoveObjectFromWorld(m_physicsScene.World, m_mapInfo.terrainBody);
138 // Frees both the body and the shape. 136 // Frees both the body and the shape.
139 PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_mapInfo.terrainBody); 137 m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_mapInfo.terrainBody);
140 } 138 }
141 } 139 }
142 m_mapInfo = null; 140 m_mapInfo = null;
@@ -155,7 +153,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
155 catch 153 catch
156 { 154 {
157 // Sometimes they give us wonky values of X and Y. Give a warning and return something. 155 // Sometimes they give us wonky values of X and Y. Give a warning and return something.
158 PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}", 156 m_physicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}",
159 LogHeader, m_mapInfo.terrainRegionBase, pos); 157 LogHeader, m_mapInfo.terrainRegionBase, pos);
160 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; 158 ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET;
161 } 159 }
@@ -165,7 +163,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
165 // The passed position is relative to the base of the region. 163 // The passed position is relative to the base of the region.
166 public override float GetWaterLevelAtXYZ(Vector3 pos) 164 public override float GetWaterLevelAtXYZ(Vector3 pos)
167 { 165 {
168 return PhysicsScene.SimpleWaterLevel; 166 return m_physicsScene.SimpleWaterLevel;
169 } 167 }
170} 168}
171} 169}