[fix] Fixed an issue that playing with offset might not work properly.

This commit is contained in:
falsycat 2019-10-17 00:00:00 +00:00
parent 1c9aa9340d
commit fc81f9dcc7
4 changed files with 34 additions and 46 deletions

View File

@ -4,22 +4,22 @@ actor [0..1] {
clip_left := 0.1; clip_left := 0.1;
} }
background [0..1] { background [0..1] {
inner_r = 0.8; inner_r := 0.8;
inner_g = 0.8; inner_g := 0.8;
inner_b = 0.8; inner_b := 0.8;
inner_a = 1; inner_a := 1;
outer_r = 0; outer_r := 0;
outer_g = 0; outer_g := 0;
outer_b = 0; outer_b := 0;
outer_a = 1; outer_a := 1;
} }
posteffect [0..1] { posteffect [0..1] {
clip_left := 0.1; clip_left := 0.1;
clip_right := 0.1; clip_right := 0.1;
} }
variable [0..3.5] { variable [0..1] {
hoge = 1-time; hoge = 1;
} }
$repeat i 2 { $repeat i 2 {

View File

@ -26,9 +26,22 @@ abstract class AbstractScheduledController : ScheduledControllerInterface {
} }
override void Operate(float time) { override void Operate(float time) {
FinalizeCurrentOperationIfEnded(time); while (true) {
PrepareNextOperationIfStarted(time); if (next_operation_index_ >= 1) {
ProcessCurrentOperationIfAvailable(time); const current = &operations_[next_operation_index_-1];
ProcessOperation(
current.period.ConvertToRelativeTime(time), *current);
if (current.period.end > time) return;
FinalizeOperation(*current);
}
if (next_operation_index_ >= operations_.length) return;
const next = &operations_[next_operation_index_];
if (next.period.start > time) return;
++next_operation_index_;
PrepareOperation(*next);
}
} }
protected: protected:
@ -87,33 +100,6 @@ abstract class AbstractScheduledController : ScheduledControllerInterface {
} }
private: private:
void FinalizeCurrentOperationIfEnded(float time) {
if (next_operation_index_ < 1) return;
const current = &operations_[next_operation_index_-1];
if (current.period.end > time) return;
FinalizeOperation(*current);
}
void PrepareNextOperationIfStarted(float time) {
if (next_operation_index_ >= operations_.length) return;
const next = &operations_[next_operation_index_];
if (next.period.start > time) return;
++next_operation_index_;
PrepareOperation(*next);
}
void ProcessCurrentOperationIfAvailable(float time) {
if (next_operation_index_ < 1) return;
const current = &operations_[next_operation_index_-1];
if (current.period.end <= time) return;
ProcessOperation(
current.period.ConvertToRelativeTime(time), *current);
}
const VarStoreInterface varstore_; const VarStoreInterface varstore_;
const ParametersBlock[] operations_; const ParametersBlock[] operations_;

View File

@ -39,7 +39,12 @@ class Context {
sjplayer.CircleElement, sjplayer.CircleElement,
sjplayer.SquareElement, sjplayer.SquareElement,
sjplayer.TriangleElement; sjplayer.TriangleElement;
// FIXME: fucking solution
auto factories = tuple( auto factories = tuple(
tuple(
"variable",
VarStoreScheduledControllerFactory(varstore),
),
tuple( tuple(
"actor", "actor",
ActorControllerFactory(varstore, actor_), ActorControllerFactory(varstore, actor_),
@ -65,10 +70,6 @@ class Context {
"triangle", "triangle",
TriangleElementScheduledControllerFactory(programs, varstore), TriangleElementScheduledControllerFactory(programs, varstore),
), ),
tuple(
"variable",
VarStoreScheduledControllerFactory(varstore),
),
); );
foreach (ref factory; factories) { foreach (ref factory; factories) {
factory[1]. factory[1].
@ -84,8 +85,8 @@ class Context {
drawers_ = builder.drawers[]; drawers_ = builder.drawers[];
controllers_ = builder.controllers[]; controllers_ = builder.controllers[];
actor_controller_ = factories[0][1].product; actor_controller_ = factories[1][1].product;
posteffect_controller_ = factories[1][1].product; posteffect_controller_ = factories[2][1].product;
} }
/// ///
~this() { ~this() {

View File

@ -22,6 +22,7 @@ class VarStoreScheduledController : AbstractScheduledController {
varstore_ = varstore; varstore_ = varstore;
} }
protected:
override void SetParameter( override void SetParameter(
ref in Parameter param, ref in Parameter param,
ref in AbstractScheduledController.VarStore vars) { ref in AbstractScheduledController.VarStore vars) {