| 195 | } |
| 196 | |
| 197 | void Sc::ArticulationSim::addBody(BodySim& body, |
| 198 | BodySim* parent, |
| 199 | ArticulationJointSim* joint) |
| 200 | { |
| 201 | mBodies.pushBack(&body); |
| 202 | mJoints.pushBack(joint); |
| 203 | mLLArticulation->addBody(); |
| 204 | |
| 205 | PxU32 index = mLinks.size(); |
| 206 | |
| 207 | PX_ASSERT((((index==0) && (joint == 0)) && (parent == 0)) || |
| 208 | (((index!=0) && joint) && (parent && (parent->getArticulation() == this)))); |
| 209 | |
| 210 | ArticulationLink &link = mLinks.insert(); |
| 211 | link.body = &body.getLowLevelBody(); |
| 212 | link.bodyCore = &body.getBodyCore().getCore(); |
| 213 | link.children = 0; |
| 214 | bool shouldSleep; |
| 215 | bool currentlyAsleep; |
| 216 | bool bodyReadyForSleep = body.checkSleepReadinessBesidesWakeCounter(); |
| 217 | PxReal wakeCounter = getCore().getWakeCounter(); |
| 218 | |
| 219 | if(parent) |
| 220 | { |
| 221 | currentlyAsleep = !mBodies[0]->isActive(); |
| 222 | shouldSleep = currentlyAsleep && bodyReadyForSleep; |
| 223 | |
| 224 | PxU32 parentIndex = findBodyIndex(*parent); |
| 225 | link.parent = parentIndex; |
| 226 | link.pathToRoot = mLinks[parentIndex].pathToRoot | ArticulationBitField(1)<<index; |
| 227 | link.inboundJoint = &joint->getCore().getCore(); |
| 228 | mLinks[parentIndex].children |= ArticulationBitField(1)<<index; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | currentlyAsleep = (wakeCounter == 0.0f); |
| 233 | shouldSleep = currentlyAsleep && bodyReadyForSleep; |
| 234 | |
| 235 | link.parent = DY_ARTICULATION_LINK_NONE; |
| 236 | link.pathToRoot = 1; |
| 237 | link.inboundJoint = NULL; |
| 238 | } |
| 239 | |
| 240 | const PxU32 low = PxU32(link.pathToRoot & 0xffffffff); |
| 241 | const PxU32 high = PxU32(link.pathToRoot >> 32); |
| 242 | const PxU32 depth = Ps::bitCount(low) + Ps::bitCount(high); |
| 243 | mMaxDepth = PxMax(depth, mMaxDepth); |
| 244 | |
| 245 | mLLArticulation->setMaxDepth(mMaxDepth); |
| 246 | |
| 247 | if (currentlyAsleep && (!shouldSleep)) |
| 248 | { |
| 249 | for(PxU32 i=0; i < (mBodies.size() - 1); i++) |
| 250 | mBodies[i]->internalWakeUpArticulationLink(wakeCounter); |
| 251 | } |
| 252 | |
| 253 | body.setArticulation(this, wakeCounter, shouldSleep, index); |
| 254 | } |
nothing calls this directly
no test coverage detected