Skip to content

Commit

Permalink
DerivePerspTrack: Switch to prepareForPerspective
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Jan 16, 2024
1 parent c6f0cea commit 3dd1295
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 4 additions & 0 deletions DependencyControl.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
],
"1.1.1": [
"Bump ArchMath dependency to fix a bug"
],
"1.1.2": [
"Remove unused Line dependency",
"Switch to prepareForPerspective function"
]
}
},
Expand Down
24 changes: 9 additions & 15 deletions macros/arch.DerivePerspTrack.moon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export script_name = "Derive Perspective Track"
export script_description = "Create a power-pin track file from the outer perspective quads of a set of lines."
export script_author = "arch1t3cht"
export script_namespace = "arch.DerivePerspTrack"
export script_version = "1.1.1"
export script_version = "1.1.2"

DependencyControl = require("l0.DependencyControl")
dep = DependencyControl{
Expand All @@ -24,7 +24,7 @@ dep = DependencyControl{

Functional, LineCollection, ASS, AMath, APersp = dep\requireModules!
{:Point} = AMath
{:transformPoints, :Quad} = APersp
{:prepareForPerspective, :transformPoints, :Quad} = APersp


outer_quad_key = "_aegi_perspective_ambient_plane"
Expand All @@ -46,19 +46,13 @@ get_quad_from_tags = (subs, i) ->
lines = LineCollection subs, {i}

data = ASS\parse(lines.lines[1])
tags = data\getEffectiveTags(-1, true, true, true).tags

width, height = data\getTextExtents!
width /= (tags.scale_x.value / 100)
height /= (tags.scale_y.value / 100)
if data\getPosition().class == ASS.Tag.Move
aegisub.log("Failed to derive: line has \\move!")
aegisub.cancel()

-- Manually enforce the relations between tags
if #data\getTags({"origin"}) == 0
tags.origin.x = tags.position.x
tags.origin.y = tags.position.y
tags, width, height, warnings = prepareForPerspective(ASS, data)

for warn in *warnings
if warn[1] == "move"
aegisub.log("Failed to derive: line has \\move!")
aegisub.cancel()
-- ignore the other ones for now

return transformPoints(tags, width, height)

Expand Down

0 comments on commit 3dd1295

Please sign in to comment.