本文整理汇总了C++中CMovementRequest::ClearLean方法的典型用法代码示例。如果您正苦于以下问题:C++ CMovementRequest::ClearLean方法的具体用法?C++ CMovementRequest::ClearLean怎么用?C++ CMovementRequest::ClearLean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMovementRequest
的用法示例。
在下文中一共展示了CMovementRequest::ClearLean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PreUpdate
void CNetPlayerInput::PreUpdate()
{
IPhysicalEntity * pPhysEnt = m_pPlayer->GetEntity()->GetPhysics();
if (!pPhysEnt)
return;
CMovementRequest moveRequest;
SMovementState moveState;
m_pPlayer->GetMovementController()->GetMovementState(moveState);
Quat worldRot = m_pPlayer->GetBaseQuat(); // m_pPlayer->GetEntity()->GetWorldRotation();
Vec3 deltaMovement = worldRot.GetInverted().GetNormalized() * m_curInput.deltaMovement;
// absolutely ensure length is correct
deltaMovement = deltaMovement.GetNormalizedSafe(ZERO) * m_curInput.deltaMovement.GetLength();
moveRequest.AddDeltaMovement( deltaMovement );
if( IsDemoPlayback() )
{
Vec3 localVDir(m_pPlayer->GetViewQuatFinal().GetInverted() * m_curInput.lookDirection);
Ang3 deltaAngles(asin(localVDir.z),0,cry_atan2f(-localVDir.x,localVDir.y));
moveRequest.AddDeltaRotation(deltaAngles*gEnv->pTimer->GetFrameTime());
}
//else
{
Vec3 distantTarget = moveState.eyePosition + 1000.0f * m_curInput.lookDirection;
Vec3 lookTarget = distantTarget;
if (gEnv->bClient && m_pPlayer->GetGameObject()->IsProbablyVisible())
{
// post-process aim direction
ray_hit hit;
static const int obj_types = ent_all; // ent_terrain|ent_static|ent_rigid|ent_sleeping_rigid|ent_living;
static const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
bool rayHitAny = 0 != gEnv->pPhysicalWorld->RayWorldIntersection( moveState.eyePosition, 150.0f * m_curInput.lookDirection, obj_types, flags, &hit, 1, pPhysEnt );
if (rayHitAny)
{
lookTarget = hit.pt;
}
static float proneDist = 1.0f;
static float crouchDist = 0.6f;
static float standDist = 0.3f;
float dist = standDist;
if(m_pPlayer->GetStance() == STANCE_CROUCH)
dist = crouchDist;
else if(m_pPlayer->GetStance() == STANCE_PRONE)
dist = proneDist;
if((lookTarget - moveState.eyePosition).GetLength2D() < dist)
{
Vec3 eyeToTarget2d = lookTarget - moveState.eyePosition;
eyeToTarget2d.z = 0.0f;
eyeToTarget2d.NormalizeSafe();
eyeToTarget2d *= dist;
ray_hit newhit;
bool rayHitAny = 0 != gEnv->pPhysicalWorld->RayWorldIntersection( moveState.eyePosition + eyeToTarget2d, 3 * Vec3(0,0,-1), obj_types, flags, &newhit, 1, pPhysEnt );
if (rayHitAny)
{
lookTarget = newhit.pt;
}
}
// SNH: new approach. Make sure the aimTarget is at least 1.5m away,
// if not, pick a point 1m down the vector instead.
Vec3 dir = lookTarget - moveState.eyePosition;
static float minDist = 1.5f;
if(dir.GetLengthSquared() < minDist)
{
lookTarget = moveState.eyePosition + dir.GetNormalizedSafe();
}
// draw eye pos for comparison
//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(moveState.eyePosition, 0.04f, ColorF(0.3f,0.2f,0.7f,1.0f));
}
moveRequest.SetLookTarget( lookTarget );
moveRequest.SetAimTarget( lookTarget );
if (m_curInput.deltaMovement.GetLengthSquared() > sqr(0.2f)) // 0.2f is almost stopped
moveRequest.SetBodyTarget( distantTarget );
else
moveRequest.ClearBodyTarget();
}
moveRequest.SetAllowStrafing(true);
float pseudoSpeed = 0.0f;
if (m_curInput.deltaMovement.len2() > 0.0f)
{
pseudoSpeed = m_pPlayer->CalculatePseudoSpeed(m_curInput.sprint);
}
moveRequest.SetPseudoSpeed(pseudoSpeed);
float lean=0.0f;
if (m_curInput.leanl)
lean-=1.0f;
if (m_curInput.leanr)
lean+=1.0f;
if (fabsf(lean)>0.01f)
moveRequest.SetLean(lean);
else
moveRequest.ClearLean();
//.........这里部分代码省略.........