Fix bug when comparing materials

- The functions for comparing materials assumed non compound materials
  always have a numerical ID less than compound materials. This is
  usually true, but not always. E.g. when using the add_surface_water
  user object. This can create the 'water' material after compound
  materials have been created by a fractal box
这个提交包含在:
Nathan Mannall
2025-05-01 12:02:32 +01:00
父节点 4d061ef91f
当前提交 49ed537bda

查看文件

@@ -72,8 +72,10 @@ class Material:
)
elif self.is_compound_material() and value.is_compound_material():
return self.ID < value.ID
elif not self.is_compound_material() and not value.is_compound_material():
return self.numID < value.numID
else:
return value.is_compound_material() or self.numID < value.numID
return value.is_compound_material()
def __gt__(self, value: "Material") -> bool:
"""Greater than comparator for two Materials.
@@ -89,8 +91,10 @@ class Material:
)
elif self.is_compound_material() and value.is_compound_material():
return self.ID > value.ID
elif not self.is_compound_material() and not value.is_compound_material():
return self.numID > value.numID
else:
return self.is_compound_material() or self.numID > value.numID
return self.is_compound_material()
def is_compound_material(self) -> bool:
"""Check if a material is a compound material.