diff options
author | teravus | 2013-01-20 08:07:49 -0500 |
---|---|---|
committer | teravus | 2013-01-20 08:07:49 -0500 |
commit | 6a75949323dedce1e141190cc90175f04afdad0a (patch) | |
tree | 80fe212c610f4c6a0fffaf6917d156d8374fb6b6 /OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs | |
parent | * Tweak the BulletSimN API a bit. (diff) | |
download | opensim-SC-6a75949323dedce1e141190cc90175f04afdad0a.zip opensim-SC-6a75949323dedce1e141190cc90175f04afdad0a.tar.gz opensim-SC-6a75949323dedce1e141190cc90175f04afdad0a.tar.bz2 opensim-SC-6a75949323dedce1e141190cc90175f04afdad0a.tar.xz |
* Dumping BulletSimNPlugin in favor of combining the API
Diffstat (limited to 'OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs | 280 |
1 files changed, 0 insertions, 280 deletions
diff --git a/OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs deleted file mode 100644 index f509dc4..0000000 --- a/OpenSim/Region/Physics/BulletSNPlugin/BulletSimData.cs +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OMV = OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BulletSNPlugin | ||
33 | { | ||
34 | // Classes to allow some type checking for the API | ||
35 | // These hold pointers to allocated objects in the unmanaged space. | ||
36 | |||
37 | // The physics engine controller class created at initialization | ||
38 | public struct BulletWorld | ||
39 | { | ||
40 | public BulletWorld(uint worldId, BSScene bss, object xx) | ||
41 | { | ||
42 | ptr = xx; | ||
43 | worldID = worldId; | ||
44 | physicsScene = bss; | ||
45 | } | ||
46 | public object ptr; | ||
47 | public uint worldID; | ||
48 | // The scene is only in here so very low level routines have a handle to print debug/error messages | ||
49 | public BSScene physicsScene; | ||
50 | } | ||
51 | |||
52 | // An allocated Bullet btRigidBody | ||
53 | public struct BulletBody | ||
54 | { | ||
55 | public BulletBody(uint id) : this(id, null) | ||
56 | { | ||
57 | } | ||
58 | public BulletBody(uint id, object xx) | ||
59 | { | ||
60 | ID = id; | ||
61 | ptr = xx; | ||
62 | collisionType = CollisionType.Static; | ||
63 | } | ||
64 | public object ptr; | ||
65 | public uint ID; | ||
66 | public CollisionType collisionType; | ||
67 | |||
68 | public void Clear() | ||
69 | { | ||
70 | ptr = null; | ||
71 | } | ||
72 | public bool HasPhysicalBody { get { return ptr != null; } } | ||
73 | |||
74 | // Apply the specificed collision mask into the physical world | ||
75 | public void ApplyCollisionMask() | ||
76 | { | ||
77 | // Should assert the body has been added to the physical world. | ||
78 | // (The collision masks are stored in the collision proxy cache which only exists for | ||
79 | // a collision body that is in the world.) | ||
80 | BulletSimAPI.SetCollisionGroupMask2(ptr, | ||
81 | BulletSimData.CollisionTypeMasks[collisionType].group, | ||
82 | BulletSimData.CollisionTypeMasks[collisionType].mask); | ||
83 | } | ||
84 | |||
85 | public override string ToString() | ||
86 | { | ||
87 | StringBuilder buff = new StringBuilder(); | ||
88 | buff.Append("<id="); | ||
89 | buff.Append(ID.ToString()); | ||
90 | buff.Append(",p="); | ||
91 | buff.Append(ptr.ToString()); | ||
92 | buff.Append(",c="); | ||
93 | buff.Append(collisionType); | ||
94 | buff.Append(">"); | ||
95 | return buff.ToString(); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | public struct BulletShape | ||
100 | { | ||
101 | public BulletShape(object xx) : this(xx, BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
102 | { | ||
103 | } | ||
104 | public BulletShape(object xx, BSPhysicsShapeType typ) | ||
105 | { | ||
106 | ptr = xx; | ||
107 | type = typ; | ||
108 | shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE; | ||
109 | isNativeShape = false; | ||
110 | } | ||
111 | public object ptr; | ||
112 | public BSPhysicsShapeType type; | ||
113 | public System.UInt64 shapeKey; | ||
114 | public bool isNativeShape; | ||
115 | |||
116 | public void Clear() | ||
117 | { | ||
118 | ptr = null; | ||
119 | } | ||
120 | public bool HasPhysicalShape { get { return ptr != null; } } | ||
121 | |||
122 | public override string ToString() | ||
123 | { | ||
124 | StringBuilder buff = new StringBuilder(); | ||
125 | buff.Append("<p="); | ||
126 | buff.Append(ptr.ToString()); | ||
127 | buff.Append(",s="); | ||
128 | buff.Append(type.ToString()); | ||
129 | buff.Append(",k="); | ||
130 | buff.Append(shapeKey.ToString("X")); | ||
131 | buff.Append(",n="); | ||
132 | buff.Append(isNativeShape.ToString()); | ||
133 | buff.Append(">"); | ||
134 | return buff.ToString(); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | // An allocated Bullet btConstraint | ||
139 | public struct BulletConstraint | ||
140 | { | ||
141 | public BulletConstraint(object xx) | ||
142 | { | ||
143 | ptr = xx; | ||
144 | } | ||
145 | public object ptr; | ||
146 | |||
147 | public void Clear() | ||
148 | { | ||
149 | ptr = null; | ||
150 | } | ||
151 | public bool HasPhysicalConstraint { get { return ptr != null; } } | ||
152 | } | ||
153 | |||
154 | // An allocated HeightMapThing which holds various heightmap info. | ||
155 | // Made a class rather than a struct so there would be only one | ||
156 | // instance of this and C# will pass around pointers rather | ||
157 | // than making copies. | ||
158 | public class BulletHeightMapInfo | ||
159 | { | ||
160 | public BulletHeightMapInfo(uint id, float[] hm, object xx) { | ||
161 | ID = id; | ||
162 | Ptr = xx; | ||
163 | heightMap = hm; | ||
164 | terrainRegionBase = OMV.Vector3.Zero; | ||
165 | minCoords = new OMV.Vector3(100f, 100f, 25f); | ||
166 | maxCoords = new OMV.Vector3(101f, 101f, 26f); | ||
167 | minZ = maxZ = 0f; | ||
168 | sizeX = sizeY = 256f; | ||
169 | } | ||
170 | public uint ID; | ||
171 | public object Ptr; | ||
172 | public float[] heightMap; | ||
173 | public OMV.Vector3 terrainRegionBase; | ||
174 | public OMV.Vector3 minCoords; | ||
175 | public OMV.Vector3 maxCoords; | ||
176 | public float sizeX, sizeY; | ||
177 | public float minZ, maxZ; | ||
178 | public BulletShape terrainShape; | ||
179 | public BulletBody terrainBody; | ||
180 | |||
181 | public float collisionMargin { get; set; } | ||
182 | } | ||
183 | |||
184 | // The general class of collsion object. | ||
185 | public enum CollisionType | ||
186 | { | ||
187 | Avatar, | ||
188 | Groundplane, | ||
189 | Terrain, | ||
190 | Static, | ||
191 | Dynamic, | ||
192 | VolumeDetect, | ||
193 | // Linkset, // A linkset should be either Static or Dynamic | ||
194 | LinksetChild, | ||
195 | Unknown | ||
196 | }; | ||
197 | |||
198 | // Hold specification of group and mask collision flags for a CollisionType | ||
199 | public struct CollisionTypeFilterGroup | ||
200 | { | ||
201 | public CollisionTypeFilterGroup(CollisionType t, uint g, uint m) | ||
202 | { | ||
203 | type = t; | ||
204 | group = g; | ||
205 | mask = m; | ||
206 | } | ||
207 | public CollisionType type; | ||
208 | public uint group; | ||
209 | public uint mask; | ||
210 | }; | ||
211 | |||
212 | /* NOTE: old definitions kept for reference. Delete when things are working. | ||
213 | // The collsion filters and masked are defined in one place -- don't want them scattered | ||
214 | AvatarGroup = BCharacterGroup, | ||
215 | AvatarMask = BAllGroup, | ||
216 | ObjectGroup = BSolidGroup, | ||
217 | ObjectMask = BAllGroup, | ||
218 | StaticObjectGroup = BStaticGroup, | ||
219 | StaticObjectMask = AvatarGroup | ObjectGroup, // static things don't interact with much | ||
220 | LinksetGroup = BLinksetGroup, | ||
221 | LinksetMask = BAllGroup, | ||
222 | LinksetChildGroup = BLinksetChildGroup, | ||
223 | LinksetChildMask = BNoneGroup, // Linkset children disappear from the world | ||
224 | VolumeDetectGroup = BSensorTrigger, | ||
225 | VolumeDetectMask = ~BSensorTrigger, | ||
226 | TerrainGroup = BTerrainGroup, | ||
227 | TerrainMask = BAllGroup & ~BStaticGroup, // static objects on the ground don't collide | ||
228 | GroundPlaneGroup = BGroundPlaneGroup, | ||
229 | GroundPlaneMask = BAllGroup | ||
230 | */ | ||
231 | |||
232 | public static class BulletSimData | ||
233 | { | ||
234 | |||
235 | // Map of collisionTypes to flags for collision groups and masks. | ||
236 | // As mentioned above, don't use the CollisionFilterGroups definitions directly in the code | ||
237 | // but, instead, use references to this dictionary. Finding and debugging | ||
238 | // collision flag problems will be made easier. | ||
239 | public static Dictionary<CollisionType, CollisionTypeFilterGroup> CollisionTypeMasks | ||
240 | = new Dictionary<CollisionType, CollisionTypeFilterGroup>() | ||
241 | { | ||
242 | { CollisionType.Avatar, | ||
243 | new CollisionTypeFilterGroup(CollisionType.Avatar, | ||
244 | (uint)CollisionFilterGroups.BCharacterGroup, | ||
245 | (uint)CollisionFilterGroups.BAllGroup) | ||
246 | }, | ||
247 | { CollisionType.Groundplane, | ||
248 | new CollisionTypeFilterGroup(CollisionType.Groundplane, | ||
249 | (uint)CollisionFilterGroups.BGroundPlaneGroup, | ||
250 | (uint)CollisionFilterGroups.BAllGroup) | ||
251 | }, | ||
252 | { CollisionType.Terrain, | ||
253 | new CollisionTypeFilterGroup(CollisionType.Terrain, | ||
254 | (uint)CollisionFilterGroups.BTerrainGroup, | ||
255 | (uint)(CollisionFilterGroups.BAllGroup & ~CollisionFilterGroups.BStaticGroup)) | ||
256 | }, | ||
257 | { CollisionType.Static, | ||
258 | new CollisionTypeFilterGroup(CollisionType.Static, | ||
259 | (uint)CollisionFilterGroups.BStaticGroup, | ||
260 | (uint)(CollisionFilterGroups.BCharacterGroup | CollisionFilterGroups.BSolidGroup)) | ||
261 | }, | ||
262 | { CollisionType.Dynamic, | ||
263 | new CollisionTypeFilterGroup(CollisionType.Dynamic, | ||
264 | (uint)CollisionFilterGroups.BSolidGroup, | ||
265 | (uint)(CollisionFilterGroups.BAllGroup)) | ||
266 | }, | ||
267 | { CollisionType.VolumeDetect, | ||
268 | new CollisionTypeFilterGroup(CollisionType.VolumeDetect, | ||
269 | (uint)CollisionFilterGroups.BSensorTrigger, | ||
270 | (uint)(~CollisionFilterGroups.BSensorTrigger)) | ||
271 | }, | ||
272 | { CollisionType.LinksetChild, | ||
273 | new CollisionTypeFilterGroup(CollisionType.LinksetChild, | ||
274 | (uint)CollisionFilterGroups.BTerrainGroup, | ||
275 | (uint)(CollisionFilterGroups.BNoneGroup)) | ||
276 | }, | ||
277 | }; | ||
278 | |||
279 | } | ||
280 | } | ||