| 1207 | /////////////////////////////////////////////////////////////////////////////// |
| 1208 | |
| 1209 | void NpScene::addCollection(const PxCollection& collection) |
| 1210 | { |
| 1211 | PX_PROFILE_ZONE("API.addCollection", getContextId()); |
| 1212 | const Cm::Collection& col = static_cast<const Cm::Collection&>(collection); |
| 1213 | |
| 1214 | PxU32 nb = col.internalGetNbObjects(); |
| 1215 | #if PX_CHECKED |
| 1216 | for(PxU32 i=0;i<nb;i++) |
| 1217 | { |
| 1218 | PxRigidStatic* a = col.internalGetObject(i)->is<PxRigidStatic>(); |
| 1219 | if(a && !static_cast<NpRigidStatic*>(a)->checkConstraintValidity()) |
| 1220 | { |
| 1221 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxScene::addCollection(): collection contains an actor with an invalid constraint!"); |
| 1222 | return; |
| 1223 | } |
| 1224 | } |
| 1225 | #endif |
| 1226 | |
| 1227 | Ps::Array<PxActor*> actorsToInsert; |
| 1228 | actorsToInsert.reserve(nb); |
| 1229 | |
| 1230 | struct Local |
| 1231 | { |
| 1232 | static void addActorIfNeeded(PxActor* actor, Ps::Array<PxActor*>& actorArray) |
| 1233 | { |
| 1234 | if(actor->getAggregate()) |
| 1235 | return; // The actor will be added when the aggregate is added |
| 1236 | actorArray.pushBack(actor); |
| 1237 | } |
| 1238 | }; |
| 1239 | |
| 1240 | for(PxU32 i=0;i<nb;i++) |
| 1241 | { |
| 1242 | PxBase* s = col.internalGetObject(i); |
| 1243 | const PxType serialType = s->getConcreteType(); |
| 1244 | |
| 1245 | //NpArticulationLink, NpArticulationJoint are added with the NpArticulation |
| 1246 | //Actors and Articulations that are members of an Aggregate are added with the NpAggregate |
| 1247 | |
| 1248 | if(serialType==PxConcreteType::eRIGID_DYNAMIC) |
| 1249 | { |
| 1250 | NpRigidDynamic* np = static_cast<NpRigidDynamic*>(s); |
| 1251 | // if pruner structure exists for the actor, actor will be added with the pruner structure |
| 1252 | if(!np->getShapeManager().getPruningStructure()) |
| 1253 | Local::addActorIfNeeded(np, actorsToInsert); |
| 1254 | } |
| 1255 | else if(serialType==PxConcreteType::eRIGID_STATIC) |
| 1256 | { |
| 1257 | NpRigidStatic* np = static_cast<NpRigidStatic*>(s); |
| 1258 | // if pruner structure exists for the actor, actor will be added with the pruner structure |
| 1259 | if(!np->getShapeManager().getPruningStructure()) |
| 1260 | Local::addActorIfNeeded(np, actorsToInsert); |
| 1261 | } |
| 1262 | else if(serialType==PxConcreteType::eSHAPE) |
| 1263 | { |
| 1264 | } |
| 1265 | else if(serialType==PxConcreteType::eARTICULATION) |
| 1266 | { |
no test coverage detected