From 45c84ea93318a4ab8921a20d7d2c086cfc313999 Mon Sep 17 00:00:00 2001 From: DevToaster Date: Tue, 31 Mar 2015 11:03:35 -0400 Subject: Changed air drag units to 'interpolated ticks' per second --- src/Entities/ArrowEntity.cpp | 2 +- src/Entities/Boat.cpp | 2 +- src/Entities/Entity.cpp | 4 ++-- src/Entities/Entity.h | 6 ++++-- src/Entities/FallingBlock.cpp | 2 +- src/Entities/Minecart.cpp | 2 +- src/Entities/Pawn.cpp | 2 +- src/Entities/ProjectileEntity.cpp | 6 +++--- src/Entities/TNTEntity.cpp | 2 +- src/Mobs/Bat.cpp | 2 ++ src/Mobs/Blaze.cpp | 2 +- 11 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 3516b7540..32952100c 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -51,7 +51,7 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) : m_PickupState = psInCreative; } SetGravity(-20.0f); - SetAirDrag(0.2f); + SetAirDrag(0.01f); } diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index 8899921ab..4ad418be4 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -18,7 +18,7 @@ cBoat::cBoat(double a_X, double a_Y, double a_Z) : { SetMass(20.0f); SetGravity(-16.0f); - SetAirDrag(1.0f); + SetAirDrag(0.05f); SetMaxHealth(6); SetHealth(6); } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 67dae44b2..51cee248e 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -36,7 +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_AirDrag(0.02f), m_LastPos(a_X, a_Y, a_Z), m_IsInitialized(false), m_WorldTravellingFrom(nullptr), @@ -944,7 +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 -= NextSpeed * (m_AirDrag * 20.0f) * DtSec.count(); } NextSpeed.y += static_cast(fallspeed); } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 2c994c550..dd6190ced 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -508,8 +508,10 @@ protected: For realistic effects, this should be negative. For spaaaaaaace, this can be zero or even positive */ float m_Gravity; - /** Stores the air drag that is applied to the entity every tick, measured in speed ratio per second - Acts as air friction and slows down flight */ + /** Stores the air drag that is applied to the entity every tick, measured in speed ratio per tick + Acts as air friction and slows down flight + Will be interpolated if the server tick rate varies + Data: http://minecraft.gamepedia.com/Entity#Motion_of_entities */ float m_AirDrag; /** Last position sent to client via the Relative Move or Teleport packets (not Velocity) diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index 82daeb4bf..4a165909a 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -17,7 +17,7 @@ cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_Block m_OriginalPosition(a_BlockPosition) { SetGravity(-16.0f); - SetAirDrag(0.4f); + SetAirDrag(0.02f); } diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 7fdb39ea7..3d56570ba 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -94,7 +94,7 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : { SetMass(20.0f); SetGravity(-16.0f); - SetAirDrag(1.0f); + SetAirDrag(0.05f); SetMaxHealth(6); SetHealth(6); SetWidth(1); diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp index a4a9c6f21..fcb686e28 100644 --- a/src/Entities/Pawn.cpp +++ b/src/Entities/Pawn.cpp @@ -14,7 +14,7 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) : , m_EntityEffects(tEffectMap()) { SetGravity(-32.0f); - SetAirDrag(0.4f); + SetAirDrag(0.02f); } diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 28f7d0dea..05b7669cd 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -228,7 +228,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a m_IsInGround(false) { SetGravity(-12.0f); - SetAirDrag(0.2f); + SetAirDrag(0.01f); } @@ -245,7 +245,7 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Ve SetYawFromSpeed(); SetPitchFromSpeed(); SetGravity(-12.0f); - SetAirDrag(0.2f); + SetAirDrag(0.01f); } @@ -395,7 +395,7 @@ 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 * DtSec.count(); - NewSpeed -= NewSpeed * m_AirDrag * DtSec.count(); + NewSpeed -= NewSpeed * (m_AirDrag * 20.0f) * DtSec.count(); SetSpeed(NewSpeed); SetYawFromSpeed(); SetPitchFromSpeed(); diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp index b5b98f833..d849bd4c9 100644 --- a/src/Entities/TNTEntity.cpp +++ b/src/Entities/TNTEntity.cpp @@ -13,7 +13,7 @@ cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) : m_FuseTicks(a_FuseTicks) { SetGravity(-16.0f); - SetAirDrag(0.4f); + SetAirDrag(0.02f); } diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp index c072d4f48..e187e928a 100644 --- a/src/Mobs/Bat.cpp +++ b/src/Mobs/Bat.cpp @@ -9,6 +9,8 @@ cBat::cBat(void) : super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9) { + SetGravity(-2.0f); + SetAirDrag(0.05f); } diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index ed2a98201..d4ad24166 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -12,7 +12,7 @@ cBlaze::cBlaze(void) : super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8) { SetGravity(-8.0f); - SetAirDrag(0.8f); + SetAirDrag(0.05f); } -- cgit v1.2.3