TrueCraft icon indicating copy to clipboard operation
TrueCraft copied to clipboard

Lighting errors (server)

Open ddevault opened this issue 10 years ago • 7 comments

I've noticed two problems with lighting that need to be addressed:

  • Deleting a semitransparent block (like leaves of a tree) will not update the blocks underneath it correctly
  • Something is wrong with the way light propagates horizontally, we should have a unit test that covers propagation across all four cardinal directions

ddevault avatar Jul 07 '15 05:07 ddevault

This might not be the issue but the heightmap calculation in WorldLighting doens't work properly. It seems that the chunk heightmap isn't correctly updated, which throws off the lighting because it starts at chunk.GetHeight() + 2. Grass, dirt, stone, and bedrock don't seem to count in the heightmap calculation, so for most blocks the chunk heightmap is 0 and the light heightmap is 2. This might be breaking the skylight field in LightingOperation and causing the incorrect light values.

ghost avatar Jul 07 '15 20:07 ghost

I don't follow why starting from chunk.GetHeight() + 2 causes issues.

ddevault avatar Jul 07 '15 20:07 ddevault

Because GetHeight() returns 0, so the search starts at 2, and immediately ends because level 2 is usually an opaque block.

ghost avatar Jul 07 '15 20:07 ghost

Why would GetHeight return 0? It returns the height of that column.

ddevault avatar Jul 07 '15 20:07 ddevault

I think it's because this loop doesn't break once it hits a solid block.

 // Shift height downwards
 while (coordinates.Y > 0)
{
    coordinates.Y--;
    if (GetBlockID(coordinates) != 0)
    {
        SetHeight((byte)coordinates.X, (byte)coordinates.Z, coordinates.Y);
        if (coordinates.Y > MaxHeight)
            MaxHeight = coordinates.Y;
       // Should break here;
    }
}

ghost avatar Jul 07 '15 20:07 ghost

Huh. That's very odd. I feel like that should be causing unit tests failures all over the place.

ddevault avatar Jul 07 '15 20:07 ddevault

Something is wrong with the way light propagates horizontally, we should have a unit test that covers propagation across all four cardinal directions

This is the only one of the two issues that remains.

ddevault avatar Oct 02 '15 12:10 ddevault