class Tracksperanto::Export::FlameStabilizer2014Cornerpin::Sorter

The trackers for cornerpins should go in Z order, but now in N order, unline it did previously. Like so:

TL(1)     TR(3)
 ˆ \       ˆ
 |  \      |
 |    \    |
 |      \  |
BL(0)     BR(2)

This “kinda tool” ensures that this is indeed taking place

Public Class Methods

new(exporter) click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 26
def initialize(exporter)
  @exp = exporter
end

Public Instance Methods

end_export() click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 50
def end_export
  # We will have problems sorting if we have too few trackers
  return @exp.just_export(@corners, @width, @height) unless @corners.length == 4
  
  # Sort the trackers, first in Y of the first keyframe
  in_y = sort_on_first_keyframe(@corners, :abs_y)
  
  # then on the X for the two separate blocks for top and bottom
  tl, tr = sort_on_first_keyframe(in_y[2..3], :abs_x)
  bl, br = sort_on_first_keyframe(in_y[0..1], :abs_x)
  
  bulk = [bl, tl, br, tr] # New Flame 2014 order
  
  @exp.just_export(bulk, @width, @height)
end
end_tracker_segment() click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 46
def end_tracker_segment
  # Just leave that
end
export_point(f, x, y, r) click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 41
def export_point(f, x, y, r)
  return if @four_done
  @corners[-1].keyframe! :frame => f, :abs_x => x, :abs_y => y, :residual => r
end
start_export(w,h) click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 30
def start_export(w,h)
  @width, @height = w, h
  @corners, @four_done = [], false
end
start_tracker_segment(name) click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 35
def start_tracker_segment(name)
  @four_done = (@corners.length == 4)
  return if @four_done
  @corners.push(Tracksperanto::Tracker.new(:name => name))
end

Private Instance Methods

sort_on_first_keyframe(enum, property) click to toggle source
# File lib/export/flame_stabilizer_2014_cornerpin.rb, line 68
def sort_on_first_keyframe(enum, property)
  enum.sort{|a, b| a[0].send(property) <=> b[0].send(property) }
end