1
0
Fork 0

Changed air drag units to 'interpolated ticks' per second

This commit is contained in:
DevToaster 2015-03-31 11:03:35 -04:00
parent d315534b76
commit 45c84ea933
11 changed files with 18 additions and 14 deletions

View File

@ -51,7 +51,7 @@ cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
m_PickupState = psInCreative;
}
SetGravity(-20.0f);
SetAirDrag(0.2f);
SetAirDrag(0.01f);
}

View File

@ -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);
}

View File

@ -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<float>(fallspeed);
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}