Skip to content

Commit

Permalink
fix: don't try to ease plan timings when there are zero
Browse files Browse the repository at this point in the history
  • Loading branch information
cryy22 committed Apr 10, 2024
1 parent d3b2ecd commit df34546
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,14 @@ public static Arrangement EaseMovementPlanTimings(this Arrangement arrangement,

public static void EaseMovementPlanTimings(IEnumerable<Arrangement> arrangements, Easings.Enum easing)
{
int arrangementsCount = arrangements.SelectMany(a => a.ElementsMovementPlans).Count();
var plans = new Plan[arrangementsCount];
var arrangementsForPlans = new Arrangement[arrangementsCount];
int plansCount = arrangements.SelectMany(a => a.ElementsMovementPlans).Count();
if (plansCount == 0) return;
var plans = new Plan[plansCount];
var arrangementsForPlans = new Arrangement[plansCount];

var index = 0;
foreach (Arrangement arrangement in arrangements)
foreach (ElementMovementPlan plan in arrangement.ElementsMovementPlans.Values)
foreach (Plan plan in arrangement.ElementsMovementPlans.Values)
{
plans[index] = plan;
arrangementsForPlans[index] = arrangement;
Expand All @@ -295,12 +296,13 @@ public static void EaseMovementPlanTimings(IEnumerable<Arrangement> arrangements

EaseMovementPlanTimings(plans: plans, easing: easing);

for (var i = 0; i < arrangementsCount; i++)
for (var i = 0; i < plansCount; i++)
arrangementsForPlans[i].SetMovementPlan(plans[i]);
}

public static void EaseMovementPlanTimings(Plan[] plans, Easings.Enum easing)
{
if (plans.Length == 0) return;
float startDuration = plans.Max(p => p.StartTime);

for (var i = 0; i < plans.Length; i++)
Expand Down

0 comments on commit df34546

Please sign in to comment.