| 286 | DEFINE_VECTOR(Fmatrix, TRANSFORM_VECTOR, TRANSFORM_I) |
| 287 | static TRANSFORM_VECTOR bones_bind_forms; |
| 288 | shell_root CPHShellSplitterHolder::ElementSingleSplit(const element_fracture& split_elem, const CPHElement* source_element) |
| 289 | { |
| 290 | // const CPHShellSplitter& splitter=m_splitters[aspl]; |
| 291 | // CPHElement* element=m_pShell->elements[splitter.m_element]; |
| 292 | CPhysicsShell* new_shell_last = P_create_Shell(); |
| 293 | CPHShell* new_shell_last_desc = smart_cast<CPHShell*>(new_shell_last); |
| 294 | new_shell_last->mXFORM.set(m_pShell->mXFORM); |
| 295 | const u16 start_joint = split_elem.second.m_start_jt_num; |
| 296 | R_ASSERT(_valid(new_shell_last->mXFORM)); |
| 297 | const u16 end_joint = split_elem.second.m_end_jt_num; |
| 298 | // it is not right for multiple joints attached to the unsplited part becource all these need to be reattached |
| 299 | if (start_joint != end_joint) |
| 300 | { |
| 301 | JOINT_STORAGE& joints = m_pShell->joints; |
| 302 | JOINT_I i = joints.begin() + start_joint, e = joints.begin() + end_joint; |
| 303 | for (; i != e; ++i) |
| 304 | { |
| 305 | CPHJoint* joint = (*i); |
| 306 | if (joint->PFirst_element() == source_element) |
| 307 | { |
| 308 | IKinematics* K = m_pShell->PKinematics(); |
| 309 | dVector3 safe_pos1, safe_pos2; |
| 310 | dQuaternion safe_q1, safe_q2; |
| 311 | CPhysicsElement *el1 = cast_PhysicsElement(split_elem.first), *el2 = joint->PSecond_element(); |
| 312 | dBodyID body1 = el1->get_body(), body2 = el2->get_body(); |
| 313 | dVectorSet(safe_pos1, dBodyGetPosition(body1)); |
| 314 | dVectorSet(safe_pos2, dBodyGetPosition(body2)); |
| 315 | |
| 316 | dQuaternionSet(safe_q1, dBodyGetQuaternion(body1)); |
| 317 | dQuaternionSet(safe_q2, dBodyGetQuaternion(body2)); |
| 318 | |
| 319 | // m_pShell->PlaceBindToElForms(); |
| 320 | |
| 321 | K->LL_GetBindTransform(bones_bind_forms); |
| 322 | el1->SetTransform(bones_bind_forms[el1->m_SelfID]); |
| 323 | el2->SetTransform(bones_bind_forms[el2->m_SelfID]); |
| 324 | joint->ReattachFirstElement(split_elem.first); |
| 325 | |
| 326 | dVectorSet(const_cast<dReal*>(dBodyGetPosition(body1)), safe_pos1); |
| 327 | dVectorSet(const_cast<dReal*>(dBodyGetPosition(body2)), safe_pos2); |
| 328 | |
| 329 | dQuaternionSet(const_cast<dReal*>(dBodyGetQuaternion(body1)), safe_q1); |
| 330 | dQuaternionSet(const_cast<dReal*>(dBodyGetQuaternion(body2)), safe_q2); |
| 331 | |
| 332 | dBodySetPosition(body1, safe_pos1[0], safe_pos1[1], safe_pos1[2]); |
| 333 | dBodySetPosition(body2, safe_pos2[0], safe_pos2[1], safe_pos2[2]); |
| 334 | dBodySetQuaternion(body1, safe_q1); |
| 335 | dBodySetQuaternion(body2, safe_q2); |
| 336 | } |
| 337 | } |
| 338 | // m_pShell->joints[split_elem.second.m_start_jt_num]->ReattachFirstElement(split_elem.first); |
| 339 | } |
| 340 | |
| 341 | // the last new shell will have all splitted old elements end joints and one new element reattached to old joint |
| 342 | // m_splitters.erase(m_splitters.begin()+aspl); |
| 343 | // now aspl points to the next splitter |
| 344 | if ((split_elem.first)->FracturesHolder()) // if this element can be splitted add a splitter for it |
| 345 | new_shell_last_desc->AddSplitter(CPHShellSplitter::splElement, 0, u16(-1)); // |
nothing calls this directly
no test coverage detected