当前位置: 首页>>代码示例>>C++>>正文


C++ NxVec3::max方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:gbaumgart,项目名称:vt,代码行数:101,代码来源:CharacterController.cpp


注:本文中的NxVec3::max方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。