11-22-2013, 09:47 PM
(11-22-2013, 03:51 PM)xoft Wrote:You could wrap it with a C++ struct/class so it doesn't require a table in Lua.(11-22-2013, 08:14 AM)FakeTruth Wrote: ... it could be stored in a fixed size array which should be pretty fast.That's fast in C++, but giving that list to Lua means creating a Lua table, which means allocating lots of memory chunks off the heap, which is gonna be slow again. And it's not gonna bring the counts that low - 19*19 chunks, 20 times per second, is 7k calls per second, which means 14k thread context switches per second. Barely doable.
(11-22-2013, 03:51 PM)xoft Wrote: Remembering all the blocks eligible for growing is probably going to be too memory-intensive. There's nothing preventing the player from having an entire chunk full of mossy cobble, which would translate to storing 65k coord triplets. Again, too many heap allocations for storing that in a Lua table.Like I said, only store potentially growable blocks. If you have an entire chunk full of mossy cobblestone blocks there is nothing left to grow there, it will store 0 blocks of that chunk.
Might just be best to select a random few coords per chunk in each tick, see if there's a mossy cobble there and growing it then. Pity that the plugins don't have access to per-chunk ticking which would make it considerably faster; also there's no way to enumerate the loaded chunks, so probably this is not possible atm.