Ejemplo n.º 1
0
def generate_render_setting_files(install_path, generate_ds_files):
    header_template = (
'''
#ifndef GENERATED_HDRPR_CONFIG_H
#define GENERATED_HDRPR_CONFIG_H

#include "pxr/imaging/hd/tokens.h"
#include "pxr/imaging/hd/renderDelegate.h"

#include <mutex>

PXR_NAMESPACE_OPEN_SCOPE

{rs_tokens_declaration}
{rs_mapped_values_enum}

class HdRprConfig {{
public:
    enum ChangeTracker {{
        Clean = 0,
        DirtyAll = ~0u,
        DirtyInteractiveMode = 1 << 0,
{rs_category_dirty_flags}
    }};

    static HdRenderSettingDescriptorList GetRenderSettingDescriptors();
    static std::unique_lock<std::mutex> GetInstance(HdRprConfig** instance);

    void Sync(HdRenderDelegate* renderDelegate);

    void SetInteractiveMode(bool enable);
    bool GetInteractiveMode() const;

{rs_get_set_method_declarations}
    bool IsDirty(ChangeTracker dirtyFlag) const;
    void CleanDirtyFlag(ChangeTracker dirtyFlag);
    void ResetDirty();

private:
    HdRprConfig() = default;

    struct PrefData {{
        bool enableInteractive;

{rs_variables_declaration}

        PrefData();

        void SetDefault();

        bool IsValid();
    }};
    PrefData m_prefData;

    uint32_t m_dirtyFlags = DirtyAll;
    int m_lastRenderSettingsVersion = -1;
}};

PXR_NAMESPACE_CLOSE_SCOPE

#endif // GENERATED_HDRPR_CONFIG_H
''').strip()

    cpp_template = (
'''
#include "config.h"
#include "rprApi.h"
#include "pxr/base/arch/fileSystem.h"
#include "pxr/usd/usdRender/tokens.h"

PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(HdRprRenderSettingsTokens, HDRPR_RENDER_SETTINGS_TOKENS);
TF_DEFINE_PRIVATE_TOKENS(_tokens,
    ((houdiniInteractive, "houdini:interactive"))
    ((rprInteractive, "rpr:interactive"))
);

{rs_public_token_definitions}

namespace {{

{rs_range_definitions}
}} // namespace anonymous

HdRenderSettingDescriptorList HdRprConfig::GetRenderSettingDescriptors() {{
    HdRenderSettingDescriptorList settingDescs;
{rs_list_initialization}
    return settingDescs;
}}


std::unique_lock<std::mutex> HdRprConfig::GetInstance(HdRprConfig** instancePtr) {{
    static std::mutex instanceMutex;
    static HdRprConfig instance;
    *instancePtr = &instance;
    return std::unique_lock<std::mutex>(instanceMutex);
}}

void HdRprConfig::Sync(HdRenderDelegate* renderDelegate) {{
    int currentSettingsVersion = renderDelegate->GetRenderSettingsVersion();
    if (m_lastRenderSettingsVersion != currentSettingsVersion) {{
        m_lastRenderSettingsVersion = currentSettingsVersion;
    
        auto getBoolSetting = [&renderDelegate](TfToken const& token, bool defaultValue) {{
            auto boolValue = renderDelegate->GetRenderSetting(token);
            if (boolValue.IsHolding<int64_t>()) {{
                return static_cast<bool>(boolValue.UncheckedGet<int64_t>());
            }} else if (boolValue.IsHolding<bool>()) {{
                return static_cast<bool>(boolValue.UncheckedGet<bool>());
            }}
            return defaultValue;
        }};

        bool interactiveMode = getBoolSetting(_tokens->rprInteractive, false);

        if (renderDelegate->GetRenderSetting<std::string>(_tokens->houdiniInteractive, "normal") != "normal") {{
            interactiveMode = true;
        }}

        SetInteractiveMode(interactiveMode);

{rs_sync}
    }}
}}

void HdRprConfig::SetInteractiveMode(bool enable) {{
    if (m_prefData.enableInteractive != enable) {{
        m_prefData.enableInteractive = enable;
        m_dirtyFlags |= DirtyInteractiveMode;
    }}
}}

bool HdRprConfig::GetInteractiveMode() const {{
    return m_prefData.enableInteractive;
}}

{rs_get_set_method_definitions}

bool HdRprConfig::IsDirty(ChangeTracker dirtyFlag) const {{
    return m_dirtyFlags & dirtyFlag;
}}

void HdRprConfig::CleanDirtyFlag(ChangeTracker dirtyFlag) {{
    m_dirtyFlags &= ~dirtyFlag;
}}

void HdRprConfig::ResetDirty() {{
    m_dirtyFlags = Clean;
}}

HdRprConfig::PrefData::PrefData() {{
    SetDefault();
}}

void HdRprConfig::PrefData::SetDefault() {{
    enableInteractive = false;

{rs_set_default_values}
}}

bool HdRprConfig::PrefData::IsValid() {{
    return true
{rs_validate_values};
}}

PXR_NAMESPACE_CLOSE_SCOPE

''').strip()

    dirty_flags_offset = 1

    rs_public_token_definitions = []
    rs_tokens_declaration = ['#define HDRPR_RENDER_SETTINGS_TOKENS \\\n']
    rs_category_dirty_flags = []
    rs_get_set_method_declarations = []
    rs_variables_declaration = []
    rs_mapped_values_enum = []
    rs_range_definitions = []
    rs_list_initialization = []
    rs_sync = []
    rs_get_set_method_definitions = []
    rs_set_default_values = []
    rs_validate_values = []
    for category in render_setting_categories:
        disabled_category = False

        category_name = category['name']
        dirty_flag = 'Dirty{}'.format(category_name)
        rs_category_dirty_flags.append('        {} = 1 << {},\n'.format(dirty_flag, dirty_flags_offset))
        dirty_flags_offset += 1

        def process_setting(setting):
            name = setting['name']
            rs_tokens_declaration.append('    ({}) \\\n'.format(name))

            name_title = camel_case_capitalize(name)

            default_value = setting['defaultValue']

            if 'c_type' in setting:
                c_type_str = setting['c_type']
            else:
                c_type_str = type(default_value).__name__
                if c_type_str == 'str':
                    c_type_str = 'TfToken'
            type_str = c_type_str

            if 'values' in setting:
                value_tokens_list_name = '__{}Tokens'.format(name_title)
                value_tokens_name = 'HdRpr{}Tokens'.format(name_title)

                rs_mapped_values_enum.append('#define ' + value_tokens_list_name)
                for value in setting['values']:
                    rs_mapped_values_enum.append(' ({})'.format(value.get_key()))
                rs_mapped_values_enum.append('\n')

                rs_mapped_values_enum.append('TF_DECLARE_PUBLIC_TOKENS({}, {});\n\n'.format(value_tokens_name, value_tokens_list_name))
                rs_public_token_definitions.append('TF_DEFINE_PUBLIC_TOKENS({}, {});\n'.format(value_tokens_name, value_tokens_list_name))

                type_str = 'TfToken'
                c_type_str = type_str
                default_value = next(value for value in setting['values'] if value == default_value)

            rs_get_set_method_declarations.append('    void Set{}({} {});\n'.format(name_title, c_type_str, name))
            rs_get_set_method_declarations.append('    {} const& Get{}() const {{ return m_prefData.{}; }}\n\n'.format(type_str, name_title, name))

            rs_variables_declaration.append('        {} {};\n'.format(type_str, name))

            if isinstance(default_value, bool):
                rs_sync.append('        Set{name_title}(getBoolSetting(HdRprRenderSettingsTokens->{name}, k{name_title}Default));\n'.format(name_title=name_title, name=name))
            else:
                rs_sync.append('        Set{name_title}(renderDelegate->GetRenderSetting(HdRprRenderSettingsTokens->{name}, k{name_title}Default));\n'.format(name_title=name_title, name=name))

            if 'values' in setting:
                rs_range_definitions.append('#define k{name_title}Default {value_tokens_name}->{value}'.format(name_title=name_title, value_tokens_name=value_tokens_name, value=default_value.get_key()))
            else:
                value_str = str(default_value)
                if isinstance(default_value, bool):
                    value_str = value_str.lower()
                rs_range_definitions.append('const {type} k{name_title}Default = {type}({value});\n'.format(type=type_str, name_title=name_title, value=value_str))

            set_validation = ''
            if 'minValue' in setting or 'maxValue' in setting:
                rs_validate_values.append('           ')
            if 'minValue' in setting:
                rs_range_definitions.append('const {type} k{name_title}Min = {type}({value});\n'.format(type=type_str, name_title=name_title, value=setting['minValue']))
                set_validation += '    if ({name} < k{name_title}Min) {{ return; }}\n'.format(name=name, name_title=name_title)
                rs_validate_values.append('&& {name} < k{name_title}Min'.format(name=name, name_title=name_title))
            if 'maxValue' in setting:
                rs_range_definitions.append('const {type} k{name_title}Max = {type}({value});\n'.format(type=type_str, name_title=name_title, value=setting['maxValue']))
                set_validation += '    if ({name} > k{name_title}Max) {{ return; }}\n'.format(name=name, name_title=name_title)
                rs_validate_values.append('&& {name} > k{name_title}Max'.format(name=name, name_title=name_title))
            if 'minValue' in setting or 'maxValue' in setting:
                rs_validate_values.append('\n')
            rs_range_definitions.append('\n')

            if 'values' in setting:
                value_range = value_tokens_name + '->allTokens'
                set_validation += '    if (std::find({range}.begin(), {range}.end(), {name}) == {range}.end()) return;\n'.format(range=value_range, name=name)

            if 'ui_name' in setting:
                rs_list_initialization.append('    settingDescs.push_back({{"{}", HdRprRenderSettingsTokens->{}, VtValue(k{}Default)}});\n'.format(setting['ui_name'], name, name_title))

            if disabled_category:
                rs_get_set_method_definitions.append('void HdRprConfig::Set{name_title}({c_type} {name}) {{ /* Platform no-op */ }}'.format(name_title=name_title, c_type=c_type_str, name=name))
            else:
                rs_get_set_method_definitions.append((
'''
void HdRprConfig::Set{name_title}({c_type} {name}) {{
{set_validation}
    if (m_prefData.{name} != {name}) {{
        m_prefData.{name} = {name};
        m_dirtyFlags |= {dirty_flag};
    }}
}}
''').format(name_title=name_title, c_type=c_type_str, name=name, dirty_flag=dirty_flag, set_validation=set_validation))

            rs_set_default_values.append('    {name} = k{name_title}Default;\n'.format(name=name, name_title=name_title))

        for setting in category['settings']:
            if 'folder' in setting:
                for sub_setting in setting['settings']:
                    process_setting(sub_setting)
            else:
                process_setting(setting)

    rs_tokens_declaration.append('\nTF_DECLARE_PUBLIC_TOKENS(HdRprRenderSettingsTokens, HDRPR_RENDER_SETTINGS_TOKENS);\n')

    header_dst_path = os.path.join(install_path, 'config.h')
    header_file = open(header_dst_path, 'w')
    header_file.write(header_template.format(
        rs_tokens_declaration=''.join(rs_tokens_declaration),
        rs_category_dirty_flags=''.join(rs_category_dirty_flags),
        rs_get_set_method_declarations=''.join(rs_get_set_method_declarations),
        rs_variables_declaration=''.join(rs_variables_declaration),
        rs_mapped_values_enum=''.join(rs_mapped_values_enum)))

    cpp_dst_path = os.path.join(install_path, 'config.cpp')
    cpp_file = open(cpp_dst_path, 'w')
    cpp_file.write(cpp_template.format(
        rs_public_token_definitions=''.join(rs_public_token_definitions),
        rs_range_definitions=''.join(rs_range_definitions),
        rs_list_initialization=''.join(rs_list_initialization),
        rs_sync=''.join(rs_sync),
        rs_get_set_method_definitions=''.join(rs_get_set_method_definitions),
        rs_set_default_values=''.join(rs_set_default_values),
        rs_validate_values=''.join(rs_validate_values)))

    if generate_ds_files:
        generate_houdini_ds(install_path, 'Global', render_setting_categories)
def generate(install, generate_ds_files):
    if generate_ds_files:
        generate_houdini_ds(install, 'Light', light_settings)
Ejemplo n.º 3
0
def generate_render_setting_files(install_path, generate_ds_files):
    header_template = ('''
#ifndef GENERATED_HDRPR_CONFIG_H
#define GENERATED_HDRPR_CONFIG_H

#include "pxr/imaging/hd/tokens.h"
#include "pxr/imaging/hd/renderDelegate.h"

#include <mutex>

PXR_NAMESPACE_OPEN_SCOPE

{rs_tokens_declaration}
{rs_mapped_values_enum}

class HdRprConfig {{
public:
    enum ChangeTracker {{
        Clean = 0,
        DirtyAll = ~0u,
        DirtyInteractiveMode = 1 << 0,
{rs_category_dirty_flags}
    }};

    static HdRenderSettingDescriptorList GetRenderSettingDescriptors();
    static std::unique_lock<std::mutex> GetInstance(HdRprConfig** instance);

    void Sync(HdRenderDelegate* renderDelegate);

    void SetInteractiveMode(bool enable);
    bool GetInteractiveMode() const;

{rs_get_set_method_declarations}
    bool IsDirty(ChangeTracker dirtyFlag) const;
    void CleanDirtyFlag(ChangeTracker dirtyFlag);
    void ResetDirty();

private:
    HdRprConfig() = default;

    struct PrefData {{
        bool enableInteractive;

{rs_variables_declaration}

        PrefData();
        ~PrefData();

        void SetDefault();

        bool Load();
        void Save();

        bool IsValid();
    }};
    PrefData m_prefData;

    uint32_t m_dirtyFlags = DirtyAll;
    int m_lastRenderSettingsVersion = -1;

    constexpr static const char* k_rprPreferenceFilename = "hdRprPreferences.dat";
}};

PXR_NAMESPACE_CLOSE_SCOPE

#endif // GENERATED_HDRPR_CONFIG_H
''').strip()

    cpp_template = ('''
#include "config.h"
#include "rprApi.h"
#include "pxr/base/arch/fileSystem.h"
#include "pxr/usd/usdRender/tokens.h"

PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(HdRprRenderSettingsTokens, HDRPR_RENDER_SETTINGS_TOKENS);
TF_DEFINE_PRIVATE_TOKENS(_tokens,
    ((houdiniInteractive, "houdini:interactive"))
);

namespace {{

{rs_range_definitions}
}} // namespace anonymous

HdRenderSettingDescriptorList HdRprConfig::GetRenderSettingDescriptors() {{
    HdRenderSettingDescriptorList settingDescs;
{rs_list_initialization}
    return settingDescs;
}}


std::unique_lock<std::mutex> HdRprConfig::GetInstance(HdRprConfig** instancePtr) {{
    static std::mutex instanceMutex;
    static HdRprConfig instance;
    *instancePtr = &instance;
    return std::unique_lock<std::mutex>(instanceMutex);
}}

void HdRprConfig::Sync(HdRenderDelegate* renderDelegate) {{
    int currentSettingsVersion = renderDelegate->GetRenderSettingsVersion();
    if (m_lastRenderSettingsVersion != currentSettingsVersion) {{
        m_lastRenderSettingsVersion = currentSettingsVersion;
    
        auto getBoolSetting = [&renderDelegate](TfToken const& token, bool defaultValue) {{
            auto boolValue = renderDelegate->GetRenderSetting(token);
            if (boolValue.IsHolding<int64_t>()) {{
                return static_cast<bool>(boolValue.UncheckedGet<int64_t>());
            }} else if (boolValue.IsHolding<bool>()) {{
                return static_cast<bool>(boolValue.UncheckedGet<bool>());
            }}
            return defaultValue;
        }};

        auto interactiveMode = renderDelegate->GetRenderSetting<std::string>(_tokens->houdiniInteractive, "normal");
        SetInteractiveMode(interactiveMode != "normal");

{rs_sync}
    }}
}}

void HdRprConfig::SetInteractiveMode(bool enable) {{
    if (m_prefData.enableInteractive != enable) {{
        m_prefData.enableInteractive = enable;
        m_prefData.Save();
        m_dirtyFlags |= DirtyInteractiveMode;
    }}
}}

bool HdRprConfig::GetInteractiveMode() const {{
    return m_prefData.enableInteractive;
}}

{rs_get_set_method_definitions}

bool HdRprConfig::IsDirty(ChangeTracker dirtyFlag) const {{
    return m_dirtyFlags & dirtyFlag;
}}

void HdRprConfig::CleanDirtyFlag(ChangeTracker dirtyFlag) {{
    m_dirtyFlags &= ~dirtyFlag;
}}

void HdRprConfig::ResetDirty() {{
    m_dirtyFlags = Clean;
}}

bool HdRprConfig::PrefData::Load() {{
#ifdef ENABLE_PREFERENCES_FILE
    std::string appDataDir = HdRprApi::GetAppDataPath();
    std::string rprPreferencePath = (appDataDir.empty()) ? k_rprPreferenceFilename : (appDataDir + ARCH_PATH_SEP) + k_rprPreferenceFilename;

    if (FILE* f = fopen(rprPreferencePath.c_str(), "rb")) {{
        if (!fread(this, sizeof(PrefData), 1, f)) {{
            TF_RUNTIME_ERROR("Fail to read rpr preferences dat file");
        }}
        fclose(f);
        return IsValid();
    }}
#endif // ENABLE_PREFERENCES_FILE

    return false;
}}

void HdRprConfig::PrefData::Save() {{
#ifdef ENABLE_PREFERENCES_FILE
    std::string appDataDir = HdRprApi::GetAppDataPath();
    std::string rprPreferencePath = (appDataDir.empty()) ? k_rprPreferenceFilename : (appDataDir + ARCH_PATH_SEP) + k_rprPreferenceFilename;

    if (FILE* f = fopen(rprPreferencePath.c_str(), "wb")) {{
        if (!fwrite(this, sizeof(PrefData), 1, f)) {{
            TF_CODING_ERROR("Fail to write rpr preferences dat file");
        }}
        fclose(f);
    }}
#endif // ENABLE_PREFERENCES_FILE
}}

HdRprConfig::PrefData::PrefData() {{
    if (!Load()) {{
        SetDefault();
    }}
}}

HdRprConfig::PrefData::~PrefData() {{
    Save();
}}

void HdRprConfig::PrefData::SetDefault() {{
    enableInteractive = false;

{rs_set_default_values}
}}

bool HdRprConfig::PrefData::IsValid() {{
    return true
{rs_validate_values};
}}

PXR_NAMESPACE_CLOSE_SCOPE

''').strip()

    dirty_flags_offset = 1

    rs_tokens_declaration = '#define HDRPR_RENDER_SETTINGS_TOKENS \\\n'
    rs_category_dirty_flags = ''
    rs_get_set_method_declarations = ''
    rs_variables_declaration = ''
    rs_mapped_values_enum = ''
    rs_range_definitions = ''
    rs_list_initialization = ''
    rs_sync = ''
    rs_get_set_method_definitions = ''
    rs_set_default_values = ''
    rs_validate_values = ''
    for category in render_setting_categories:
        disabled_category = False
        if 'disabled_platform' in category:
            if platform.system() in category['disabled_platform']:
                disabled_category = True

        category_name = category['name']
        dirty_flag = 'Dirty{}'.format(category_name)
        rs_category_dirty_flags += '        {} = 1 << {},\n'.format(
            dirty_flag, dirty_flags_offset)
        dirty_flags_offset += 1

        for setting in category['settings']:
            name = setting['name']
            rs_tokens_declaration += '    ({}) \\\n'.format(name)

            name_title = camel_case_capitalize(name)

            default_value = setting['defaultValue']

            c_type_str = type(default_value).__name__
            if c_type_str == 'str':
                c_type_str = 'TfToken'
            type_str = c_type_str

            if 'values' in setting:
                setting['minValue'] = 0
                setting['maxValue'] = len(setting['values']) - 1
                rs_mapped_values_enum += 'enum {name_title}Type {{\n'.format(
                    name_title=name_title)
                for value in setting['values']:
                    rs_mapped_values_enum += '    k{name_title}{value},\n'.format(
                        name_title=name_title,
                        value=value.key.replace(' ', ''))
                rs_mapped_values_enum += '};\n'
                default_value = setting['values'].index(default_value)
                type_str = '{name_title}Type'.format(name_title=name_title)
                c_type_str = type(default_value).__name__

            rs_get_set_method_declarations += '    void Set{}({} {});\n'.format(
                name_title, c_type_str, name)
            rs_get_set_method_declarations += '    {} Get{}() const {{ return m_prefData.{}; }}\n\n'.format(
                type_str, name_title, name)

            rs_variables_declaration += '        {} {};\n'.format(
                type_str, name)

            value_str = str(default_value)
            if isinstance(default_value, bool):
                value_str = value_str.lower()
                rs_sync += '        Set{name_title}(getBoolSetting(HdRprRenderSettingsTokens->{name}, k{name_title}Default));\n'.format(
                    name_title=name_title, name=name)
            else:
                rs_sync += '        Set{name_title}(renderDelegate->GetRenderSetting(HdRprRenderSettingsTokens->{name}, {type}(k{name_title}Default)));\n'.format(
                    name_title=name_title, name=name, type=c_type_str)

            rs_range_definitions += 'const {type} k{name_title}Default = {type}({value});\n'.format(
                type=type_str, name_title=name_title, value=value_str)
            set_validation = ''
            if 'minValue' in setting or 'maxValue' in setting:
                rs_validate_values += '           '
            if 'minValue' in setting:
                rs_range_definitions += 'const {type} k{name_title}Min = {type}({value});\n'.format(
                    type=type_str,
                    name_title=name_title,
                    value=setting['minValue'])
                set_validation += '    if ({name} < k{name_title}Min) {{ return; }}\n'.format(
                    name=name, name_title=name_title)
                rs_validate_values += '&& {name} < k{name_title}Min'.format(
                    name=name, name_title=name_title)
            if 'maxValue' in setting:
                rs_range_definitions += 'const {type} k{name_title}Max = {type}({value});\n'.format(
                    type=type_str,
                    name_title=name_title,
                    value=setting['maxValue'])
                set_validation += '    if ({name} > k{name_title}Max) {{ return; }}\n'.format(
                    name=name, name_title=name_title)
                rs_validate_values += '&& {name} > k{name_title}Max'.format(
                    name=name, name_title=name_title)
            if 'minValue' in setting or 'maxValue' in setting:
                rs_validate_values += '\n'
            rs_range_definitions += '\n'

            if 'hidden_values' in setting:
                set_validation += '    switch ({name}) {{\n'.format(name=name)
                for value in setting['hidden_values']:
                    set_validation += '        case k{name_title}{value}:\n'.format(
                        name_title=name_title, value=value.replace(' ', ''))
                set_validation += '            return;\n'.format(
                    name_title=name_title, value=value.replace(' ', ''))
                set_validation += '        default: break;}\n'

            if 'ui_name' in setting:
                rs_list_initialization += '    settingDescs.push_back({{"{}", HdRprRenderSettingsTokens->{}, VtValue(k{}Default)}});\n'.format(
                    setting['ui_name'], name, name_title)

            if disabled_category:
                rs_get_set_method_definitions += 'void HdRprConfig::Set{name_title}({c_type} {name}) {{ /* Platform no-op */ }}'.format(
                    name_title=name_title, c_type=c_type_str, name=name)
            else:
                rs_get_set_method_definitions += ('''
void HdRprConfig::Set{name_title}({c_type} {name}) {{
{set_validation}
    if (m_prefData.{name} != {name}) {{
        m_prefData.{name} = {type}({name});
        m_prefData.Save();
        m_dirtyFlags |= {dirty_flag};
    }}
}}
''').format(name_title=name_title,
                c_type=c_type_str,
                type=type_str,
                name=name,
                dirty_flag=dirty_flag,
                set_validation=set_validation)

            rs_set_default_values += '    {name} = k{name_title}Default;\n'.format(
                name=name, name_title=name_title)

    rs_tokens_declaration += '\nTF_DECLARE_PUBLIC_TOKENS(HdRprRenderSettingsTokens, HDRPR_RENDER_SETTINGS_TOKENS);'

    header_dst_path = os.path.join(install_path, 'config.h')
    header_file = open(header_dst_path, 'w')
    header_file.write(
        header_template.format(
            rs_tokens_declaration=rs_tokens_declaration,
            rs_category_dirty_flags=rs_category_dirty_flags,
            rs_get_set_method_declarations=rs_get_set_method_declarations,
            rs_variables_declaration=rs_variables_declaration,
            rs_mapped_values_enum=rs_mapped_values_enum))

    cpp_dst_path = os.path.join(install_path, 'config.cpp')
    cpp_file = open(cpp_dst_path, 'w')
    cpp_file.write(
        cpp_template.format(
            rs_range_definitions=rs_range_definitions,
            rs_list_initialization=rs_list_initialization,
            rs_sync=rs_sync,
            rs_get_set_method_definitions=rs_get_set_method_definitions,
            rs_set_default_values=rs_set_default_values,
            rs_validate_values=rs_validate_values))

    if generate_ds_files:
        generate_houdini_ds(install_path, 'Global', render_setting_categories)
Ejemplo n.º 4
0
def generate(install, generate_ds_files):
    if generate_ds_files:
        generate_houdini_ds(install, 'Geometry', geometry_settings)
Ejemplo n.º 5
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import argparse

from commonSettings import visibility_flag_settings
from houdiniDsGenerator import generate_houdini_ds

geometry_settings = [{
    'name':
    'Mesh',
    'settings': [{
        'name': 'primvars:rpr:subdivisionLevel',
        'ui_name': 'Subidivision Level',
        'defaultValue': 0,
        'minValue': 0,
        'maxValue': 7
    }] + visibility_flag_settings
}]

if __name__ == "__main__":
    p = argparse.ArgumentParser()
    p.add_argument("install", help="The install root for generated files.")
    p.add_argument("--generate_ds_files", default=False, action='store_true')
    args = p.parse_args()

    if args.generate_ds_files:
        generate_houdini_ds(args.install, 'Geometry', geometry_settings)
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import argparse

from commonSettings import visibility_flag_settings
from houdiniDsGenerator import generate_houdini_ds

light_visibility_flag_settings = visibility_flag_settings
for setting in light_visibility_flag_settings:
    if setting['name'] == 'primvars:rpr:visibilityPrimary' or \
       setting['name'] == 'primvars:rpr:visibilityShadow' or \
       setting['name'] == 'primvars:rpr:visibilityLight':
        setting['defaultValue'] = False

light_settings = [{
    'name': 'Light',
    'settings': light_visibility_flag_settings
}]

if __name__ == "__main__":
    p = argparse.ArgumentParser()
    p.add_argument("install", help="The install root for generated files.")
    p.add_argument("--generate_ds_files", default=False, action='store_true')
    args = p.parse_args()

    if args.generate_ds_files:
        generate_houdini_ds(args.install, 'Light', light_settings)