| 495 | } |
| 496 | |
| 497 | ShapeData::ShapeData(const PxGeometry& g, const PxTransform& t, PxReal inflation) |
| 498 | { |
| 499 | using namespace physx::shdfnd::aos; |
| 500 | |
| 501 | // PT: this cast to matrix is already done in GeometryUnion::computeBounds (e.g. for boxes). So we do it first, |
| 502 | // then we'll pass the matrix directly to computeBoundsShapeData, to avoid the double conversion. |
| 503 | const bool isOBB = PxAbs(t.q.w) < 0.999999f; |
| 504 | if(isOBB) |
| 505 | { |
| 506 | // PT: writes 4 bytes after 'rot' but it's safe since we then write 'center' just afterwards |
| 507 | buildFrom(mGuBox, t.q); |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | mGuBox.rot = PxMat33(PxIdentity); |
| 512 | } |
| 513 | |
| 514 | // PT: can't use V4Load here since there's no guarantee on 't.p' |
| 515 | // PT: must store 'center' after 'rot' now |
| 516 | mGuBox.center = t.p; |
| 517 | |
| 518 | // Compute AABB, used by the BucketPruner as cullBox |
| 519 | switch(g.getType()) |
| 520 | { |
| 521 | case PxGeometryType::eSPHERE: |
| 522 | { |
| 523 | const PxSphereGeometry& shape = static_cast<const PxSphereGeometry&>(g); |
| 524 | computeMinMaxBounds(&mPrunerInflatedAABB, mGuBox.center, PxVec3(0.0f), SQ_PRUNER_INFLATION, shape.radius+inflation); |
| 525 | |
| 526 | // |
| 527 | |
| 528 | reinterpret_cast<Sphere&>(mGuSphere) = Sphere(t.p, shape.radius); |
| 529 | } |
| 530 | break; |
| 531 | |
| 532 | case PxGeometryType::eCAPSULE: |
| 533 | { |
| 534 | const PxCapsuleGeometry& shape = static_cast<const PxCapsuleGeometry&>(g); |
| 535 | const Vec3p extents = mGuBox.rot.column0.abs() * shape.halfHeight; |
| 536 | computeMinMaxBounds(&mPrunerInflatedAABB, mGuBox.center, extents, SQ_PRUNER_INFLATION, shape.radius+inflation); |
| 537 | |
| 538 | // |
| 539 | |
| 540 | Capsule& dstWorldCapsule = reinterpret_cast<Capsule&>(mGuCapsule); // store a narrow phase version copy |
| 541 | getCapsule(dstWorldCapsule, shape, t); |
| 542 | |
| 543 | mGuBox.extents.x = shape.halfHeight; |
| 544 | |
| 545 | // compute PxBoxGeometry pruner geom around input capsule geom; transform remains unchanged |
| 546 | |
| 547 | computeBoxExtentsAroundCapsule(mPrunerBoxGeomExtents, shape, SQ_PRUNER_INFLATION); |
| 548 | } |
| 549 | break; |
| 550 | |
| 551 | case PxGeometryType::eBOX: |
| 552 | { |
| 553 | const PxBoxGeometry& shape = static_cast<const PxBoxGeometry&>(g); |
| 554 | // PT: cast is safe because 'rot' followed by other members |
nothing calls this directly
no test coverage detected