Skip to content

Commit aebb7d3

Browse files
committed
Unit test fixes and two important notes - XPlanePrimative is now of equal start weight to XPlaneObject again and ATTR_light_level_reset is not "written" by default. This makes the resetter system try less hard and actually get it right. See test_03_mesh_ll_overload for the perforamance increase and the v12 repo's #26 for when we debugged this in the resetter system. The change to assertAttributesEqualDict fixes materials.test.py's instability.
1 parent f4eacaa commit aebb7d3

File tree

11 files changed

+274
-234
lines changed

11 files changed

+274
-234
lines changed

io_xplane2blender/tests/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,22 +467,20 @@ def assertAttributesEqualDict(
467467
f"Attribute lists {list(expected_attrs.keys())}, {list(attrs.keys())} have different length",
468468
)
469469

470-
attr_names = tuple(attrs.keys())
471-
attr_values = tuple((v.getValue() for v in attrs.values()))
472-
for name, (value, expected_value) in zip(
473-
attr_names, zip(attr_values, expected_attrs.values())
474-
):
470+
for name in attrs.keys():
471+
value = attrs[name].getValue()
472+
expected_value = expected_attrs[name]
475473

476474
if isinstance(expected_value, (list, tuple)):
477475
self.assertIsInstance(
478476
value,
479477
(list, tuple),
480-
msg='Attribute value for "%s" is no list or tuple but: %s',
478+
msg='Attribute value for "{value}" is a {type(value)}, not a list or tuple',
481479
)
482480
self.assertEquals(
483481
len(expected_value),
484482
len(value),
485-
'Attribute values for "%s" have different length' % name,
483+
'Attribute value list for "{name}" have different length',
486484
)
487485

488486
for i, (v, expectedV) in enumerate(zip(value, expected_value)):
@@ -492,11 +490,11 @@ def assertAttributesEqualDict(
492490
self.assertEquals(
493491
expectedV,
494492
v,
495-
'Attribute list value %d for "%s" is different' % (i, name),
496493
)
497494
else:
498495
self.assertEquals(
499-
expected_value, value, 'Attribute "%s" is not equal' % name
496+
expected_value,
497+
value,
500498
)
501499

502500
def createXPlaneFileFromPotentialRoot(

io_xplane2blender/xplane_types/xplane_material.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(self, xplaneObject: xplane_object.XPlaneObject):
7676
self.attributes.add(XPlaneAttribute("ATTR_solid_camera"))
7777
self.attributes.add(XPlaneAttribute("ATTR_no_solid_camera"))
7878

79+
# These weights are hueristics
7980
self.attributes.add(XPlaneAttribute("ATTR_light_level", None, 1000))
8081
self.attributes.add(XPlaneAttribute("ATTR_light_level_reset", True, 1000))
8182
self.attributes.add(XPlaneAttribute("ATTR_poly_os", None, 1000))

io_xplane2blender/xplane_types/xplane_primitive.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class XPlanePrimitive(XPlaneObject):
3030
def __init__(self, blenderObject: bpy.types.Object):
3131
assert blenderObject.type == "MESH"
3232
super().__init__(blenderObject)
33-
self.attributes.add(XPlaneAttribute("ATTR_light_level", None, 1000))
34-
self.attributes.add(XPlaneAttribute("ATTR_light_level_reset", True, 1000))
33+
# TODO: Do these weights make sense?
34+
self.attributes.add(XPlaneAttribute("ATTR_light_level"))
35+
self.attributes.add(XPlaneAttribute("ATTR_light_level_reset"))
3536
# Starting end ending indices for this object.
3637
self.indices = [0, 0]
3738
self.material = XPlaneMaterial(self)

0 commit comments

Comments
 (0)