MontyTRC89 / Tomb-Editor

Tomb Editor
57 stars 16 forks source link

TE: Convert Block class to struct #816

Open Raildex opened 5 months ago

Raildex commented 5 months ago

The room class contains a multi-dimensional array of Block like this:

public Block[,] Blocks { get; private set; }

Because Block is a class, the memory access pattern is completely random: Each array entry only stores a reference to a Block and the data itself is just somewhere randomly in memory.

With a struct, the elements are contiguous in the array itself. which allows a more efficient access pattern, especially for large group transformations of blocks such as rotation, smart geometry and copying rooms.