Optimization interne de chunk!
This commit is contained in:
@@ -25,9 +25,13 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
|
||||
static bool jumped = true;
|
||||
static int dbljump = 0; // Peut sauter ou dasher tant que la variable est en dessous de 2.
|
||||
static float dashtimeout = 0;
|
||||
static float gametime = 0;
|
||||
static float bobbingtime = 0;
|
||||
|
||||
if (gametime <= 360.f) gametime += elapsedTime * m_topspeed / 2; else gametime = 0;
|
||||
m_direction = Vector3f(cos(m_rotY / 57.2957795056f) * cos(m_rotX / 57.2957795056f),
|
||||
-sin(m_rotX / 57.2957795056f),
|
||||
sin(m_rotY / 57.2957795056f) * cos(m_rotX / 57.2957795056f));
|
||||
|
||||
if (bobbingtime <= 360.f) bobbingtime += elapsedTime * m_topspeed / 2; else bobbingtime = 0;
|
||||
|
||||
if (dashtimeout > 0.f) {
|
||||
dash = false;
|
||||
@@ -73,18 +77,16 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
|
||||
}
|
||||
|
||||
if ((dbljump < 1 && ( left || right || front || back)) ||
|
||||
(dash && !(left || right || front || back)) )
|
||||
{
|
||||
(dash && !(left || right || front || back)) ) {
|
||||
yrotrad = (m_rotY / 57.2957795056f); // 180/Pi = 57.295...
|
||||
xrotrad = (m_rotX / 57.2957795056f);
|
||||
if (dash) accWS = m_topspeed; // Pour avoir un boost de vitesse vers l'avant si le dash est appuy<75> seul.
|
||||
}
|
||||
|
||||
// Ajoute l'acc<63>l<EFBFBD>ration de saut et le view bobbing.
|
||||
m_velocity.y = accjmp + (sin(gametime) - 0.5f) * ((abs(accWS) + abs(accAD)) / 2.f) / (10.f * m_topspeed);
|
||||
m_velocity.y = accjmp + (sin(bobbingtime) - 0.5f) * ((abs(accWS) + abs(accAD)) / 2.f) / (10.f * m_topspeed);
|
||||
m_position.y += m_velocity.y;
|
||||
|
||||
|
||||
if (front) {
|
||||
if (dbljump == 0)
|
||||
if (accWS < m_topspeed) accWS += elapsedTime * 30; else accWS = m_topspeed;
|
||||
@@ -144,13 +146,16 @@ void Player::Move(bool front, bool back, bool left, bool right, bool jump, bool
|
||||
if (accAD < 1.f && accAD > -1.f) accAD = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Gestion de si le personnage va en diagonale, qu'il n'aille pas plus vite que s'il allait en ligne droite.
|
||||
if ((accWS >= 0.f ? accWS : -accWS + accAD >= 0.f ? accAD : -accAD) > sqrtf(exp2f(m_topspeed) * 2)) {
|
||||
if (abs(accAD) + abs(accWS) > sqrtf(exp2f(m_topspeed) * 2)) {
|
||||
accWS *= 0.8f;
|
||||
accAD *= 0.8f;
|
||||
}
|
||||
|
||||
// Threshold de v<>locit<69>.
|
||||
if (abs(m_velocity.x) < 0.02f) m_velocity.x = 0;
|
||||
if (abs(m_velocity.y) < 0.02f) m_velocity.y = 0;
|
||||
if (abs(m_velocity.z) < 0.02f) m_velocity.z = 0;
|
||||
}
|
||||
|
||||
void Player::ApplyTransformation(Transformation& transformation, bool rel) const {
|
||||
@@ -163,6 +168,4 @@ Vector3f Player::GetPosition() const { return m_position; }
|
||||
|
||||
Vector3f Player::GetVelocity() const { return m_velocity; }
|
||||
|
||||
Vector3f Player::GetDirection() const { return Vector3f(cos(m_rotY / 57.2957795056f) * cos(m_rotX / 57.2957795056f),
|
||||
-sin(m_rotX / 57.2957795056f) ,
|
||||
sin(m_rotY / 57.2957795056f) * cos(m_rotX / 57.2957795056f)); }
|
||||
Vector3f Player::GetDirection() const { return m_direction; }
|
||||
|
Reference in New Issue
Block a user