Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-1134 export assigned materials #3786

Merged
merged 1 commit into from
May 30, 2024

Conversation

pierrebai-adsk
Copy link
Collaborator

Modify the export command:

  • Add new export flag "exportAssignedMaterials" (-ama).
  • Default to be turned on.
  • Expose it in Python.
  • Document it.
  • Add a checkbox UI for it in the export options.

Modify how material assignments are found:

  • Bundle all information about assignments for a material in a single struct.
  • Add a flag to the info set if the material is used anywhere, even by meshes not being exported.
  • Add a flag to the info set if the material is used by something in the selection.
  • Also check any ancestor of the mesh for the selection inclusion since selection in the viewport selects the parent transform.
  • Also, by default, the outliner shows the parent transforms, not the shape/mesh, so selection there would also select an ancestor.
  • Modify the GetAssignments function to fill those flags.

Modify how materials are filtered:

  • In the filter function for materials, add the logic for assigned-materials.
  • Use the flags about assignments and assignments-in-selection to determine if a material should be exported.
  • When exporting assigned materials, if the material is not used at all, then the material is not exported.
  • When exporting the selection, if a material was used by something in the selection, export it even if the user was something not exported, like when the meshes are off.

Add unit tests for when assigned materials are off. (The case when it is on was already tested by existing tests.)

Modify the export command:
- Add new export flag "exportAssignedMaterials" (-ama).
- Default to be turned on.
- Expose it in Python.
- Document it.
- Add a checkbox UI for it in the export options.

Modify how material assignments are found:
- Bundle all informations about assignments for a material in a single struct.
- Add a flag to the info set if the material is used anywhere, even by
  meshes not being exported.
- Add a flag to the info set if the material is used by something in the
  selection.
- Also check any ancestor of the mesh for the selection inclusion since
  selection in the viewport selects the parent transform.
- Also, by default, the outliner shows the parent transforms, not the
  shape/mesh, so selection there would also select an ancestor.
- Modify the GetAssignments function to fill those flags.

Modify how materials are filtered:
- In the filter function for materials, add the logic for
  assigned-materials.
- Use the flags about assignments and assignments-in-selection to
  determine if a material should be exported.
- When exporting assigned materials, if the material is not used at all,
  then the material is not exported.
- When exporting the selection, if a material was used by something in
  the selection, export it even if the user was something not exported,
  like when the meshes are off.

Add unit tests for when assigned materials are off. (The case when it is
on was already tested by existing tests.)
@pierrebai-adsk pierrebai-adsk added the import-export Related to Import and/or Export label May 27, 2024
@pierrebai-adsk pierrebai-adsk self-assigned this May 27, 2024
for (MDagPath walkUpPath(dagPath); walkUpPath.length() > 0; walkUpPath.pop())
if (GetExportArgs().fullObjectList.hasItem(walkUpPath))
ret.hasAnyAssignmentInSelection = true;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support the logic of determining if a material should be exported, we need to know if it is used in the scene and if it used by something that was selected. This is what the new code above does.

@pierrebai-adsk pierrebai-adsk requested a review from barbalt May 27, 2024 18:28
// contains the transform above the mesh or a higher-up ancestor,
// so also check the ancestors of the mesh.
for (MDagPath walkUpPath(dagPath); walkUpPath.length() > 0; walkUpPath.pop())
if (GetExportArgs().fullObjectList.hasItem(walkUpPath))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a policy in code guidelines for one line if cases like if they should have {} or not? I couldn't find one. This is minor, anyways

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no policy for this (no {} is allowed), other than the formatting done by clang-format.

@pierrebai-adsk pierrebai-adsk added the ready-for-merge Development process is finished, PR is ready for merge label May 29, 2024
@seando-adsk seando-adsk merged commit 969b20d into dev May 30, 2024
11 checks passed
@seando-adsk seando-adsk deleted the bailp/EMSUSD-1134/export-assigned-materials branch May 30, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import-export Related to Import and/or Export ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants