{
    "sourceFile": "Documentation/02_Developer_Guide/04_Configuration_System_and_Presets.md",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 1,
            "patches": [
                {
                    "date": 1745494552943,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                },
                {
                    "date": 1745934423187,
                    "content": "Index: \n===================================================================\n--- \n+++ \n@@ -38,5 +38,7 @@\n *   `source_naming_convention`: Rules for extracting the base asset name and potentially the archetype from source filenames or directory structures (e.g., using separators and indices).\r\n *   `asset_category_rules`: Keywords or patterns used to determine the asset category (e.g., identifying `\"Decal\"` based on keywords).\r\n *   `archetype_rules`: Keywords or patterns used to determine the asset archetype (e.g., identifying `\"Wood\"` or `\"Metal\"`).\r\n \r\n-Careful definition of these patterns and rules, especially the regex in `map_type_mapping`, `bit_depth_variants`, `model_patterns`, and `move_to_extra_patterns`, is essential for correct asset processing.\n\\ No newline at end of file\n+Careful definition of these patterns and rules, especially the regex in `map_type_mapping`, `bit_depth_variants`, `model_patterns`, and `move_to_extra_patterns`, is essential for correct asset processing.\r\n+\r\n+**Note on Data Passing:** As mentioned in the Architecture documentation, major changes to the data passing mechanisms between the GUI, Main (CLI orchestration), and `AssetProcessor` modules are currently being planned. The descriptions of how configuration data is handled and passed within this document reflect the current state and will require review and updates once the plan for these changes is finalized.\n\\ No newline at end of file\n"
                }
            ],
            "date": 1745494552943,
            "name": "Commit-0",
            "content": "# Developer Guide: Configuration System and Presets\r\n\r\nThis document provides technical details about the configuration system and the structure of preset files for developers working on the Asset Processor Tool.\r\n\r\n## Configuration Flow\r\n\r\nThe tool utilizes a two-tiered configuration system:\r\n\r\n1.  **Core Settings (`config.py`):** This Python module defines global default settings, constants, and core rules that apply generally across different asset sources. Examples include default output paths, standard image resolutions, map merge rules, output format rules, Blender executable paths, and default map types.\r\n2.  **Preset Files (`Presets/*.json`):** These JSON files define supplier-specific rules and overrides. They contain patterns (often regular expressions) to interpret filenames, classify map types, handle variants, define naming conventions, and specify other source-specific behaviors.\r\n\r\n## `Configuration` Class (`configuration.py`)\r\n\r\nThe `Configuration` class is responsible for loading, merging, and preparing the configuration settings for use by the `AssetProcessor`.\r\n\r\n*   **Initialization:** An instance is created with a specific `preset_name`.\r\n*   **Loading:**\r\n    *   It loads the core settings from `config.py` using `importlib.util`.\r\n    *   It loads the specified preset JSON file from the `Presets/` directory.\r\n*   **Merging:** The loaded core settings and preset rules are merged into a single configuration object accessible via instance attributes. Preset values generally override core settings where applicable.\r\n*   **Validation (`_validate_configs`):** Performs basic structural validation on the loaded settings, checking for the presence of required keys and basic data types (e.g., ensuring `map_type_mapping` is a list of dictionaries).\r\n*   **Regex Compilation (`_compile_regex_patterns`):** A crucial step for performance. It iterates through the regex patterns defined in the preset (for extra files, models, bit depth variants, map keywords) and compiles them using `re.compile` (mostly case-insensitive). These compiled regex objects are stored as instance attributes (e.g., `self.compiled_map_keyword_regex`) for fast matching during file classification. It uses a helper (`_fnmatch_to_regex`) for basic wildcard (`*`, `?`) conversion in patterns.\r\n\r\nAn instance of `Configuration` is created within each worker process (`main.process_single_asset_wrapper`) to ensure that each concurrently processed asset uses the correct, isolated configuration based on the specified preset.\r\n\r\n## Preset File Structure (`Presets/*.json`)\r\n\r\nPreset files are the primary way to adapt the tool to new asset sources. Developers should use `Presets/_template.json` as a starting point. Key fields include:\r\n\r\n*   `supplier_name`: The name of the asset source (e.g., `\"Poliigon\"`). Used for output directory naming.\r\n*   `map_type_mapping`: A list of dictionaries, each mapping source filename patterns/keywords to a standard internal map type (defined in `config.py`).\r\n    *   `target_type`: The standard internal map type (e.g., `\"COL\"`, `\"NRM\"`).\r\n    *   `keywords`: A list of filename patterns (regex or fnmatch-style wildcards) used to identify this map type. The order of keywords within this list, and the order of dictionaries in the `map_type_mapping` list, determines the priority for assigning variant suffixes (`-1`, `-2`, etc.) when multiple files match the same `target_type`.\r\n*   `bit_depth_variants`: A dictionary mapping standard map types (e.g., `\"NRM\"`) to a pattern identifying its high bit-depth variant (e.g., `\"*_NRM16*.tif\"`). Files matching these patterns are prioritized over their standard counterparts.\r\n*   `map_bit_depth_rules`: Defines how to handle the bit depth of source maps. Can specify a default behavior (`\"respect\"` or `\"force_8bit\"`) and overrides for specific map types.\r\n*   `model_patterns`: A list of regex patterns to identify model files (e.g., `\".*\\\\.fbx\"`, `\".*\\\\.obj\"`).\r\n*   `move_to_extra_patterns`: A list of regex patterns for files that should be moved directly to the `Extra/` output subdirectory without further processing.\r\n*   `source_naming_convention`: Rules for extracting the base asset name and potentially the archetype from source filenames or directory structures (e.g., using separators and indices).\r\n*   `asset_category_rules`: Keywords or patterns used to determine the asset category (e.g., identifying `\"Decal\"` based on keywords).\r\n*   `archetype_rules`: Keywords or patterns used to determine the asset archetype (e.g., identifying `\"Wood\"` or `\"Metal\"`).\r\n\r\nCareful definition of these patterns and rules, especially the regex in `map_type_mapping`, `bit_depth_variants`, `model_patterns`, and `move_to_extra_patterns`, is essential for correct asset processing."
        }
    ]
}