Add center orbit slides

This commit is contained in:
Luke Hubmayer-Werner 2021-02-21 00:19:23 +10:30
parent 1297a6f342
commit 6fa4c5f34a
2 changed files with 35 additions and 8 deletions

View File

@ -369,12 +369,13 @@ class RGT:
if SLIDE_TYPES[slide_type] == Note.SlideType.COMPLEX: if SLIDE_TYPES[slide_type] == Note.SlideType.COMPLEX:
var col_hit = slide_ids[slide_id].column var col_hit = slide_ids[slide_id].column
var RUV = GameTheme.RADIAL_UNIT_VECTORS var RUV = GameTheme.RADIAL_UNIT_VECTORS
var RCA = GameTheme.RADIAL_COL_ANGLES
slide_ids[slide_id].values.curve2d.add_point(RUV[col_hit]) # Start col slide_ids[slide_id].values.curve2d.add_point(RUV[col_hit]) # Start col
match slide_type: match slide_type:
'4': # TODO: Loop ACW around center. Size of loop is roughly inscribed in chords of 0-3, 1-4, 2-5... NB: doesn't loop if directly opposite col '4': # Orbit ACW around center. Size of loop is roughly inscribed in chords of 0-3, 1-4, 2-5... NB: doesn't loop if directly opposite col
slide_ids[slide_id].values.curve2d.add_point((RUV[posmod(col_hit-3, Rules.COLS)] + RUV[col_hit]) * 0.5) Note.curve2d_make_orbit(slide_ids[slide_id].values.curve2d, RCA[col_hit], RCA[column], true)
'5': # TODO: CW of above '5': # CW of above
slide_ids[slide_id].values.curve2d.add_point((RUV[posmod(col_hit+3, Rules.COLS)] + RUV[col_hit]) * 0.5) Note.curve2d_make_orbit(slide_ids[slide_id].values.curve2d, RCA[col_hit], RCA[column], false)
'6': # S zigzag through center '6': # S zigzag through center
slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit-2, Rules.COLS)] * SLIDE_IN_R) slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit-2, Rules.COLS)] * SLIDE_IN_R)
slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit+2, Rules.COLS)] * SLIDE_IN_R) slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit+2, Rules.COLS)] * SLIDE_IN_R)
@ -388,10 +389,10 @@ class RGT:
'a': # TODO: CW of above 'a': # TODO: CW of above
slide_ids[slide_id].values.curve2d.add_point(Vector2.ZERO) slide_ids[slide_id].values.curve2d.add_point(Vector2.ZERO)
'b': # V into column 2 places ACW 'b': # V into column 2 places ACW
slide_ids[slide_id].values.curve2d.add_point(GameTheme.RADIAL_UNIT_VECTORS[posmod(col_hit-2, Rules.COLS)]) slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit-2, Rules.COLS)])
'c': # V into column 2 places CW 'c': # V into column 2 places CW
slide_ids[slide_id].values.curve2d.add_point(GameTheme.RADIAL_UNIT_VECTORS[posmod(col_hit+2, Rules.COLS)]) slide_ids[slide_id].values.curve2d.add_point(RUV[posmod(col_hit+2, Rules.COLS)])
slide_ids[slide_id].values.curve2d.add_point(GameTheme.RADIAL_UNIT_VECTORS[column]) # End col slide_ids[slide_id].values.curve2d.add_point(RUV[column]) # End col
else: # Naked slide start else: # Naked slide start
if last_star[column] != null: if last_star[column] != null:
slide_stars[slide_id] = last_star[column] slide_stars[slide_id] = last_star[column]

View File

@ -1,4 +1,4 @@
#extends Object tool
extends Node extends Node
#class_name Note #class_name Note
@ -260,3 +260,29 @@ static func process_note_list(note_array: Array, check_doubles:=true):
note_array[i].slide_id = slide_id note_array[i].slide_id = slide_id
slide_id += 1 slide_id += 1
# These should probably get their own singleton later
const ORBIT_INNER_RADIUS = sin(deg2rad(22.5)) # ~0.38
const ORBIT_KAPPA = (sqrt(2)-1) * 4.0 / 3.0 # This is the length of control points along a tangent to approximate a circle (multiply by desired radius)
func curve2d_make_orbit(curve2d, rad_in, rad_out, ccw, rad_max_arc:=PI*0.25, kappa:=ORBIT_KAPPA, inner_radius:=ORBIT_INNER_RADIUS): #
# curve2d.clear_points()
# curve2d.bake_interval = 0.05
var d_sign = -1 if ccw else 1
var rad_2 = rad_in+PI*3/8*d_sign
var rad_2t = rad_2+PI*0.5*d_sign
var rad_3 = rad_out-PI*3/8*d_sign
var rad_3t = rad_3-PI*0.5*d_sign
var a_diff = wrapf((rad_3-rad_2)*d_sign, 0.0001, TAU+0.0001)
var n = ceil(a_diff/rad_max_arc)
var ad = a_diff/n
var k = kappa*inner_radius*(2*ad/PI) # Not geometrically correct scaling but reasonable for now
# curve2d.add_point(polar2cartesian(1.0, rad_in))
curve2d.add_point(polar2cartesian(inner_radius, rad_2), Vector2.ZERO, polar2cartesian(k, rad_2t))
for i in range(1, n):
var ang = rad_2 + i*ad*d_sign
curve2d.add_point(polar2cartesian(inner_radius, ang), polar2cartesian(k, ang-PI/2*d_sign), polar2cartesian(k, ang+PI/2*d_sign))
curve2d.add_point(polar2cartesian(inner_radius, rad_3), polar2cartesian(k, rad_3t))
# curve2d.add_point(polar2cartesian(1.0, rad_out))