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
|
2659,2804d2658
<
< /******************** breakable joint contribution ***********************/
< extern "C" void dJointSetBreakable (dxJoint *joint, int b) {
< dAASSERT(joint);
< if (b) {
< // we want this joint to be breakable but we must first check if it
< // was already breakable
< if (!joint->breakInfo) {
< // allocate a dxJointBreakInfo struct
< joint->breakInfo = new dxJointBreakInfo;
< joint->breakInfo->flags = 0;
< for (int i = 0; i < 3; i++) {
< joint->breakInfo->b1MaxF[0] = 0;
< joint->breakInfo->b1MaxT[0] = 0;
< joint->breakInfo->b2MaxF[0] = 0;
< joint->breakInfo->b2MaxT[0] = 0;
< }
< joint->breakInfo->callback = 0;
< }
< else {
< // the joint was already breakable
< return;
< }
< }
< else {
< // we want this joint to be unbreakable mut we must first check if
< // it is alreay unbreakable
< if (joint->breakInfo) {
< // deallocate the dxJointBreakInfo struct
< delete joint->breakInfo;
< joint->breakInfo = 0;
< }
< else {
< // the joint was already unbreakable
< return;
< }
< }
< }
<
< extern "C" void dJointSetBreakCallback (dxJoint *joint, dJointBreakCallback *callbackFunc) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointSetBreakCallback called on unbreakable joint");
< }
< # endif
< joint->breakInfo->callback = callbackFunc;
< }
<
< extern "C" void dJointSetBreakMode (dxJoint *joint, int mode) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointSetBreakMode called on unbreakable joint");
< }
< # endif
< joint->breakInfo->flags = mode;
< }
<
< extern "C" int dJointGetBreakMode (dxJoint *joint) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointGetBreakMode called on unbreakable joint");
< }
< # endif
< return joint->breakInfo->flags;
< }
<
< extern "C" void dJointSetBreakForce (dxJoint *joint, int body, dReal x, dReal y, dReal z) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointSetBreakForce called on unbreakable joint");
< }
< # endif
< if (body) {
< joint->breakInfo->b2MaxF[0] = x;
< joint->breakInfo->b2MaxF[1] = y;
< joint->breakInfo->b2MaxF[2] = z;
< }
< else {
< joint->breakInfo->b1MaxF[0] = x;
< joint->breakInfo->b1MaxF[1] = y;
< joint->breakInfo->b1MaxF[2] = z;
< }
< }
<
< extern "C" void dJointSetBreakTorque (dxJoint *joint, int body, dReal x, dReal y, dReal z) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointSetBreakTorque called on unbreakable joint");
< }
< # endif
< if (body) {
< joint->breakInfo->b2MaxT[0] = x;
< joint->breakInfo->b2MaxT[1] = y;
< joint->breakInfo->b2MaxT[2] = z;
< }
< else {
< joint->breakInfo->b1MaxT[0] = x;
< joint->breakInfo->b1MaxT[1] = y;
< joint->breakInfo->b1MaxT[2] = z;
< }
< }
<
< extern "C" int dJointIsBreakable (dxJoint *joint) {
< dAASSERT(joint);
< return joint->breakInfo != 0;
< }
<
< extern "C" void dJointGetBreakForce (dxJoint *joint, int body, dReal *force) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointGetBreakForce called on unbreakable joint");
< }
< # endif
< if (body)
< for (int i=0; i<3; i++) force[i]=joint->breakInfo->b2MaxF[i];
< else
< for (int i=0; i<3; i++) force[i]=joint->breakInfo->b1MaxF[i];
< }
<
< extern "C" void dJointGetBreakTorque (dxJoint *joint, int body, dReal *torque) {
< dAASSERT(joint);
< # ifndef dNODEBUG
< // only works for a breakable joint
< if (!joint->breakInfo) {
< dDebug (0, "dJointGetBreakTorque called on unbreakable joint");
< }
< # endif
< if (body)
< for (int i=0; i<3; i++) torque[i]=joint->breakInfo->b2MaxT[i];
< else
< for (int i=0; i<3; i++) torque[i]=joint->breakInfo->b1MaxT[i];
< }
< /*************************************************************************/
<
\ No newline at end of file
|