summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorDevToaster <blazetoaster@gmail.com>2015-03-31 01:42:32 +0200
committerDevToaster <blazetoaster@gmail.com>2015-03-31 01:42:32 +0200
commitc743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4 (patch)
treeaef0d73b4a70ea991894dd1f739f074a622485ef /src/Entities/Entity.cpp
parentQtBiomeVisualiser: Fixed compilation and INI loading. (diff)
downloadcuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar.gz
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar.bz2
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar.lz
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar.xz
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.tar.zst
cuberite-c743c7fd0cc12bf10d76ecb8cdcb8029ed8429a4.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index c8df6b4b1..67dae44b2 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -36,6 +36,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
m_bHasSentNoSpeed(true),
m_bOnGround(false),
m_Gravity(-9.81f),
+ m_AirDrag(0.4f),
m_LastPos(a_X, a_Y, a_Z),
m_IsInitialized(false),
m_WorldTravellingFrom(nullptr),
@@ -943,6 +944,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Normal gravity
fallspeed = m_Gravity * DtSec.count();
+ NextSpeed -= NextSpeed * m_AirDrag * DtSec.count();
}
NextSpeed.y += static_cast<float>(fallspeed);
}
@@ -999,7 +1001,7 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
NextSpeed += m_WaterSpeed;
- if (NextSpeed.SqrLength() > 0.f)
+ if (NextSpeed.SqrLength() > 0.0f)
{
cTracer Tracer(GetWorld());
// Distance traced is an integer, so we round up from the distance we should go (Speed * Delta), else we will encounter collision detection failurse
@@ -1015,20 +1017,20 @@ void cEntity::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Block hit was within our projected path
// Begin by stopping movement in the direction that we hit something. The Normal is the line perpendicular to a 2D face and in this case, stores what block face was hit through either -1 or 1.
// For example: HitNormal.y = -1 : BLOCK_FACE_YM; HitNormal.y = 1 : BLOCK_FACE_YP
- if (Tracer.HitNormal.x != 0.f)
+ if (Tracer.HitNormal.x != 0.0f)
{
- NextSpeed.x = 0.f;
+ NextSpeed.x = 0.0f;
}
- if (Tracer.HitNormal.y != 0.f)
+ if (Tracer.HitNormal.y != 0.0f)
{
- NextSpeed.y = 0.f;
+ NextSpeed.y = 0.0f;
}
- if (Tracer.HitNormal.z != 0.f)
+ if (Tracer.HitNormal.z != 0.0f)
{
- NextSpeed.z = 0.f;
+ NextSpeed.z = 0.0f;
}
- if (Tracer.HitNormal.y == 1.f) // Hit BLOCK_FACE_YP, we are on the ground
+ if (Tracer.HitNormal.y == 1.0f) // Hit BLOCK_FACE_YP, we are on the ground
{
m_bOnGround = true;
}
@@ -1971,7 +1973,7 @@ void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
{
return;
}
- if ((a_Forward != 0.f) || (a_Sideways != 0.f))
+ if ((a_Forward != 0.0f) || (a_Sideways != 0.0f))
{
m_AttachedTo->HandleSpeedFromAttachee(a_Forward, a_Sideways);
}