| 836 | } |
| 837 | |
| 838 | void NpScene::addArticulationInternal(PxArticulationBase& npa) |
| 839 | { |
| 840 | |
| 841 | // Add root link first |
| 842 | PxU32 nbLinks = npa.getNbLinks(); |
| 843 | PX_ASSERT(nbLinks > 0); |
| 844 | PxArticulationImpl* impl = reinterpret_cast<PxArticulationImpl*>(npa.getImpl()); |
| 845 | NpArticulationLink* rootLink = static_cast<NpArticulationLink*>(impl->getRoot()); |
| 846 | |
| 847 | #if PX_CHECKED |
| 848 | checkPositionSanity(*rootLink, rootLink->getGlobalPose(), "PxScene::addArticulation or PxScene::addAggregate"); |
| 849 | #endif |
| 850 | if(rootLink->getMass()==0) |
| 851 | { |
| 852 | Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::addArticulation(): Articulation link with zero mass added to scene; defaulting mass to 1"); |
| 853 | rootLink->setMass(1.0f); |
| 854 | } |
| 855 | |
| 856 | PxVec3 inertia0 = rootLink->getMassSpaceInertiaTensor(); |
| 857 | if(inertia0.x == 0.0f || inertia0.y == 0.0f || inertia0.z == 0.0f) |
| 858 | { |
| 859 | Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::addArticulation(): Articulation link with zero moment of inertia added to scene; defaulting inertia to (1,1,1)"); |
| 860 | rootLink->setMassSpaceInertiaTensor(PxVec3(1.0f, 1.0f, 1.0f)); |
| 861 | } |
| 862 | |
| 863 | bool linkTriggersWakeUp = !rootLink->getScbBodyFast().checkSleepReadinessBesidesWakeCounter(); |
| 864 | |
| 865 | addArticulationLinkBody(*rootLink); |
| 866 | |
| 867 | // Add articulation |
| 868 | PxArticulationImpl* npaImpl = reinterpret_cast<PxArticulationImpl*>(npa.getImpl()); |
| 869 | Scb::Articulation& scbArt = npaImpl->getArticulation(); |
| 870 | scbArt.setArticulationType(npa.getType()); |
| 871 | mScene.addArticulation(scbArt); |
| 872 | |
| 873 | Sc::ArticulationCore& scArtCore = scbArt.getScArticulation(); |
| 874 | Sc::ArticulationSim* scArtSim = scArtCore.getSim(); |
| 875 | |
| 876 | if (scArtSim) |
| 877 | { |
| 878 | PxU32 handle = scArtSim->findBodyIndex(*rootLink->getScbBodyFast().getScBody().getSim()); |
| 879 | rootLink->setLLIndex(handle); |
| 880 | } |
| 881 | rootLink->setInboundJointDof(0); |
| 882 | |
| 883 | addArticulationLinkConstraint(*rootLink); |
| 884 | |
| 885 | // Add links & joints |
| 886 | PX_ALLOCA(linkStack, NpArticulationLink*, nbLinks); |
| 887 | linkStack[0] = rootLink; |
| 888 | PxU32 curLink = 0; |
| 889 | PxU32 stackSize = 1; |
| 890 | while(curLink < (nbLinks-1)) |
| 891 | { |
| 892 | PX_ASSERT(curLink < stackSize); |
| 893 | NpArticulationLink* l = linkStack[curLink]; |
| 894 | NpArticulationLink*const* children = l->getChildren(); |
| 895 |
no test coverage detected