summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDevToaster <blazetoaster@gmail.com>2015-03-31 02:07:19 +0200
committerDevToaster <blazetoaster@gmail.com>2015-03-31 02:07:19 +0200
commitd315534b76f0523d0a7bd7973ab7d209ee7d610e (patch)
tree2eee6179348d6dec4a3d5f2b11d6c5ea25b83528 /src
parentModified physics for more vanilla-like behavior (diff)
downloadcuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar.gz
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar.bz2
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar.lz
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar.xz
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.tar.zst
cuberite-d315534b76f0523d0a7bd7973ab7d209ee7d610e.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/ProjectileEntity.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index 2b8573d4d..28f7d0dea 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -353,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);
@@ -392,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 * DtSec.count();
SetSpeed(NewSpeed);
SetYawFromSpeed();
SetPitchFromSpeed();