diff options
author | Robert Adams | 2013-01-06 14:01:15 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-06 14:01:15 -0800 |
commit | 939340325396c80e8798ec43361ffd983ce325c9 (patch) | |
tree | d44d92743c96ea0abb998eaaa42d0118c04c1f36 /OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |
parent | BulletSim: fix problem where mesh shapes were physically just their bounding ... (diff) | |
download | opensim-SC_OLD-939340325396c80e8798ec43361ffd983ce325c9.zip opensim-SC_OLD-939340325396c80e8798ec43361ffd983ce325c9.tar.gz opensim-SC_OLD-939340325396c80e8798ec43361ffd983ce325c9.tar.bz2 opensim-SC_OLD-939340325396c80e8798ec43361ffd983ce325c9.tar.xz |
BulletSim: update DLLs and SOs with better debugging output.
Add definition of hand crafted avatar mesh. Not used yet.
Comments and cleanup.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 145 |
1 files changed, 137 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index c75eb9b..cc725e8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -27,24 +27,19 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Linq; | ||
31 | using System.Text; | 30 | using System.Text; |
32 | 31 | ||
32 | using OMV = OpenMetaverse; | ||
33 | |||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | 34 | namespace OpenSim.Region.Physics.BulletSPlugin |
34 | { | 35 | { |
35 | public abstract class BSShape | 36 | public abstract class BSShape |
36 | { | 37 | { |
37 | public IntPtr ptr { get; set; } | ||
38 | public BSPhysicsShapeType type { get; set; } | ||
39 | public System.UInt64 key { get; set; } | ||
40 | public int referenceCount { get; set; } | 38 | public int referenceCount { get; set; } |
41 | public DateTime lastReferenced { get; set; } | 39 | public DateTime lastReferenced { get; set; } |
42 | 40 | ||
43 | public BSShape() | 41 | public BSShape() |
44 | { | 42 | { |
45 | ptr = IntPtr.Zero; | ||
46 | type = BSPhysicsShapeType.SHAPE_UNKNOWN; | ||
47 | key = 0; | ||
48 | referenceCount = 0; | 43 | referenceCount = 0; |
49 | lastReferenced = DateTime.Now; | 44 | lastReferenced = DateTime.Now; |
50 | } | 45 | } |
@@ -63,7 +58,7 @@ public abstract class BSShape | |||
63 | } | 58 | } |
64 | 59 | ||
65 | // Compound shapes are handled special as they are rebuilt from scratch. | 60 | // Compound shapes are handled special as they are rebuilt from scratch. |
66 | // This isn't too great a hardship since most of the child shapes will already been created. | 61 | // This isn't too great a hardship since most of the child shapes will have already been created. |
67 | if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) | 62 | if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) |
68 | { | 63 | { |
69 | // Getting a reference to a compound shape gets you the compound shape with the root prim shape added | 64 | // Getting a reference to a compound shape gets you the compound shape with the root prim shape added |
@@ -71,6 +66,14 @@ public abstract class BSShape | |||
71 | physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret); | 66 | physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret); |
72 | } | 67 | } |
73 | 68 | ||
69 | // Avatars have their own unique shape | ||
70 | if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_AVATAR) | ||
71 | { | ||
72 | // Getting a reference to a compound shape gets you the compound shape with the root prim shape added | ||
73 | ret = BSShapeAvatar.GetReference(prim); | ||
74 | physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,avatarShape,shape={1}", prim.LocalID, ret); | ||
75 | } | ||
76 | |||
74 | if (ret == null) | 77 | if (ret == null) |
75 | ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim); | 78 | ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim); |
76 | 79 | ||
@@ -228,5 +231,131 @@ public class BSShapeAvatar : BSShape | |||
228 | return new BSShapeNull(); | 231 | return new BSShapeNull(); |
229 | } | 232 | } |
230 | public override void Dereference(BSScene physicsScene) { } | 233 | public override void Dereference(BSScene physicsScene) { } |
234 | |||
235 | // From the front: | ||
236 | // A---A | ||
237 | // / \ | ||
238 | // B-------B | ||
239 | // / \ +Z | ||
240 | // C-----------C | | ||
241 | // \ / -Y --+-- +Y | ||
242 | // \ / | | ||
243 | // \ / -Z | ||
244 | // D-----D | ||
245 | // \ / | ||
246 | // E-E | ||
247 | |||
248 | // From the top A and E are just lines. | ||
249 | // B, C and D are hexagons: | ||
250 | // | ||
251 | // C1--C2 +X | ||
252 | // / \ | | ||
253 | // C0 C3 -Y --+-- +Y | ||
254 | // \ / | | ||
255 | // C5--C4 -X | ||
256 | |||
257 | // Zero goes directly through the middle so the offsets are from that middle axis | ||
258 | // and up and down from a middle horizon (A and E are the same distance from the zero). | ||
259 | // The height, width and depth is one. All scaling is done by the simulator. | ||
260 | |||
261 | // Z component -- how far the level is from the middle zero | ||
262 | private const float Aup = 0.5f; | ||
263 | private const float Bup = 0.4f; | ||
264 | private const float Cup = 0.3f; | ||
265 | private const float Dup = -0.4f; | ||
266 | private const float Eup = -0.5f; | ||
267 | |||
268 | // Y component -- distance from center to x0 and x3 | ||
269 | private const float Awid = 0.25f; | ||
270 | private const float Bwid = 0.3f; | ||
271 | private const float Cwid = 0.5f; | ||
272 | private const float Dwid = 0.3f; | ||
273 | private const float Ewid = 0.2f; | ||
274 | |||
275 | // Y component -- distance from center to x1, x2, x4 and x5 | ||
276 | private const float Afwid = 0.0f; | ||
277 | private const float Bfwid = 0.2f; | ||
278 | private const float Cfwid = 0.4f; | ||
279 | private const float Dfwid = 0.2f; | ||
280 | private const float Efwid = 0.0f; | ||
281 | |||
282 | // X component -- distance from zero to the front or back of a level | ||
283 | private const float Adep = 0f; | ||
284 | private const float Bdep = 0.3f; | ||
285 | private const float Cdep = 0.5f; | ||
286 | private const float Ddep = 0.2f; | ||
287 | private const float Edep = 0f; | ||
288 | |||
289 | private OMV.Vector3[] avatarVertices = { | ||
290 | new OMV.Vector3( 0.0f, -Awid, Aup), // A0 | ||
291 | new OMV.Vector3( 0.0f, +Awid, Aup), // A3 | ||
292 | |||
293 | new OMV.Vector3( 0.0f, -Bwid, Bup), // B0 | ||
294 | new OMV.Vector3(+Bdep, -Bfwid, Bup), // B1 | ||
295 | new OMV.Vector3(+Bdep, +Bfwid, Bup), // B2 | ||
296 | new OMV.Vector3( 0.0f, +Bwid, Bup), // B3 | ||
297 | new OMV.Vector3(-Bdep, +Bfwid, Bup), // B4 | ||
298 | new OMV.Vector3(-Bdep, -Bfwid, Bup), // B5 | ||
299 | |||
300 | new OMV.Vector3( 0.0f, -Cwid, Cup), // C0 | ||
301 | new OMV.Vector3(+Cdep, -Cfwid, Cup), // C1 | ||
302 | new OMV.Vector3(+Cdep, +Cfwid, Cup), // C2 | ||
303 | new OMV.Vector3( 0.0f, +Cwid, Cup), // C3 | ||
304 | new OMV.Vector3(-Cdep, +Cfwid, Cup), // C4 | ||
305 | new OMV.Vector3(-Cdep, -Cfwid, Cup), // C5 | ||
306 | |||
307 | new OMV.Vector3( 0.0f, -Dwid, Dup), // D0 | ||
308 | new OMV.Vector3(+Ddep, -Dfwid, Dup), // D1 | ||
309 | new OMV.Vector3(+Ddep, +Dfwid, Dup), // D2 | ||
310 | new OMV.Vector3( 0.0f, +Dwid, Dup), // D3 | ||
311 | new OMV.Vector3(-Ddep, +Dfwid, Dup), // D4 | ||
312 | new OMV.Vector3(-Ddep, -Dfwid, Dup), // D5 | ||
313 | |||
314 | new OMV.Vector3( 0.0f, -Ewid, Eup), // E0 | ||
315 | new OMV.Vector3( 0.0f, +Ewid, Eup), // E3 | ||
316 | }; | ||
317 | |||
318 | // Offsets of the vertices in the vertices array | ||
319 | private enum Ind : int | ||
320 | { | ||
321 | A0, A3, | ||
322 | B0, B1, B2, B3, B4, B5, | ||
323 | C0, C1, C2, C3, C4, C5, | ||
324 | D0, D1, D2, D3, D4, D5, | ||
325 | E0, E3 | ||
326 | } | ||
327 | |||
328 | // Comments specify trianges and quads in clockwise direction | ||
329 | private Ind[] avatarIndices = { | ||
330 | Ind.A0, Ind.B0, Ind.B1, // A0,B0,B1 | ||
331 | Ind.A0, Ind.B1, Ind.B2, Ind.B2, Ind.A3, Ind.A0, // A0,B1,B2,A3 | ||
332 | Ind.A3, Ind.B2, Ind.B3, // A3,B2,B3 | ||
333 | Ind.A3, Ind.B3, Ind.B4, // A3,B3,B4 | ||
334 | Ind.A3, Ind.B4, Ind.B5, Ind.B5, Ind.A0, Ind.A3, // A3,B4,B5,A0 | ||
335 | Ind.A0, Ind.B5, Ind.B0, // A0,B5,B0 | ||
336 | |||
337 | Ind.B0, Ind.C0, Ind.C1, Ind.C1, Ind.B1, Ind.B0, // B0,C0,C1,B1 | ||
338 | Ind.B1, Ind.C1, Ind.C2, Ind.C2, Ind.B2, Ind.B1, // B1,C1,C2,B2 | ||
339 | Ind.B2, Ind.C2, Ind.C3, Ind.C3, Ind.B3, Ind.B2, // B2,C2,C3,B3 | ||
340 | Ind.B3, Ind.C3, Ind.C4, Ind.C4, Ind.B4, Ind.B3, // B3,C3,C4,B4 | ||
341 | Ind.B4, Ind.C4, Ind.C5, Ind.C5, Ind.B5, Ind.B4, // B4,C4,C5,B5 | ||
342 | Ind.B5, Ind.C5, Ind.C0, Ind.C0, Ind.B0, Ind.B5, // B5,C5,C0,B0 | ||
343 | |||
344 | Ind.C0, Ind.D0, Ind.D1, Ind.D1, Ind.C1, Ind.C0, // C0,D0,D1,C1 | ||
345 | Ind.C1, Ind.D1, Ind.D2, Ind.D2, Ind.C2, Ind.C1, // C1,D1,D2,C2 | ||
346 | Ind.C2, Ind.D2, Ind.D3, Ind.D3, Ind.C3, Ind.C2, // C2,D2,D3,C3 | ||
347 | Ind.C3, Ind.D3, Ind.D4, Ind.D4, Ind.C4, Ind.C3, // C3,D3,D4,C4 | ||
348 | Ind.C4, Ind.D4, Ind.D5, Ind.D5, Ind.C5, Ind.C4, // C4,D4,D5,C5 | ||
349 | Ind.C5, Ind.D5, Ind.D0, Ind.D0, Ind.C0, Ind.C5, // C5,D5,D0,C0 | ||
350 | |||
351 | Ind.E0, Ind.D0, Ind.D1, // E0,D0,D1 | ||
352 | Ind.E0, Ind.D1, Ind.D2, Ind.D2, Ind.E3, Ind.E0, // E0,D1,D2,E3 | ||
353 | Ind.E3, Ind.D2, Ind.D3, // E3,D2,D3 | ||
354 | Ind.E3, Ind.D3, Ind.D4, // E3,D3,D4 | ||
355 | Ind.E3, Ind.D4, Ind.D5, Ind.D5, Ind.E0, Ind.E3, // E3,D4,D5,E0 | ||
356 | Ind.E0, Ind.D5, Ind.D0, // E0,D5,D0 | ||
357 | |||
358 | }; | ||
359 | |||
231 | } | 360 | } |
232 | } | 361 | } |