-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathSoftBody.cs
More file actions
4768 lines (4251 loc) · 175 KB
/
SoftBody.cs
File metadata and controls
4768 lines (4251 loc) · 175 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using BulletSharp.Math;
using AOT;
namespace BulletSharp.SoftBody
{
public class SoftBodyCollisionShape : ConvexShape
{
internal SoftBodyCollisionShape(IntPtr native)
: base(native, true)
{
}
}
public enum AeroModel
{
VertexPoint,
VertexTwoSided,
VertexTwoSidedLiftDrag,
VertexOneSided,
FaceTwoSided,
FaceTwoSidedLiftDrag,
FaceOneSided
}
[Flags]
public enum CollisionFlags
{
None = 0,
RigidSoftMask = 0x000f,
SdfRigidSoft = 0x0001,
ClusterConvexRigidSoft = 0x0002,
SoftSoftMask = 0x0030,
VertexFaceSoftSoft = 0x0010,
ClusterClusterSoftSoft = 0x0020,
ClusterSelf = 0x0040,
Default = SdfRigidSoft
}
public enum FeatureType
{
None,
Node,
Link,
Face,
Tetra
}
public enum JointType
{
Linear,
Angular,
Contact
}
[Flags]
public enum MaterialFlags
{
None = 0,
DebugDraw = 0x0001,
Default = DebugDraw
}
public enum PositionSolver
{
Linear,
Anchors,
RigidContacts,
SoftContacts
}
public enum SolverPresets
{
Positions,
Velocities,
Default
}
public enum VelocitySolver
{
Linear
}
public class SoftBodyWorldInfo : IDisposable
{
internal IntPtr _native;
private bool _preventDelete;
private BroadphaseInterface _broadphase;
private Dispatcher _dispatcher;
private SparseSdf _sparseSdf;
internal SoftBodyWorldInfo(IntPtr native, bool preventDelete)
{
_native = native;
_preventDelete = preventDelete;
}
public SoftBodyWorldInfo()
{
_native = btSoftBodyWorldInfo_new();
}
public float AirDensity
{
get { return btSoftBodyWorldInfo_getAir_density(_native); }
set { btSoftBodyWorldInfo_setAir_density(_native, value); }
}
public BroadphaseInterface Broadphase
{
get { return _broadphase; }
set
{
btSoftBodyWorldInfo_setBroadphase(_native, (value != null) ? value._native : IntPtr.Zero);
_broadphase = value;
}
}
public Dispatcher Dispatcher
{
get { return _dispatcher; }
set
{
btSoftBodyWorldInfo_setDispatcher(_native, (value != null) ? value._native : IntPtr.Zero);
_dispatcher = value;
}
}
public Vector3 Gravity
{
get
{
Vector3 value;
btSoftBodyWorldInfo_getGravity(_native, out value);
return value;
}
set { btSoftBodyWorldInfo_setGravity(_native, ref value); }
}
public float MaxDisplacement
{
get { return btSoftBodyWorldInfo_getMaxDisplacement(_native); }
set { btSoftBodyWorldInfo_setMaxDisplacement(_native, value); }
}
public SparseSdf SparseSdf
{
get
{
if (_sparseSdf == null)
{
_sparseSdf = new SparseSdf(btSoftBodyWorldInfo_getSparsesdf(_native));
}
return _sparseSdf;
}
}
public float WaterDensity
{
get { return btSoftBodyWorldInfo_getWater_density(_native); }
set { btSoftBodyWorldInfo_setWater_density(_native, value); }
}
public Vector3 WaterNormal
{
get
{
Vector3 value;
btSoftBodyWorldInfo_getWater_normal(_native, out value);
return value;
}
set { btSoftBodyWorldInfo_setWater_normal(_native, ref value); }
}
public float WaterOffset
{
get { return btSoftBodyWorldInfo_getWater_offset(_native); }
set { btSoftBodyWorldInfo_setWater_offset(_native, value); }
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (_native != IntPtr.Zero)
{
if (!_preventDelete)
{
btSoftBodyWorldInfo_delete(_native);
}
_native = IntPtr.Zero;
}
}
~SoftBodyWorldInfo()
{
Dispose(false);
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBodyWorldInfo_new();
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBodyWorldInfo_getAir_density(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_getGravity(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBodyWorldInfo_getMaxDisplacement(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBodyWorldInfo_getSparsesdf(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBodyWorldInfo_getWater_density(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_getWater_normal(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBodyWorldInfo_getWater_offset(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setAir_density(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setBroadphase(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setDispatcher(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setGravity(IntPtr obj, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setMaxDisplacement(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setWater_density(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setWater_normal(IntPtr obj, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_setWater_offset(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBodyWorldInfo_delete(IntPtr obj);
}
public class AngularJoint : Joint
{
public class IControl : IDisposable
{
internal IntPtr _native;
private bool _preventDelete;
[UnmanagedFunctionPointer(Native.Conv), SuppressUnmanagedCodeSecurity]
delegate void PrepareUnmanagedDelegate(IntPtr thisPtr, IntPtr aJoint);
[UnmanagedFunctionPointer(Native.Conv), SuppressUnmanagedCodeSecurity]
delegate float SpeedUnmanagedDelegate(IntPtr thisPtr, IntPtr aJoint, float current);
PrepareUnmanagedDelegate _prepare;
SpeedUnmanagedDelegate _speed;
internal static IControl GetManaged(IntPtr native)
{
if (native == IntPtr.Zero)
{
return null;
}
if (native == Default._native)
{
return Default;
}
IntPtr handle = btSoftBody_AJoint_IControlWrapper_getWrapperData(native);
return GCHandle.FromIntPtr(handle).Target as IControl;
}
internal IControl(IntPtr native, bool preventDelete)
{
_native = native;
_preventDelete = preventDelete;
}
public IControl()
{
_prepare = PrepareUnmanaged;
_speed = SpeedUnmanaged;
_native = btSoftBody_AJoint_IControlWrapper_new(
Marshal.GetFunctionPointerForDelegate(_prepare),
Marshal.GetFunctionPointerForDelegate(_speed)
);
GCHandle handle = GCHandle.Alloc(this, GCHandleType.Normal);
btSoftBody_AJoint_IControlWrapper_setWrapperData(_native, GCHandle.ToIntPtr(handle));
}
static IControl _default;
public static IControl Default
{
get
{
if (_default == null)
{
_default = new IControl(btSoftBody_AJoint_IControl_Default(), true);
}
return _default;
}
}
[MonoPInvokeCallback(typeof(PrepareUnmanagedDelegate))]
static private void PrepareUnmanaged(IntPtr thisPtr,IntPtr aJoint)
{
IControl ms = GCHandle.FromIntPtr(thisPtr).Target as IControl;
ms.Prepare(new AngularJoint(aJoint));
}
[MonoPInvokeCallback(typeof(SpeedUnmanagedDelegate))]
static public float SpeedUnmanaged(IntPtr thisPtr, IntPtr aJoint, float current)
{
IControl ms = GCHandle.FromIntPtr(thisPtr).Target as IControl;
return ms.Speed(new AngularJoint(aJoint), current);
}
public virtual void Prepare(AngularJoint angularJoint)
{
}
public virtual float Speed(AngularJoint angularJoint, float current)
{
return current;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (_native != IntPtr.Zero)
{
if (!_preventDelete)
{
IntPtr handle = btSoftBody_AJoint_IControlWrapper_getWrapperData(_native);
GCHandle.FromIntPtr(handle).Free();
btSoftBody_AJoint_IControl_delete(_native);
}
_native = IntPtr.Zero;
}
}
~IControl()
{
Dispose(false);
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_IControlWrapper_new(IntPtr prepareCallback, IntPtr speedCallback);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_IControlWrapper_getWrapperData(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_IControlWrapper_setWrapperData(IntPtr obj, IntPtr data);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_IControl_Default();
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_IControl_Prepare(IntPtr obj, IntPtr __unnamed0);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBody_AJoint_IControl_Speed(IntPtr obj, IntPtr __unnamed0, float current);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_IControl_delete(IntPtr obj);
}
public new class Specs : Joint.Specs
{
private IControl _iControl;
public Specs()
: base(btSoftBody_AJoint_Specs_new())
{
}
public Vector3 Axis
{
get
{
Vector3 value;
btSoftBody_AJoint_Specs_getAxis(_native, out value);
return value;
}
set { btSoftBody_AJoint_Specs_setAxis(_native, ref value); }
}
public IControl Control
{
get
{
if (_iControl == null)
{
_iControl = IControl.GetManaged(btSoftBody_AJoint_Specs_getIcontrol(_native));
}
return _iControl;
}
set
{
_iControl = value;
btSoftBody_AJoint_Specs_setIcontrol(_native, value._native);
}
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_Specs_new();
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_Specs_getAxis(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_Specs_getIcontrol(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_Specs_setAxis(IntPtr obj, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_Specs_setIcontrol(IntPtr obj, IntPtr value);
}
private IControl _iControl;
private Vector3Array _axis;
internal AngularJoint(IntPtr native)
: base(native)
{
}
public Vector3Array Axis
{
get
{
if (_axis == null)
{
_axis = new Vector3Array(btSoftBody_AJoint_getAxis(_native), 2);
}
return _axis;
}
}
public IControl Control
{
get
{
if (_iControl == null)
{
_iControl = IControl.GetManaged(btSoftBody_AJoint_getIcontrol(_native));
}
return _iControl;
}
set
{
_iControl = value;
btSoftBody_AJoint_setIcontrol(_native, value._native);
}
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_getAxis(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_AJoint_getIcontrol(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_AJoint_setIcontrol(IntPtr obj, IntPtr value);
}
public class Anchor
{
internal IntPtr _native;
private Node _node;
internal Anchor(IntPtr native)
{
_native = native;
}
public RigidBody Body
{
get { return CollisionObject.GetManaged(btSoftBody_Anchor_getBody(_native)) as RigidBody; }
set { btSoftBody_Anchor_setBody(_native, (value != null) ? value._native : IntPtr.Zero); }
}
public Matrix C0
{
get
{
Matrix value;
btSoftBody_Anchor_getC0(_native, out value);
return value;
}
set { btSoftBody_Anchor_setC0(_native, ref value); }
}
public Vector3 C1
{
get
{
Vector3 value;
btSoftBody_Anchor_getC1(_native, out value);
return value;
}
set { btSoftBody_Anchor_setC1(_native, ref value); }
}
public float C2
{
get { return btSoftBody_Anchor_getC2(_native); }
set { btSoftBody_Anchor_setC2(_native, value); }
}
public float Influence
{
get { return btSoftBody_Anchor_getInfluence(_native); }
set { btSoftBody_Anchor_setInfluence(_native, value); }
}
public Vector3 Local
{
get
{
Vector3 value;
btSoftBody_Anchor_getLocal(_native, out value);
return value;
}
set { btSoftBody_Anchor_setLocal(_native, ref value); }
}
public Node Node
{
get
{
IntPtr nodePtr = btSoftBody_Anchor_getNode(_native);
if (_node != null && _node._native == nodePtr) return _node;
if (nodePtr == IntPtr.Zero) return null;
_node = new Node(nodePtr);
return _node;
}
set
{
btSoftBody_Anchor_setNode(_native, (value != null) ? value._native : IntPtr.Zero);
_node = value;
}
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Anchor_getBody(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_getC0(IntPtr obj, [Out] out Matrix value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_getC1(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBody_Anchor_getC2(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBody_Anchor_getInfluence(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_getLocal(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Anchor_getNode(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setBody(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setC0(IntPtr obj, [In] ref Matrix value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setC1(IntPtr obj, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setC2(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setInfluence(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setLocal(IntPtr obj, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Anchor_setNode(IntPtr obj, IntPtr value);
}
public class Body : IDisposable
{
internal IntPtr _native;
private Cluster _soft;
internal Body(IntPtr native)
{
_native = native;
}
public Body()
{
_native = btSoftBody_Body_new();
}
public Body(CollisionObject colObj)
{
_native = btSoftBody_Body_new2(colObj._native);
}
public Body(Cluster p)
{
_native = btSoftBody_Body_new3(p._native);
}
public void Activate()
{
btSoftBody_Body_activate(_native);
}
public void ApplyAImpulse(Impulse impulse)
{
btSoftBody_Body_applyAImpulse(_native, impulse._native);
}
public void ApplyDAImpulse(Vector3 impulse)
{
btSoftBody_Body_applyDAImpulse(_native, ref impulse);
}
public void ApplyDCImpulse(Vector3 impulse)
{
btSoftBody_Body_applyDCImpulse(_native, ref impulse);
}
public void ApplyDImpulse(Vector3 impulse, Vector3 rpos)
{
btSoftBody_Body_applyDImpulse(_native, ref impulse, ref rpos);
}
public void ApplyImpulse(Impulse impulse, Vector3 rpos)
{
btSoftBody_Body_applyImpulse(_native, impulse._native, ref rpos);
}
public void ApplyVAImpulse(Vector3 impulse)
{
btSoftBody_Body_applyVAImpulse(_native, ref impulse);
}
public void ApplyVImpulse(Vector3 impulse, Vector3 rpos)
{
btSoftBody_Body_applyVImpulse(_native, ref impulse, ref rpos);
}
public Vector3 GetAngularVelocity(Vector3 rpos)
{
Vector3 value;
btSoftBody_Body_angularVelocity(_native, ref rpos, out value);
return value;
}
public Vector3 Velocity(Vector3 rpos)
{
Vector3 value;
btSoftBody_Body_velocity(_native, ref rpos, out value);
return value;
}
public Vector3 AngularVelocity
{
get
{
Vector3 value;
btSoftBody_Body_angularVelocity2(_native, out value);
return value;
}
}
public CollisionObject CollisionObject
{
get { return CollisionObject.GetManaged(btSoftBody_Body_getCollisionObject(_native)); }
set { btSoftBody_Body_setCollisionObject(_native, value._native); }
}
public float InverseMass
{
get { return btSoftBody_Body_invMass(_native); }
}
public Matrix InverseWorldInertia
{
get
{
Matrix value;
btSoftBody_Body_invWorldInertia(_native, out value);
return value;
}
}
public Vector3 LinearVelocity
{
get
{
Vector3 value;
btSoftBody_Body_linearVelocity(_native, out value);
return value;
}
}
public RigidBody Rigid
{
get { return CollisionObject.GetManaged(btSoftBody_Body_getRigid(_native)) as RigidBody; }
set { btSoftBody_Body_setRigid(_native, value._native); }
}
public Cluster Soft
{
get
{
IntPtr softPtr = btSoftBody_Body_getSoft(_native);
if (_soft != null && _soft._native == softPtr) return _soft;
if (softPtr == IntPtr.Zero) return null;
_soft = new Cluster(softPtr);
return _soft;
}
set
{
btSoftBody_Body_setSoft(_native, (value != null) ? value._native : IntPtr.Zero);
_soft = value;
}
}
public Matrix Transform
{
get
{
Matrix value;
btSoftBody_Body_xform(_native, out value);
return value;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (_native != IntPtr.Zero)
{
btSoftBody_Body_delete(_native);
_native = IntPtr.Zero;
}
}
~Body()
{
Dispose(false);
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_new();
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_new2(IntPtr colObj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_new3(IntPtr p);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_activate(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_angularVelocity(IntPtr obj, [In] ref Vector3 rpos, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_angularVelocity2(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyAImpulse(IntPtr obj, IntPtr impulse);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyDAImpulse(IntPtr obj, [In] ref Vector3 impulse);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyDCImpulse(IntPtr obj, [In] ref Vector3 impulse);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyDImpulse(IntPtr obj, [In] ref Vector3 impulse, [In] ref Vector3 rpos);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyImpulse(IntPtr obj, IntPtr impulse, [In] ref Vector3 rpos);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyVAImpulse(IntPtr obj, [In] ref Vector3 impulse);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_applyVImpulse(IntPtr obj, [In] ref Vector3 impulse, [In] ref Vector3 rpos);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_getCollisionObject(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_getRigid(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_Body_getSoft(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBody_Body_invMass(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_invWorldInertia(IntPtr obj, [Out] out Matrix value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_linearVelocity(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_setCollisionObject(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_setRigid(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_setSoft(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_velocity(IntPtr obj, [In] ref Vector3 rpos, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_xform(IntPtr obj, [Out] out Matrix value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_Body_delete(IntPtr obj);
}
public class ContactJoint : Joint
{
private Vector3Array _rPos;
internal ContactJoint(IntPtr native)
: base(native)
{
}
public float Friction
{
get { return btSoftBody_CJoint_getFriction(_native); }
set { btSoftBody_CJoint_setFriction(_native, value); }
}
public int Life
{
get { return btSoftBody_CJoint_getLife(_native); }
set { btSoftBody_CJoint_setLife(_native, value); }
}
public int MaxLife
{
get { return btSoftBody_CJoint_getMaxlife(_native); }
set { btSoftBody_CJoint_setMaxlife(_native, value); }
}
public Vector3 Normal
{
get
{
Vector3 value;
btSoftBody_CJoint_getNormal(_native, out value);
return value;
}
set { btSoftBody_CJoint_setNormal(_native, ref value); }
}
public Vector3Array RPosition
{
get
{
if (_rPos == null)
{
_rPos = new Vector3Array(btSoftBody_CJoint_getRpos(_native), 2);
}
return _rPos;
}
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern float btSoftBody_CJoint_getFriction(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern int btSoftBody_CJoint_getLife(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern int btSoftBody_CJoint_getMaxlife(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_CJoint_getNormal(IntPtr obj, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btSoftBody_CJoint_getRpos(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_CJoint_setFriction(IntPtr obj, float value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_CJoint_setLife(IntPtr obj, int value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_CJoint_setMaxlife(IntPtr obj, int value);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btSoftBody_CJoint_setNormal(IntPtr obj, [In] ref Vector3 value);
}
public class Cluster
{
internal IntPtr _native;
private AlignedVector3Array _framerefs;
private Vector3Array _dImpulses;
private DbvtNode _leaf;
//private AlignedScalarArray _masses;
private AlignedNodeArray _nodes;
private Vector3Array _vImpulses;
internal Cluster(IntPtr native)
{
_native = native;
}
public float AngularDamping
{
get { return btSoftBody_Cluster_getAdamping(_native); }
set { btSoftBody_Cluster_setAdamping(_native, value); }
}
public Vector3 AngularVelocity
{
get
{
Vector3 value;
btSoftBody_Cluster_getAv(_native, out value);
return value;
}
set { btSoftBody_Cluster_setAv(_native, ref value); }
}
public int ClusterIndex
{
get { return btSoftBody_Cluster_getClusterIndex(_native); }
set { btSoftBody_Cluster_setClusterIndex(_native, value); }
}
public bool Collide
{
get { return btSoftBody_Cluster_getCollide(_native); }
set { btSoftBody_Cluster_setCollide(_native, value); }
}
public Vector3 CenterOfMass
{
get
{
Vector3 value;
btSoftBody_Cluster_getCom(_native, out value);
return value;
}
set { btSoftBody_Cluster_setCom(_native, ref value); }
}
public bool ContainsAnchor
{
get { return btSoftBody_Cluster_getContainsAnchor(_native); }
set { btSoftBody_Cluster_setContainsAnchor(_native, value); }
}
public Vector3Array DImpulses
{
get
{
if (_dImpulses == null)
{
_dImpulses = new Vector3Array(btSoftBody_Cluster_getDimpulses(_native), 2);
}
return _dImpulses;
}
}
public AlignedVector3Array FrameRefs
{
get
{
if (_framerefs == null)
{
_framerefs = new AlignedVector3Array(btSoftBody_Cluster_getFramerefs(_native));
}
return _framerefs;
}
}
public Matrix FrameTransform
{
get
{
Matrix value;
btSoftBody_Cluster_getFramexform(_native, out value);
return value;
}
set { btSoftBody_Cluster_setFramexform(_native, ref value); }
}
public float Idmass
{
get { return btSoftBody_Cluster_getIdmass(_native); }
set { btSoftBody_Cluster_setIdmass(_native, value); }
}
public float InverseMass
{
get { return btSoftBody_Cluster_getImass(_native); }
set { btSoftBody_Cluster_setImass(_native, value); }
}
public Matrix InverseWorldInertia
{
get
{
Matrix value;
btSoftBody_Cluster_getInvwi(_native, out value);
return value;
}
set { btSoftBody_Cluster_setInvwi(_native, ref value); }
}
public float LinearDamping
{
get { return btSoftBody_Cluster_getLdamping(_native); }
set { btSoftBody_Cluster_setLdamping(_native, value); }
}
public DbvtNode Leaf
{
get
{
IntPtr leafPtr = btSoftBody_Cluster_getLeaf(_native);