Skip to content

Commit

Permalink
subdivision scheme setting (#649)
Browse files Browse the repository at this point in the history
* subdivision scheme setting

* subdiv scheme setting removed
  • Loading branch information
dmitrii-z authored May 23, 2023
1 parent 9925a20 commit 564a6f7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
5 changes: 2 additions & 3 deletions pxr/imaging/plugin/hdRpr/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ void HdRprMesh::Sync(HdSceneDelegate* sceneDelegate,
m_adjacencyValid = false;
m_normalsValid = false;

m_enableSubdiv = m_topology.GetScheme() == PxOsdOpenSubdivTokens->catmullClark;
m_geomSubsets = m_topology.GetGeomSubsets();

// GeomSubset data is directly transfered from USD into Hydra topology.
Expand Down Expand Up @@ -449,7 +448,7 @@ void HdRprMesh::Sync(HdSceneDelegate* sceneDelegate,

m_smoothNormals = !m_displayStyle.flatShadingEnabled;
// Don't compute smooth normals on a refined mesh. They are implicitly smooth.
if (m_enableSubdiv && m_refineLevel != 0) {
if (m_refineLevel != 0) {
m_smoothNormals = false;
}

Expand Down Expand Up @@ -657,7 +656,7 @@ void HdRprMesh::Sync(HdSceneDelegate* sceneDelegate,

if (newMesh || isRefineLevelDirty) {
for (auto& rprMesh : m_rprMeshes) {
rprApi->SetMeshRefineLevel(rprMesh, m_enableSubdiv ? m_refineLevel : 0);
rprApi->SetMeshRefineLevel(rprMesh, m_refineLevel);
}
}

Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/plugin/hdRpr/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class HdRprMesh final : public HdRprBaseRprim<HdMesh> {
VtArray<VtVec3fArray> m_pointSamples;
VtIntArray m_faceVertexCounts;
VtIntArray m_faceVertexIndices;
bool m_enableSubdiv = false;

Hd_VertexAdjacency m_adjacency;
bool m_adjacencyValid = false;
Expand Down
33 changes: 19 additions & 14 deletions pxr/imaging/plugin/hdRpr/python/houdiniDsGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,20 @@
)

def _get_valid_houdini_param_name(name):
name = name.replace('$', '')
if all(c.isalnum() or c == '_' for c in name):
return name
else:
import hou
return hou.encode(name)

def _get_usd_render_setting_name(name):
if not name.startswith('rpr:') and not name.startswith('primvars:'):
if not name.startswith('rpr:') and not name.startswith('primvars:') and not name.startswith('$'):
name = 'rpr:' + name
return name
return name.replace('$', '')

def _get_houdini_hidewhen_string(condition, settings):
houdini_hidewhen_conditions = []
def _get_houdini_condition_string(condition, settings):
houdini_conditions = []
def process_condition(condition):
if not condition:
return
Expand All @@ -68,33 +69,36 @@ def process_condition(condition):
for entry in condition:
process_condition(entry)
elif isinstance(condition, str):
if ':' in condition:
if ':' in condition or '$' in condition:
setting_name, tail = condition.split(' ', 1)

setting_name = _get_usd_render_setting_name(setting_name)
houdini_name = _get_valid_houdini_param_name(setting_name)
condition = ' '.join([houdini_name, tail])

houdini_hidewhen_conditions.append(condition)
houdini_conditions.append(condition)
else:
print('ERROR: Unexpected condition value: {}'.format(condition))
exit(1)
process_condition(condition)

houdini_hidewhen = ''
if houdini_hidewhen_conditions:
houdini_hidewhen += 'hidewhen "'
for condition in houdini_hidewhen_conditions:
houdini_hidewhen += '{{ {} }} '.format(condition)
houdini_hidewhen += '"'
return houdini_hidewhen
houdini_condition = ''
if houdini_conditions:
for condition in houdini_conditions:
houdini_condition += '{{ {} }} '.format(condition)
return houdini_condition

def _get_houdini_hidewhen_string(condition, settings):
conditions = _get_houdini_condition_string(condition, settings)
return 'hidewhen "' + conditions + '"' if conditions else ''

def _generate_ds_setting(setting, spare_category, global_hidewhen, settings):
if not 'ui_name' in setting:
return ''

houdini_settings = setting.get('houdini', {})
houdini_hidewhen = _get_houdini_hidewhen_string([houdini_settings.get('hidewhen'), global_hidewhen], settings)
disablewhen_predefined_conditions = _get_houdini_condition_string([houdini_settings.get('disablewhen')], settings)

def CreateHoudiniParam(name, label, htype, default, values=[], tags=[], disablewhen_conditions=[], size=None, valid_range=None, help_msg=None):
param = 'parm {\n'
Expand All @@ -111,10 +115,11 @@ def CreateHoudiniParam(name, label, htype, default, values=[], tags=[], disablew
param += ' }\n'
if houdini_hidewhen:
param += ' {}\n'.format(houdini_hidewhen)
if disablewhen_conditions:
if disablewhen_conditions or disablewhen_predefined_conditions:
param += ' disablewhen "'
for condition in disablewhen_conditions:
param += '{{ {} }} '.format(condition)
param += disablewhen_predefined_conditions
param += '"\n'
if valid_range:
param += ' range {{ {}! {} }}\n'.format(valid_range[0], valid_range[1])
Expand Down

0 comments on commit 564a6f7

Please sign in to comment.