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

Method Update

ogsr_engine/xrGame/PHFracture.cpp:286–532  ·  view source on GitHub ↗

define DBG_BREAK

Source from the content-addressed store, hash-verified

284
285//#define DBG_BREAK
286bool CPHFracture::Update(CPHElement* element)
287{
288 ////itterate through impacts & calculate
289 dBodyID body = element->get_body();
290 // const Fvector& v_bodyvel=*((Fvector*)dBodyGetLinearVel(body));
291 CPHFracturesHolder* holder = element->FracturesHolder();
292 PH_IMPACT_STORAGE& impacts = holder->Impacts();
293
294 Fvector second_part_force, first_part_force, second_part_torque, first_part_torque;
295 second_part_force.set(0.f, 0.f, 0.f);
296 first_part_force.set(0.f, 0.f, 0.f);
297 second_part_torque.set(0.f, 0.f, 0.f);
298 first_part_torque.set(0.f, 0.f, 0.f);
299
300 // const Fvector& body_local_pos=element->local_mass_Center();
301 const Fvector& body_global_pos = *(const Fvector*)dBodyGetPosition(body);
302 Fvector body_to_first, body_to_second;
303 body_to_first.set(*((const Fvector*)m_firstM.c)); //,body_local_pos
304 body_to_second.set(*((const Fvector*)m_secondM.c)); //,body_local_pos
305 // float body_to_first_smag=body_to_first.square_magnitude();
306 // float body_to_second_smag=body_to_second.square_magnitude();
307 int num = dBodyGetNumJoints(body);
308 for (int i = 0; i < num; i++)
309 {
310 bool applied_to_second = false;
311 dJointID joint = dBodyGetJoint(body, i);
312 dJointFeedback* feedback = dJointGetFeedback(joint);
313 VERIFY2(feedback, "Feedback was not set!!!");
314 dxJoint* b_joint = (dxJoint*)joint;
315 bool b_body_second = (b_joint->node[1].body == body);
316 Fvector joint_position;
317 if (dJointGetType(joint) == dJointTypeContact)
318 {
319 dxJointContact* c_joint = (dxJointContact*)joint;
320 dGeomID first_geom = c_joint->contact.geom.g1;
321 dGeomID second_geom = c_joint->contact.geom.g2;
322 joint_position.set(*(Fvector*)c_joint->contact.geom.pos);
323 if (dGeomGetClass(first_geom) == dGeomTransformClass)
324 {
325 first_geom = dGeomTransformGetGeom(first_geom);
326 }
327 if (dGeomGetClass(second_geom) == dGeomTransformClass)
328 {
329 second_geom = dGeomTransformGetGeom(second_geom);
330 }
331 dxGeomUserData* UserData;
332 UserData = dGeomGetUserData(first_geom);
333 if (UserData)
334 {
335 u16 el_position = UserData->element_position;
336 // define if the contact applied to second part;
337 if (el_position < element->numberOfGeoms() && el_position >= m_start_geom_num && el_position < m_end_geom_num &&
338 first_geom == element->Geom(el_position)->geometry())
339 applied_to_second = true;
340 }
341 UserData = dGeomGetUserData(second_geom);
342 if (UserData)
343 {

Callers 1

PhDataUpdateMethod · 0.45

Calls 15

dBodyGetPositionFunction · 0.85
dBodyGetNumJointsFunction · 0.85
dBodyGetJointFunction · 0.85
dJointGetFeedbackFunction · 0.85
dJointGetTypeFunction · 0.85
dGeomGetClassFunction · 0.85
dGeomTransformGetGeomFunction · 0.85
dJointGetDataFunction · 0.85
MsgFunction · 0.85
FracturesHolderMethod · 0.80
GeomMethod · 0.80
PSecondElementMethod · 0.80

Tested by

no test coverage detected