|
4 | 4 | using System; |
5 | 5 | using TSMapEditor.CCEngine; |
6 | 6 | using TSMapEditor.GameMath; |
| 7 | +using TSMapEditor.Initialization; |
7 | 8 | using TSMapEditor.Models; |
8 | 9 |
|
9 | 10 | namespace TSMapEditor.Rendering.ObjectRenderers |
@@ -283,18 +284,24 @@ public virtual void DrawShadow(T gameObject) |
283 | 284 |
|
284 | 285 | float textureHeight = (regularFrame != null && regularFrame.Texture != null) ? (float)regularFrame.Texture.Height : shadowFrame.Texture.Height; |
285 | 286 |
|
286 | | - float depth = GetDepthFromPosition(gameObject); |
| 287 | + float depth = GetDepthFromPosition(gameObject, drawingBounds.Bottom); |
287 | 288 | // depth += GetDepthAddition(gameObject); |
288 | 289 | depth += textureHeight / Map.HeightInPixelsWithCellHeight; |
289 | 290 |
|
290 | 291 | RenderDependencies.ObjectSpriteRecord.AddGraphicsEntry(new ObjectSpriteEntry(null, texture, drawingBounds, new Color(255, 255, 255, 128), false, true, depth)); |
291 | 292 | } |
292 | 293 |
|
293 | | - private float GetDepthFromPosition(T gameObject) |
| 294 | + private float GetDepthFromPosition(T gameObject, int bottomDrawPoint) |
294 | 295 | { |
295 | | - var southernmostCell = GetSouthernmostCell(gameObject); |
| 296 | + var southernmostCell = Map.GetTile(gameObject.Position); // GetSouthernmostCell(gameObject); |
| 297 | + |
| 298 | + int height = 0; |
| 299 | + if (southernmostCell != null) |
| 300 | + { |
| 301 | + height = southernmostCell.Level; |
| 302 | + } |
296 | 303 |
|
297 | | - return CellMath.GetDepthForCell(southernmostCell.CoordsToPoint(), Map); |
| 304 | + return ((bottomDrawPoint + Constants.CellSizeY) / (float)Map.HeightInPixelsWithCellHeight) * Constants.DownwardsDepthRenderSpace + (height * Constants.DepthRenderStep); |
298 | 305 | } |
299 | 306 |
|
300 | 307 | private MapTile GetSouthernmostCell(T gameObject) |
@@ -406,7 +413,7 @@ protected void DrawShapeImage(T gameObject, ShapeImage image, int frameIndex, Co |
406 | 413 | } |
407 | 414 | } |
408 | 415 |
|
409 | | - depthAddition += GetDepthFromPosition(gameObject); |
| 416 | + depthAddition += GetDepthFromPosition(gameObject, drawingBounds.Bottom); |
410 | 417 | depthAddition += GetDepthAddition(gameObject); |
411 | 418 |
|
412 | 419 | RenderFrame(gameObject, frame, remapFrame, color, drawRemap, remapColor, |
@@ -454,13 +461,13 @@ protected void DrawVoxelModel(T gameObject, VoxelModel model, byte facing, RampT |
454 | 461 | } |
455 | 462 | } |
456 | 463 |
|
457 | | - depthAddition += GetDepthFromPosition(gameObject); |
| 464 | + Rectangle drawingBounds = GetTextureDrawCoords(gameObject, frame, drawPoint); |
| 465 | + |
| 466 | + depthAddition += GetDepthFromPosition(gameObject, drawingBounds.Bottom); |
458 | 467 | depthAddition += GetDepthAddition(gameObject); |
459 | 468 |
|
460 | 469 | remapColor = ScaleColorToAmbient(remapColor, mapCell.CellLighting); |
461 | 470 |
|
462 | | - Rectangle drawingBounds = GetTextureDrawCoords(gameObject, frame, drawPoint); |
463 | | - |
464 | 471 | RenderFrame(gameObject, frame, remapFrame, color, drawRemap, remapColor, |
465 | 472 | drawingBounds, null, lighting, depthAddition, 0.5f, compensateForBottomGap); |
466 | 473 | } |
|
0 commit comments