From 284c1c0514168e30338f2ad372b7e7f185dba0c4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 1 Jul 2014 22:39:37 +0100 Subject: Vector clamping fixes Thank you, @madmaxoft. --- src/Entities/ArrowEntity.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Entities/ArrowEntity.cpp') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 2d6683f0a..7e96a666d 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -69,14 +69,18 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) { Vector3d Hit = a_HitPos; - Vector3d SinkMovement = GetSpeed() / 800; - SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05); + Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration + SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P) + SinkMovement, + (SinkMovement * 0.001) / SinkMovement.Length(), + (SinkMovement * 0.05) / SinkMovement.Length() + ); Hit += SinkMovement; // Make arrow sink into block a little super::OnHitSolidBlock(Hit, a_HitFace); - Hit.Floor(); + Vector3i BlockHit = Hit.Floor(); - int X = Hit.x, Y = Hit.y, Z = Hit.z; + int X = BlockHit.x, Y = BlockHit.y, Z = BlockHit.z; m_HitBlockPos = Vector3i(X, Y, Z); // Broadcast arrow hit sound -- cgit v1.2.3