When a new ship is loaded in the Tech Room, the hash for the new meshes may sometimes collide with the old meshes stored in _meshVerticesViews, _meshNormalsViews, _meshTextureCoordsViews, _vertexBuffers, _triangleBuffers and _vertexCounters, causing artifacts.
We just need to call FlightStart every time a new ship is loaded to reset these maps.
One way to do this is by counting the number of draw calls executed during one frame. Then, in SceneEnd() we can call FlightStart() to reset the cache if we're in the Tech Room and the number of draw calls changed since the last frame. This is an example of how I fixed this problem in my branch:
To reproduce this problem, as soon as the game begins, load the Tech Room, then click on "Cycle Craft" 9 times or until you reach the Preybird Fighter. Then click one time on "Cycle by Type" so that the the shuttles are loaded. Then click on "Cycle Craft" 11 times or until you reach the "System Patrol Craft". This ship will display broken geometry.
When a new ship is loaded in the Tech Room, the hash for the new meshes may sometimes collide with the old meshes stored in _meshVerticesViews, _meshNormalsViews, _meshTextureCoordsViews, _vertexBuffers, _triangleBuffers and _vertexCounters, causing artifacts.
We just need to call FlightStart every time a new ship is loaded to reset these maps.
One way to do this is by counting the number of draw calls executed during one frame. Then, in SceneEnd() we can call FlightStart() to reset the cache if we're in the Tech Room and the number of draw calls changed since the last frame. This is an example of how I fixed this problem in my branch:
https://github.com/Prof-Butts/xwa_ddraw_d3d11/blob/d3d_hook_merge/impl11/ddraw/XwaD3dRendererHook.cpp#L191
To reproduce this problem, as soon as the game begins, load the Tech Room, then click on "Cycle Craft" 9 times or until you reach the Preybird Fighter. Then click one time on "Cycle by Type" so that the the shuttles are loaded. Then click on "Cycle Craft" 11 times or until you reach the "System Patrol Craft". This ship will display broken geometry.