MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / addCollection

Method addCollection

deps/physx/physx/source/physx/src/NpScene.cpp:1241–1327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1239///////////////////////////////////////////////////////////////////////////////
1240
1241void 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 {

Callers 6

deserializeObjectsFunction · 0.45
snippetMainFunction · 0.45
addReadyChunkToSceneMethod · 0.45
loadMethod · 0.45
PxAddCollectionToPhysicsFunction · 0.45

Calls 11

internalGetNbObjectsMethod · 0.80
internalGetObjectMethod · 0.80
getShapeManagerMethod · 0.80
getContextIdFunction · 0.50
errorMethod · 0.45
reserveMethod · 0.45
getConcreteTypeMethod · 0.45
getAggregateMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected