diff options
author | Mattes D <github@xoft.cz> | 2015-04-14 22:31:09 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-14 22:31:09 +0200 |
commit | 54289aeccbb5a4d9624c369435ec29ce858374b9 (patch) | |
tree | 347b00bdfc68314d6a5e0a0aac5c89e3a19d6599 /src/Entities/ProjectileEntity.cpp | |
parent | Debuggers: Renamed conflicting /cs command to /cstay. (diff) | |
parent | Changed air drag for pickups (diff) | |
download | cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar.gz cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar.bz2 cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar.lz cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar.xz cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.tar.zst cuberite-54289aeccbb5a4d9624c369435ec29ce858374b9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 4684e3e09..05b7669cd 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -227,6 +227,8 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a ), m_IsInGround(false) { + SetGravity(-12.0f); + SetAirDrag(0.01f); } @@ -242,6 +244,8 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve SetSpeed(a_Speed); SetYawFromSpeed(); SetPitchFromSpeed(); + SetGravity(-12.0f); + SetAirDrag(0.01f); } @@ -349,9 +353,11 @@ void cProjectileEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a return; } - const Vector3d PerTickSpeed = GetSpeed() / 20; + auto DtSec = std::chrono::duration_cast<std::chrono::duration<double>>(a_Dt); + + const Vector3d DeltaSpeed = GetSpeed() * DtSec.count(); const Vector3d Pos = GetPosition(); - const Vector3d NextPos = Pos + PerTickSpeed; + const Vector3d NextPos = Pos + DeltaSpeed; // Test for entity collisions: cProjectileEntityCollisionCallback EntityCollisionCallback(this, Pos, NextPos); @@ -388,8 +394,8 @@ void cProjectileEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a // Add slowdown and gravity effect to the speed: Vector3d NewSpeed(GetSpeed()); - NewSpeed.y += m_Gravity / 20; - NewSpeed *= TracerCallback.GetSlowdownCoeff(); + NewSpeed.y += m_Gravity * DtSec.count(); + NewSpeed -= NewSpeed * (m_AirDrag * 20.0f) * DtSec.count(); SetSpeed(NewSpeed); SetYawFromSpeed(); SetPitchFromSpeed(); |