From 0a864950cde6b1c7e9d6e1f1f291d75b30123343 Mon Sep 17 00:00:00 2001 From: falsycat Date: Tue, 8 Oct 2019 00:00:00 +0000 Subject: [PATCH] [update] Allowed ElementScheduledController not to require Initialize() method. --- sjplayer/src/sjplayer/Background.d | 4 +--- sjplayer/src/sjplayer/CircleElementScheduledController.d | 1 + sjplayer/src/sjplayer/ElementScheduledController.d | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sjplayer/src/sjplayer/Background.d b/sjplayer/src/sjplayer/Background.d index b2fcd74..0d77129 100644 --- a/sjplayer/src/sjplayer/Background.d +++ b/sjplayer/src/sjplayer/Background.d @@ -9,13 +9,11 @@ class Background { /// this(BackgroundProgram program) { program_ = program; - } - /// - void Initialize() { inner_color = vec4(0, 0, 0, 0); outer_color = vec4(0, 0, 0, 0); } + /// void Draw() { program_.Draw(inner_color, outer_color); diff --git a/sjplayer/src/sjplayer/CircleElementScheduledController.d b/sjplayer/src/sjplayer/CircleElementScheduledController.d index 2a485e0..3bda07b 100644 --- a/sjplayer/src/sjplayer/CircleElementScheduledController.d +++ b/sjplayer/src/sjplayer/CircleElementScheduledController.d @@ -22,6 +22,7 @@ alias CircleElementScheduledController = ElementScheduledController!( ); static assert(CircleElementScheduledController.AliveManagementAvailable); static assert(CircleElementScheduledController.MatrixModificationAvailable); +static assert(CircleElementScheduledController.AutoInitializationAvailable); /// alias CircleElementScheduledControllerFactory = diff --git a/sjplayer/src/sjplayer/ElementScheduledController.d b/sjplayer/src/sjplayer/ElementScheduledController.d index dcfbc3b..ada4add 100644 --- a/sjplayer/src/sjplayer/ElementScheduledController.d +++ b/sjplayer/src/sjplayer/ElementScheduledController.d @@ -35,6 +35,9 @@ class ElementScheduledController( enum MatrixModificationAvailable = is(typeof((Element e) => e.matrix)) && is(ReturnType!((Element e) => e.matrix) == mat3); + /// + enum AutoInitializationAvailable = + is(typeof((Element e) => e.Initialize())); /// this( @@ -47,7 +50,9 @@ class ElementScheduledController( protected: override void PrepareOperation(ref in ParametersBlock params) { - element_.Initialize(); + static if (AutoInitializationAvailable) { + element_.Initialize(); + } static if (AliveManagementAvailable) { element_.alive = true; }