X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fscene.h;h=77155479adeb2f25280a0b822b67de0f2044541f;hb=948d715655a84b93d8292e64731ea3c32b45deb7;hp=bf23fbd1f2bb789d1fb350393fadf84ff2c5629c;hpb=14b28982a33cb9bea818446217e69fdf4de13dab;p=nageru diff --git a/nageru/scene.h b/nageru/scene.h index bf23fbd..7715547 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 @@ -76,9 +77,23 @@ 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. + int chosen_alternative(size_t chain_idx) const { + 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. std::vector inputs; // One for each input of alternatives[0] (ie., typically 0 or 1, occasionally 2). + std::vector disablers; // If any of these are disabled (IdentityEffect chosen), so should this one. int currently_chosen_alternative = 0; + // What alternative to use if the block is disabled. + // Points to an alternative with IDENTITY_EFFECT if it exists + // (to disable as much as possible), otherwise 0. + int canonical_alternative = 0; bool is_input = false; // For LIVE_INPUT* only. We can't just always populate signal_to_connect, @@ -100,12 +115,16 @@ struct Block { std::map float_parameters; std::map> vec3_parameters; std::map> vec4_parameters; + + std::string declaration_point; // For error messages. }; int Block_display(lua_State* L); int Block_choose(lua_State* L); int Block_enable(lua_State *L); +int Block_enable_if(lua_State *L); int Block_disable(lua_State *L); +int Block_always_disable_if_disabled(lua_State *L); int Block_set_int(lua_State *L); int Block_set_float(lua_State *L); int Block_set_vec3(lua_State *L); @@ -127,7 +146,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 canonical_alternative 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);