| 1239 | /////////////////////////////////////////////////////////////////////////////// |
| 1240 | |
| 1241 | void NpScene::addCollection(const PxCollection& collection) |
| 1242 | { |
| 1243 | PX_PROFILE_ZONE("API.addCollection", getContextId()); |
| 1244 | const Cm::Collection& col = static_cast<const Cm::Collection&>(collection); |
| 1245 | |
| 1246 | PxU32 nb = col.internalGetNbObjects(); |
| 1247 | #if PX_CHECKED |
| 1248 | for(PxU32 i=0;i<nb;i++) |
| 1249 | { |
| 1250 | PxRigidStatic* a = col.internalGetObject(i)->is<PxRigidStatic>(); |
| 1251 | if(a && !static_cast<NpRigidStatic*>(a)->checkConstraintValidity()) |
| 1252 | { |
| 1253 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxScene::addCollection(): collection contains an actor with an invalid constraint!"); |
| 1254 | return; |
| 1255 | } |
| 1256 | } |
| 1257 | #endif |
| 1258 | |
| 1259 | Ps::Array<PxActor*> actorsToInsert; |
| 1260 | actorsToInsert.reserve(nb); |
| 1261 | |
| 1262 | struct Local |
| 1263 | { |
| 1264 | static void addActorIfNeeded(PxActor* actor, Ps::Array<PxActor*>& actorArray) |
| 1265 | { |
| 1266 | if(actor->getAggregate()) |
| 1267 | return; // The actor will be added when the aggregate is added |
| 1268 | actorArray.pushBack(actor); |
| 1269 | } |
| 1270 | }; |
| 1271 | |
| 1272 | for(PxU32 i=0;i<nb;i++) |
| 1273 | { |
| 1274 | PxBase* s = col.internalGetObject(i); |
| 1275 | const PxType serialType = s->getConcreteType(); |
| 1276 | |
| 1277 | //NpArticulationLink, NpArticulationJoint are added with the NpArticulation |
| 1278 | //Actors and Articulations that are members of an Aggregate are added with the NpAggregate |
| 1279 | |
| 1280 | if(serialType==PxConcreteType::eRIGID_DYNAMIC) |
| 1281 | { |
| 1282 | NpRigidDynamic* np = static_cast<NpRigidDynamic*>(s); |
| 1283 | // if pruner structure exists for the actor, actor will be added with the pruner structure |
| 1284 | if(!np->getShapeManager().getPruningStructure()) |
| 1285 | Local::addActorIfNeeded(np, actorsToInsert); |
| 1286 | } |
| 1287 | else if(serialType==PxConcreteType::eRIGID_STATIC) |
| 1288 | { |
| 1289 | NpRigidStatic* np = static_cast<NpRigidStatic*>(s); |
| 1290 | // if pruner structure exists for the actor, actor will be added with the pruner structure |
| 1291 | if(!np->getShapeManager().getPruningStructure()) |
| 1292 | Local::addActorIfNeeded(np, actorsToInsert); |
| 1293 | } |
| 1294 | else if(serialType==PxConcreteType::eSHAPE) |
| 1295 | { |
| 1296 | } |
| 1297 | else if(serialType==PxConcreteType::eARTICULATION) |
| 1298 | { |
no test coverage detected