[fix] Fixed an issue that time
variable returned an absolute beat count.
This commit is contained in:
parent
0684fd293d
commit
92ee305fff
@ -35,8 +35,9 @@ abstract class AbstractScheduledController : ScheduledControllerInterface {
|
|||||||
assert(next_operation_index_ <= operations_.length);
|
assert(next_operation_index_ <= operations_.length);
|
||||||
|
|
||||||
const last_operation = &operations_[next_operation_index_-1];
|
const last_operation = &operations_[next_operation_index_-1];
|
||||||
if (IsTimeInPeriod(time, last_operation.period)) {
|
const period = last_operation.period;
|
||||||
ProcessOperation(time, *last_operation);
|
if (IsTimeInPeriod(time, period)) {
|
||||||
|
ProcessOperation(period.ConvertToRelativeTime(time), *last_operation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FinalizeOperation(*last_operation);
|
FinalizeOperation(*last_operation);
|
||||||
@ -47,7 +48,8 @@ abstract class AbstractScheduledController : ScheduledControllerInterface {
|
|||||||
const next_operation = &operations_[next_operation_index_];
|
const next_operation = &operations_[next_operation_index_];
|
||||||
if (IsTimeInPeriod(time, next_operation.period)) {
|
if (IsTimeInPeriod(time, next_operation.period)) {
|
||||||
PrepareOperation(*next_operation);
|
PrepareOperation(*next_operation);
|
||||||
ProcessOperation(time, *next_operation);
|
ProcessOperation(
|
||||||
|
next_operation.period.ConvertToRelativeTime(time), *next_operation);
|
||||||
++next_operation_index_;
|
++next_operation_index_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,9 @@ bool IsTimeInPeriod(float time, in Period period) {
|
|||||||
bool IsPeriodIntersectedToPeriod(in Period p1, in Period p2) {
|
bool IsPeriodIntersectedToPeriod(in Period p1, in Period p2) {
|
||||||
return p1.start < p2.end && p2.start < p1.end;
|
return p1.start < p2.end && p2.start < p1.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
float ConvertToRelativeTime(in Period period, float src)
|
||||||
|
in (period.start < period.end) {
|
||||||
|
return (src - period.start) / (period.end - period.start);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user