Skip to content

Commit

Permalink
editting colliders now block selection
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed May 12, 2024
1 parent 927d5dc commit 58d7e8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Murder.Editor/Services/EditorServices.cs
Expand Up @@ -273,7 +273,7 @@ public static bool BoxHandle(string id, RenderContext render, Vector2 cursorPosi
return false;
}

public static bool PolyHandle(string id, RenderContext render, Vector2 basePosition, Vector2 cursorPosition, Polygon polygon, Color color, out Polygon newPolygon)
public static bool PolyHandle(string id, RenderContext render, Vector2 basePosition, Vector2 cursorPosition, Polygon polygon, Color outline, Color color, out Polygon newPolygon)
{
newPolygon = polygon;
cursorPosition -= basePosition;
Expand All @@ -297,7 +297,7 @@ public static bool PolyHandle(string id, RenderContext render, Vector2 basePosit
}
else
{
RenderServices.DrawPoints(render.DebugBatch, Vector2.Zero, polygonWorld.Vertices.AsSpan(), color, 1);
RenderServices.DrawPoints(render.DebugBatch, Vector2.Zero, polygonWorld.Vertices.AsSpan(), outline, 1);
RenderServices.DrawPolygon(render.DebugFxBatch, polygonWorld.Vertices, new DrawInfo(color * 0.45f, 0.8f));

if (_draggingAnchor < 0)
Expand Down Expand Up @@ -370,7 +370,7 @@ public static bool PolyHandle(string id, RenderContext render, Vector2 basePosit
}
}
RenderServices.DrawRectangle(render.DebugBatch, new Rectangle(origin.X - 1 + basePosition.X, origin.Y - 1 + basePosition.Y, 2, 2), Color.Lerp(color, Color.White, 0.5f), 1f);
RenderServices.DrawLine(render.DebugBatch, line.Start + basePosition, line.End + basePosition, color, 0.8f);
RenderServices.DrawLine(render.DebugBatch, line.Start + basePosition, line.End + basePosition, Color.Lerp(outline, color, 0.35f), 0.8f);
}

if (selectedPoint != null)
Expand Down
4 changes: 4 additions & 0 deletions src/Murder.Editor/Systems/Debug/DebugColliderRenderSystem.cs
Expand Up @@ -57,6 +57,10 @@ public static void DrawImpl(RenderContext render, Context context, bool allowEdi
ImmutableArray<IShape> newShapes = [];

bool showHandles = allowEditingByDefault ? true : e.HasComponent<ShowColliderHandlesComponent>();
if (showHandles)
{
usingCursor = true;
}

bool isSolid = collider.Layer.HasFlag(CollisionLayersBase.SOLID);
for (int shapeIndex = 0; shapeIndex < collider.Shapes.Length; shapeIndex++)
Expand Down

0 comments on commit 58d7e8e

Please sign in to comment.