feat(rm): allow registering custom radio mat. prior to loading scenes - #71
Open
jeertmans wants to merge 1 commit into
Open
feat(rm): allow registering custom radio mat. prior to loading scenes#71jeertmans wants to merge 1 commit into
jeertmans wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
While this PR is linked to #70, it does not depend on #70 and should not cause any conflicts.
Currently, loading a scene file containing unknown radio material names or unlisted ITU radio materials raises an error. This presents a challenge in two common scenarios:
Currently, custom radio materials can only be assigned after loading the scene, which I believe can be error-prone and time-consuming for large scenes.
This PR introduces two helper functions,
register_itu_radio_materialandregister_radio_material, to make registering custom radio materials idiomatic before callingload_scene.Summary of changes:
register_itu_radio_material: Addsregister_itu_radio_material(name, parameters, color=None)to allow registering custom ITU materials or updating existing parameters and visual colors inITU_MATERIALS_PROPERTIESandITU_MATERIAL_COLORS. Ifcoloris omitted or set toNone, a random color is generated upon material instantiation, matchingRadioMaterial. This changes the previous behavior, which required a color even though it could eventually be overridden.register_radio_material: Addsregister_radio_material(rm)andradio_material_registryto registerRadioMaterialBaseinstances prior to scene loading.process_xmlandScene._load_scene_objectsto handle both explicit XML plugin syntax (<bsdf type="itu-radio-material"...>and<bsdf type="radio-material"...>) as well as legacy/Blender syntax (id="itu_..."orid="mat-itu_..."). Any attribute specified in the XML file (such asthicknessandcolor) correctly overrides default or pre-registered material attributes.my_custom_thick_woodandmy_custom_thin_wood) referencing the same underlying ITU material type while specifying different property overrides (e.g. thickness).doc/source/api/radio_materials.rstand comprehensive developer guide examples indoc/source/developer/dev_custom_radio_materials.rstdemonstrating explicit XML syntax, material reuse, and attribute overrides.test08_register_itu_radio_materialandtest09_register_radio_materialintest_scene_utils.pycovering prefix error validation, explicit vs legacy XML syntax, optional color generation, multiple material IDs referencing the same ITU type, and XML thickness/color overrides.Let me know if you'd like any adjustments! :-)