-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbox2d_c-joint.go
More file actions
10516 lines (10276 loc) · 369 KB
/
box2d_c-joint.go
File metadata and controls
10516 lines (10276 loc) · 369 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
package b2
import (
"reflect"
"unsafe"
)
var _ unsafe.Pointer
var _ reflect.Type
func b2AssignJointColor(tls *_Stack, graph uintptr, bodyIdA int32, bodyIdB int32, staticA uint8, staticB uint8) (r int32) {
var blockIndex, blockIndex1, v12, v14, v17, v21, v24, v28, v3, v7 uint32_t
var color, color1, color2, v11, v13, v16, v2, v20, v23, v27, v6 uintptr
var i, i1, i2 int32
var v10 bool
var v18, v25, v4, v8 uint8
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = blockIndex, blockIndex1, color, color1, color2, i, i1, i2, v10, v11, v12, v13, v14, v16, v17, v18, v2, v20, v21, v23, v24, v25, v27, v28, v3, v4, v6, v7, v8
if !(int32FromUint8(staticA) == false1 || int32FromUint8(staticB) == false1) && b2InternalAssertFcn(tls, __ccgo_ts+2939, __ccgo_ts+2787, int32FromInt32(216)) != 0 {
__builtin_trap(tls)
}
if int32FromUint8(staticA) == false1 && int32FromUint8(staticB) == false1 {
i = 0
for {
if !(i < int32FromInt32(_B2_GRAPH_COLOR_COUNT)-int32FromInt32(1)) {
break
}
color = graph + uintptr(i)*56
v2 = color
v3 = uint32FromInt32(bodyIdA)
blockIndex1 = v3 / uint32(64)
if blockIndex1 >= (*b2BitSet)(unsafe.Pointer(v2)).BlockCount {
v4 = boolUint8(false1 != 0)
goto _5
}
v4 = boolUint8(*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v2)).Bits + uintptr(blockIndex1)*8))&(uint64FromInt32(1)<<(v3%uint32FromInt32(64))) != uint64(0))
goto _5
_5:
;
if v10 = v4 != 0; !v10 {
v6 = color
v7 = uint32FromInt32(bodyIdB)
blockIndex1 = v7 / uint32(64)
if blockIndex1 >= (*b2BitSet)(unsafe.Pointer(v6)).BlockCount {
v8 = boolUint8(false1 != 0)
goto _9
}
v8 = boolUint8(*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v6)).Bits + uintptr(blockIndex1)*8))&(uint64FromInt32(1)<<(v7%uint32FromInt32(64))) != uint64(0))
goto _9
_9:
}
if v10 || v8 != 0 {
goto _1
}
v11 = color
v12 = uint32FromInt32(bodyIdA)
blockIndex = v12 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v11)).BlockCount {
b2GrowBitSet(tls, v11, blockIndex+uint32(1))
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v11)).Bits + uintptr(blockIndex)*8)) |= uint64FromInt32(1) << (v12 % uint32FromInt32(64))
v13 = color
v14 = uint32FromInt32(bodyIdB)
blockIndex = v14 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v13)).BlockCount {
b2GrowBitSet(tls, v13, blockIndex+uint32(1))
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v13)).Bits + uintptr(blockIndex)*8)) |= uint64FromInt32(1) << (v14 % uint32FromInt32(64))
return i
goto _1
_1:
;
i = i + 1
}
} else {
if int32FromUint8(staticA) == false1 {
i1 = 0
for {
if !(i1 < int32FromInt32(_B2_GRAPH_COLOR_COUNT)-int32FromInt32(1)) {
break
}
color1 = graph + uintptr(i1)*56
v16 = color1
v17 = uint32FromInt32(bodyIdA)
blockIndex1 = v17 / uint32(64)
if blockIndex1 >= (*b2BitSet)(unsafe.Pointer(v16)).BlockCount {
v18 = boolUint8(false1 != 0)
goto _19
}
v18 = boolUint8(*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v16)).Bits + uintptr(blockIndex1)*8))&(uint64FromInt32(1)<<(v17%uint32FromInt32(64))) != uint64(0))
goto _19
_19:
if v18 != 0 {
goto _15
}
v20 = color1
v21 = uint32FromInt32(bodyIdA)
blockIndex = v21 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v20)).BlockCount {
b2GrowBitSet(tls, v20, blockIndex+uint32(1))
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v20)).Bits + uintptr(blockIndex)*8)) |= uint64FromInt32(1) << (v21 % uint32FromInt32(64))
return i1
goto _15
_15:
;
i1 = i1 + 1
}
} else {
if int32FromUint8(staticB) == false1 {
i2 = 0
for {
if !(i2 < int32FromInt32(_B2_GRAPH_COLOR_COUNT)-int32FromInt32(1)) {
break
}
color2 = graph + uintptr(i2)*56
v23 = color2
v24 = uint32FromInt32(bodyIdB)
blockIndex1 = v24 / uint32(64)
if blockIndex1 >= (*b2BitSet)(unsafe.Pointer(v23)).BlockCount {
v25 = boolUint8(false1 != 0)
goto _26
}
v25 = boolUint8(*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v23)).Bits + uintptr(blockIndex1)*8))&(uint64FromInt32(1)<<(v24%uint32FromInt32(64))) != uint64(0))
goto _26
_26:
if v25 != 0 {
goto _22
}
v27 = color2
v28 = uint32FromInt32(bodyIdB)
blockIndex = v28 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v27)).BlockCount {
b2GrowBitSet(tls, v27, blockIndex+uint32(1))
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v27)).Bits + uintptr(blockIndex)*8)) |= uint64FromInt32(1) << (v28 % uint32FromInt32(64))
return i2
goto _22
_22:
;
i2 = i2 + 1
}
}
}
}
return int32FromInt32(_B2_GRAPH_COLOR_COUNT) - int32FromInt32(1)
}
func b2CreateJointInGraph(tls *_Stack, world uintptr, joint uintptr) (r uintptr) {
var bodyA, bodyB, graph, jointSim, v1, v11, v3, v5, v7, v9 uintptr
var bodyIdA, bodyIdB, colorIndex, newCapacity, v10, v2, v6 int32
var staticA, staticB uint8
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = bodyA, bodyB, bodyIdA, bodyIdB, colorIndex, graph, jointSim, newCapacity, staticA, staticB, v1, v10, v11, v2, v3, v5, v6, v7, v9
graph = world + 328
bodyIdA = (*(*b2JointEdge)(unsafe.Pointer(joint + 20))).BodyId
bodyIdB = (*(*b2JointEdge)(unsafe.Pointer(joint + 20 + 1*12))).BodyId
v1 = world + 1024
v2 = bodyIdA
if !(0 <= v2 && v2 < (*b2BodyArray)(unsafe.Pointer(v1)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(192)) != 0 {
__builtin_trap(tls)
}
v3 = (*b2BodyArray)(unsafe.Pointer(v1)).Data + uintptr(v2)*128
goto _4
_4:
bodyA = v3
v5 = world + 1024
v6 = bodyIdB
if !(0 <= v6 && v6 < (*b2BodyArray)(unsafe.Pointer(v5)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(192)) != 0 {
__builtin_trap(tls)
}
v7 = (*b2BodyArray)(unsafe.Pointer(v5)).Data + uintptr(v6)*128
goto _8
_8:
bodyB = v7
staticA = boolUint8((*b2Body)(unsafe.Pointer(bodyA)).SetIndex == int32(b2_staticSet))
staticB = boolUint8((*b2Body)(unsafe.Pointer(bodyB)).SetIndex == int32(b2_staticSet))
colorIndex = b2AssignJointColor(tls, graph, bodyIdA, bodyIdB, staticA, staticB)
v9 = graph + uintptr(colorIndex)*56 + 32
if (*b2JointSimArray)(unsafe.Pointer(v9)).Count == (*b2JointSimArray)(unsafe.Pointer(v9)).Capacity {
if (*b2JointSimArray)(unsafe.Pointer(v9)).Capacity < int32(2) {
v10 = int32(2)
} else {
v10 = (*b2JointSimArray)(unsafe.Pointer(v9)).Capacity + (*b2JointSimArray)(unsafe.Pointer(v9)).Capacity>>int32(1)
}
newCapacity = v10
b2JointSimArray_Reserve(tls, v9, newCapacity)
}
*(*int32)(unsafe.Pointer(v9 + 8)) += int32(1)
v11 = (*b2JointSimArray)(unsafe.Pointer(v9)).Data + uintptr((*b2JointSimArray)(unsafe.Pointer(v9)).Count-int32FromInt32(1))*196
goto _12
_12:
jointSim = v11
memset(tls, jointSim, 0, uint64(196))
(*b2Joint)(unsafe.Pointer(joint)).ColorIndex = colorIndex
(*b2Joint)(unsafe.Pointer(joint)).LocalIndex = (*(*b2GraphColor)(unsafe.Pointer(graph + uintptr(colorIndex)*56))).JointSims.Count - int32(1)
return jointSim
}
func b2AddJointToGraph(tls *_Stack, world uintptr, jointSim uintptr, joint uintptr) {
var jointDst uintptr
_ = jointDst
jointDst = b2CreateJointInGraph(tls, world, joint)
memcpy(tls, jointDst, jointSim, uint64(196))
}
func b2RemoveJointFromGraph(tls *_Stack, world uintptr, bodyIdA int32, bodyIdB int32, colorIndex int32, localIndex int32) {
var blockIndex, v2, v5 uint32_t
var color, graph, movedJoint, movedJointSim, v1, v11, v13, v4, v7 uintptr
var movedId, movedIndex, movedIndex1, v12, v8, v9 int32
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = blockIndex, color, graph, movedId, movedIndex, movedIndex1, movedJoint, movedJointSim, v1, v11, v12, v13, v2, v4, v5, v7, v8, v9
graph = world + 328
if !(0 <= colorIndex && colorIndex < int32(_B2_GRAPH_COLOR_COUNT)) && b2InternalAssertFcn(tls, __ccgo_ts+3038, __ccgo_ts+2787, int32FromInt32(300)) != 0 {
__builtin_trap(tls)
}
color = graph + uintptr(colorIndex)*56
if colorIndex != int32FromInt32(_B2_GRAPH_COLOR_COUNT)-int32FromInt32(1) {
// May clear static bodies, no effect
v1 = color
v2 = uint32FromInt32(bodyIdA)
blockIndex = v2 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v1)).BlockCount {
goto _3
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v1)).Bits + uintptr(blockIndex)*8)) &= ^(uint64FromInt32(1) << (v2 % uint32FromInt32(64)))
_3:
;
v4 = color
v5 = uint32FromInt32(bodyIdB)
blockIndex = v5 / uint32(64)
if blockIndex >= (*b2BitSet)(unsafe.Pointer(v4)).BlockCount {
goto _6
}
*(*uint64_t)(unsafe.Pointer((*b2BitSet)(unsafe.Pointer(v4)).Bits + uintptr(blockIndex)*8)) &= ^(uint64FromInt32(1) << (v5 % uint32FromInt32(64)))
_6:
}
v7 = color + 32
v8 = localIndex
if !(0 <= v8 && v8 < (*b2JointSimArray)(unsafe.Pointer(v7)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+1361, int32FromInt32(342)) != 0 {
__builtin_trap(tls)
}
movedIndex = -int32(1)
if v8 != (*b2JointSimArray)(unsafe.Pointer(v7)).Count-int32FromInt32(1) {
movedIndex = (*b2JointSimArray)(unsafe.Pointer(v7)).Count - int32(1)
*(*b2JointSim)(unsafe.Pointer((*b2JointSimArray)(unsafe.Pointer(v7)).Data + uintptr(v8)*196)) = *(*b2JointSim)(unsafe.Pointer((*b2JointSimArray)(unsafe.Pointer(v7)).Data + uintptr(movedIndex)*196))
}
*(*int32)(unsafe.Pointer(v7 + 8)) -= int32(1)
v9 = movedIndex
goto _10
_10:
movedIndex1 = v9
if movedIndex1 != -int32(1) {
// Fix moved joint
movedJointSim = (*b2GraphColor)(unsafe.Pointer(color)).JointSims.Data + uintptr(localIndex)*196
movedId = (*b2JointSim)(unsafe.Pointer(movedJointSim)).JointId
v11 = world + 1104
v12 = movedId
if !(0 <= v12 && v12 < (*b2JointArray)(unsafe.Pointer(v11)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+1361, int32FromInt32(341)) != 0 {
__builtin_trap(tls)
}
v13 = (*b2JointArray)(unsafe.Pointer(v11)).Data + uintptr(v12)*72
goto _14
_14:
movedJoint = v13
if !((*b2Joint)(unsafe.Pointer(movedJoint)).SetIndex == int32(b2_awakeSet)) && b2InternalAssertFcn(tls, __ccgo_ts+3207, __ccgo_ts+2787, int32FromInt32(317)) != 0 {
__builtin_trap(tls)
}
if !((*b2Joint)(unsafe.Pointer(movedJoint)).ColorIndex == colorIndex) && b2InternalAssertFcn(tls, __ccgo_ts+3243, __ccgo_ts+2787, int32FromInt32(318)) != 0 {
__builtin_trap(tls)
}
if !((*b2Joint)(unsafe.Pointer(movedJoint)).LocalIndex == movedIndex1) && b2InternalAssertFcn(tls, __ccgo_ts+3280, __ccgo_ts+2787, int32FromInt32(319)) != 0 {
__builtin_trap(tls)
}
(*b2Joint)(unsafe.Pointer(movedJoint)).LocalIndex = localIndex
}
}
func b2DistanceJoint_SetLength(tls *_Stack, jointId JointId, length float32) {
var base, joint uintptr
var v1, v2, v3, v4, v6, v7 float32
_, _, _, _, _, _, _, _ = base, joint, v1, v2, v3, v4, v6, v7
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
v1 = length
v2 = float32(float32FromFloat32(0.005) * b2_lengthUnitsPerMeter)
v3 = float32(float32FromFloat32(100000) * b2_lengthUnitsPerMeter)
if v1 < v2 {
v6 = v2
} else {
if v1 > v3 {
v7 = v3
} else {
v7 = v1
}
v6 = v7
}
v4 = v6
goto _5
_5:
(*b2DistanceJoint)(unsafe.Pointer(joint)).Length = v4
(*b2DistanceJoint)(unsafe.Pointer(joint)).Impulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).LowerImpulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).UpperImpulse = float32FromFloat32(0)
}
func b2DistanceJoint_GetLength(tls *_Stack, jointId JointId) (r float32) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
return (*b2DistanceJoint)(unsafe.Pointer(joint)).Length
}
func b2DistanceJoint_EnableLimit(tls *_Stack, jointId JointId, enableLimit uint8) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
(*b2DistanceJoint)(unsafe.Pointer(joint)).EnableLimit = enableLimit
}
func b2DistanceJoint_IsLimitEnabled(tls *_Stack, jointId JointId) (r uint8) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return (*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.EnableLimit
}
func b2DistanceJoint_SetLengthRange(tls *_Stack, jointId JointId, minLength float32, maxLength float32) {
var base, joint uintptr
var v1, v10, v11, v13, v14, v15, v16, v17, v19, v2, v20, v21, v22, v24, v3, v4, v6, v7, v8, v9 float32
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base, joint, v1, v10, v11, v13, v14, v15, v16, v17, v19, v2, v20, v21, v22, v24, v3, v4, v6, v7, v8, v9
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
v1 = minLength
v2 = float32(float32FromFloat32(0.005) * b2_lengthUnitsPerMeter)
v3 = float32(float32FromFloat32(100000) * b2_lengthUnitsPerMeter)
if v1 < v2 {
v6 = v2
} else {
if v1 > v3 {
v7 = v3
} else {
v7 = v1
}
v6 = v7
}
v4 = v6
goto _5
_5:
minLength = v4
v8 = maxLength
v9 = float32(float32FromFloat32(0.005) * b2_lengthUnitsPerMeter)
v10 = float32(float32FromFloat32(100000) * b2_lengthUnitsPerMeter)
if v8 < v9 {
v13 = v9
} else {
if v8 > v10 {
v14 = v10
} else {
v14 = v8
}
v13 = v14
}
v11 = v13
goto _12
_12:
maxLength = v11
v15 = minLength
v16 = maxLength
if v15 < v16 {
v19 = v15
} else {
v19 = v16
}
v17 = v19
goto _18
_18:
(*b2DistanceJoint)(unsafe.Pointer(joint)).MinLength = v17
v20 = minLength
v21 = maxLength
if v20 > v21 {
v24 = v20
} else {
v24 = v21
}
v22 = v24
goto _23
_23:
(*b2DistanceJoint)(unsafe.Pointer(joint)).MaxLength = v22
(*b2DistanceJoint)(unsafe.Pointer(joint)).Impulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).LowerImpulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).UpperImpulse = float32FromFloat32(0)
}
func b2DistanceJoint_GetMinLength(tls *_Stack, jointId JointId) (r float32) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
return (*b2DistanceJoint)(unsafe.Pointer(joint)).MinLength
}
func b2DistanceJoint_GetMaxLength(tls *_Stack, jointId JointId) (r float32) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
return (*b2DistanceJoint)(unsafe.Pointer(joint)).MaxLength
}
func b2DistanceJoint_GetCurrentLength(tls *_Stack, jointId JointId) (r float32) {
var base, world uintptr
var d, pA, pB, v10, v11, v13, v2, v3, v6, v7, v9 Vec2
var length, x, y, v14 float32
var transformA, transformB, v1, v5 Transform
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = base, d, length, pA, pB, transformA, transformB, world, x, y, v1, v10, v11, v13, v14, v2, v3, v5, v6, v7, v9
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
world = b2GetWorld(tls, int32FromUint16(jointId.World0))
if !(int32FromUint8((*b2World)(unsafe.Pointer(world)).Locked) == int32FromInt32(false1)) && b2InternalAssertFcn(tls, __ccgo_ts+1152, __ccgo_ts+4580, int32FromInt32(84)) != 0 {
__builtin_trap(tls)
}
if (*b2World)(unsafe.Pointer(world)).Locked != 0 {
return float32FromFloat32(0)
}
transformA = b2GetBodyTransform(tls, world, (*b2JointSim)(unsafe.Pointer(base)).BodyIdA)
transformB = b2GetBodyTransform(tls, world, (*b2JointSim)(unsafe.Pointer(base)).BodyIdB)
v1 = transformA
v2 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorA
x = float32(v1.Q.C*v2.X) - float32(v1.Q.S*v2.Y) + v1.P.X
y = float32(v1.Q.S*v2.X) + float32(v1.Q.C*v2.Y) + v1.P.Y
v3 = Vec2{
X: x,
Y: y,
}
goto _4
_4:
pA = v3
v5 = transformB
v6 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorB
x = float32(v5.Q.C*v6.X) - float32(v5.Q.S*v6.Y) + v5.P.X
y = float32(v5.Q.S*v6.X) + float32(v5.Q.C*v6.Y) + v5.P.Y
v7 = Vec2{
X: x,
Y: y,
}
goto _8
_8:
pB = v7
v9 = pB
v10 = pA
v11 = Vec2{
X: v9.X - v10.X,
Y: v9.Y - v10.Y,
}
goto _12
_12:
d = v11
v13 = d
v14 = sqrtf(tls, float32(v13.X*v13.X)+float32(v13.Y*v13.Y))
goto _15
_15:
length = v14
return length
}
func b2DistanceJoint_EnableSpring(tls *_Stack, jointId JointId, enableSpring uint8) {
var base uintptr
_ = base
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
(*b2JointSim)(unsafe.Pointer(base)).f__ccgo13_68.DistanceJoint.EnableSpring = enableSpring
}
func b2DistanceJoint_IsSpringEnabled(tls *_Stack, jointId JointId) (r uint8) {
var base uintptr
_ = base
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return (*b2JointSim)(unsafe.Pointer(base)).f__ccgo13_68.DistanceJoint.EnableSpring
}
func b2DistanceJoint_SetSpringHertz(tls *_Stack, jointId JointId, hertz float32) {
var base uintptr
_ = base
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
(*b2JointSim)(unsafe.Pointer(base)).f__ccgo13_68.DistanceJoint.Hertz = hertz
}
func b2DistanceJoint_SetSpringDampingRatio(tls *_Stack, jointId JointId, dampingRatio float32) {
var base uintptr
_ = base
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
(*b2JointSim)(unsafe.Pointer(base)).f__ccgo13_68.DistanceJoint.DampingRatio = dampingRatio
}
func b2DistanceJoint_GetSpringHertz(tls *_Stack, jointId JointId) (r float32) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
return (*b2DistanceJoint)(unsafe.Pointer(joint)).Hertz
}
func b2DistanceJoint_GetSpringDampingRatio(tls *_Stack, jointId JointId) (r float32) {
var base, joint uintptr
_, _ = base, joint
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
joint = base + 68
return (*b2DistanceJoint)(unsafe.Pointer(joint)).DampingRatio
}
func b2DistanceJoint_EnableMotor(tls *_Stack, jointId JointId, enableMotor uint8) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
if enableMotor != (*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.EnableMotor {
(*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.EnableMotor = enableMotor
(*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.MotorImpulse = float32FromFloat32(0)
}
}
func b2DistanceJoint_IsMotorEnabled(tls *_Stack, jointId JointId) (r uint8) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return (*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.EnableMotor
}
func b2DistanceJoint_SetMotorSpeed(tls *_Stack, jointId JointId, motorSpeed float32) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
(*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.MotorSpeed = motorSpeed
}
func b2DistanceJoint_GetMotorSpeed(tls *_Stack, jointId JointId) (r float32) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return (*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.MotorSpeed
}
func b2DistanceJoint_GetMotorForce(tls *_Stack, jointId JointId) (r float32) {
var base, world uintptr
_, _ = base, world
world = b2GetWorld(tls, int32FromUint16(jointId.World0))
base = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return float32((*b2World)(unsafe.Pointer(world)).Inv_h * (*b2JointSim)(unsafe.Pointer(base)).f__ccgo13_68.DistanceJoint.MotorImpulse)
}
func b2DistanceJoint_SetMaxMotorForce(tls *_Stack, jointId JointId, force float32) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
(*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.MaxMotorForce = force
}
func b2DistanceJoint_GetMaxMotorForce(tls *_Stack, jointId JointId) (r float32) {
var joint uintptr
_ = joint
joint = b2GetJointSimCheckType(tls, jointId, int32(b2_distanceJoint))
return (*b2JointSim)(unsafe.Pointer(joint)).f__ccgo13_68.DistanceJoint.MaxMotorForce
}
func b2GetDistanceJointForce(tls *_Stack, world uintptr, base uintptr) (r Vec2) {
var axis, d, n, pA, pB, v10, v11, v13, v14, v17, v18, v2, v3, v6, v7, v9 Vec2
var force, invLength, length, x, y, v16 float32
var joint uintptr
var transformA, transformB, v1, v5 Transform
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = axis, d, force, invLength, joint, length, n, pA, pB, transformA, transformB, x, y, v1, v10, v11, v13, v14, v16, v17, v18, v2, v3, v5, v6, v7, v9
joint = base + 68
transformA = b2GetBodyTransform(tls, world, (*b2JointSim)(unsafe.Pointer(base)).BodyIdA)
transformB = b2GetBodyTransform(tls, world, (*b2JointSim)(unsafe.Pointer(base)).BodyIdB)
v1 = transformA
v2 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorA
x = float32(v1.Q.C*v2.X) - float32(v1.Q.S*v2.Y) + v1.P.X
y = float32(v1.Q.S*v2.X) + float32(v1.Q.C*v2.Y) + v1.P.Y
v3 = Vec2{
X: x,
Y: y,
}
goto _4
_4:
pA = v3
v5 = transformB
v6 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorB
x = float32(v5.Q.C*v6.X) - float32(v5.Q.S*v6.Y) + v5.P.X
y = float32(v5.Q.S*v6.X) + float32(v5.Q.C*v6.Y) + v5.P.Y
v7 = Vec2{
X: x,
Y: y,
}
goto _8
_8:
pB = v7
v9 = pB
v10 = pA
v11 = Vec2{
X: v9.X - v10.X,
Y: v9.Y - v10.Y,
}
goto _12
_12:
d = v11
v13 = d
length = sqrtf(tls, float32(v13.X*v13.X)+float32(v13.Y*v13.Y))
if length < float32FromFloat32(1.1920928955078125e-07) {
v14 = Vec2{}
goto _15
}
invLength = float32FromFloat32(1) / length
n = Vec2{
X: float32(invLength * v13.X),
Y: float32(invLength * v13.Y),
}
v14 = n
goto _15
_15:
axis = v14
force = float32(((*b2DistanceJoint)(unsafe.Pointer(joint)).Impulse + (*b2DistanceJoint)(unsafe.Pointer(joint)).LowerImpulse - (*b2DistanceJoint)(unsafe.Pointer(joint)).UpperImpulse + (*b2DistanceJoint)(unsafe.Pointer(joint)).MotorImpulse) * (*b2World)(unsafe.Pointer(world)).Inv_h)
v16 = force
v17 = axis
v18 = Vec2{
X: float32(v16 * v17.X),
Y: float32(v16 * v17.Y),
}
goto _19
_19:
return v18
}
// 1-D constrained system
// m (v2 - v1) = lambda
// v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass.
// x2 = x1 + h * v2
// 1-D mass-damper-spring system
// m (v2 - v1) + h * d * v2 + h * k *
// C = norm(p2 - p1) - L
// u = (p2 - p1) / norm(p2 - p1)
// Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1))
// J = [-u -cross(r1, u) u cross(r2, u)]
// K = J * invM * JT
// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2
func b2PrepareDistanceJoint(tls *_Stack, base uintptr, context uintptr) {
var a11, a21, a31, crA, crB, iA, iB, invLength, k, length, mA, mB, omega, v60, v64, v66, v67, v68 float32
var axis, n, rA, rB, separation, v27, v28, v29, v32, v33, v35, v36, v37, v40, v41, v43, v44, v45, v47, v48, v49, v51, v52, v53, v55, v56, v58, v59, v62, v63 Vec2
var bodyA, bodyB, bodySimA, bodySimB, joint, setA, setB, world, v1, v11, v13, v15, v17, v19, v21, v23, v3, v5, v7, v9 uintptr
var idA, idB, localIndexA, localIndexB, v10, v14, v18, v2, v22, v25, v26, v6 int32
var v31, v39 Rot
var v69 b2Softness
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = a11, a21, a31, axis, bodyA, bodyB, bodySimA, bodySimB, crA, crB, iA, iB, idA, idB, invLength, joint, k, length, localIndexA, localIndexB, mA, mB, n, omega, rA, rB, separation, setA, setB, world, v1, v10, v11, v13, v14, v15, v17, v18, v19, v2, v21, v22, v23, v25, v26, v27, v28, v29, v3, v31, v32, v33, v35, v36, v37, v39, v40, v41, v43, v44, v45, v47, v48, v49, v5, v51, v52, v53, v55, v56, v58, v59, v6, v60, v62, v63, v64, v66, v67, v68, v69, v7, v9
if !((*b2JointSim)(unsafe.Pointer(base)).Type1 == int32(b2_distanceJoint)) && b2InternalAssertFcn(tls, __ccgo_ts+4612, __ccgo_ts+4580, int32FromInt32(217)) != 0 {
__builtin_trap(tls)
}
// chase body id to the solver set where the body lives
idA = (*b2JointSim)(unsafe.Pointer(base)).BodyIdA
idB = (*b2JointSim)(unsafe.Pointer(base)).BodyIdB
world = (*b2StepContext)(unsafe.Pointer(context)).World
v1 = world + 1024
v2 = idA
if !(0 <= v2 && v2 < (*b2BodyArray)(unsafe.Pointer(v1)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(192)) != 0 {
__builtin_trap(tls)
}
v3 = (*b2BodyArray)(unsafe.Pointer(v1)).Data + uintptr(v2)*128
goto _4
_4:
bodyA = v3
v5 = world + 1024
v6 = idB
if !(0 <= v6 && v6 < (*b2BodyArray)(unsafe.Pointer(v5)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(192)) != 0 {
__builtin_trap(tls)
}
v7 = (*b2BodyArray)(unsafe.Pointer(v5)).Data + uintptr(v6)*128
goto _8
_8:
bodyB = v7
if !((*b2Body)(unsafe.Pointer(bodyA)).SetIndex == int32(b2_awakeSet) || (*b2Body)(unsafe.Pointer(bodyB)).SetIndex == int32(b2_awakeSet)) && b2InternalAssertFcn(tls, __ccgo_ts+4643, __ccgo_ts+4580, int32FromInt32(227)) != 0 {
__builtin_trap(tls)
}
v9 = world + 1064
v10 = (*b2Body)(unsafe.Pointer(bodyA)).SetIndex
if !(0 <= v10 && v10 < (*b2SolverSetArray)(unsafe.Pointer(v9)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+402, int32FromInt32(57)) != 0 {
__builtin_trap(tls)
}
v11 = (*b2SolverSetArray)(unsafe.Pointer(v9)).Data + uintptr(v10)*88
goto _12
_12:
setA = v11
v13 = world + 1064
v14 = (*b2Body)(unsafe.Pointer(bodyB)).SetIndex
if !(0 <= v14 && v14 < (*b2SolverSetArray)(unsafe.Pointer(v13)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+402, int32FromInt32(57)) != 0 {
__builtin_trap(tls)
}
v15 = (*b2SolverSetArray)(unsafe.Pointer(v13)).Data + uintptr(v14)*88
goto _16
_16:
setB = v15
localIndexA = (*b2Body)(unsafe.Pointer(bodyA)).LocalIndex
localIndexB = (*b2Body)(unsafe.Pointer(bodyB)).LocalIndex
v17 = setA
v18 = localIndexA
if !(0 <= v18 && v18 < (*b2BodySimArray)(unsafe.Pointer(v17)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(193)) != 0 {
__builtin_trap(tls)
}
v19 = (*b2BodySimArray)(unsafe.Pointer(v17)).Data + uintptr(v18)*100
goto _20
_20:
bodySimA = v19
v21 = setB
v22 = localIndexB
if !(0 <= v22 && v22 < (*b2BodySimArray)(unsafe.Pointer(v21)).Count) && b2InternalAssertFcn(tls, __ccgo_ts+349, __ccgo_ts+380, int32FromInt32(193)) != 0 {
__builtin_trap(tls)
}
v23 = (*b2BodySimArray)(unsafe.Pointer(v21)).Data + uintptr(v22)*100
goto _24
_24:
bodySimB = v23
mA = (*b2BodySim)(unsafe.Pointer(bodySimA)).InvMass
iA = (*b2BodySim)(unsafe.Pointer(bodySimA)).InvInertia
mB = (*b2BodySim)(unsafe.Pointer(bodySimB)).InvMass
iB = (*b2BodySim)(unsafe.Pointer(bodySimB)).InvInertia
(*b2JointSim)(unsafe.Pointer(base)).InvMassA = mA
(*b2JointSim)(unsafe.Pointer(base)).InvMassB = mB
(*b2JointSim)(unsafe.Pointer(base)).InvIA = iA
(*b2JointSim)(unsafe.Pointer(base)).InvIB = iB
joint = base + 68
if (*b2Body)(unsafe.Pointer(bodyA)).SetIndex == int32(b2_awakeSet) {
v25 = localIndexA
} else {
v25 = -int32(1)
}
(*b2DistanceJoint)(unsafe.Pointer(joint)).IndexA = v25
if (*b2Body)(unsafe.Pointer(bodyB)).SetIndex == int32(b2_awakeSet) {
v26 = localIndexB
} else {
v26 = -int32(1)
}
(*b2DistanceJoint)(unsafe.Pointer(joint)).IndexB = v26
// initial anchors in world space
v27 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorA
v28 = (*b2BodySim)(unsafe.Pointer(bodySimA)).LocalCenter
v29 = Vec2{
X: v27.X - v28.X,
Y: v27.Y - v28.Y,
}
goto _30
_30:
v31 = (*b2BodySim)(unsafe.Pointer(bodySimA)).Transform.Q
v32 = v29
v33 = Vec2{
X: float32(v31.C*v32.X) - float32(v31.S*v32.Y),
Y: float32(v31.S*v32.X) + float32(v31.C*v32.Y),
}
goto _34
_34:
(*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorA = v33
v35 = (*b2JointSim)(unsafe.Pointer(base)).LocalOriginAnchorB
v36 = (*b2BodySim)(unsafe.Pointer(bodySimB)).LocalCenter
v37 = Vec2{
X: v35.X - v36.X,
Y: v35.Y - v36.Y,
}
goto _38
_38:
v39 = (*b2BodySim)(unsafe.Pointer(bodySimB)).Transform.Q
v40 = v37
v41 = Vec2{
X: float32(v39.C*v40.X) - float32(v39.S*v40.Y),
Y: float32(v39.S*v40.X) + float32(v39.C*v40.Y),
}
goto _42
_42:
(*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorB = v41
v43 = (*b2BodySim)(unsafe.Pointer(bodySimB)).Center
v44 = (*b2BodySim)(unsafe.Pointer(bodySimA)).Center
v45 = Vec2{
X: v43.X - v44.X,
Y: v43.Y - v44.Y,
}
goto _46
_46:
(*b2DistanceJoint)(unsafe.Pointer(joint)).DeltaCenter = v45
rA = (*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorA
rB = (*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorB
v47 = rB
v48 = rA
v49 = Vec2{
X: v47.X - v48.X,
Y: v47.Y - v48.Y,
}
goto _50
_50:
v51 = v49
v52 = (*b2DistanceJoint)(unsafe.Pointer(joint)).DeltaCenter
v53 = Vec2{
X: v51.X + v52.X,
Y: v51.Y + v52.Y,
}
goto _54
_54:
separation = v53
v55 = separation
length = sqrtf(tls, float32(v55.X*v55.X)+float32(v55.Y*v55.Y))
if length < float32FromFloat32(1.1920928955078125e-07) {
v56 = Vec2{}
goto _57
}
invLength = float32FromFloat32(1) / length
n = Vec2{
X: float32(invLength * v55.X),
Y: float32(invLength * v55.Y),
}
v56 = n
goto _57
_57:
axis = v56
v58 = rA
v59 = axis
v60 = float32(v58.X*v59.Y) - float32(v58.Y*v59.X)
goto _61
_61:
// compute effective mass
crA = v60
v62 = rB
v63 = axis
v64 = float32(v62.X*v63.Y) - float32(v62.Y*v63.X)
goto _65
_65:
crB = v64
k = mA + mB + float32(float32(iA*crA)*crA) + float32(float32(iB*crB)*crB)
if k > float32FromFloat32(0) {
v66 = float32FromFloat32(1) / k
} else {
v66 = float32FromFloat32(0)
}
(*b2DistanceJoint)(unsafe.Pointer(joint)).AxialMass = v66
v67 = (*b2DistanceJoint)(unsafe.Pointer(joint)).Hertz
v68 = (*b2StepContext)(unsafe.Pointer(context)).H
if v67 == float32FromFloat32(0) {
v69 = b2Softness{}
goto _70
}
omega = float32(float32(float32FromFloat32(2)*float32FromFloat32(3.14159265359)) * v67)
a11 = float32(float32FromFloat32(2)*(*b2DistanceJoint)(unsafe.Pointer(joint)).DampingRatio) + float32(v68*omega)
a21 = float32(float32(v68*omega) * a11)
a31 = float32FromFloat32(1) / (float32FromFloat32(1) + a21)
v69 = b2Softness{
BiasRate: omega / a11,
MassScale: float32(a21 * a31),
ImpulseScale: a31,
}
goto _70
_70:
(*b2DistanceJoint)(unsafe.Pointer(joint)).DistanceSoftness = v69
if int32FromUint8((*b2StepContext)(unsafe.Pointer(context)).EnableWarmStarting) == false1 {
(*b2DistanceJoint)(unsafe.Pointer(joint)).Impulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).LowerImpulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).UpperImpulse = float32FromFloat32(0)
(*b2DistanceJoint)(unsafe.Pointer(joint)).MotorImpulse = float32FromFloat32(0)
}
}
func b2WarmStartDistanceJoint(tls *_Stack, base uintptr, context uintptr) {
bp := tls.Alloc(32)
defer tls.Free(32)
var P, axis, ds, n, rA, rB, separation, v11, v12, v13, v15, v16, v17, v19, v20, v21, v23, v24, v25, v27, v28, v31, v32, v34, v36, v37, v39, v4, v40, v43, v45, v46, v48, v49, v5, v8, v9 Vec2
var axialImpulse, iA, iB, invLength, length, mA, mB, v30, v35, v41, v44, v50 float32
var joint, stateA, stateB, v1, v2 uintptr
var v3, v7 Rot
var _ /* dummyState at bp+0 */ b2BodyState
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ = P, axialImpulse, axis, ds, iA, iB, invLength, joint, length, mA, mB, n, rA, rB, separation, stateA, stateB, v1, v11, v12, v13, v15, v16, v17, v19, v2, v20, v21, v23, v24, v25, v27, v28, v3, v30, v31, v32, v34, v35, v36, v37, v39, v4, v40, v41, v43, v44, v45, v46, v48, v49, v5, v50, v7, v8, v9
if !((*b2JointSim)(unsafe.Pointer(base)).Type1 == int32(b2_distanceJoint)) && b2InternalAssertFcn(tls, __ccgo_ts+4612, __ccgo_ts+4580, int32FromInt32(282)) != 0 {
__builtin_trap(tls)
}
mA = (*b2JointSim)(unsafe.Pointer(base)).InvMassA
mB = (*b2JointSim)(unsafe.Pointer(base)).InvMassB
iA = (*b2JointSim)(unsafe.Pointer(base)).InvIA
iB = (*b2JointSim)(unsafe.Pointer(base)).InvIB
// dummy state for static bodies
*(*b2BodyState)(unsafe.Pointer(bp)) = b2_identityBodyState5
joint = base + 68
if (*b2DistanceJoint)(unsafe.Pointer(joint)).IndexA == -int32(1) {
v1 = bp
} else {
v1 = (*b2StepContext)(unsafe.Pointer(context)).States + uintptr((*b2DistanceJoint)(unsafe.Pointer(joint)).IndexA)*32
}
stateA = v1
if (*b2DistanceJoint)(unsafe.Pointer(joint)).IndexB == -int32(1) {
v2 = bp
} else {
v2 = (*b2StepContext)(unsafe.Pointer(context)).States + uintptr((*b2DistanceJoint)(unsafe.Pointer(joint)).IndexB)*32
}
stateB = v2
v3 = (*b2BodyState)(unsafe.Pointer(stateA)).DeltaRotation
v4 = (*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorA
v5 = Vec2{
X: float32(v3.C*v4.X) - float32(v3.S*v4.Y),
Y: float32(v3.S*v4.X) + float32(v3.C*v4.Y),
}
goto _6
_6:
rA = v5
v7 = (*b2BodyState)(unsafe.Pointer(stateB)).DeltaRotation
v8 = (*b2DistanceJoint)(unsafe.Pointer(joint)).AnchorB
v9 = Vec2{
X: float32(v7.C*v8.X) - float32(v7.S*v8.Y),
Y: float32(v7.S*v8.X) + float32(v7.C*v8.Y),
}
goto _10
_10:
rB = v9
v11 = (*b2BodyState)(unsafe.Pointer(stateB)).DeltaPosition
v12 = (*b2BodyState)(unsafe.Pointer(stateA)).DeltaPosition
v13 = Vec2{
X: v11.X - v12.X,
Y: v11.Y - v12.Y,
}
goto _14
_14:
v15 = rB
v16 = rA
v17 = Vec2{
X: v15.X - v16.X,
Y: v15.Y - v16.Y,
}
goto _18
_18:
v19 = v13
v20 = v17
v21 = Vec2{
X: v19.X + v20.X,
Y: v19.Y + v20.Y,
}
goto _22
_22:
ds = v21
v23 = (*b2DistanceJoint)(unsafe.Pointer(joint)).DeltaCenter
v24 = ds
v25 = Vec2{
X: v23.X + v24.X,
Y: v23.Y + v24.Y,
}
goto _26
_26:
separation = v25
v27 = separation
length = sqrtf(tls, float32(v27.X*v27.X)+float32(v27.Y*v27.Y))
if length < float32FromFloat32(1.1920928955078125e-07) {
v28 = Vec2{}
goto _29
}
invLength = float32FromFloat32(1) / length
n = Vec2{
X: float32(invLength * v27.X),
Y: float32(invLength * v27.Y),
}
v28 = n
goto _29
_29:
axis = v28
axialImpulse = (*b2DistanceJoint)(unsafe.Pointer(joint)).Impulse + (*b2DistanceJoint)(unsafe.Pointer(joint)).LowerImpulse - (*b2DistanceJoint)(unsafe.Pointer(joint)).UpperImpulse + (*b2DistanceJoint)(unsafe.Pointer(joint)).MotorImpulse
v30 = axialImpulse
v31 = axis
v32 = Vec2{
X: float32(v30 * v31.X),
Y: float32(v30 * v31.Y),
}
goto _33
_33:
P = v32
v34 = (*b2BodyState)(unsafe.Pointer(stateA)).LinearVelocity
v35 = mA
v36 = P
v37 = Vec2{
X: v34.X - float32(v35*v36.X),
Y: v34.Y - float32(v35*v36.Y),
}
goto _38
_38:
(*b2BodyState)(unsafe.Pointer(stateA)).LinearVelocity = v37
v39 = rA
v40 = P
v41 = float32(v39.X*v40.Y) - float32(v39.Y*v40.X)
goto _42
_42:
*(*float32)(unsafe.Pointer(stateA + 8)) -= float32(iA * v41)
v43 = (*b2BodyState)(unsafe.Pointer(stateB)).LinearVelocity
v44 = mB
v45 = P
v46 = Vec2{
X: v43.X + float32(v44*v45.X),
Y: v43.Y + float32(v44*v45.Y),
}
goto _47
_47:
(*b2BodyState)(unsafe.Pointer(stateB)).LinearVelocity = v46
v48 = rB
v49 = P
v50 = float32(v48.X*v49.Y) - float32(v48.Y*v49.X)
goto _51