| 3638 | } |
| 3639 | |
| 3640 | bool PhysicsServerCommandProcessor::loadUrdf(const char* fileName, const btVector3& pos, const btQuaternion& orn, |
| 3641 | bool useMultiBody, bool useFixedBase, int* bodyUniqueIdPtr, char* bufferServerToClient, int bufferSizeInBytes, int orgFlags, btScalar globalScaling) |
| 3642 | { |
| 3643 | //clear the LOAD_SDF_FILE=1 bit, which is reserved for internal use of loadSDF command. |
| 3644 | int flags = orgFlags & ~1; |
| 3645 | m_data->m_sdfRecentLoadedBodies.clear(); |
| 3646 | *bodyUniqueIdPtr = -1; |
| 3647 | |
| 3648 | BT_PROFILE("loadURDF"); |
| 3649 | btAssert(m_data->m_dynamicsWorld); |
| 3650 | if (!m_data->m_dynamicsWorld) |
| 3651 | { |
| 3652 | b3Error("loadUrdf: No valid m_dynamicsWorld"); |
| 3653 | return false; |
| 3654 | } |
| 3655 | |
| 3656 | CommonFileIOInterface* fileIO = m_data->m_pluginManager.getFileIOInterface(); |
| 3657 | BulletURDFImporter u2b(m_data->m_guiHelper, m_data->m_pluginManager.getRenderInterface(), fileIO, globalScaling, flags); |
| 3658 | u2b.setEnableTinyRenderer(m_data->m_enableTinyRenderer); |
| 3659 | bool loadOk = u2b.loadURDF(fileName, useFixedBase); |
| 3660 | |
| 3661 | if (loadOk) |
| 3662 | { |
| 3663 | btTransform rootTrans; |
| 3664 | rootTrans.setOrigin(pos); |
| 3665 | rootTrans.setRotation(orn); |
| 3666 | u2b.setRootTransformInWorld(rootTrans); |
| 3667 | if (!(u2b.getDeformableModel().m_visualFileName.empty())) |
| 3668 | { |
| 3669 | bool use_self_collision = false; |
| 3670 | use_self_collision = (flags & CUF_USE_SELF_COLLISION); |
| 3671 | bool ok = processDeformable(u2b.getDeformableModel(), pos, orn, bodyUniqueIdPtr, bufferServerToClient, bufferSizeInBytes, globalScaling, use_self_collision); |
| 3672 | if (ok) |
| 3673 | { |
| 3674 | const UrdfModel* urdfModel = u2b.getUrdfModel(); |
| 3675 | if (urdfModel) |
| 3676 | { |
| 3677 | addUserData(urdfModel->m_userData, *bodyUniqueIdPtr); |
| 3678 | } |
| 3679 | return true; |
| 3680 | } |
| 3681 | else |
| 3682 | { |
| 3683 | return false; |
| 3684 | } |
| 3685 | } |
| 3686 | if (!(u2b.getReducedDeformableModel().m_visualFileName.empty())) |
| 3687 | { |
| 3688 | bool use_self_collision = false; |
| 3689 | return processReducedDeformable(u2b.getReducedDeformableModel(), pos, orn, bodyUniqueIdPtr, bufferServerToClient, bufferSizeInBytes, globalScaling, use_self_collision); |
| 3690 | } |
| 3691 | bool ok = processImportedObjects(fileName, bufferServerToClient, bufferSizeInBytes, useMultiBody, flags, u2b); |
| 3692 | if (ok) |
| 3693 | { |
| 3694 | if (m_data->m_sdfRecentLoadedBodies.size() == 1) |
| 3695 | { |
| 3696 | *bodyUniqueIdPtr = m_data->m_sdfRecentLoadedBodies[0]; |
| 3697 | } |
no test coverage detected