MontyTRC89 / Tomb-Editor

Tomb Editor
57 stars 16 forks source link

Added two new Editor Events that allow suspending and resuming rendering #833

Closed Raildex closed 4 months ago

Raildex commented 4 months ago

When building RoomGeometry of rooms in Parallel (Parallel.For(Each)), the C# Runtime would occasionally fire a OnPaint Event to avoid unresponsiveness. See this: https://stackoverflow.com/questions/4540244/how-is-this-possible-onpaint-processed-while-in-waitone and this: https://stackoverflow.com/questions/35535580/why-does-parallel-for-execute-the-winforms-message-pump-and-how-to-prevent-it

This Event causes Dx11DrawRenderingRoom to invalidate it's cache and rebuild geometry while the Room Geometry is still being processed.

This would not only occur during Undo/Redo, but also during Smart Geometry such as Shovel.

To avoid this, I created two new Events: SuspendRenderingEvent to ignore any drawing attempts and ResumRenderingEvent to reenable rendering.

The RenderingPanel class got a new bool AllowRendering (default true). It also got an overriden WndProc, which checks whether the Message is WM_PAINT and AllowRendering is true to accept the message.