From adb86a75dac91a210149fc28b1dbf5225896f66c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Jul 2020 20:15:09 +0100 Subject: Do not GetBlock individually in simulators * Have the simulator manager get the block and pass it on + Add new overload for WakeUp, called when the manager wakes face positions --- src/Simulator/Simulator.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/Simulator/Simulator.h') diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index aacd5f52f..f82b579cb 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -13,9 +13,9 @@ class cCuboid; Each descendant provides an implementation of what needs to be done on each world tick. The descendant may choose to do all processing in a single call for the entire world (Simulate()) or do per-chunk calculations (SimulateChunk()). -Whenever a block is changed, the WakeUp() or WakeUpArea() functions are called to notify all simulators. -The functions add all affected blocks and all their direct neighbors using the AddBlock() function. The simulator -may update its internal state based on this call. */ +Whenever a block is changed, the WakeUp() functions are called to notify all simulators by the simulator manager. +The functions are invoked to add all affected blocks and their direct neighbors using the AddBlock() function. +The simulator may update its internal state based on this call. */ class cSimulator { public: @@ -27,7 +27,18 @@ public: virtual ~cSimulator() {} - virtual void WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block); + // Contains our direct adjacents + inline static std::array AdjacentOffsets + { + { + { 1, 0, 0 }, + { -1, 0, 0 }, + { 0, 1, 0 }, + { 0, -1, 0 }, + { 0, 0, 1 }, + { 0, 0, -1 }, + } + }; protected: -- cgit v1.2.3