本文整理汇总了C++中PhysicsObject::bounds方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsObject::bounds方法的具体用法?C++ PhysicsObject::bounds怎么用?C++ PhysicsObject::bounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsObject
的用法示例。
在下文中一共展示了PhysicsObject::bounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: construct_support_mappings
//#################### PRIVATE METHODS ####################
void NarrowPhaseCollisionDetector::construct_support_mappings(const PhysicsObject& objectA, const PhysicsObject& objectB,
SupportMapping_CPtr& mapping, SupportMapping_CPtr& mappingA,
SupportMapping_CPtr& mappingS, Vector3d& interiorPoint,
Vector3d& relativeMovement) const
{
// Construct the support mapping in the reference frame of A. (In that frame, A is centred at the origin.)
// We'll be colliding a relative, swept version of B (called S) against a stationary A and then transforming
// the result back into world space.
Vector3d aPos0 = objectA.previous_position() ? *objectA.previous_position() : objectA.position();
Vector3d aPos1 = objectA.position();
Vector3d bPos0 = objectB.previous_position() ? *objectB.previous_position() : objectB.position();
Vector3d bPos1 = objectB.position();
Vector3d bRelPos0 = bPos0 - aPos0;
Vector3d bRelPos1 = bPos1 - aPos1;
relativeMovement = bRelPos1 - bRelPos0;
// Construct the support mapping for the stationary A.
Bounds_CPtr aBounds = objectA.bounds(m_boundsManager);
mappingA.reset(new BoundsSupportMapping(aBounds));
// Construct the support mapping for S (the relative, swept B).
Bounds_CPtr bBounds = objectB.bounds(m_boundsManager);
SupportMapping_CPtr mappingB(new BoundsSupportMapping(bBounds));
SupportMapping_CPtr mappingL(new SegmentSupportMapping(bRelPos0, bRelPos1));
mappingS.reset(new SweptSupportMapping(mappingB, mappingL));
// Construct the support mapping for their Minkowski difference (S - A).
mapping.reset(new MinkDiffSupportMapping(mappingS, mappingA));
// Find a point interior to S - A. Note that the midpoint of B's relative movement
// vector will do because it's definitely inside S (which is the relative sweep of
// B as it moves), whilst A is centred at the origin and symmetrical about it, so
// subtracting A won't move the overall shape.
interiorPoint = (bRelPos0 + bRelPos1) / 2;
// Ensure that the interior point isn't too near the origin. If it is, any point
// right next to the origin can be substituted instead.
if(interiorPoint.length_squared() < EPSILON*EPSILON) interiorPoint = Vector3d(EPSILON, 0, 0);
}