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

Method addActor

physx/source/physx/src/NpAggregate.cpp:139–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139bool NpAggregate::addActor(PxActor& actor, const PxBVHStructure* bvhStructure)
140{
141 NP_WRITE_CHECK(getOwnerScene());
142 PX_SIMD_GUARD;
143
144 if(mNbActors==mAggregate.getMaxActorCount())
145 {
146 Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxAggregate: can't add actor to aggregate, max number of actors reached");
147 return false;
148 }
149
150 if(actor.getAggregate())
151 {
152 Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxAggregate: can't add actor to aggregate, actor already belongs to an aggregate");
153 return false;
154 }
155
156 if(actor.getScene())
157 {
158 Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxAggregate: can't add actor to aggregate, actor already belongs to a scene");
159 return false;
160 }
161
162 if(actor.getType() == PxActorType::eARTICULATION_LINK)
163 {
164 Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxAggregate: can't add articulation link to aggregate, only whole articulations can be added");
165 return false;
166 }
167
168 setAggregate(this, actor);
169
170 mActors[mNbActors++] = &actor;
171
172 // PT: when an object is added to a aggregate at runtime, i.e. when the aggregate has already been added to the scene,
173 // we need to immediately add the newcomer to the scene as well.
174 NpScene* s = getAPIScene();
175 if(s)
176 {
177 addActorInternal(actor, *s, bvhStructure);
178 }
179 else
180 {
181 // A.B. if BVH structure is provided we need to keep it stored till the aggregate is inseted into a scene
182 if(bvhStructure)
183 {
184 PxBVHStructure* bvhStructureMutable = const_cast<PxBVHStructure*>(bvhStructure);
185 static_cast<Gu::BVHStructure*>(bvhStructureMutable)->incRefCount();
186 NpActor::getFromPxActor(actor).addConnector(NpConnectorType::eBvhStructure, bvhStructureMutable, "PxBVHStructure already added to the PxActor!");
187 }
188 }
189
190 return true;
191}
192
193bool NpAggregate::removeActorAndReinsert(PxActor& actor, bool reinsert)
194{

Callers 2

addActorInternalMethod · 0.45
addArticulationMethod · 0.45

Calls 8

getMaxActorCountMethod · 0.80
errorMethod · 0.80
addConnectorMethod · 0.80
setAggregateFunction · 0.70
getAggregateMethod · 0.45
getSceneMethod · 0.45
getTypeMethod · 0.45
incRefCountMethod · 0.45

Tested by

no test coverage detected