MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / CreateFullControl

Method CreateFullControl

ogsr_engine/xrGame/PHJoint.cpp:305–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303#define FIX_BY_ONE_HINGE
304#endif
305void CPHJoint::CreateFullControl()
306{
307 Fvector pos;
308 Fmatrix first_matrix, second_matrix;
309 Fvector axis;
310 CPHElement* first = (pFirst_element);
311 CPHElement* second = (pSecond_element);
312 VERIFY(first);
313 first->GetGlobalTransformDynamic(&first_matrix);
314 dBodyID body1 = body_for_joint(first);
315 VERIFY(second);
316 second->GetGlobalTransformDynamic(&second_matrix);
317 dBodyID body2 = body_for_joint(second);
318
319 pos.set(0, 0, 0);
320 switch (vs_anchor)
321 {
322 case vs_first: first_matrix.transform_tiny(pos, anchor); break;
323 case vs_second: second_matrix.transform_tiny(pos, anchor); break;
324 case vs_global: pShell->mXFORM.transform_tiny(pos, anchor); break;
325 default: NODEFAULT;
326 }
327 //////////////////////////////////////
328
329 m_joint = dJointCreateBall(0, 0);
330 dJointAttach(m_joint, body1, body2);
331 dJointSetBallAnchor(m_joint, pos.x, pos.y, pos.z);
332
333 m_joint1 = dJointCreateAMotor(0, 0);
334 dJointSetAMotorMode(m_joint1, dAMotorEuler);
335 dJointSetAMotorNumAxes(m_joint1, 3);
336
337 dJointAttach(m_joint1, body1, body2);
338
339 /////////////////////////////////////////////
340
341 Fmatrix first_matrix_inv;
342 first_matrix_inv.set(first_matrix);
343 first_matrix_inv.invert();
344 Fmatrix rotate;
345 rotate.mul(first_matrix_inv, second_matrix);
346 /////////////////////////////////////////////
347
348 float lo;
349 float hi;
350 //////////////////////////////////////////////////////////
351 /////////////////////////////////////////////////////////
352 axis.set(0, 0, 0);
353 // axis 0
354 CalcAxis(0, axis, lo, hi, first_matrix, second_matrix, rotate);
355 if (!body1)
356 axis.invert(); // SwapLimits(lo,hi);
357 dJointSetAMotorAxis(m_joint1, 0, 1, axis.x, axis.y, axis.z);
358 dJointSetAMotorParam(m_joint1, dParamLoStop, lo);
359 dJointSetAMotorParam(m_joint1, dParamHiStop, hi);
360
361 if (!(axes[0].force < 0.f))
362 {

Callers

nothing calls this directly

Calls 14

body_for_jointFunction · 0.85
dJointCreateBallFunction · 0.85
dJointAttachFunction · 0.85
dJointSetBallAnchorFunction · 0.85
dJointCreateAMotorFunction · 0.85
dJointSetAMotorModeFunction · 0.85
dJointSetAMotorNumAxesFunction · 0.85
dJointSetAMotorAxisFunction · 0.85
dJointSetAMotorParamFunction · 0.85
transform_tinyMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected