From 84a910f7476a38dab2c0adccdc7d27b06dfd1019 Mon Sep 17 00:00:00 2001 From: William Herald Snyder Date: Wed, 5 Oct 2022 09:23:02 -0400 Subject: [PATCH] When exporting collision primitives, check the swbf_msh_coll_prim primitive property before the name to catch primitives which have incorrect names. Previously the property would only be checked if the primitive was missing a name indicator, but it should be checked first and always because some primitives from XSI have name-type mismatch (cis_hover_aat) --- addons/io_scene_swbf_msh/msh_model_gather.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/io_scene_swbf_msh/msh_model_gather.py b/addons/io_scene_swbf_msh/msh_model_gather.py index bbe82c6..cb95369 100644 --- a/addons/io_scene_swbf_msh/msh_model_gather.py +++ b/addons/io_scene_swbf_msh/msh_model_gather.py @@ -354,6 +354,14 @@ def get_collision_primitive_shape(obj: bpy.types.Object) -> CollisionPrimitiveSh """ Gets the CollisionPrimitiveShape of an object or raises an error if it can't. """ + # arc170 fighter has examples of box colliders without proper naming + # and cis_hover_aat has a cylinder which is named p_vehiclesphere. + # To export these properly we must check the collision_prim property + # that was assigned on import BEFORE looking at the name. + prim_type = obj.swbf_msh_coll_prim.prim_type + if prim_type in [item.value for item in CollisionPrimitiveShape]: + return CollisionPrimitiveShape(prim_type) + name = obj.name.lower() if "sphere" in name or "sphr" in name or "spr" in name: @@ -363,11 +371,6 @@ def get_collision_primitive_shape(obj: bpy.types.Object) -> CollisionPrimitiveSh if "box" in name or "cube" in name or "cuboid" in name: return CollisionPrimitiveShape.BOX - # arc170 fighter has examples of box colliders without proper naming - prim_type = obj.swbf_msh_coll_prim.prim_type - if prim_type in [item.value for item in CollisionPrimitiveShape]: - return CollisionPrimitiveShape(prim_type) - raise RuntimeError(f"Object '{obj.name}' has no primitive type specified in it's name!")