aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/contrib/BreakableJoints/diff/stepfast.cpp.diff
blob: ed64cbaec9f185dbd18713e5f43b82aa2225aaf1 (plain)
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
587,598c587,593
< /******************** breakable joint contribution ***********************/
< 	// this saves us a few dereferences
<     dxJointBreakInfo *jBI = joint->breakInfo;
<     // we need joint feedback if the joint is breakable or if the user
<     // requested feedback.
< 	if (jBI||fb) {
< 		// we need feedback on the amount of force that this joint is
< 		// applying to the bodies. we use a slightly slower computation
< 		// that splits out the force components and puts them in the
< 		// feedback structure.
< 		dJointFeedback temp_fb; // temporary storage for joint feedback
< 		dReal data1[8],data2[8];
---
> 	if (fb)
> 	{
> 		// the user has requested feedback on the amount of force that this
> 		// joint is applying to the bodies. we use a slightly slower
> 		// computation that splits out the force components and puts them
> 		// in the feedback structure.
> 		dReal data1[8], data2[8];
603,608c598,603
< 			cf1[0] = (temp_fb.f1[0] = data1[0]);
< 			cf1[1] = (temp_fb.f1[1] = data1[1]);
< 			cf1[2] = (temp_fb.f1[2] = data1[2]);
< 			cf1[4] = (temp_fb.t1[0] = data1[4]);
< 			cf1[5] = (temp_fb.t1[1] = data1[5]);
< 			cf1[6] = (temp_fb.t1[2] = data1[6]);
---
> 			cf1[0] = (fb->f1[0] = data1[0]);
> 			cf1[1] = (fb->f1[1] = data1[1]);
> 			cf1[2] = (fb->f1[2] = data1[2]);
> 			cf1[4] = (fb->t1[0] = data1[4]);
> 			cf1[5] = (fb->t1[1] = data1[5]);
> 			cf1[6] = (fb->t1[2] = data1[6]);
614,691c609,614
< 			cf2[0] = (temp_fb.f2[0] = data2[0]);
< 			cf2[1] = (temp_fb.f2[1] = data2[1]);
< 			cf2[2] = (temp_fb.f2[2] = data2[2]);
< 			cf2[4] = (temp_fb.t2[0] = data2[4]);
< 			cf2[5] = (temp_fb.t2[1] = data2[5]);
< 			cf2[6] = (temp_fb.t2[2] = data2[6]);
< 		}
< 		// if the user requested so we must copy the feedback information to
< 		// the feedback struct that the user suplied.
< 		if (fb) {
< 			// copy temp_fb to fb
< 			fb->f1[0] = temp_fb.f1[0];
< 			fb->f1[1] = temp_fb.f1[1];
< 			fb->f1[2] = temp_fb.f1[2];
< 			fb->t1[0] = temp_fb.t1[0];
< 			fb->t1[1] = temp_fb.t1[1];
< 			fb->t1[2] = temp_fb.t1[2];
< 			if (body[1]) {
< 				fb->f2[0] = temp_fb.f2[0];
< 				fb->f2[1] = temp_fb.f2[1];
< 				fb->f2[2] = temp_fb.f2[2];
< 				fb->t2[0] = temp_fb.t2[0];
< 				fb->t2[1] = temp_fb.t2[1];
< 				fb->t2[2] = temp_fb.t2[2];
< 			}
< 		}
< 		// if the joint is breakable we need to check the breaking conditions
< 		if (jBI) {
< 			dReal relCF1[3];
< 			dReal relCT1[3];
< 			// multiply the force and torque vectors by the rotation matrix of body 1
< 			dMULTIPLY1_331 (&relCF1[0],body[0]->R,&temp_fb.f1[0]);
< 			dMULTIPLY1_331 (&relCT1[0],body[0]->R,&temp_fb.t1[0]);
< 			if (jBI->flags & dJOINT_BREAK_AT_B1_FORCE) {
< 				// check if the force is to high
< 				for (int i = 0; i < 3; i++) {
< 					if (relCF1[i] > jBI->b1MaxF[i]) {
< 						jBI->flags |= dJOINT_BROKEN;
< 						goto doneCheckingBreaks;
< 					}
< 				}
< 			}
< 			if (jBI->flags & dJOINT_BREAK_AT_B1_TORQUE) {
< 				// check if the torque is to high
< 				for (int i = 0; i < 3; i++) {
< 					if (relCT1[i] > jBI->b1MaxT[i]) {
< 						jBI->flags |= dJOINT_BROKEN;
< 						goto doneCheckingBreaks;
< 					}
< 				}
< 			}
< 			if (body[1]) {
< 				dReal relCF2[3];
< 				dReal relCT2[3];
< 				// multiply the force and torque vectors by the rotation matrix of body 2
< 				dMULTIPLY1_331 (&relCF2[0],body[1]->R,&temp_fb.f2[0]);
< 				dMULTIPLY1_331 (&relCT2[0],body[1]->R,&temp_fb.t2[0]);
< 				if (jBI->flags & dJOINT_BREAK_AT_B2_FORCE) {
< 					// check if the force is to high
< 					for (int i = 0; i < 3; i++) {
< 						if (relCF2[i] > jBI->b2MaxF[i]) {
< 							jBI->flags |= dJOINT_BROKEN;
< 							goto doneCheckingBreaks;
< 						}
< 					}
< 				}
< 				if (jBI->flags & dJOINT_BREAK_AT_B2_TORQUE) {
< 					// check if the torque is to high
< 					for (int i = 0; i < 3; i++) {
< 						if (relCT2[i] > jBI->b2MaxT[i]) {
< 							jBI->flags |= dJOINT_BROKEN;
< 							goto doneCheckingBreaks;
< 						}
< 					}
< 				}
< 			}
< 			doneCheckingBreaks:
< 			;
---
> 			cf2[0] = (fb->f2[0] = data2[0]);
> 			cf2[1] = (fb->f2[1] = data2[1]);
> 			cf2[2] = (fb->f2[2] = data2[2]);
> 			cf2[4] = (fb->t2[0] = data2[4]);
> 			cf2[5] = (fb->t2[1] = data2[5]);
> 			cf2[6] = (fb->t2[2] = data2[6]);
694d616
< /*************************************************************************/
1178,1196d1099
<   /******************** breakable joint contribution ***********************/
<   dxJoint* nextJ;
<   if (!world->firstjoint)
<     nextJ = 0;
<   else
<     nextJ = (dxJoint*)world->firstjoint->next;
<   for (j=world->firstjoint; j; j=nextJ) {
<   	nextJ = (dxJoint*)j->next;
< 	// check if joint is breakable and broken
<     if (j->breakInfo && j->breakInfo->flags & dJOINT_BROKEN) {
< 		// detach (break) the joint
<         dJointAttach (j, 0, 0);
< 		// call the callback function if it is set
< 		if (j->breakInfo->callback) j->breakInfo->callback (j);
< 		// finally destroy the joint if the dJOINT_DELETE_ON_BREAK is set
< 		if (j->breakInfo->flags & dJOINT_DELETE_ON_BREAK) dJointDestroy (j);
<       }
<   }
<   /*************************************************************************/