Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 62 additions & 11 deletions dread_editor/level_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import colorsys
import copy
import hashlib
import math
import os
import struct
import typing
Expand Down Expand Up @@ -289,19 +290,69 @@ def lerp_y(y):
if ("LOGICSHAPE" in actor.pComponents
and actor.pComponents.LOGICSHAPE["@type"] == 'CLogicShapeComponent'):
shape = actor.pComponents.LOGICSHAPE.pLogicShape
if shape is not None and shape["@type"] == 'game::logic::collision::CPolygonCollectionShape':
for poly in shape.oPolyCollection.vPolys:
vertices = []
for p in poly.oSegmentData:
vertices.append(
(lerp_x(p.vPos[0] + actor.vPos[0]),
lerp_y(p.vPos[1] + actor.vPos[1]))


if shape is not None and shape["@type"] == 'game::logic::collision::CAABoxShape2D':
try:
draw_list.add_rect(
lerp_x(shape.v2Min[0] + actor.vPos[0]),
lerp_y(shape.v2Min[1] + actor.vPos[1]),
lerp_x(shape.v2Max[0] + actor.vPos[0]),
lerp_y(shape.v2Max[1] + actor.vPos[1]),
color,
thickness=3,
)
except AttributeError:
pass
elif shape is not None and shape["@type"] == 'game::logic::collision::CCircleShape2D':
try:
draw_list.add_circle(
lerp_x(actor.vPos[0]),
lerp_y(actor.vPos[1]),
shape.fRadius,
color,
num_segments=32,
thickness=3,
)
except AttributeError:
pass
elif shape is not None and shape["@type"] == 'game::logic::collision::COBoxShape2D':
try:
angleSin = math.sin(shape.fDegrees)
angleCos = math.cos(shape.fDegrees)
draw_list.add_polyline(
vertices, color,
closed=poly.bClosed,
thickness=3,
)
[
(lerp_x((shape.v2Extent[0] * -1 * angleCos) - (shape.v2Extent[1] * angleSin) + actor.vPos[0]),
lerp_y((shape.v2Extent[0] * -1 * angleSin) + (shape.v2Extent[1] * angleCos) + actor.vPos[1])),
(lerp_x((shape.v2Extent[0] * angleCos) - (shape.v2Extent[1] * angleSin) + actor.vPos[0]),
lerp_y((shape.v2Extent[0] * angleSin) + (shape.v2Extent[1] * angleCos) + actor.vPos[1])),
(lerp_x((shape.v2Extent[0] * angleCos) - (shape.v2Extent[1] * -1 * angleSin) + actor.vPos[0]),
lerp_y((shape.v2Extent[0] * angleSin) + (shape.v2Extent[1] * -1 * angleCos) + actor.vPos[1])),
(lerp_x((shape.v2Extent[0] * -1 * angleCos) - (shape.v2Extent[1] * -1 * angleSin) + actor.vPos[0]),
lerp_y((shape.v2Extent[0] * -1 * angleSin) + (shape.v2Extent[1] * -1 * angleCos) + actor.vPos[1]))
],
color,
closed=poly.bClosed,
thickness=3,
)
except AttributeError:
pass
elif shape is not None and shape["@type"] == 'game::logic::collision::CPolygonCollectionShape':
try:
for poly in shape.oPolyCollection.vPolys:
vertices = []
for p in poly.oSegmentData:
vertices.append(
(lerp_x(p.vPos[0] + actor.vPos[0]),
lerp_y(p.vPos[1] + actor.vPos[1]))
)
draw_list.add_polyline(
vertices, color,
closed=poly.bClosed,
thickness=3,
)
except AttributeError:
pass

if self.highlighted_actors_in_canvas and imgui.is_window_hovered():
imgui.begin_tooltip()
Expand Down