MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / addCollection

Method addCollection

physx/source/physx/src/NpScene.cpp:1209–1290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1207///////////////////////////////////////////////////////////////////////////////
1208
1209void 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 {

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
errorMethod · 0.80
getShapeManagerMethod · 0.80
getContextIdFunction · 0.50
reserveMethod · 0.45
getConcreteTypeMethod · 0.45
getAggregateMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected