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

Method addAggregate

physx/source/physx/src/NpScene.cpp:1095–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093///////////////////////////////////////////////////////////////////////////////
1094
1095void NpScene::addAggregate(PxAggregate& aggregate)
1096{
1097 PX_PROFILE_ZONE("API.addAggregate", getContextId());
1098 NP_WRITE_CHECK(this);
1099 PX_SIMD_GUARD;
1100
1101 NpAggregate& np = static_cast<NpAggregate&>(aggregate);
1102
1103 const PxU32 nb = np.getCurrentSizeFast();
1104#if PX_CHECKED
1105 for(PxU32 i=0;i<nb;i++)
1106 {
1107 PxRigidStatic* a = np.getActorFast(i)->is<PxRigidStatic>();
1108 if(a && !static_cast<NpRigidStatic*>(a)->checkConstraintValidity())
1109 {
1110 Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxScene::addAggregate(): Aggregate contains an actor with an invalid constraint!");
1111 return;
1112 }
1113 }
1114#endif
1115
1116 Scb::Aggregate& agg = np.getScbAggregate();
1117 const Scb::ControlState::Enum cs = agg.getControlState();
1118 if ((cs == Scb::ControlState::eNOT_IN_SCENE) || ((cs == Scb::ControlState::eREMOVE_PENDING) && (agg.getScbScene()->getPxScene() == this)))
1119 {
1120 mScene.addAggregate(agg);
1121
1122 for(PxU32 i=0;i<nb;i++)
1123 {
1124 PX_ASSERT(np.getActorFast(i));
1125 PxActor& actor = *np.getActorFast(i);
1126
1127 //A.B. check if a bvh structure was connected to that actor, we will use it for the insert and remove it
1128 NpActor& npActor = NpActor::getFromPxActor(actor);
1129 Gu::BVHStructure* bvhStructure = NULL;
1130 if(npActor.getConnectors<Gu::BVHStructure>(NpConnectorType::eBvhStructure, &bvhStructure, 1))
1131 {
1132 npActor.removeConnector(actor, NpConnectorType::eBvhStructure, bvhStructure, "PxBVHStructure connector could not have been removed!");
1133 }
1134
1135 np.addActorInternal(actor, *this, bvhStructure);
1136
1137 // if a bvh structure was used dec ref count, we increased the ref count when adding the actor connection
1138 if(bvhStructure)
1139 {
1140 bvhStructure->decRefCount();
1141 }
1142 }
1143
1144 mAggregates.insert(&aggregate);
1145 }
1146 else
1147 Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxScene::addAggregate(): Aggregate already assigned to a scene. Call will be ignored!");
1148}
1149
1150void NpScene::removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch)
1151{

Callers 1

createLargeSphereFunction · 0.45

Calls 10

getCurrentSizeFastMethod · 0.80
getActorFastMethod · 0.80
errorMethod · 0.80
getPxSceneMethod · 0.80
removeConnectorMethod · 0.80
getContextIdFunction · 0.50
addActorInternalMethod · 0.45
decRefCountMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected