Cuberite Forum
Why doesn't cTracer use Chunks? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Why doesn't cTracer use Chunks? (/thread-1973.html)



Why doesn't cTracer use Chunks? - LogicParrot - 05-22-2015

I've been inspecting cTracer in an attempt to fix some mob line-of-sight issues, and I noticed that it doesn't use Chunks at all. Instead, it queries cWorld directly for blocks using m_World->GetBlock().

Is there any performance difference between querying a chunk for blocks and querying the World for blocks? And why do we need both approaches?


RE: Why doesn't cTracer use Chunks? - xoft - 05-22-2015

The cTracer class had been written before the chunks were made available. It is a somewhat legacy API; if you can change its usage to cLineBlockTracer instead, that would be great.

The performance hasn't been measured, but is assumed to be better with the direct chunk approach. Getting a single block from cWorld requires the underlying cChunkMap to lock a mutex, find the chunk to which the block belongs (a linear list search of the cChunkLayer objects), then query the chunk in the same way as the direct approach does.


RE: Why doesn't cTracer use Chunks? - LogicParrot - 05-22-2015

Thanks.
It should be noted that cLineBlockTracer also lacks a constructor which accepts a chunk instead of a world.