diff options
author | Robert Adams | 2012-11-20 20:36:49 -0800 |
---|---|---|
committer | Robert Adams | 2012-11-21 16:43:21 -0800 |
commit | 34cbc738a84b7946a87e8bfd3bb04869519b3dee (patch) | |
tree | 1e0c0891022162f4aac9793ef5937c254bbaa2fa /OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |
parent | BulletSim: pull heightmap implementation out of the terrain manager so a mesh... (diff) | |
download | opensim-SC_OLD-34cbc738a84b7946a87e8bfd3bb04869519b3dee.zip opensim-SC_OLD-34cbc738a84b7946a87e8bfd3bb04869519b3dee.tar.gz opensim-SC_OLD-34cbc738a84b7946a87e8bfd3bb04869519b3dee.tar.bz2 opensim-SC_OLD-34cbc738a84b7946a87e8bfd3bb04869519b3dee.tar.xz |
BulletSim: enablement and debugging of mesh terrain.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index 3bb63cd..e9fd0cb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -44,10 +44,11 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
44 | { | 44 | { |
45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; | 45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; |
46 | 46 | ||
47 | BulletHeightMapInfo m_mapInfo; | 47 | BulletHeightMapInfo m_mapInfo = null; |
48 | 48 | ||
49 | public BSTerrainHeightmap(BSScene physicsScene, uint id, Vector3 regionSize) | 49 | // Constructor to build a default, flat heightmap terrain. |
50 | : base(physicsScene) | 50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) |
51 | : base(physicsScene, regionBase, id) | ||
51 | { | 52 | { |
52 | Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE); | 53 | Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE); |
53 | Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION); | 54 | Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION); |
@@ -60,21 +61,23 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
60 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 61 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); |
61 | m_mapInfo.minCoords = minTerrainCoords; | 62 | m_mapInfo.minCoords = minTerrainCoords; |
62 | m_mapInfo.maxCoords = maxTerrainCoords; | 63 | m_mapInfo.maxCoords = maxTerrainCoords; |
64 | m_mapInfo.terrainRegionBase = TerrainBase; | ||
63 | // Don't have to free any previous since we just got here. | 65 | // Don't have to free any previous since we just got here. |
64 | BuildHeightmapTerrain(); | 66 | BuildHeightmapTerrain(); |
65 | } | 67 | } |
66 | 68 | ||
67 | // This minCoords and maxCoords passed in give the size of the terrain (min and max Z | 69 | // This minCoords and maxCoords passed in give the size of the terrain (min and max Z |
68 | // are the high and low points of the heightmap). | 70 | // are the high and low points of the heightmap). |
69 | public BSTerrainHeightmap(BSScene physicsScene, uint id, float[] initialMap, | 71 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, |
70 | Vector3 minCoords, Vector3 maxCoords) | 72 | Vector3 minCoords, Vector3 maxCoords) |
71 | : base(physicsScene) | 73 | : base(physicsScene, regionBase, id) |
72 | { | 74 | { |
73 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | 75 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); |
74 | m_mapInfo.minCoords = minCoords; | 76 | m_mapInfo.minCoords = minCoords; |
75 | m_mapInfo.maxCoords = maxCoords; | 77 | m_mapInfo.maxCoords = maxCoords; |
76 | m_mapInfo.minZ = minCoords.Z; | 78 | m_mapInfo.minZ = minCoords.Z; |
77 | m_mapInfo.maxZ = maxCoords.Z; | 79 | m_mapInfo.maxZ = maxCoords.Z; |
80 | m_mapInfo.terrainRegionBase = TerrainBase; | ||
78 | 81 | ||
79 | // Don't have to free any previous since we just got here. | 82 | // Don't have to free any previous since we just got here. |
80 | BuildHeightmapTerrain(); | 83 | BuildHeightmapTerrain(); |
@@ -135,12 +138,10 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
135 | { | 138 | { |
136 | if (m_mapInfo.terrainBody.ptr != IntPtr.Zero) | 139 | if (m_mapInfo.terrainBody.ptr != IntPtr.Zero) |
137 | { | 140 | { |
138 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr)) | 141 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); |
139 | { | 142 | // Frees both the body and the shape. |
140 | // Frees both the body and the shape. | 143 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); |
141 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | 144 | BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr); |
142 | BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr); | ||
143 | } | ||
144 | } | 145 | } |
145 | } | 146 | } |
146 | m_mapInfo = null; | 147 | m_mapInfo = null; |
@@ -165,10 +166,5 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys | |||
165 | } | 166 | } |
166 | return ret; | 167 | return ret; |
167 | } | 168 | } |
168 | |||
169 | public override Vector3 TerrainBase | ||
170 | { | ||
171 | get { return m_mapInfo.terrainRegionBase; } | ||
172 | } | ||
173 | } | 169 | } |
174 | } | 170 | } |