From 284f54ed81186d3122b994db7395e870703efb4f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 10 Jul 2022 23:56:25 +0100 Subject: Explosions: improve performance --- src/Items/ItemBoat.h | 6 +++--- src/Items/ItemBottle.h | 4 ++-- src/Items/ItemBucket.h | 14 ++++++-------- src/Items/ItemLilypad.h | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemBoat.h b/src/Items/ItemBoat.h index 4fc041787..62d6f546e 100644 --- a/src/Items/ItemBoat.h +++ b/src/Items/ItemBoat.h @@ -2,7 +2,7 @@ #pragma once #include "../Entities/Boat.h" -#include "../LineBlockTracer.h" +#include "../Physics/Tracers/LineBlockTracer.h" @@ -38,7 +38,7 @@ public: // Find the actual placement position by tracing line of sight until non-air block: class cCallbacks: - public cBlockTracer::cCallbacks + public BlockTracerCallbacks { public: Vector3d m_Pos; @@ -62,7 +62,7 @@ public: } Callbacks; auto Start = a_Player->GetEyePosition() + a_Player->GetLookVector(); auto End = a_Player->GetEyePosition() + a_Player->GetLookVector() * 5; - cLineBlockTracer::Trace(*a_World, Callbacks, Start, End); + LineBlockTracer::Trace(*a_World, Callbacks, Start, End); if (!Callbacks.m_HasFound) { return false; diff --git a/src/Items/ItemBottle.h b/src/Items/ItemBottle.h index a324eb101..748dc0860 100644 --- a/src/Items/ItemBottle.h +++ b/src/Items/ItemBottle.h @@ -28,7 +28,7 @@ public: bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) const { class cCallbacks: - public cBlockTracer::cCallbacks + public BlockTracerCallbacks { public: Vector3i m_Pos; @@ -57,7 +57,7 @@ public: } Callbacks; auto Start = a_Player->GetEyePosition() + a_Player->GetLookVector(); auto End = a_Player->GetEyePosition() + a_Player->GetLookVector() * 5; - cLineBlockTracer::Trace(*a_World, Callbacks, Start, End); + LineBlockTracer::Trace(*a_World, Callbacks, Start, End); if (!Callbacks.m_HasHitFluid) { return false; diff --git a/src/Items/ItemBucket.h b/src/Items/ItemBucket.h index e7fa0fe38..4403342f8 100644 --- a/src/Items/ItemBucket.h +++ b/src/Items/ItemBucket.h @@ -6,7 +6,7 @@ #include "../World.h" #include "../Simulator/FluidSimulator.h" #include "../Blocks/BlockHandler.h" -#include "../LineBlockTracer.h" +#include "../Physics/Tracers/LineBlockTracer.h" #include "../Blocks/ChunkInterface.h" @@ -185,7 +185,7 @@ public: bool GetBlockFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos) const { class cCallbacks : - public cBlockTracer::cCallbacks + public BlockTracerCallbacks { public: Vector3i m_Pos; @@ -213,11 +213,10 @@ public: } } Callbacks; - cLineBlockTracer Tracer(*a_World, Callbacks); Vector3d Start(a_Player->GetEyePosition() + a_Player->GetLookVector()); Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - Tracer.Trace(Start, End); + LineBlockTracer::Trace(*a_World, Callbacks, Start, End); if (!Callbacks.m_HasHitFluid) { @@ -236,7 +235,7 @@ public: bool GetPlacementCoordsFromTrace(cWorld * a_World, cPlayer * a_Player, Vector3i & a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta, eBlockFace & a_BlockFace) const { class cCallbacks : - public cBlockTracer::cCallbacks + public BlockTracerCallbacks { public: Vector3i m_Pos; @@ -262,14 +261,13 @@ public: } } Callbacks; - cLineBlockTracer Tracer(*a_World, Callbacks); Vector3d Start(a_Player->GetEyePosition()); Vector3d End(a_Player->GetEyePosition() + a_Player->GetLookVector() * 5); - // cLineBlockTracer::Trace() returns true when whole line was traversed. By returning true from the callback when we hit something, + // LineBlockTracer::Trace() returns true when whole line was traversed. By returning true from the callback when we hit something, // we ensure that this never happens if liquid could be placed // Use this to judge whether the position is valid - if (!Tracer.Trace(Start, End)) + if (!LineBlockTracer::Trace(*a_World, Callbacks, Start, End)) { a_BlockPos = Callbacks.m_Pos; a_BlockType = Callbacks.m_ReplacedBlockType; diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index f13212b07..10bc5f75a 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -3,7 +3,7 @@ #include "ItemHandler.h" #include "../Entities/Player.h" -#include "../LineBlockTracer.h" +#include "../Physics/Tracers/LineBlockTracer.h" @@ -89,7 +89,7 @@ public: } class cCallbacks: - public cBlockTracer::cCallbacks + public BlockTracerCallbacks { public: @@ -118,7 +118,7 @@ public: const auto EyePosition = a_Player->GetEyePosition(); const auto End = EyePosition + a_Player->GetLookVector() * 5; - if (cLineBlockTracer::Trace(*a_Player->GetWorld(), Callbacks, EyePosition, End)) + if (LineBlockTracer::Trace(*a_Player->GetWorld(), Callbacks, EyePosition, End)) { // The line traced to completion; no suitable water was found: return false; -- cgit v1.2.3