MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / getBody

Method getBody

Extras/InverseDynamics/RandomTreeCreator.cpp:31–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31int RandomTreeCreator::getBody(const int body_index, int* parent_index, JointType* joint_type,
32 vec3* parent_r_parent_body_ref, mat33* body_T_parent_ref,
33 vec3* body_axis_of_motion, idScalar* mass, vec3* body_r_body_com,
34 mat33* body_I_body, int* user_int, void** user_ptr) const
35{
36 if (0 == body_index)
37 { //root body
38 *parent_index = -1;
39 }
40 else
41 {
42 *parent_index = randomInt(0, body_index - 1);
43 }
44
45 switch (randomInt(0, 3))
46 {
47 case 0:
48 *joint_type = FIXED;
49 break;
50 case 1:
51 *joint_type = REVOLUTE;
52 break;
53 case 2:
54 *joint_type = PRISMATIC;
55 break;
56 case 3:
57 *joint_type = FLOATING;
58 break;
59 default:
60 bt_id_error_message("randomInt() result out of range\n");
61 return -1;
62 }
63
64 (*parent_r_parent_body_ref)(0) = randomFloat(-1.0, 1.0);
65 (*parent_r_parent_body_ref)(1) = randomFloat(-1.0, 1.0);
66 (*parent_r_parent_body_ref)(2) = randomFloat(-1.0, 1.0);
67
68 bodyTParentFromAxisAngle(randomAxis(), randomFloat(-BT_ID_PI, BT_ID_PI), body_T_parent_ref);
69
70 *body_axis_of_motion = randomAxis();
71 *mass = randomMass();
72 (*body_r_body_com)(0) = randomFloat(-1.0, 1.0);
73 (*body_r_body_com)(1) = randomFloat(-1.0, 1.0);
74 (*body_r_body_com)(2) = randomFloat(-1.0, 1.0);
75 const double a = randomFloat(-BT_ID_PI, BT_ID_PI);
76 const double b = randomFloat(-BT_ID_PI, BT_ID_PI);
77 const double c = randomFloat(-BT_ID_PI, BT_ID_PI);
78 vec3 ii = randomInertiaPrincipal();
79 mat33 ii_diag;
80 setZero(ii_diag);
81 ii_diag(0, 0) = ii(0);
82 ii_diag(1, 1) = ii(1);
83 ii_diag(2, 2) = ii(2);
84 *body_I_body = transformX(a) * transformY(b) * transformZ(c) * ii_diag *
85 transformZ(-c) * transformY(-b) * transformX(-a);
86 *user_int = 0;
87 *user_ptr = 0;
88

Callers

nothing calls this directly

Calls 10

randomIntFunction · 0.85
randomFloatFunction · 0.85
bodyTParentFromAxisAngleFunction · 0.85
randomAxisFunction · 0.85
randomMassFunction · 0.85
randomInertiaPrincipalFunction · 0.85
transformXFunction · 0.85
transformYFunction · 0.85
transformZFunction · 0.85
setZeroFunction · 0.50

Tested by

no test coverage detected