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

feat(rhino): DUI3-142 adds render materials to objects on send and receive #63

Merged

Conversation

clairekuang
Copy link
Member

Adds render materials to atomic objects on send and receive.
Behavior notes:

  • rhino objects and layers have a MaterialSource attribute, which by default is set to ByLayer. This pr sends a renderMaterialId on every object, even if it is inheriting its material. This means that on receive, the MaterialSource property is not preserved
  • the MaterialSource property on receive is set to ByObject if a valid renderMaterialId is found on the object, or ByLayer if no material is found (default material is used in this case)
  • materials are cleansed from the doc on receive by the baseLayerName (same as for block definitions). They are named with the same convention as block definitions.

TODO: add render materials to layers

image

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 7.97%. Comparing base (f4e7214) to head (32f0f91).

Files Patch % Lines
...kle.Connectors.Utils/RenderMaterials/BakeResult.cs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             dev     #63      +/-   ##
========================================
- Coverage   7.98%   7.97%   -0.01%     
========================================
  Files        229     230       +1     
  Lines       4397    4401       +4     
  Branches     497     497              
========================================
  Hits         351     351              
- Misses      4035    4039       +4     
  Partials      11      11              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


// get physically based render material
Material pbMaterial = material;
if (!material.IsPhysicallyBased)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a noob on Rhino materials. Why do we need to check it like this?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can show me later on Rhino

Copy link
Member Author

Choose a reason for hiding this comment

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


int matIndex = doc.Materials.Add(rhinoMaterial);

// POC: check on matIndex -1, means we haven't created anything - this is most likely an recoverable error at this stage
Copy link
Member

Choose a reason for hiding this comment

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

or does it mean we have it already with the same name? This is also something we need to check if you haven't already. "What will happen if we have the materials with the same name already?"

Copy link
Member Author

Choose a reason for hiding this comment

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

Any material with the same name should've been purged already

var currentDoc = RhinoDoc.ActiveDoc; // POC: too much right now to interface around
foreach (Material material in currentDoc.Materials)
{
if (!material.IsDeleted && material.Name.Contains(namePrefix))
Copy link
Member

Choose a reason for hiding this comment

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

No action needed: later we should handle these checks with UserDictionaries instead of messing with the name of materials.

@oguzhankoral
Copy link
Member

I guess we do not receive again if the material name is "default" which seems to me a bit fragile to have it with that simple naming. Maybe it is worth to consider add prop to render material object as isDefault? @clairekuang

@clairekuang
Copy link
Member Author

I guess we do not receive again if the material name is "default" which seems to me a bit fragile to have it with that simple naming. Maybe it is worth to consider add prop to render material object as isDefault? @clairekuang

not necessarily - depends on the expected behavior when receiving default materials in other applications. Eg the default material in rhino != default material in autocad, i'd rather receive the rhino default material in autocad rather than set incoming objs to the autocad default

@clairekuang clairekuang merged commit b07a61a into dev Jul 23, 2024
6 checks passed
@clairekuang clairekuang deleted the DUI3-142-Basically-do-the-block-thing-in-connectors-x-y-z branch July 23, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants