cBlocksToTick
#1
UPDATE: This whole idea was wrong and has been scratched, never to be revived again Smile

This thread is only to document what I'm doing at the moment; I'll put a link to this thread into the source so that if anyone wants to touch the source, they'll know what I meant to do Smile

Current blockticking in MCS is rather chaotic. Each chunk has a list of blocks that it wants to "check", and then a coord triplet where to start random blockticking.
"Checking" means that the block is checked if its surroundings allow it to stay (cBlockHandler::CanBeAt() ), if not, the block is dropped.
"Blockticking" means picking 50 random coords and calling cBlockHandler::OnUpdate().

I believe this should be merged together. So there should be a list of blocks "to be ticked"; each block should then be both checked and updated. And since this is gonna be called 20 times per second for each live chunk, it needs to be fast. Therefore it's a bad idea to make the list dynamically-allocated.

I'll be making a cBlocksToTick object that will represent the list of block coords to tick. This object will have a fixed number of coords that it can take without dynamic memory allocation, and an overflow area just in case there are more blockticks at the time.
Each chunk will have two pointers to two such objects. One will be written to when a blocktick is requested; the other one will be "waiting in queue". When the tickthread wants to tick the chunk's blocks, it will swap the two pointers and use the inactive one for reading and the active one for writing (many blocks, when they update, schedule more blockticks) (<-- doublebuffering, more or less Smile )
It seems reasonable that the cBlocksToTick will have a Tick() method that will tick all the coords stored in the object - because it's simpler to iterate over the elements that I own than exporting some kind of an iterator to an external object. Additionally, it will make possible some optimizations, such as calculating the chunk base coords for adding to the relative coords only once.
This method will take all the parameters needed to call all the blockticking handler functions.
Reply
Thanks given by:


Messages In This Thread
cBlocksToTick - by xoft - 10-08-2012, 05:45 AM
RE: cBlocksToTick - by FakeTruth - 10-08-2012, 06:14 AM
RE: cBlocksToTick - by xoft - 10-08-2012, 05:45 PM
RE: cBlocksToTick - by FakeTruth - 10-08-2012, 07:55 PM



Users browsing this thread: 1 Guest(s)