From a66e154b90a96d41fd2cc0c9ac30f2e55e692546 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 13 Jan 2014 22:37:09 +0000 Subject: 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. --- src/Entities/Entity.cpp | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index bc66305b1..cd97c6766 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -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; } } } -- cgit v1.2.3