]> git.sesse.net Git - nageru/blobdiff - nageru/scene.h
Small refactoring in Block.
[nageru] / nageru / scene.h
index fc36963cc9eebd3ae56943293e9c74ce71886ea5..b659429fbd5a8ef9a1ef54ec55cdc3175924739a 100644 (file)
@@ -9,7 +9,7 @@
 // ResizeEffect or IdentityEffect (effectively doing nothing), or many
 // different input types. On finalization, every different combination of
 // block alternatives are tried, and one EffectChain is generated for each.
-// This also goes for whether the chain is destined for preview outputs
+// This also goes for whether the scene is destined for preview outputs
 // (directly to screen, RGBA) or live (Y'CbCr output).
 
 #include <stddef.h>
@@ -64,7 +64,7 @@ struct Block {
        // where C_0 = 0 and C_(i+1) = C_i * B_i. In other words, C_i is
        // the product of the cardinalities of each previous effect; if we
        // are e.g. at the third index and there have been C_2 = 3 * 5 = 15
-       // different alternatives for constructing the chain so far
+       // different alternatives for constructing the scene so far
        // (with possible indexes 0..14), it is only logical that if we
        // want three new options (B_2 = 3), we must add 0, 15 or 30 to
        // the index. (Then the local possible indexes become 0..44 and
@@ -76,6 +76,11 @@ struct Block {
        // (B_i is alternatives.size().) Not set before finalize() has run.
        size_t cardinality_base = 0;
 
+       // Find the chosen alternative for this block in a given instance.
+       size_t chosen_alternative(size_t chain_idx) const {
+               return (chain_idx / cardinality_base) % alternatives.size();
+       }
+
        std::vector<EffectBlueprint *> alternatives;  // Must all have the same amount of inputs. Pointers to make things easier for Lua.
        std::vector<Index> inputs;  // One for each input of alternatives[0] (ie., typically 0 or 1, occasionally 2).
        int currently_chosen_alternative = 0;