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

Method computeBounds

physx/source/geomutils/src/GuBounds.cpp:210–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210void Gu::computeBounds(PxBounds3& bounds, const PxGeometry& geometry, const PxTransform& pose, float contactOffset, const CenterExtentsPadded* PX_RESTRICT localSpaceBounds, float inflation)
211{
212 PX_ASSERT(contactOffset==0.0f || inflation==1.0f);
213
214 // Box, Convex, Mesh and HeightField will compute local bounds and pose to world space.
215 // Sphere, Capsule & Plane will compute world space bounds directly.
216
217 switch(geometry.getType())
218 {
219 case PxGeometryType::eSPHERE:
220 {
221 PX_ASSERT(!localSpaceBounds);
222
223 const PxSphereGeometry& shape = static_cast<const PxSphereGeometry&>(geometry);
224 const PxVec3 extents((shape.radius+contactOffset)*inflation);
225 bounds.minimum = pose.p - extents;
226 bounds.maximum = pose.p + extents;
227 }
228 break;
229
230 case PxGeometryType::ePLANE:
231 {
232 PX_ASSERT(!localSpaceBounds);
233
234 computePlaneBounds(bounds, pose, contactOffset, inflation);
235 }
236 break;
237
238 case PxGeometryType::eCAPSULE:
239 {
240 PX_ASSERT(!localSpaceBounds);
241
242 const PxCapsuleGeometry& shape = static_cast<const PxCapsuleGeometry& >(geometry);
243 const PxVec3 d = pose.q.getBasisVector0();
244 PxVec3 extents;
245 for(PxU32 ax = 0; ax<3; ax++)
246 extents[ax] = (PxAbs(d[ax]) * shape.halfHeight + shape.radius + contactOffset)*inflation;
247 bounds.minimum = pose.p - extents;
248 bounds.maximum = pose.p + extents;
249 }
250 break;
251
252 case PxGeometryType::eBOX:
253 {
254 PX_ASSERT(!localSpaceBounds);
255
256 const PxBoxGeometry& shape = static_cast<const PxBoxGeometry& >(geometry);
257
258 const Vec3p origin(pose.p);
259
260 const PxMat33Padded basis(pose.q);
261
262 const Vec4V extentsV = basisExtentV(basis, shape.halfExtents, contactOffset, inflation);
263
264 const Vec4V originV = V4LoadU(&origin.x);
265 const Vec4V minV = V4Sub(originV, extentsV);
266 const Vec4V maxV = V4Add(originV, extentsV);
267

Callers

nothing calls this directly

Calls 15

computePlaneBoundsFunction · 0.85
PxAbsFunction · 0.85
basisExtentVFunction · 0.85
isNonIdentityFunction · 0.85
computeScaledMatrixFunction · 0.85
computeMeshBoundsFunction · 0.85
getHullVerticesMethod · 0.80
errorMethod · 0.80
multiply3x3VFunction · 0.70
inflateBoundsFunction · 0.70
V4LoadUFunction · 0.50
V4SubFunction · 0.50

Tested by

no test coverage detected