vdm-brush-baker: Fix #105028 #105033

Merged
Germano Cavalcante merged 1 commits from robin.hohni/blender-addons:vdm-brush-baker into main 2023-11-30 15:36:47 +01:00
Contributor

This PR should fix #105028

The material that is used for baking is kept inside the blend files so users can potentially change it and thus create errors in the addon. It will now be recreated every time a brush is baked to ensure it is unchanged.
There was another issue that can happen in language settings other than English. Some nodes were referred to by their name. Now they are searched by type.

This PR should fix https://projects.blender.org/blender/blender-addons/issues/105028 The material that is used for baking is kept inside the blend files so users can potentially change it and thus create errors in the addon. It will now be recreated every time a brush is baked to ensure it is unchanged. There was another issue that can happen in language settings other than English. Some nodes were referred to by their name. Now they are searched by type.
Robin Hohnsbeen added 14 commits 2023-11-30 09:54:21 +01:00
Germano Cavalcante approved these changes 2023-11-30 12:55:55 +01:00
Germano Cavalcante left a comment
Member

Good to see the issue being dealt with quickly :)

I've check the changes and It appears that tabs were used in place of spaces.
It would be beneficial to ensure the file remains compliant with autopep8 standards.

For some reason the diff got messed up, but apparently the changes were:
Added these lines:

    if material_name in bpy.data.materials:
        # Recreate material every time to ensure it is unchanged by the user which could lead to issues.
        # I would like to keep it directly after bake though so people could look at how it is made, if they are interested.
        bpy.data.materials.remove(bpy.data.materials[material_name])

Changed these lines:

-	    nodes.remove(nodes['Principled BSDF'])
+	    principled_node = next(n for n in new_material.node_tree.nodes if n.type == "BSDF_PRINCIPLED")
-	    material_output = nodes['Material Output']
+	    material_output = next(n for n in new_material.node_tree.nodes if n.type == "OUTPUT_MATERIAL")

LGTM.

The gitea API has changed and I don't know if the PR author can now land the path after confirmation.

If not, I can merge it into main and reference it to backport list. But I'll wait a bit to see if anyone else has any input.

Good to see the issue being dealt with quickly :) I've check the changes and It appears that tabs were used in place of spaces. It would be beneficial to ensure the file remains compliant with autopep8 standards. For some reason the diff got messed up, but apparently the changes were: Added these lines: ``` if material_name in bpy.data.materials: # Recreate material every time to ensure it is unchanged by the user which could lead to issues. # I would like to keep it directly after bake though so people could look at how it is made, if they are interested. bpy.data.materials.remove(bpy.data.materials[material_name]) ``` Changed these lines: ``` - nodes.remove(nodes['Principled BSDF']) + principled_node = next(n for n in new_material.node_tree.nodes if n.type == "BSDF_PRINCIPLED") ``` ``` - material_output = nodes['Material Output'] + material_output = next(n for n in new_material.node_tree.nodes if n.type == "OUTPUT_MATERIAL") ``` LGTM. The gitea API has changed and I don't know if the PR author can now land the path after confirmation. If not, I can merge it into main and reference it to backport list. But I'll wait a bit to see if anyone else has any input.
Author
Contributor

@mano-wii The changes you mention are correct. Additionally, I moved the code which creates all the nodes outside of that first if statement. That's probably one reason why there are so many changes visible. And I've double-checked that it's all spaces and no tabs. :)

@mano-wii The changes you mention are correct. Additionally, I moved the code which creates all the nodes outside of that first if statement. That's probably one reason why there are so many changes visible. And I've double-checked that it's all spaces and no tabs. :)
Germano Cavalcante added 1 commit 2023-11-30 13:16:07 +01:00

And I've double-checked that it's all spaces and no tabs. :)

Apparently it was only in one place. (I had the impression it was more).
Resolved in 094bc297de ;)

> And I've double-checked that it's all spaces and no tabs. :) Apparently it was only in one place. (I had the impression it was more). Resolved in 094bc297de ;)
Member

The bakematerials.py file uses DOS line endings (CR LF), but it should be converted to Unix (LF) otherwise every line looks like it’s changed.

The bakematerials.py file uses DOS line endings (CR LF), but it should be converted to Unix (LF) otherwise every line looks like it’s changed.
Germano Cavalcante force-pushed vdm-brush-baker from 094bc297de to aa29a26392 2023-11-30 15:35:59 +01:00 Compare
Germano Cavalcante merged commit c79c97b774 into main 2023-11-30 15:36:47 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105033
No description provided.