| 169 | } |
| 170 | |
| 171 | void NpConstraint::setActors(PxRigidActor* actor0, PxRigidActor* actor1) |
| 172 | { |
| 173 | NP_WRITE_CHECK(getNpScene()); |
| 174 | |
| 175 | PX_CHECK_AND_RETURN((actor0 && !actor0->is<PxRigidStatic>()) || (actor1 && !actor1->is<PxRigidStatic>()), "PxConstraint: at least one actor must be non-static"); |
| 176 | PX_SIMD_GUARD; |
| 177 | |
| 178 | if(mActor0) |
| 179 | NpActor::getFromPxActor(*mActor0).removeConnector(*mActor0, NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 0: Constraint already added"); |
| 180 | if(mActor1) |
| 181 | NpActor::getFromPxActor(*mActor1).removeConnector(*mActor1, NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 1: Constraint already added"); |
| 182 | |
| 183 | if(actor0) |
| 184 | NpActor::getFromPxActor(*actor0).addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 0: Constraint already added"); |
| 185 | if(actor1) |
| 186 | NpActor::getFromPxActor(*actor1).addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 1: Constraint already added"); |
| 187 | |
| 188 | mActor0 = actor0; |
| 189 | mActor1 = actor1; |
| 190 | |
| 191 | NpScene* newScene = getSceneFromActors(actor0, actor1); |
| 192 | NpScene* oldScene = getNpScene(); |
| 193 | |
| 194 | if (oldScene != newScene) |
| 195 | { |
| 196 | if (oldScene) |
| 197 | { |
| 198 | oldScene->removeFromConstraintList(*this); |
| 199 | oldScene->getScene().removeConstraint(getScbConstraint()); |
| 200 | } |
| 201 | |
| 202 | getScbConstraint().setBodies(getScbRigidObject(actor0), getScbRigidObject(actor1)); |
| 203 | |
| 204 | if (newScene) |
| 205 | { |
| 206 | newScene->addToConstraintList(*this); |
| 207 | newScene->getScene().addConstraint(getScbConstraint()); |
| 208 | } |
| 209 | } |
| 210 | else |
| 211 | getScbConstraint().setBodies(getScbRigidObject(actor0), getScbRigidObject(actor1)); |
| 212 | } |
| 213 | |
| 214 | void NpConstraint::markDirty() |
| 215 | { |
no test coverage detected