X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fscene.h;h=83346647236eb0ecda7aa512ec1fead4172940bf;hb=6d5032cb1f330b6767053c51a8d627ac5f7c00ec;hp=7d83a27e13ed3af6842c3082f6172ff68d5be25e;hpb=5a8cccb37e6832197fac3afa0fa39cf83283d5af;p=nageru diff --git a/nageru/scene.h b/nageru/scene.h index 7d83a27..8334664 100644 --- a/nageru/scene.h +++ b/nageru/scene.h @@ -13,6 +13,7 @@ // (directly to screen, RGBA) or live (Y'CbCr output). #include +#include #include #include #include @@ -78,7 +79,11 @@ struct Block { // 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(); + if (chain_idx == size_t(-1)) { + return currently_chosen_alternative; + } else { + return (chain_idx / cardinality_base) % alternatives.size(); + } } std::vector alternatives; // Must all have the same amount of inputs. Pointers to make things easier for Lua. @@ -133,7 +138,26 @@ private: movit::ResourcePool *resource_pool; movit::Effect *instantiate_effects(const Block *block, size_t chain_idx, Instantiation *instantiation); - size_t compute_chain_number_for_block(size_t block_idx) const; + size_t compute_chain_number_for_block(size_t block_idx, const std::bitset<256> &disabled) const; + static void find_inputs_for_block(lua_State *L, Scene *scene, Block *block); + + // Find out which blocks (indexed by position in the “blocks” array), + // if any, are disabled in a given instantiation. A disabled block is + // one that will not be instantiated at all, because it is a secondary + // (ie., not the first) input of some multi-input effect that was replaced + // with IdentityEffect in the given instantiation. + // + // Set chain_idx to size_t(-1) to use whatever is in each block's + // currently_chosen_alternative. + std::bitset<256> find_disabled_blocks(size_t chain_idx) const; + void find_disabled_blocks(size_t chain_idx, size_t block_idx, bool currently_disabled, std::bitset<256> *disabled) const; + + // If a block is disabled, it should always have alternative 0 chosen, + // so that we don't instantiate a bunch of irrelevant duplicates that + // differ only in disabled blocks. You can check this property with + // is_noncanonical_chain() and then avoid instantiating the ones where + // it returns true. + bool is_noncanonical_chain(size_t chain_idx) const; public: Scene(Theme *theme, float aspect_nom, float aspect_denom);