void CrowdAgent::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
{
    if (node_)
    {
        const Vector3 pos = GetPosition();
        const Vector3 vel = GetActualVelocity();
        const Vector3 desiredVel = GetDesiredVelocity();
        const Vector3 agentHeightVec(0, height_ * 0.5f, 0);

        debug->AddLine(pos, pos + vel, Color::GREEN, depthTest);
        debug->AddLine(pos + agentHeightVec, pos + desiredVel + agentHeightVec, Color::RED, depthTest);
        debug->AddCylinder(pos, radius_, height_, Color::GREEN, depthTest);
    }
}
Пример #2
0
bool Unit::UpdateVelocity(float dt)
{
	bool ret = true;

	GetDesiredVelocity();

	if (App->entityManager->smooth)
	{
		if (!isAngleReached())
		{
			if (!Rotate(dt));
			ret = false;
		}
	}
	else
	{
		currentVelocity = desiredVelocity;
	}
	currentVelocity.position = desiredVelocity.position = position;
	return ret;
}
Пример #3
0
bool CPlayerStateJump::UpdateCommon( CPlayer& player, const bool isHeavyWeapon, const Vec3 &move, float frameTime, Vec3* pDesiredVel )
{
	GetDesiredVelocity(move, player, pDesiredVel);

	const SActorPhysics& actorPhysics = player.GetActorPhysics();

	// generate stats.
	if (actorPhysics.velocity*actorPhysics.gravity>0.0f)
	{
		const float fHeightofEntity = player.GetEntity()->GetWorldTM().GetTranslation().z;
		m_startFallingHeight= (float)__fsel(-player.m_stats.fallSpeed, fHeightofEntity, max(m_startFallingHeight, fHeightofEntity));
		player.m_stats.fallSpeed = -actorPhysics.velocity.z;
	}

	if (!gEnv->bMultiplayer && player.IsInPickAndThrowMode() && (player.m_stats.fallSpeed > 10.f))
		player.ExitPickAndThrow();

	// inAir is set to 0.0f if we're swimming later - before refactoring this test happened *after* that, hence this test is here.
	m_jumpLock = (float)__fsel(-fabsf(player.m_stats.inAir), max(0.0f, m_jumpLock - frameTime), m_jumpLock);

	return true;
}