本文整理汇总了C++中NxVec3::max方法的典型用法代码示例。如果您正苦于以下问题:C++ NxVec3::max方法的具体用法?C++ NxVec3::max怎么用?C++ NxVec3::max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NxVec3
的用法示例。
在下文中一共展示了NxVec3::max方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MoveCharacter
// Using swept code & direct position update (no physics engine)
// This function is the generic character controller logic, valid for all swept volumes
void SweepTest::MoveCharacter(
void* user_data,
void* user_data2,
SweptVolume& volume,
const NxVec3& direction,
NxU32 nb_boxes, const NxExtendedBounds3* boxes, const void** box_user_data,
NxU32 nb_capsules, const NxExtendedCapsule* capsules, const void** capsule_user_data,
NxU32 groups, float min_dist,
NxU32& collision_flags,
const NxGroupsMask* groupsMask,
bool constrainedClimbingMode
)
{
mHitNonWalkable = false;
NxU32 CollisionFlags = 0;
const NxU32 MaxIter = mMaxIter; // 1 for "collide and stop"
const NxU32 MaxIterUp = MaxIter;
const NxU32 MaxIterSides = MaxIter;
// const NxU32 MaxIterDown = gWalkExperiment ? MaxIter : 1;
const NxU32 MaxIterDown = 1;
// ### this causes the artificial gap on top of chars
float StepOffset = mStepOffset; // Default step offset can be cancelled in some cases.
// Save initial height
Extended OriginalHeight = volume.mCenter[mUpDirection];
Extended OriginalBottomPoint = OriginalHeight - volume.mHalfHeight; // UBI
// TEST! Disable auto-step when flying. Not sure this is really useful.
if(direction[mUpDirection]>0.0f)
StepOffset = 0.0f;
// Decompose motion into 3 independent motions: up, side, down
// - if the motion is purely down (gravity only), the up part is needed to fight accuracy issues. For example if the
// character is already touching the geometry a bit, the down sweep test might have troubles. If we first move it above
// the geometry, the problems disappear.
// - if the motion is lateral (character moving forward under normal gravity) the decomposition provides the autostep feature
// - if the motion is purely up, the down part can be skipped
NxVec3 UpVector(0.0f, 0.0f, 0.0f);
NxVec3 DownVector(0.0f, 0.0f, 0.0f);
if(direction[mUpDirection]<0.0f) DownVector[mUpDirection] = direction[mUpDirection];
else UpVector[mUpDirection] = direction[mUpDirection];
NxVec3 SideVector = direction;
SideVector[mUpDirection] = 0.0f;
// If the side motion is zero, i.e. if the character is not really moving, disable auto-step.
if(!SideVector.isZero())
UpVector[mUpDirection] += StepOffset;
// ==========[ Initial volume query ]===========================
if(1)
{
NxVec3 MotionExtents = UpVector;
MotionExtents.max(SideVector);
MotionExtents.max(DownVector);
NxExtendedBounds3 TemporalBox;
volume.ComputeTemporalBox(*this, TemporalBox, volume.mCenter, MotionExtents);
// Gather touched geoms
UpdateTouchedGeoms(user_data, volume,
nb_boxes, boxes, box_user_data,
nb_capsules, capsules, capsule_user_data,
groups, TemporalBox, groupsMask);
}
// ==========[ UP PASS ]===========================
mCachedTriIndexIndex = 0;
const bool PerformUpPass = true;
NxU32 NbCollisions=0;
if(PerformUpPass)
{
// Prevent user callback for up motion. This up displacement is artificial, and only needed for auto-stepping.
// If we call the user for this, we might eventually apply upward forces to objects resting on top of us, even
// if we visually don't move. This produces weird-looking motions.
mValidateCallback = false;
// In the walk-experiment we explicitely want to ban any up motions, to avoid characters climbing slopes they shouldn't climb.
// So let's bypass the whole up pass.
if(!mWalkExperiment)
{
// ### MaxIter here seems to "solve" the V bug
if(DoSweepTest(user_data,
user_data2,
nb_boxes, boxes, box_user_data,
nb_capsules, capsules, capsule_user_data,
volume, UpVector, MaxIterUp, &NbCollisions, groups, min_dist, groupsMask))
{
if(NbCollisions)
{
CollisionFlags |= NXCC_COLLISION_UP;
// Clamp step offset to make sure we don't undo more than what we did
//.........这里部分代码省略.........