Export Pointcache: Optimize forced shader assignments when writing face sets#442
Export Pointcache: Optimize forced shader assignments when writing face sets#442BigRoy wants to merge 8 commits into
Conversation
…_to_faces_use_api
…_to_faces_use_api
…_to_faces_use_api
There was a problem hiding this comment.
Pull request overview
This PR targets the performance bottleneck in force_shader_assignments_to_faces used during pointcache export (write face sets), by replacing slow cmds.sets(clear=...) / cmds.sets(..., forceElement=...) operations with Maya API 2.0 (OpenMaya) set membership operations and a custom “fast clear” implementation.
Changes:
- Added
_get_mobjectand_fast_clear_sethelpers to work with sets viaOpenMayaand clear set membership by disconnectingdagSetMembers. - Reworked
force_shader_assignments_to_facesto gather/apply/revert set members usingOpenMaya.MFnSet.getMembers/addMembersandMSelectionListinstead ofcmds.setsmember lists.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| override_assignments[shading_engine].append(member) | ||
| else: | ||
| # Preserve component assignment | ||
| override_assignments[shading_engine].add((dag, component)) |
| # Convert to face assignment | ||
| override_assignments[shading_engine].add( | ||
| f'{shape_path}.f[*]' | ||
| ) | ||
| has_conversions = True |
| fn = OpenMaya.MFnDependencyNode(_get_mobject(object_set)) | ||
| dag_set_members = fn.findPlug("dagSetMembers", False) | ||
| mod = OpenMaya.MDGModifier() | ||
| for i in range(dag_set_members.numElements()): | ||
| elem = dag_set_members.elementByPhysicalIndex(i) | ||
| if elem.isConnected: | ||
| src_plugs = elem.connectedTo(True, False) | ||
| for src in src_plugs: | ||
| mod.disconnect(src, elem) |
…_to_faces_use_api
moonyuet
left a comment
There was a problem hiding this comment.
Tested successfully in Maya 2027
LiborBatek
left a comment
There was a problem hiding this comment.
I couldnt achieve an alembic containing any face sets no matter how hard I have tried...I also tried not just pointcache but also model in alembic repre but no luck...
interestingly even if I deviated from the default values for Write Face Sets which were Disabled by default...it start to validate only if publishing the pointcache but not when trying to produce a model and Alembic repre...which brings me feeling that while trying to use it for model it still sticks to the defaults (AYON didnt fail on validation when overriding those defaults - or these arent triggered and gracefully ignored) As I was inspecting my published pointcache and model I havent found any face sets whatsoever...
Here is my hierachy and graph before and after loading resulting product:
…_to_faces_use_api
Changelog Description
Export Pointcache: Optimize forced shader assignments when writing face sets
Additional review information
Fix #441
To performance test:
Testing notes: