Xaser wrote:What can I do to help get this merged before release? I can try and play around with trying to reproducing whatever issue Randi fixed, though it'll be a bit guessworky without some assistance.
I'm not sure how much this will help, but I'll try explain what the code is doing and why (as far as I understand it):
Initially the renderer walks the BSP tree and draws all solid walls. As it does this it keeps track on what has already been drawn vertically as min/max values for each pixel column on the screen. Essentially this is the top of the mid wall stored in 'ceilingclip' arrays and the bottom in 'floorclip' arrays. For each two-sided midtexture it creates a DrawSegment for the wall, but it does not draw it yet. As part of this creation it copies the clip arrays into 'sprtopclip' and 'sprbottomclip' on the DrawSegment.
Once the renderer is done drawing all the solid walls and planes, it draws the sprites. The sprites are drawn back to front, but before each sprite is drawn it checks if a draw segment is behind the sprite. If it is, then it draws
only the part of the draw segment covered by the sprite. It then marks that part of the draw segment drawn by filling 'sprtopclip' with values beyond any 'sprbottomclip' value, thus effectively causing everything in that range to be fully clipped. That's what the 'fillshort' lines are about.
After it is done drawing all the sprites it iterates through all the draw segments again and draws them all back to front. All the places that were covered by sprites have the clip arrays modifies so they skip those blocks so sprites don't get overwritten in this last draw call.
This is Carmack's original (brain dead) way of sorting segments and sprites. On top of this 3D floors were added. I'm not 100% sure of the attempted algorithm here, but for each 3D floor height it draws only sprites above or below that floor level. Since it reuses the original sprite drawing loops, it runs into the problem with sprtopclip being cleared as part of the drawing as it now calls it multiple times. That's where the 'bkup' array enters the picture. The code attempts to take a backup of the array, so that other code can mess up the array and then it can copy back the original. The code you changed made it always copy back the backup. Apparently Randi identified a situation where restoring the array wasn't good for 3D floors.
That's about as far as I can help. The exact details of 3D floor segment/sprite clipping eludes me and for softpoly I opted for a much easier way: split/sort sprites by their subsector before drawing them. That way you have the BSP guaranteeing that wall segment is in front all sprites drawn so far and behind the rest.
[quote="Xaser"]What can I do to help get this merged before release? I can try and play around with trying to reproducing whatever issue Randi fixed, though it'll be a bit guessworky without some assistance.[/quote]
I'm not sure how much this will help, but I'll try explain what the code is doing and why (as far as I understand it):
Initially the renderer walks the BSP tree and draws all solid walls. As it does this it keeps track on what has already been drawn vertically as min/max values for each pixel column on the screen. Essentially this is the top of the mid wall stored in 'ceilingclip' arrays and the bottom in 'floorclip' arrays. For each two-sided midtexture it creates a DrawSegment for the wall, but it does not draw it yet. As part of this creation it copies the clip arrays into 'sprtopclip' and 'sprbottomclip' on the DrawSegment.
Once the renderer is done drawing all the solid walls and planes, it draws the sprites. The sprites are drawn back to front, but before each sprite is drawn it checks if a draw segment is behind the sprite. If it is, then it draws [i]only[/i] the part of the draw segment covered by the sprite. It then marks that part of the draw segment drawn by filling 'sprtopclip' with values beyond any 'sprbottomclip' value, thus effectively causing everything in that range to be fully clipped. That's what the 'fillshort' lines are about.
After it is done drawing all the sprites it iterates through all the draw segments again and draws them all back to front. All the places that were covered by sprites have the clip arrays modifies so they skip those blocks so sprites don't get overwritten in this last draw call.
This is Carmack's original (brain dead) way of sorting segments and sprites. On top of this 3D floors were added. I'm not 100% sure of the attempted algorithm here, but for each 3D floor height it draws only sprites above or below that floor level. Since it reuses the original sprite drawing loops, it runs into the problem with sprtopclip being cleared as part of the drawing as it now calls it multiple times. That's where the 'bkup' array enters the picture. The code attempts to take a backup of the array, so that other code can mess up the array and then it can copy back the original. The code you changed made it always copy back the backup. Apparently Randi identified a situation where restoring the array wasn't good for 3D floors.
That's about as far as I can help. The exact details of 3D floor segment/sprite clipping eludes me and for softpoly I opted for a much easier way: split/sort sprites by their subsector before drawing them. That way you have the BSP guaranteeing that wall segment is in front all sprites drawn so far and behind the rest.