aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs263
1 files changed, 0 insertions, 263 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
deleted file mode 100755
index 662dd68..0000000
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs
+++ /dev/null
@@ -1,263 +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 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OMV = OpenMetaverse;
31
32namespace OpenSim.Region.Physics.BulletSPlugin
33{
34// Classes to allow some type checking for the API
35// These hold pointers to allocated objects in the unmanaged space.
36// These classes are subclassed by the various physical implementations of
37// objects. In particular, there is a version for physical instances in
38// unmanaged memory ("unman") and one for in managed memory ("XNA").
39
40// Currently, the instances of these classes are a reference to a
41// physical representation and this has no releationship to other
42// instances. Someday, refarb the usage of these classes so each instance
43// refers to a particular physical instance and this class controls reference
44// counts and such. This should be done along with adding BSShapes.
45
46public class BulletWorld
47{
48 public BulletWorld(uint worldId, BSScene bss)
49 {
50 worldID = worldId;
51 physicsScene = bss;
52 }
53 public uint worldID;
54 // The scene is only in here so very low level routines have a handle to print debug/error messages
55 public BSScene physicsScene;
56}
57
58// An allocated Bullet btRigidBody
59public class BulletBody
60{
61 public BulletBody(uint id)
62 {
63 ID = id;
64 collisionType = CollisionType.Static;
65 }
66 public uint ID;
67 public CollisionType collisionType;
68
69 public virtual void Clear() { }
70 public virtual bool HasPhysicalBody { get { return false; } }
71
72 // Apply the specificed collision mask into the physical world
73 public virtual bool ApplyCollisionMask(BSScene physicsScene)
74 {
75 // Should assert the body has been added to the physical world.
76 // (The collision masks are stored in the collision proxy cache which only exists for
77 // a collision body that is in the world.)
78 return physicsScene.PE.SetCollisionGroupMask(this,
79 BulletSimData.CollisionTypeMasks[collisionType].group,
80 BulletSimData.CollisionTypeMasks[collisionType].mask);
81 }
82
83 // Used for log messages for a unique display of the memory/object allocated to this instance
84 public virtual string AddrString
85 {
86 get { return "unknown"; }
87 }
88
89 public override string ToString()
90 {
91 StringBuilder buff = new StringBuilder();
92 buff.Append("<id=");
93 buff.Append(ID.ToString());
94 buff.Append(",p=");
95 buff.Append(AddrString);
96 buff.Append(",c=");
97 buff.Append(collisionType);
98 buff.Append(">");
99 return buff.ToString();
100 }
101}
102
103public class BulletShape
104{
105 public BulletShape()
106 {
107 type = BSPhysicsShapeType.SHAPE_UNKNOWN;
108 shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE;
109 isNativeShape = false;
110 }
111 public BSPhysicsShapeType type;
112 public System.UInt64 shapeKey;
113 public bool isNativeShape;
114
115 public virtual void Clear() { }
116 public virtual bool HasPhysicalShape { get { return false; } }
117 // Make another reference to this physical object.
118 public virtual BulletShape Clone() { return new BulletShape(); }
119 // Return 'true' if this and other refer to the same physical object
120 public virtual bool ReferenceSame(BulletShape xx) { return false; }
121
122 // Used for log messages for a unique display of the memory/object allocated to this instance
123 public virtual string AddrString
124 {
125 get { return "unknown"; }
126 }
127
128 public override string ToString()
129 {
130 StringBuilder buff = new StringBuilder();
131 buff.Append("<p=");
132 buff.Append(AddrString);
133 buff.Append(",s=");
134 buff.Append(type.ToString());
135 buff.Append(",k=");
136 buff.Append(shapeKey.ToString("X"));
137 buff.Append(",n=");
138 buff.Append(isNativeShape.ToString());
139 buff.Append(">");
140 return buff.ToString();
141 }
142}
143
144// An allocated Bullet btConstraint
145public class BulletConstraint
146{
147 public BulletConstraint()
148 {
149 }
150 public virtual void Clear() { }
151 public virtual bool HasPhysicalConstraint { get { return false; } }
152
153 // Used for log messages for a unique display of the memory/object allocated to this instance
154 public virtual string AddrString
155 {
156 get { return "unknown"; }
157 }
158}
159
160// An allocated HeightMapThing which holds various heightmap info.
161// Made a class rather than a struct so there would be only one
162// instance of this and C# will pass around pointers rather
163// than making copies.
164public class BulletHMapInfo
165{
166 public BulletHMapInfo(uint id, float[] hm) {
167 ID = id;
168 heightMap = hm;
169 terrainRegionBase = OMV.Vector3.Zero;
170 minCoords = new OMV.Vector3(100f, 100f, 25f);
171 maxCoords = new OMV.Vector3(101f, 101f, 26f);
172 minZ = maxZ = 0f;
173 sizeX = sizeY = 256f;
174 }
175 public uint ID;
176 public float[] heightMap;
177 public OMV.Vector3 terrainRegionBase;
178 public OMV.Vector3 minCoords;
179 public OMV.Vector3 maxCoords;
180 public float sizeX, sizeY;
181 public float minZ, maxZ;
182 public BulletShape terrainShape;
183 public BulletBody terrainBody;
184}
185
186// The general class of collsion object.
187public enum CollisionType
188{
189 Avatar,
190 Groundplane,
191 Terrain,
192 Static,
193 Dynamic,
194 VolumeDetect,
195 // Linkset, // A linkset should be either Static or Dynamic
196 LinksetChild,
197 Unknown
198};
199
200// Hold specification of group and mask collision flags for a CollisionType
201public struct CollisionTypeFilterGroup
202{
203 public CollisionTypeFilterGroup(CollisionType t, uint g, uint m)
204 {
205 type = t;
206 group = g;
207 mask = m;
208 }
209 public CollisionType type;
210 public uint group;
211 public uint mask;
212};
213
214public static class BulletSimData
215{
216
217// Map of collisionTypes to flags for collision groups and masks.
218// As mentioned above, don't use the CollisionFilterGroups definitions directly in the code
219// but, instead, use references to this dictionary. Finding and debugging
220// collision flag problems will be made easier.
221public static Dictionary<CollisionType, CollisionTypeFilterGroup> CollisionTypeMasks
222 = new Dictionary<CollisionType, CollisionTypeFilterGroup>()
223{
224 { CollisionType.Avatar,
225 new CollisionTypeFilterGroup(CollisionType.Avatar,
226 (uint)CollisionFilterGroups.BCharacterGroup,
227 (uint)CollisionFilterGroups.BAllGroup)
228 },
229 { CollisionType.Groundplane,
230 new CollisionTypeFilterGroup(CollisionType.Groundplane,
231 (uint)CollisionFilterGroups.BGroundPlaneGroup,
232 (uint)CollisionFilterGroups.BAllGroup)
233 },
234 { CollisionType.Terrain,
235 new CollisionTypeFilterGroup(CollisionType.Terrain,
236 (uint)CollisionFilterGroups.BTerrainGroup,
237 (uint)(CollisionFilterGroups.BAllGroup & ~CollisionFilterGroups.BStaticGroup))
238 },
239 { CollisionType.Static,
240 new CollisionTypeFilterGroup(CollisionType.Static,
241 (uint)CollisionFilterGroups.BStaticGroup,
242 (uint)(CollisionFilterGroups.BCharacterGroup | CollisionFilterGroups.BSolidGroup))
243 },
244 { CollisionType.Dynamic,
245 new CollisionTypeFilterGroup(CollisionType.Dynamic,
246 (uint)CollisionFilterGroups.BSolidGroup,
247 (uint)(CollisionFilterGroups.BAllGroup))
248 },
249 { CollisionType.VolumeDetect,
250 new CollisionTypeFilterGroup(CollisionType.VolumeDetect,
251 (uint)CollisionFilterGroups.BSensorTrigger,
252 (uint)(~CollisionFilterGroups.BSensorTrigger))
253 },
254 { CollisionType.LinksetChild,
255 new CollisionTypeFilterGroup(CollisionType.LinksetChild,
256 (uint)CollisionFilterGroups.BLinksetChildGroup,
257 (uint)(CollisionFilterGroups.BNoneGroup))
258 // (uint)(CollisionFilterGroups.BCharacterGroup | CollisionFilterGroups.BSolidGroup))
259 },
260};
261
262}
263}