1
0

Final improvements to Minecarts

* Fixed curved rails being a little broken
+ Implemented detector rails
+ Implemented block collisions on rails
* Fixed snapping to rail
- Removed minecart physics conditions in Entity.cpp as minecarts use
their own simulator when on rails

Fixes #148 and #217; partially implemented #215.

This is Cave Johnson, and we're done here.
This commit is contained in:
Tiger Wang
2014-01-13 22:37:09 +00:00
parent edefa27a48
commit a66e154b90
3 changed files with 297 additions and 98 deletions

View File

@@ -629,11 +629,6 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
{
fallspeed = m_Gravity * a_Dt / 3; // Fall 3x slower in water.
}
else if (IsBlockRail(BlockBelow) && IsMinecart()) // Rails aren't solid, except for Minecarts
{
fallspeed = 0;
m_bOnGround = true;
}
else if (BlockIn == E_BLOCK_COBWEB)
{
NextSpeed.y *= 0.05; // Reduce overall falling speed
@@ -648,41 +643,18 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
else
{
if (IsMinecart())
// Friction
if (NextSpeed.SqrLength() > 0.0004f)
{
if (!IsBlockRail(BlockBelow))
NextSpeed.x *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.x) < 0.05)
{
// Friction if minecart is off track, otherwise, Minecart.cpp handles this
if (NextSpeed.SqrLength() > 0.0004f)
{
NextSpeed.x *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.x) < 0.05)
{
NextSpeed.x = 0;
}
NextSpeed.z *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.z) < 0.05)
{
NextSpeed.z = 0;
}
}
NextSpeed.x = 0;
}
}
else
{
// Friction for non-minecarts
if (NextSpeed.SqrLength() > 0.0004f)
NextSpeed.z *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.z) < 0.05)
{
NextSpeed.x *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.x) < 0.05)
{
NextSpeed.x = 0;
}
NextSpeed.z *= 0.7f / (1 + a_Dt);
if (fabs(NextSpeed.z) < 0.05)
{
NextSpeed.z = 0;
}
NextSpeed.z = 0;
}
}
}