-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNewton.h
1333 lines (1078 loc) · 89.5 KB
/
Newton.h
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
/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef __NEWTON_H__
#define __NEWTON_H__
#define NEWTON_MAJOR_VERSION 3
#define NEWTON_MINOR_VERSION 14
//#include <dgTypes.h>
#if defined(_MSC_VER)
#define DG_LIBRARY_EXPORT __declspec(dllexport)
#define DG_LIBRARY_IMPORT __declspec(dllimport)
#define DG_LIBRARY_STATIC
#else
#define DG_LIBRARY_EXPORT __attribute__((visibility("default")))
#define DG_LIBRARY_IMPORT __attribute__((visibility("default")))
#define DG_LIBRARY_STATIC
#endif
#ifdef _NEWTON_STATIC_LIB
#define NEWTON_API DG_LIBRARY_STATIC
#elif defined(_NEWTON_BUILD_DLL)
#define NEWTON_API DG_LIBRARY_EXPORT
#else
#define NEWTON_API DG_LIBRARY_IMPORT
#endif
#ifndef dLong
#define dLong long long
#endif
#ifndef dFloat
#ifdef _NEWTON_USE_DOUBLE
#define dFloat double
#else
#define dFloat float
#endif
#endif
#ifndef dFloat32
#define dFloat32 float
#endif
#ifndef dFloat64
#define dFloat64 double
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define NEWTON_BROADPHASE_DEFAULT 0
#define NEWTON_BROADPHASE_PERSINTENT 1
#define NEWTON_DYNAMIC_BODY 0
#define NEWTON_KINEMATIC_BODY 1
#define NEWTON_DYNAMIC_ASYMETRIC_BODY 2
// #define NEWTON_DEFORMABLE_BODY 2
#define SERIALIZE_ID_SPHERE 0
#define SERIALIZE_ID_CAPSULE 1
#define SERIALIZE_ID_CYLINDER 2
#define SERIALIZE_ID_CHAMFERCYLINDER 3
#define SERIALIZE_ID_BOX 4
#define SERIALIZE_ID_CONE 5
#define SERIALIZE_ID_CONVEXHULL 6
#define SERIALIZE_ID_NULL 7
#define SERIALIZE_ID_COMPOUND 8
#define SERIALIZE_ID_TREE 9
#define SERIALIZE_ID_HEIGHTFIELD 10
#define SERIALIZE_ID_CLOTH_PATCH 11
#define SERIALIZE_ID_DEFORMABLE_SOLID 12
#define SERIALIZE_ID_USERMESH 13
#define SERIALIZE_ID_SCENE 14
#define SERIALIZE_ID_FRACTURED_COMPOUND 15
#ifdef __cplusplus
class NewtonMesh;
class NewtonBody;
class NewtonWorld;
class NewtonJoint;
class NewtonMaterial;
class NewtonCollision;
class NewtonDeformableMeshSegment;
class NewtonFracturedCompoundMeshPart;
#else
typedef struct NewtonMesh NewtonMesh;
typedef struct NewtonBody NewtonBody;
typedef struct NewtonWorld NewtonWorld;
typedef struct NewtonJoint NewtonJoint;
typedef struct NewtonMaterial NewtonMaterial;
typedef struct NewtonCollision NewtonCollision;
typedef struct NewtonDeformableMeshSegment NewtonDeformableMeshSegment;
typedef struct NewtonFracturedCompoundMeshPart NewtonFracturedCompoundMeshPart;
#endif
typedef union
{
void* m_ptr;
dLong m_int;
dFloat m_float;
} NewtonMaterialData;
typedef struct NewtonCollisionMaterial
{
dLong m_userId;
NewtonMaterialData m_userData;
NewtonMaterialData m_userParam[6];
} NewtonCollisionMaterial;
typedef struct NewtonBoxParam
{
dFloat m_x;
dFloat m_y;
dFloat m_z;
} NewtonBoxParam;
typedef struct NewtonSphereParam
{
dFloat m_radio;
} NewtonSphereParam;
typedef struct NewtonCapsuleParam
{
dFloat m_radio0;
dFloat m_radio1;
dFloat m_height;
} NewtonCapsuleParam;
typedef struct NewtonCylinderParam
{
dFloat m_radio0;
dFloat m_radio1;
dFloat m_height;
} NewtonCylinderParam;
typedef struct NewtonConeParam
{
dFloat m_radio;
dFloat m_height;
} NewtonConeParam;
typedef struct NewtonChamferCylinderParam
{
dFloat m_radio;
dFloat m_height;
} NewtonChamferCylinderParam;
typedef struct NewtonConvexHullParam
{
int m_vertexCount;
int m_vertexStrideInBytes;
int m_faceCount;
dFloat* m_vertex;
} NewtonConvexHullParam;
typedef struct NewtonCompoundCollisionParam
{
int m_chidrenCount;
} NewtonCompoundCollisionParam;
typedef struct NewtonCollisionTreeParam
{
int m_vertexCount;
int m_indexCount;
} NewtonCollisionTreeParam;
typedef struct NewtonDeformableMeshParam
{
int m_vertexCount;
int m_triangleCount;
int m_vrtexStrideInBytes;
unsigned short *m_indexList;
dFloat *m_vertexList;
} NewtonDeformableMeshParam;
typedef struct NewtonHeightFieldCollisionParam
{
int m_width;
int m_height;
int m_gridsDiagonals;
int m_elevationDataType; // 0 = 32 bit floats, 1 = unsigned 16 bit integers
dFloat m_verticalScale;
dFloat m_horizonalScale_x;
dFloat m_horizonalScale_z;
void* m_vertialElevation;
char* m_atributes;
} NewtonHeightFieldCollisionParam;
typedef struct NewtonSceneCollisionParam
{
int m_childrenProxyCount;
} NewtonSceneCollisionParam;
typedef struct NewtonCollisionInfoRecord
{
dFloat m_offsetMatrix[4][4];
NewtonCollisionMaterial m_collisionMaterial;
int m_collisionType; // tag id to identify the collision primitive
union {
NewtonBoxParam m_box;
NewtonConeParam m_cone;
NewtonSphereParam m_sphere;
NewtonCapsuleParam m_capsule;
NewtonCylinderParam m_cylinder;
NewtonChamferCylinderParam m_chamferCylinder;
NewtonConvexHullParam m_convexHull;
NewtonDeformableMeshParam m_deformableMesh;
NewtonCompoundCollisionParam m_compoundCollision;
NewtonCollisionTreeParam m_collisionTree;
NewtonHeightFieldCollisionParam m_heightField;
NewtonSceneCollisionParam m_sceneCollision;
dFloat m_paramArray[64]; // user define collision can use this to store information
};
} NewtonCollisionInfoRecord;
typedef struct NewtonJointRecord
{
dFloat m_attachmenMatrix_0[4][4];
dFloat m_attachmenMatrix_1[4][4];
dFloat m_minLinearDof[3];
dFloat m_maxLinearDof[3];
dFloat m_minAngularDof[3];
dFloat m_maxAngularDof[3];
const NewtonBody* m_attachBody_0;
const NewtonBody* m_attachBody_1;
dFloat m_extraParameters[64];
int m_bodiesCollisionOn;
char m_descriptionType[128];
} NewtonJointRecord;
typedef struct NewtonUserMeshCollisionCollideDesc
{
dFloat m_boxP0[4]; // lower bounding box of intersection query in local space
dFloat m_boxP1[4]; // upper bounding box of intersection query in local space
dFloat m_boxDistanceTravel[4]; // max distance that box bpxP0 and boxP1 can travel on this timestep, used this for continue collision mode.
int m_threadNumber; // current thread executing this query
int m_faceCount; // the application should set here how many polygons intersect the query box
int m_vertexStrideInBytes; // the application should set here the size of each vertex
dFloat m_skinThickness; // this is the minimum skin separation specified by the material between these two colliding shapes
void* m_userData; // user data passed to the collision geometry at creation time
NewtonBody* m_objBody; // pointer to the colliding body
NewtonBody* m_polySoupBody; // pointer to the rigid body owner of this collision tree
NewtonCollision* m_objCollision; // collision shape of the colliding body, (no necessarily the collision of m_objBody)
NewtonCollision* m_polySoupCollision; // collision shape of the collision tree, (no necessarily the collision of m_polySoupBody)
dFloat* m_vertex; // the application should set here the pointer to the global vertex of the mesh.
int* m_faceIndexCount; // the application should set here the pointer to the vertex count of each face.
int* m_faceVertexIndex; // the application should set here the pointer index array for each vertex on a face.
// the format of a face is I0, I1, I2, I3, ..., M, N, E0, E1, E2, ..., A
// I0, I1, I2, .. are the indices to the vertex, relative to m_vertex pointer
// M is the index to the material sub shape id
// N in the index to the vertex normal relative to m_vertex pointer
// E0, E1, E2, ... are the indices of the the face normal that is shared to that face edge, when the edge does not share a face normal then the edge index is set to index N, which the index to the face normal
// A is and estimate of the largest diagonal of the face, this used internally as a hint to improve floating point accuracy and algorithm performance.
} NewtonUserMeshCollisionCollideDesc;
typedef struct NewtonWorldConvexCastReturnInfo
{
dFloat m_point[4]; // collision point in global space
dFloat m_normal[4]; // surface normal at collision point in global space
//dFloat m_normalOnHitPoint[4]; // surface normal at the surface of the hit body,
// is the same as the normal calculated by a ray cast hitting the body at the hit point
dLong m_contactID; // collision ID at contact point
const NewtonBody* m_hitBody; // body hit at contact point
dFloat m_penetration; // contact penetration at collision point
} NewtonWorldConvexCastReturnInfo;
typedef struct NewtonUserMeshCollisionRayHitDesc
{
dFloat m_p0[4]; // ray origin in collision local space
dFloat m_p1[4]; // ray destination in collision local space
dFloat m_normalOut[4]; // copy here the normal at the ray intersection
dLong m_userIdOut; // copy here a user defined id for further feedback
void* m_userData; // user data passed to the collision geometry at creation time
} NewtonUserMeshCollisionRayHitDesc;
typedef struct NewtonHingeSliderUpdateDesc
{
dFloat m_accel;
dFloat m_minFriction;
dFloat m_maxFriction;
dFloat m_timestep;
} NewtonHingeSliderUpdateDesc;
typedef struct NewtonUserContactPoint
{
dFloat m_point[4];
dFloat m_normal[4];
dLong m_shapeId0;
dLong m_shapeId1;
dFloat m_penetration;
int m_unused[3];
} NewtonUserContactPoint;
typedef struct NewtonImmediateModeConstraint
{
dFloat m_jacobian01[8][6];
dFloat m_jacobian10[8][6];
dFloat m_minFriction[8];
dFloat m_maxFriction[8];
dFloat m_jointAccel[8];
dFloat m_jointStiffness[8];
} NewtonConstraintDescriptor;
// data structure for interfacing with NewtonMesh
typedef struct NewtonMeshDoubleData
{
dFloat64* m_data;
int* m_indexList;
int m_strideInBytes;
} NewtonMeshDoubleData;
typedef struct NewtonMeshFloatData
{
dFloat* m_data;
int* m_indexList;
int m_strideInBytes;
} NewtonMeshFloatData;
typedef struct NewtonMeshVertexFormat
{
int m_faceCount;
int* m_faceIndexCount;
int* m_faceMaterial;
NewtonMeshDoubleData m_vertex;
NewtonMeshFloatData m_normal;
NewtonMeshFloatData m_binormal;
NewtonMeshFloatData m_uv0;
NewtonMeshFloatData m_uv1;
NewtonMeshFloatData m_vertexColor;
} NewtonMeshVertexFormat;
// Newton callback functions
typedef void* (*NewtonAllocMemory) (int sizeInBytes);
typedef void (*NewtonFreeMemory) (void* const ptr, int sizeInBytes);
typedef void (*NewtonWorldDestructorCallback) (const NewtonWorld* const world);
typedef void (*NewtonPostUpdateCallback) (const NewtonWorld* const world, dFloat timestep);
typedef void(*NewtonCreateContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact);
typedef void(*NewtonDestroyContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact);
typedef void (*NewtonWorldListenerDebugCallback) (const NewtonWorld* const world, void* const listener, void* const debugContext);
typedef void (*NewtonWorldListenerBodyDestroyCallback) (const NewtonWorld* const world, void* const listenerUserData, NewtonBody* const body);
typedef void (*NewtonWorldUpdateListenerCallback) (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep);
typedef void (*NewtonWorldDestroyListenerCallback) (const NewtonWorld* const world, void* const listenerUserData);
typedef dLong (*NewtonGetTimeInMicrosencondsCallback) ();
typedef void (*NewtonSerializeCallback) (void* const serializeHandle, const void* const buffer, int size);
typedef void (*NewtonDeserializeCallback) (void* const serializeHandle, void* const buffer, int size);
typedef void (*NewtonOnBodySerializationCallback) (NewtonBody* const body, void* const userData, NewtonSerializeCallback function, void* const serializeHandle);
typedef void (*NewtonOnBodyDeserializationCallback) (NewtonBody* const body, void* const userData, NewtonDeserializeCallback function, void* const serializeHandle);
typedef void (*NewtonOnJointSerializationCallback) (const NewtonJoint* const joint, NewtonSerializeCallback function, void* const serializeHandle);
typedef void (*NewtonOnJointDeserializationCallback) (NewtonBody* const body0, NewtonBody* const body1, NewtonDeserializeCallback function, void* const serializeHandle);
typedef void (*NewtonOnUserCollisionSerializationCallback) (void* const userData, NewtonSerializeCallback function, void* const serializeHandle);
// user collision callbacks
typedef void (*NewtonUserMeshCollisionDestroyCallback) (void* const userData);
typedef dFloat (*NewtonUserMeshCollisionRayHitCallback) (NewtonUserMeshCollisionRayHitDesc* const lineDescData);
typedef void (*NewtonUserMeshCollisionGetCollisionInfo) (void* const userData, NewtonCollisionInfoRecord* const infoRecord);
typedef int (*NewtonUserMeshCollisionAABBTest) (void* const userData, const dFloat* const boxP0, const dFloat* const boxP1);
typedef int (*NewtonUserMeshCollisionGetFacesInAABB) (void* const userData, const dFloat* const p0, const dFloat* const p1,
const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes,
const int* const indexList, int maxIndexCount, const int* const userDataList);
typedef void (*NewtonUserMeshCollisionCollideCallback) (NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle);
typedef int (*NewtonTreeCollisionFaceCallback) (void* const context, const dFloat* const polygon, int strideInBytes, const int* const indexArray, int indexCount);
typedef dFloat (*NewtonCollisionTreeRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const treeCollision, dFloat intersection, dFloat* const normal, int faceId, void* const usedData);
typedef dFloat (*NewtonHeightFieldRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const heightFieldCollision, dFloat intersection, int row, int col, dFloat* const normal, int faceId, void* const usedData);
typedef void (*NewtonCollisionCopyConstructionCallback) (const NewtonWorld* const newtonWorld, NewtonCollision* const collision, const NewtonCollision* const sourceCollision);
typedef void (*NewtonCollisionDestructorCallback) (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision);
// collision tree call back (obsoleted no recommended)
typedef void (*NewtonTreeCollisionCallback) (const NewtonBody* const bodyWithTreeCollision, const NewtonBody* const body, int faceID,
int vertexCount, const dFloat* const vertex, int vertexStrideInBytes);
typedef void (*NewtonBodyDestructor) (const NewtonBody* const body);
typedef void (*NewtonApplyForceAndTorque) (const NewtonBody* const body, dFloat timestep, int threadIndex);
typedef void (*NewtonSetTransform) (const NewtonBody* const body, const dFloat* const matrix, int threadIndex);
typedef int (*NewtonIslandUpdate) (const NewtonWorld* const newtonWorld, const void* islandHandle, int bodyCount);
typedef void (*NewtonFractureCompoundCollisionOnEmitCompoundFractured) (NewtonBody* const fracturedBody);
typedef void (*NewtonFractureCompoundCollisionOnEmitChunk) (NewtonBody* const chunkBody, NewtonFracturedCompoundMeshPart* const fracturexChunkMesh, const NewtonCollision* const fracturedCompountCollision);
typedef void (*NewtonFractureCompoundCollisionReconstructMainMeshCallBack) (NewtonBody* const body, NewtonFracturedCompoundMeshPart* const mainMesh, const NewtonCollision* const fracturedCompountCollision);
typedef unsigned (*NewtonWorldRayPrefilterCallback)(const NewtonBody* const body, const NewtonCollision* const collision, void* const userData);
typedef dFloat (*NewtonWorldRayFilterCallback)(const NewtonBody* const body, const NewtonCollision* const shapeHit, const dFloat* const hitContact, const dFloat* const hitNormal, dLong collisionID, void* const userData, dFloat intersectParam);
typedef int (*NewtonOnAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, int threadIndex);
typedef void (*NewtonContactsProcess) (const NewtonJoint* const contact, dFloat timestep, int threadIndex);
typedef int (*NewtonOnCompoundSubCollisionAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, const NewtonBody* const body0, const void* const collisionNode0, const NewtonBody* const body1, const void* const collisionNode1, int threadIndex);
typedef int (*NewtonOnContactGeneration) (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonCollision* const collision0, const NewtonBody* const body1, const NewtonCollision* const collision1, NewtonUserContactPoint* const contactBuffer, int maxCount, int threadIndex);
typedef int (*NewtonBodyIterator) (const NewtonBody* const body, void* const userData);
typedef void (*NewtonJointIterator) (const NewtonJoint* const joint, void* const userData);
typedef void (*NewtonCollisionIterator) (void* const userData, int vertexCount, const dFloat* const faceArray, int faceId);
typedef void (*NewtonBallCallback) (const NewtonJoint* const ball, dFloat timestep);
typedef unsigned (*NewtonHingeCallback) (const NewtonJoint* const hinge, NewtonHingeSliderUpdateDesc* const desc);
typedef unsigned (*NewtonSliderCallback) (const NewtonJoint* const slider, NewtonHingeSliderUpdateDesc* const desc);
typedef unsigned (*NewtonUniversalCallback) (const NewtonJoint* const universal, NewtonHingeSliderUpdateDesc* const desc);
typedef unsigned (*NewtonCorkscrewCallback) (const NewtonJoint* const corkscrew, NewtonHingeSliderUpdateDesc* const desc);
typedef void (*NewtonUserBilateralCallback) (const NewtonJoint* const userJoint, dFloat timestep, int threadIndex);
typedef void (*NewtonUserBilateralGetInfoCallback) (const NewtonJoint* const userJoint, NewtonJointRecord* const info);
typedef void (*NewtonConstraintDestructor) (const NewtonJoint* const me);
typedef void (*NewtonJobTask) (NewtonWorld* const world, void* const userData, int threadIndex);
typedef int (*NewtonReportProgress) (dFloat normalizedProgressPercent, void* const userData);
// **********************************************************************************************
//
// world control functions
//
// **********************************************************************************************
NEWTON_API int NewtonWorldGetVersion ();
NEWTON_API int NewtonWorldFloatSize ();
NEWTON_API int NewtonGetMemoryUsed ();
NEWTON_API void NewtonSetMemorySystem (NewtonAllocMemory malloc, NewtonFreeMemory free);
NEWTON_API NewtonWorld* NewtonCreate ();
NEWTON_API void NewtonDestroy (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonDestroyAllBodies (const NewtonWorld* const newtonWorld);
NEWTON_API NewtonPostUpdateCallback NewtonGetPostUpdateCallback(const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetPostUpdateCallback (const NewtonWorld* const newtonWorld, NewtonPostUpdateCallback callback);
NEWTON_API void* NewtonAlloc (int sizeInBytes);
NEWTON_API void NewtonFree (void* const ptr);
NEWTON_API void NewtonLoadPlugins(const NewtonWorld* const newtonWorld, const char* const plugInPath);
NEWTON_API void NewtonUnloadPlugins(const NewtonWorld* const newtonWorld);
NEWTON_API void* NewtonCurrentPlugin(const NewtonWorld* const newtonWorld);
NEWTON_API void* NewtonGetFirstPlugin(const NewtonWorld* const newtonWorld);
NEWTON_API void* NewtonGetPreferedPlugin(const NewtonWorld* const newtonWorld);
NEWTON_API void* NewtonGetNextPlugin(const NewtonWorld* const newtonWorld, const void* const plugin);
NEWTON_API const char* NewtonGetPluginString(const NewtonWorld* const newtonWorld, const void* const plugin);
NEWTON_API void NewtonSelectPlugin(const NewtonWorld* const newtonWorld, const void* const plugin);
NEWTON_API dFloat NewtonGetContactMergeTolerance (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetContactMergeTolerance (const NewtonWorld* const newtonWorld, dFloat tolerance);
NEWTON_API void NewtonInvalidateCache (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetSolverIterations (const NewtonWorld* const newtonWorld, int model);
NEWTON_API int NewtonGetSolverIterations(const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld, int mode);
NEWTON_API int NewtonGetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld);
NEWTON_API int NewtonGetBroadphaseAlgorithm (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSelectBroadphaseAlgorithm (const NewtonWorld* const newtonWorld, int algorithmType);
NEWTON_API void NewtonResetBroadphase(const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonUpdate (const NewtonWorld* const newtonWorld, dFloat timestep);
NEWTON_API void NewtonUpdateAsync (const NewtonWorld* const newtonWorld, dFloat timestep);
NEWTON_API void NewtonWaitForUpdateToFinish (const NewtonWorld* const newtonWorld);
NEWTON_API int NewtonGetNumberOfSubsteps (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetNumberOfSubsteps (const NewtonWorld* const newtonWorld, int subSteps);
NEWTON_API dFloat NewtonGetLastUpdateTime (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSerializeToFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData);
NEWTON_API void NewtonDeserializeFromFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData);
NEWTON_API void NewtonSerializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData,
NewtonSerializeCallback serializeCallback, void* const serializeHandle);
NEWTON_API void NewtonDeserializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData,
NewtonDeserializeCallback serializeCallback, void* const serializeHandle);
NEWTON_API NewtonBody* NewtonFindSerializedBody(const NewtonWorld* const newtonWorld, int bodySerializedID);
NEWTON_API void NewtonSetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback serializeJoint, NewtonOnJointDeserializationCallback deserializeJoint);
NEWTON_API void NewtonGetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback* const serializeJoint, NewtonOnJointDeserializationCallback* const deserializeJoint);
// multi threading interface
NEWTON_API void NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld, int threadIndex);
NEWTON_API void NewtonWorldCriticalSectionUnlock (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonSetThreadsCount (const NewtonWorld* const newtonWorld, int threads);
NEWTON_API int NewtonGetThreadsCount(const NewtonWorld* const newtonWorld);
NEWTON_API int NewtonGetMaxThreadsCount(const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonDispachThreadJob(const NewtonWorld* const newtonWorld, NewtonJobTask task, void* const usedData, const char* const functionName);
NEWTON_API void NewtonSyncThreadJobs(const NewtonWorld* const newtonWorld);
// atomic operations
NEWTON_API int NewtonAtomicAdd (int* const ptr, int value);
NEWTON_API int NewtonAtomicSwap (int* const ptr, int value);
NEWTON_API void NewtonYield ();
NEWTON_API void NewtonSetIslandUpdateEvent (const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate);
NEWTON_API void NewtonWorldForEachJointDo (const NewtonWorld* const newtonWorld, NewtonJointIterator callback, void* const userData);
NEWTON_API void NewtonWorldForEachBodyInAABBDo (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonBodyIterator callback, void* const userData);
NEWTON_API void NewtonWorldSetUserData (const NewtonWorld* const newtonWorld, void* const userData);
NEWTON_API void* NewtonWorldGetUserData (const NewtonWorld* const newtonWorld);
NEWTON_API void* NewtonWorldAddListener (const NewtonWorld* const newtonWorld, const char* const nameId, void* const listenerUserData);
NEWTON_API void* NewtonWorldGetListener (const NewtonWorld* const newtonWorld, const char* const nameId);
NEWTON_API void NewtonWorldListenerSetDebugCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerDebugCallback callback);
NEWTON_API void NewtonWorldListenerSetPostStepCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback);
NEWTON_API void NewtonWorldListenerSetPreUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback);
NEWTON_API void NewtonWorldListenerSetPostUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback);
NEWTON_API void NewtonWorldListenerSetDestructorCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldDestroyListenerCallback callback);
NEWTON_API void NewtonWorldListenerSetBodyDestroyCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerBodyDestroyCallback callback);
NEWTON_API void NewtonWorldListenerDebug(const NewtonWorld* const newtonWorld, void* const context);
NEWTON_API void* NewtonWorldGetListenerUserData(const NewtonWorld* const newtonWorld, void* const listener);
NEWTON_API NewtonWorldListenerBodyDestroyCallback NewtonWorldListenerGetBodyDestroyCallback (const NewtonWorld* const newtonWorld, void* const listener);
NEWTON_API void NewtonWorldSetDestructorCallback (const NewtonWorld* const newtonWorld, NewtonWorldDestructorCallback destructor);
NEWTON_API NewtonWorldDestructorCallback NewtonWorldGetDestructorCallback (const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonWorldSetCollisionConstructorDestructorCallback (const NewtonWorld* const newtonWorld, NewtonCollisionCopyConstructionCallback constructor, NewtonCollisionDestructorCallback destructor);
NEWTON_API void NewtonWorldSetCreateDestroyContactCallback(const NewtonWorld* const newtonWorld, NewtonCreateContactCallback createContact, NewtonDestroyContactCallback destroyContact);
NEWTON_API void NewtonWorldRayCast (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonWorldRayFilterCallback filter, void* const userData, NewtonWorldRayPrefilterCallback prefilter, int threadIndex);
NEWTON_API int NewtonWorldConvexCast (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const dFloat* const target, const NewtonCollision* const shape, dFloat* const param, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex);
NEWTON_API int NewtonWorldCollide (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const NewtonCollision* const shape, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex);
// world utility functions
NEWTON_API int NewtonWorldGetBodyCount(const NewtonWorld* const newtonWorld);
NEWTON_API int NewtonWorldGetConstraintCount(const NewtonWorld* const newtonWorld);
NEWTON_API NewtonJoint* NewtonWorldFindJoint(const NewtonBody* const body0, const NewtonBody* const body1);
// **********************************************************************************************
//
// Simulation islands
//
// **********************************************************************************************
NEWTON_API NewtonBody* NewtonIslandGetBody (const void* const island, int bodyIndex);
NEWTON_API void NewtonIslandGetBodyAABB (const void* const island, int bodyIndex, dFloat* const p0, dFloat* const p1);
// **********************************************************************************************
//
// Physics Material Section
//
// **********************************************************************************************
NEWTON_API int NewtonMaterialCreateGroupID(const NewtonWorld* const newtonWorld);
NEWTON_API int NewtonMaterialGetDefaultGroupID(const NewtonWorld* const newtonWorld);
NEWTON_API void NewtonMaterialDestroyAllGroupID(const NewtonWorld* const newtonWorld);
// material definitions that can not be overwritten in function callback
NEWTON_API void* NewtonMaterialGetUserData (const NewtonWorld* const newtonWorld, int id0, int id1);
NEWTON_API void NewtonMaterialSetSurfaceThickness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat thickness);
// deprecated, not longer continue collision is set on the material
// NEWTON_API void NewtonMaterialSetContinuousCollisionMode (const NewtonWorld* const newtonWorld, int id0, int id1, int state);
NEWTON_API void NewtonMaterialSetCallbackUserData (const NewtonWorld* const newtonWorld, int id0, int id1, void* const userData);
NEWTON_API void NewtonMaterialSetContactGenerationCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnContactGeneration contactGeneration);
NEWTON_API void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap);
NEWTON_API void NewtonMaterialSetCollisionCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnAABBOverlap aabbOverlap, NewtonContactsProcess process);
NEWTON_API void NewtonMaterialSetDefaultSoftness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat value);
NEWTON_API void NewtonMaterialSetDefaultElasticity (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat elasticCoef);
NEWTON_API void NewtonMaterialSetDefaultCollidable (const NewtonWorld* const newtonWorld, int id0, int id1, int state);
NEWTON_API void NewtonMaterialSetDefaultFriction (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction);
NEWTON_API void NewtonMaterialJointResetIntraJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1);
NEWTON_API void NewtonMaterialJointResetSelftJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1);
NEWTON_API NewtonMaterial* NewtonWorldGetFirstMaterial (const NewtonWorld* const newtonWorld);
NEWTON_API NewtonMaterial* NewtonWorldGetNextMaterial (const NewtonWorld* const newtonWorld, const NewtonMaterial* const material);
NEWTON_API NewtonBody* NewtonWorldGetFirstBody (const NewtonWorld* const newtonWorld);
NEWTON_API NewtonBody* NewtonWorldGetNextBody (const NewtonWorld* const newtonWorld, const NewtonBody* const curBody);
// **********************************************************************************************
//
// Physics Contact control functions
//
// **********************************************************************************************
NEWTON_API void *NewtonMaterialGetMaterialPairUserData (const NewtonMaterial* const material);
NEWTON_API unsigned NewtonMaterialGetContactFaceAttribute (const NewtonMaterial* const material);
NEWTON_API NewtonCollision* NewtonMaterialGetBodyCollidingShape (const NewtonMaterial* const material, const NewtonBody* const body);
NEWTON_API dFloat NewtonMaterialGetContactNormalSpeed (const NewtonMaterial* const material);
NEWTON_API void NewtonMaterialGetContactForce (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const force);
NEWTON_API void NewtonMaterialGetContactPositionAndNormal (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const posit, dFloat* const normal);
NEWTON_API void NewtonMaterialGetContactTangentDirections (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const dir0, dFloat* const dir1);
NEWTON_API dFloat NewtonMaterialGetContactTangentSpeed (const NewtonMaterial* const material, int index);
NEWTON_API dFloat NewtonMaterialGetContactMaxNormalImpact (const NewtonMaterial* const material);
NEWTON_API dFloat NewtonMaterialGetContactMaxTangentImpact (const NewtonMaterial* const material, int index);
NEWTON_API dFloat NewtonMaterialGetContactPenetration (const NewtonMaterial* const material);
NEWTON_API void NewtonMaterialSetAsSoftContact (const NewtonMaterial* const material, dFloat relaxation);
NEWTON_API void NewtonMaterialSetContactSoftness (const NewtonMaterial* const material, dFloat softness);
NEWTON_API void NewtonMaterialSetContactThickness (const NewtonMaterial* const material, dFloat thickness);
NEWTON_API void NewtonMaterialSetContactElasticity (const NewtonMaterial* const material, dFloat restitution);
NEWTON_API void NewtonMaterialSetContactFrictionState (const NewtonMaterial* const material, int state, int index);
NEWTON_API void NewtonMaterialSetContactFrictionCoef (const NewtonMaterial* const material, dFloat staticFrictionCoef, dFloat kineticFrictionCoef, int index);
NEWTON_API void NewtonMaterialSetContactNormalAcceleration (const NewtonMaterial* const material, dFloat accel);
NEWTON_API void NewtonMaterialSetContactNormalDirection (const NewtonMaterial* const material, const dFloat* const directionVector);
NEWTON_API void NewtonMaterialSetContactPosition (const NewtonMaterial* const material, const dFloat* const position);
NEWTON_API void NewtonMaterialSetContactTangentFriction (const NewtonMaterial* const material, dFloat friction, int index);
NEWTON_API void NewtonMaterialSetContactTangentAcceleration (const NewtonMaterial* const material, dFloat accel, int index);
NEWTON_API void NewtonMaterialContactRotateTangentDirections (const NewtonMaterial* const material, const dFloat* const directionVector);
//NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1);
//NEWTON_API void NewtonMaterialSetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1, dFloat tolerance);
NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance(const NewtonJoint* const contactJoint);
NEWTON_API void NewtonMaterialSetContactPruningTolerance(const NewtonJoint* const contactJoint, dFloat tolerance);
// **********************************************************************************************
//
// convex collision primitives creation functions
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateNull (const NewtonWorld* const newtonWorld);
NEWTON_API NewtonCollision* NewtonCreateSphere (const NewtonWorld* const newtonWorld, dFloat radius, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateBox (const NewtonWorld* const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateCone (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateCapsule (const NewtonWorld* const newtonWorld, dFloat radius0, dFloat radius1, dFloat height, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateCylinder (const NewtonWorld* const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateChamferCylinder (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateConvexHull (const NewtonWorld* const newtonWorld, int count, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance, int shapeID, const dFloat* const offsetMatrix);
NEWTON_API NewtonCollision* NewtonCreateConvexHullFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat tolerance, int shapeID);
NEWTON_API int NewtonCollisionGetMode(const NewtonCollision* const convexCollision);
NEWTON_API void NewtonCollisionSetMode (const NewtonCollision* const convexCollision, int mode);
NEWTON_API int NewtonConvexHullGetFaceIndices (const NewtonCollision* const convexHullCollision, int face, int* const faceIndices);
NEWTON_API int NewtonConvexHullGetVertexData (const NewtonCollision* const convexHullCollision, dFloat** const vertexData, int* strideInBytes);
NEWTON_API dFloat NewtonConvexCollisionCalculateVolume (const NewtonCollision* const convexCollision);
NEWTON_API void NewtonConvexCollisionCalculateInertialMatrix (const NewtonCollision* convexCollision, dFloat* const inertia, dFloat* const origin);
NEWTON_API dFloat NewtonConvexCollisionCalculateBuoyancyVolume (const NewtonCollision* const convexCollision, const dFloat* const matrix, const dFloat* const fluidPlane, dFloat* const centerOfBuoyancy);
NEWTON_API const void* NewtonCollisionDataPointer (const NewtonCollision* const convexCollision);
// **********************************************************************************************
//
// compound collision primitives creation functions
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* const newtonWorld, int shapeID);
NEWTON_API NewtonCollision* NewtonCreateCompoundCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat hullTolerance, int shapeID, int subShapeID);
NEWTON_API void NewtonCompoundCollisionBeginAddRemove (NewtonCollision* const compoundCollision);
NEWTON_API void* NewtonCompoundCollisionAddSubCollision (NewtonCollision* const compoundCollision, const NewtonCollision* const convexCollision);
NEWTON_API void NewtonCompoundCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode);
NEWTON_API void NewtonCompoundCollisionRemoveSubCollisionByIndex (NewtonCollision* const compoundCollision, int nodeIndex);
NEWTON_API void NewtonCompoundCollisionSetSubCollisionMatrix (NewtonCollision* const compoundCollision, const void* const collisionNode, const dFloat* const matrix);
NEWTON_API void NewtonCompoundCollisionEndAddRemove (NewtonCollision* const compoundCollision);
NEWTON_API void* NewtonCompoundCollisionGetFirstNode (NewtonCollision* const compoundCollision);
NEWTON_API void* NewtonCompoundCollisionGetNextNode (NewtonCollision* const compoundCollision, const void* const collisionNode);
NEWTON_API void* NewtonCompoundCollisionGetNodeByIndex (NewtonCollision* const compoundCollision, int index);
NEWTON_API int NewtonCompoundCollisionGetNodeIndex (NewtonCollision* const compoundCollision, const void* const collisionNode);
NEWTON_API NewtonCollision* NewtonCompoundCollisionGetCollisionFromNode (NewtonCollision* const compoundCollision, const void* const collisionNode);
// **********************************************************************************************
//
// Fractured compound collision primitives interface
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateFracturedCompoundCollision (const NewtonWorld* const newtonWorld, const NewtonMesh* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix,
NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback,
NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk);
NEWTON_API NewtonCollision* NewtonFracturedCompoundPlaneClip (const NewtonCollision* const fracturedCompound, const dFloat* const plane);
NEWTON_API void NewtonFracturedCompoundSetCallbacks (const NewtonCollision* const fracturedCompound, NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback,
NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk);
NEWTON_API int NewtonFracturedCompoundIsNodeFreeToDetach (const NewtonCollision* const fracturedCompound, void* const collisionNode);
NEWTON_API int NewtonFracturedCompoundNeighborNodeList (const NewtonCollision* const fracturedCompound, void* const collisionNode, void** const list, int maxCount);
NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetMainMesh (const NewtonCollision* const fracturedCompound);
NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetFirstSubMesh(const NewtonCollision* const fracturedCompound);
NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetNextSubMesh(const NewtonCollision* const fracturedCompound, NewtonFracturedCompoundMeshPart* const subMesh);
NEWTON_API int NewtonFracturedCompoundCollisionGetVertexCount (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner);
NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexPositions (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner);
NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexNormals (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner);
NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexUVs (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner);
NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexStream (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner, const void* const segment, int* const index);
NEWTON_API void* NewtonFracturedCompoundMeshPartGetFirstSegment (const NewtonFracturedCompoundMeshPart* const fractureCompoundMeshPart);
NEWTON_API void* NewtonFracturedCompoundMeshPartGetNextSegment (const void* const fractureCompoundMeshSegment);
NEWTON_API int NewtonFracturedCompoundMeshPartGetMaterial (const void* const fractureCompoundMeshSegment);
NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexCount (const void* const fractureCompoundMeshSegment);
// **********************************************************************************************
//
// scene collision are static compound collision that can take polygonal static collisions
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateSceneCollision (const NewtonWorld* const newtonWorld, int shapeID);
NEWTON_API void NewtonSceneCollisionBeginAddRemove (NewtonCollision* const sceneCollision);
NEWTON_API void* NewtonSceneCollisionAddSubCollision (NewtonCollision* const sceneCollision, const NewtonCollision* const collision);
NEWTON_API void NewtonSceneCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode);
NEWTON_API void NewtonSceneCollisionRemoveSubCollisionByIndex (NewtonCollision* const sceneCollision, int nodeIndex);
NEWTON_API void NewtonSceneCollisionSetSubCollisionMatrix (NewtonCollision* const sceneCollision, const void* const collisionNode, const dFloat* const matrix);
NEWTON_API void NewtonSceneCollisionEndAddRemove (NewtonCollision* const sceneCollision);
NEWTON_API void* NewtonSceneCollisionGetFirstNode (NewtonCollision* const sceneCollision);
NEWTON_API void* NewtonSceneCollisionGetNextNode (NewtonCollision* const sceneCollision, const void* const collisionNode);
NEWTON_API void* NewtonSceneCollisionGetNodeByIndex (NewtonCollision* const sceneCollision, int index);
NEWTON_API int NewtonSceneCollisionGetNodeIndex (NewtonCollision* const sceneCollision, const void* const collisionNode);
NEWTON_API NewtonCollision* NewtonSceneCollisionGetCollisionFromNode (NewtonCollision* const sceneCollision, const void* const collisionNode);
// ***********************************************************************************************************
//
// User Static mesh collision interface
//
// ***********************************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateUserMeshCollision (const NewtonWorld* const newtonWorld, const dFloat* const minBox,
const dFloat* const maxBox, void* const userData, NewtonUserMeshCollisionCollideCallback collideCallback,
NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback,
NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, NewtonUserMeshCollisionAABBTest getLocalAABBCallback,
NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, NewtonOnUserCollisionSerializationCallback serializeCallback, int shapeID);
NEWTON_API int NewtonUserMeshCollisionContinuousOverlapTest (const NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle, const dFloat* const minAabb, const dFloat* const maxAabb);
// ***********************************************************************************************************
//
// Collision serialization functions
//
// ***********************************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateCollisionFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle);
NEWTON_API void NewtonCollisionSerialize (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, NewtonSerializeCallback serializeFunction, void* const serializeHandle);
NEWTON_API void NewtonCollisionGetInfo (const NewtonCollision* const collision, NewtonCollisionInfoRecord* const collisionInfo);
// **********************************************************************************************
//
// Static collision shapes functions
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCreateHeightFieldCollision (const NewtonWorld* const newtonWorld, int width, int height, int gridsDiagonals, int elevationdatType, const void* const elevationMap, const char* const attributeMap, dFloat verticalScale, dFloat horizontalScale_x, dFloat horizontalScale_z, int shapeID);
NEWTON_API void NewtonHeightFieldSetUserRayCastCallback (const NewtonCollision* const heightfieldCollision, NewtonHeightFieldRayCastCallback rayHitCallback);
NEWTON_API NewtonCollision* NewtonCreateTreeCollision (const NewtonWorld* const newtonWorld, int shapeID);
NEWTON_API NewtonCollision* NewtonCreateTreeCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID);
NEWTON_API void NewtonTreeCollisionSetUserRayCastCallback (const NewtonCollision* const treeCollision, NewtonCollisionTreeRayCastCallback rayHitCallback);
NEWTON_API void NewtonTreeCollisionBeginBuild (const NewtonCollision* const treeCollision);
NEWTON_API void NewtonTreeCollisionAddFace (const NewtonCollision* const treeCollision, int vertexCount, const dFloat* const vertexPtr, int strideInBytes, int faceAttribute);
NEWTON_API void NewtonTreeCollisionEndBuild (const NewtonCollision* const treeCollision, int optimize);
NEWTON_API int NewtonTreeCollisionGetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount);
NEWTON_API void NewtonTreeCollisionSetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount, int attribute);
NEWTON_API void NewtonTreeCollisionForEachFace (const NewtonCollision* const treeCollision, NewtonTreeCollisionFaceCallback forEachFaceCallback, void* const context);
NEWTON_API int NewtonTreeCollisionGetVertexListTriangleListInAABB (const NewtonCollision* const treeCollision, const dFloat* const p0, const dFloat* const p1, const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, const int* const indexList, int maxIndexCount, const int* const faceAttribute);
NEWTON_API void NewtonStaticCollisionSetDebugCallback (const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback);
// **********************************************************************************************
//
// General purpose collision library functions
//
// **********************************************************************************************
NEWTON_API NewtonCollision* NewtonCollisionCreateInstance (const NewtonCollision* const collision);
NEWTON_API int NewtonCollisionGetType (const NewtonCollision* const collision);
NEWTON_API int NewtonCollisionIsConvexShape (const NewtonCollision* const collision);
NEWTON_API int NewtonCollisionIsStaticShape (const NewtonCollision* const collision);
// for the end user
NEWTON_API void NewtonCollisionSetUserData (const NewtonCollision* const collision, void* const userData);
NEWTON_API void* NewtonCollisionGetUserData (const NewtonCollision* const collision);
NEWTON_API void NewtonCollisionSetUserID (const NewtonCollision* const collision, dLong id);
NEWTON_API dLong NewtonCollisionGetUserID (const NewtonCollision* const collision);
NEWTON_API void NewtonCollisionGetMaterial (const NewtonCollision* const collision, NewtonCollisionMaterial* const userData);
NEWTON_API void NewtonCollisionSetMaterial (const NewtonCollision* const collision, const NewtonCollisionMaterial* const userData);
NEWTON_API void* NewtonCollisionGetSubCollisionHandle (const NewtonCollision* const collision);
NEWTON_API NewtonCollision* NewtonCollisionGetParentInstance (const NewtonCollision* const collision);
NEWTON_API void NewtonCollisionSetMatrix (const NewtonCollision* const collision, const dFloat* const matrix);
NEWTON_API void NewtonCollisionGetMatrix (const NewtonCollision* const collision, dFloat* const matrix);
NEWTON_API void NewtonCollisionSetScale (const NewtonCollision* const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ);
NEWTON_API void NewtonCollisionGetScale (const NewtonCollision* const collision, dFloat* const scaleX, dFloat* const scaleY, dFloat* const scaleZ);
NEWTON_API void NewtonDestroyCollision (const NewtonCollision* const collision);
NEWTON_API dFloat NewtonCollisionGetSkinThickness (const NewtonCollision* const collision);
NEWTON_API void NewtonCollisionSetSkinThickness(const NewtonCollision* const collision, dFloat thickness);
NEWTON_API int NewtonCollisionIntersectionTest (const NewtonWorld* const newtonWorld,
const NewtonCollision* const collisionA, const dFloat* const matrixA,
const NewtonCollision* const collisionB, const dFloat* const matrixB, int threadIndex);
NEWTON_API int NewtonCollisionPointDistance (const NewtonWorld* const newtonWorld, const dFloat* const point,
const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const contact, dFloat* const normal, int threadIndex);
NEWTON_API int NewtonCollisionClosestPoint (const NewtonWorld* const newtonWorld,
const NewtonCollision* const collisionA, const dFloat* const matrixA,
const NewtonCollision* const collisionB, const dFloat* const matrixB,
dFloat* const contactA, dFloat* const contactB, dFloat* const normalAB, int threadIndex);
NEWTON_API int NewtonCollisionCollide (const NewtonWorld* const newtonWorld, int maxSize,
const NewtonCollision* const collisionA, const dFloat* const matrixA,
const NewtonCollision* const collisionB, const dFloat* const matrixB,
dFloat* const contacts, dFloat* const normals, dFloat* const penetration,
dLong* const attributeA, dLong* const attributeB, int threadIndex);
NEWTON_API int NewtonCollisionCollideContinue (const NewtonWorld* const newtonWorld, int maxSize, dFloat timestep,
const NewtonCollision* const collisionA, const dFloat* const matrixA, const dFloat* const velocA, const dFloat* omegaA,
const NewtonCollision* const collisionB, const dFloat* const matrixB, const dFloat* const velocB, const dFloat* const omegaB,
dFloat* const timeOfImpact, dFloat* const contacts, dFloat* const normals, dFloat* const penetration,
dLong* const attributeA, dLong* const attributeB, int threadIndex);
NEWTON_API void NewtonCollisionSupportVertex (const NewtonCollision* const collision, const dFloat* const dir, dFloat* const vertex);
NEWTON_API dFloat NewtonCollisionRayCast (const NewtonCollision* const collision, const dFloat* const p0, const dFloat* const p1, dFloat* const normal, dLong* const attribute);
NEWTON_API void NewtonCollisionCalculateAABB (const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const p0, dFloat* const p1);
NEWTON_API void NewtonCollisionForEachPolygonDo (const NewtonCollision* const collision, const dFloat* const matrix, NewtonCollisionIterator callback, void* const userData);
// **********************************************************************************************
//
// collision aggregates, are a collision node on eh broad phase the serve as the root nod for a collection of rigid bodies
// that shared the property of being in close proximity all the time, they are similar to compound collision by the group bodies instead of collision instances
// These are good for speeding calculation calculation of rag doll, Vehicles or contractions of rigid bodied lined by joints.
// also for example if you know that many the life time of a group of bodies like the object on a house of a building will be localize to the confide of the building
// then warping the bodies under an aggregate will reduce collision calculation of almost an order of magnitude.
//
// **********************************************************************************************
NEWTON_API void* NewtonCollisionAggregateCreate (NewtonWorld* const world);
NEWTON_API void NewtonCollisionAggregateDestroy (void* const aggregate);
NEWTON_API void NewtonCollisionAggregateAddBody (void* const aggregate, const NewtonBody* const body);
NEWTON_API void NewtonCollisionAggregateRemoveBody (void* const aggregate, const NewtonBody* const body);
NEWTON_API int NewtonCollisionAggregateGetSelfCollision (void* const aggregate);
NEWTON_API void NewtonCollisionAggregateSetSelfCollision (void* const aggregate, int state);
// **********************************************************************************************
//
// transforms utility functions
//
// **********************************************************************************************
NEWTON_API void NewtonSetEulerAngle (const dFloat* const eulersAngles, dFloat* const matrix);
NEWTON_API void NewtonGetEulerAngle (const dFloat* const matrix, dFloat* const eulersAngles0, dFloat* const eulersAngles1);
NEWTON_API dFloat NewtonCalculateSpringDamperAcceleration (dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat s);
// **********************************************************************************************
//
// body manipulation functions
//
// **********************************************************************************************
NEWTON_API NewtonBody* NewtonCreateDynamicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix);
NEWTON_API NewtonBody* NewtonCreateKinematicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix);
NEWTON_API NewtonBody* NewtonCreateAsymetricDynamicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix);
NEWTON_API void NewtonDestroyBody(const NewtonBody* const body);
NEWTON_API int NewtonBodyGetSimulationState(const NewtonBody* const body);
NEWTON_API void NewtonBodySetSimulationState(const NewtonBody* const bodyPtr, const int state);
NEWTON_API int NewtonBodyGetType (const NewtonBody* const body);
NEWTON_API int NewtonBodyGetCollidable (const NewtonBody* const body);
NEWTON_API void NewtonBodySetCollidable (const NewtonBody* const body, int collidableState);
NEWTON_API void NewtonBodyAddForce (const NewtonBody* const body, const dFloat* const force);
NEWTON_API void NewtonBodyAddTorque (const NewtonBody* const body, const dFloat* const torque);
NEWTON_API void NewtonBodySetCentreOfMass (const NewtonBody* const body, const dFloat* const com);
NEWTON_API void NewtonBodySetMassMatrix (const NewtonBody* const body, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz);
NEWTON_API void NewtonBodySetFullMassMatrix (const NewtonBody* const body, dFloat mass, const dFloat* const inertiaMatrix);
NEWTON_API void NewtonBodySetMassProperties (const NewtonBody* const body, dFloat mass, const NewtonCollision* const collision);
NEWTON_API void NewtonBodySetMatrix (const NewtonBody* const body, const dFloat* const matrix);
NEWTON_API void NewtonBodySetMatrixNoSleep (const NewtonBody* const body, const dFloat* const matrix);
NEWTON_API void NewtonBodySetMatrixRecursive (const NewtonBody* const body, const dFloat* const matrix);
NEWTON_API void NewtonBodySetMaterialGroupID (const NewtonBody* const body, int id);
NEWTON_API void NewtonBodySetContinuousCollisionMode (const NewtonBody* const body, unsigned state);
NEWTON_API void NewtonBodySetJointRecursiveCollision (const NewtonBody* const body, unsigned state);
NEWTON_API void NewtonBodySetOmega (const NewtonBody* const body, const dFloat* const omega);
NEWTON_API void NewtonBodySetOmegaNoSleep (const NewtonBody* const body, const dFloat* const omega);
NEWTON_API void NewtonBodySetVelocity (const NewtonBody* const body, const dFloat* const velocity);
NEWTON_API void NewtonBodySetVelocityNoSleep (const NewtonBody* const body, const dFloat* const velocity);
NEWTON_API void NewtonBodySetForce (const NewtonBody* const body, const dFloat* const force);
NEWTON_API void NewtonBodySetTorque (const NewtonBody* const body, const dFloat* const torque);
NEWTON_API void NewtonBodySetLinearDamping (const NewtonBody* const body, dFloat linearDamp);
NEWTON_API void NewtonBodySetAngularDamping (const NewtonBody* const body, const dFloat* const angularDamp);
NEWTON_API void NewtonBodySetCollision (const NewtonBody* const body, const NewtonCollision* const collision);
NEWTON_API void NewtonBodySetCollisionScale (const NewtonBody* const body, dFloat scaleX, dFloat scaleY, dFloat scaleZ);
NEWTON_API int NewtonBodyGetSleepState (const NewtonBody* const body);
NEWTON_API void NewtonBodySetSleepState (const NewtonBody* const body, int state);
NEWTON_API int NewtonBodyGetAutoSleep (const NewtonBody* const body);
NEWTON_API void NewtonBodySetAutoSleep (const NewtonBody* const body, int state);
NEWTON_API int NewtonBodyGetFreezeState(const NewtonBody* const body);
NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* const body, int state);
NEWTON_API int NewtonBodyGetGyroscopicTorque(const NewtonBody* const body);
NEWTON_API void NewtonBodySetGyroscopicTorque(const NewtonBody* const body, int state);
NEWTON_API void NewtonBodySetDestructorCallback (const NewtonBody* const body, NewtonBodyDestructor callback);
NEWTON_API NewtonBodyDestructor NewtonBodyGetDestructorCallback (const NewtonBody* const body);
NEWTON_API void NewtonBodySetTransformCallback (const NewtonBody* const body, NewtonSetTransform callback);
NEWTON_API NewtonSetTransform NewtonBodyGetTransformCallback (const NewtonBody* const body);
NEWTON_API void NewtonBodySetForceAndTorqueCallback (const NewtonBody* const body, NewtonApplyForceAndTorque callback);
NEWTON_API NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback (const NewtonBody* const body);
NEWTON_API int NewtonBodyGetID (const NewtonBody* const body);
NEWTON_API void NewtonBodySetUserData (const NewtonBody* const body, void* const userData);
NEWTON_API void* NewtonBodyGetUserData (const NewtonBody* const body);
NEWTON_API NewtonWorld* NewtonBodyGetWorld (const NewtonBody* const body);
NEWTON_API NewtonCollision* NewtonBodyGetCollision (const NewtonBody* const body);
NEWTON_API int NewtonBodyGetMaterialGroupID (const NewtonBody* const body);
NEWTON_API int NewtonBodyGetSerializedID(const NewtonBody* const body);
NEWTON_API int NewtonBodyGetContinuousCollisionMode (const NewtonBody* const body);
NEWTON_API int NewtonBodyGetJointRecursiveCollision (const NewtonBody* const body);
NEWTON_API void NewtonBodyGetPosition(const NewtonBody* const body, dFloat* const pos);
NEWTON_API void NewtonBodyGetMatrix(const NewtonBody* const body, dFloat* const matrix);
NEWTON_API void NewtonBodyGetRotation(const NewtonBody* const body, dFloat* const rotation);
NEWTON_API void NewtonBodyGetMass (const NewtonBody* const body, dFloat* mass, dFloat* const Ixx, dFloat* const Iyy, dFloat* const Izz);
NEWTON_API void NewtonBodyGetInvMass(const NewtonBody* const body, dFloat* const invMass, dFloat* const invIxx, dFloat* const invIyy, dFloat* const invIzz);
NEWTON_API void NewtonBodyGetInertiaMatrix(const NewtonBody* const body, dFloat* const inertiaMatrix);
NEWTON_API void NewtonBodyGetInvInertiaMatrix(const NewtonBody* const body, dFloat* const invInertiaMatrix);
NEWTON_API void NewtonBodyGetOmega(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetVelocity(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetAlpha(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetAcceleration(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetForce(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetTorque(const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetCentreOfMass (const NewtonBody* const body, dFloat* const com);
NEWTON_API void NewtonBodyGetPointVelocity (const NewtonBody* const body, const dFloat* const point, dFloat* const velocOut);
NEWTON_API void NewtonBodyApplyImpulsePair (const NewtonBody* const body, dFloat* const linearImpulse, dFloat* const angularImpulse, dFloat timestep);
NEWTON_API void NewtonBodyAddImpulse (const NewtonBody* const body, const dFloat* const pointDeltaVeloc, const dFloat* const pointPosit, dFloat timestep);
NEWTON_API void NewtonBodyApplyImpulseArray (const NewtonBody* const body, int impuleCount, int strideInByte, const dFloat* const impulseArray, const dFloat* const pointArray, dFloat timestep);
NEWTON_API void NewtonBodyIntegrateVelocity (const NewtonBody* const body, dFloat timestep);
NEWTON_API dFloat NewtonBodyGetLinearDamping (const NewtonBody* const body);
NEWTON_API void NewtonBodyGetAngularDamping (const NewtonBody* const body, dFloat* const vector);
NEWTON_API void NewtonBodyGetAABB (const NewtonBody* const body, dFloat* const p0, dFloat* const p1);
NEWTON_API NewtonJoint* NewtonBodyGetFirstJoint (const NewtonBody* const body);
NEWTON_API NewtonJoint* NewtonBodyGetNextJoint (const NewtonBody* const body, const NewtonJoint* const joint);
NEWTON_API NewtonJoint* NewtonBodyGetFirstContactJoint (const NewtonBody* const body);
NEWTON_API NewtonJoint* NewtonBodyGetNextContactJoint (const NewtonBody* const body, const NewtonJoint* const contactJoint);
NEWTON_API NewtonJoint* NewtonBodyFindContact (const NewtonBody* const body0, const NewtonBody* const body1);
// **********************************************************************************************
//
// contact joints interface
//
// **********************************************************************************************
NEWTON_API void* NewtonContactJointGetFirstContact (const NewtonJoint* const contactJoint);