]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix handling of techniques in object exporter
authorMikko Rasa <tdb@tdb.fi>
Sun, 28 Mar 2021 10:40:17 +0000 (13:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 28 Mar 2021 10:40:17 +0000 (13:40 +0300)
Materials with external rendering mode don't get technique resources
generated them, so it's better to use the technique name here.

blender/io_mspgl/export_object.py

index dcb5623f06a24bd632e43c82bdba2a9bd887f2b7..7c1c56034053a65dff98dd1d0e0bf1f8c5e37788 100644 (file)
@@ -177,19 +177,21 @@ class ObjectExporter:
                        if l.material_slots:
                                material = l.material_slots[0].material
                        if material:
-                               if material.material_map:
-                                       tech_res = resources["material_map_{}.tech".format(os.path.splitext(material.technique)[0])]
+                               if material.render_mode=='EXTERNAL':
+                                       tech_name = material.technique
+                               elif material.material_map:
+                                       tech_name = "material_map_{}.tech".format(os.path.splitext(material.technique)[0])
                                else:
-                                       tech_res = resources[material.name+".tech"]
+                                       tech_name = material.name+".tech"
                        else:
-                               tech_res = resources["stub.tech"]
+                               tech_name = "stub.tech"
 
-                       if tech_res.name!=prev_tech:
+                       if tech_name!=prev_tech:
                                if material and material.render_mode=='EXTERNAL':
                                        lod_st.append(Statement("technique", material.technique))
                                else:
-                                       lod_st.append(obj_res.create_reference_statement("technique", tech_res))
-                               prev_tech = tech_res.name
+                                       lod_st.append(obj_res.create_reference_statement("technique", resources[tech_name]))
+                               prev_tech = tech_name
 
                        if i>0:
                                st = Statement("level_of_detail", i)