File tree Expand file tree Collapse file tree
src/TSMapEditor/Rendering/ObjectRenderers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,28 @@ protected override CommonDrawParams GetDrawParams(Unit gameObject)
2626 } ;
2727 }
2828
29+ protected override float GetDepthFromPosition ( Unit gameObject , int bottomDrawPoint )
30+ {
31+ // Because vehicles can include turrets, the default implementation
32+ // is not suitable. For example, bodies can be rendered southward of turrets
33+ // facing north, leading the bodies to have higher depth and overlapping turrets.
34+ //
35+ // Instead, we calculate a positional depth value using the vehicle's cell.
36+ // This depth value is identical for the base vehicle sprite and turret,
37+ // making it easy to draw the turret either above or below the vehicle
38+ // by applying DepthEpsilon.
39+ var cell = Map . GetTile ( gameObject . Position ) ;
40+
41+ int height = 0 ;
42+ if ( cell != null )
43+ {
44+ height = cell . Level ;
45+ }
46+
47+ return ( ( CellMath . CellTopLeftPointFromCellCoords ( cell . CoordsToPoint ( ) , Map ) . Y + Constants . CellSizeY ) / ( float ) Map . HeightInPixelsWithCellHeight ) * Constants . DownwardsDepthRenderSpace +
48+ ( height * Constants . DepthRenderStep ) ;
49+ }
50+
2951 protected override float GetDepthAddition ( Unit gameObject )
3052 {
3153 return Constants . DepthEpsilon * ObjectDepthAdjustments . Vehicle ;
You can’t perform that action at this time.
0 commit comments