diff --git a/collider_shapes/add_bounding_capsule.py b/collider_shapes/add_bounding_capsule.py index 87a3e13..509be30 100644 --- a/collider_shapes/add_bounding_capsule.py +++ b/collider_shapes/add_bounding_capsule.py @@ -159,9 +159,6 @@ def execute(self, context): # Calculate the radius and height of the bounding capsule radius, height = Capsule.calculate_radius_height(verts_loc) - #height, radius = calculate_bounding_capsule(verts_loc) - print("Optimal bounding capsule height:", height) - print("Optimal bounding capsule radius:", radius) data = Capsule.create_capsule(longitudes=self.current_settings_dic['capsule_segments'], latitudes=int(self.current_settings_dic['capsule_segments']), radius=radius, depth=height, uv_profile="FIXED") bm = Capsule.mesh_data_to_bmesh( vs=data["vs"], diff --git a/collider_shapes/add_bounding_primitive.py b/collider_shapes/add_bounding_primitive.py index 055af60..c72601d 100644 --- a/collider_shapes/add_bounding_primitive.py +++ b/collider_shapes/add_bounding_primitive.py @@ -821,7 +821,7 @@ def create_collection(collection_name): # Collections @classmethod - def add_to_collections(cls, obj, collection_name, hide=False): + def add_to_collections(cls, obj, collection_name, hide=False, color='NONE'): col = cls.create_collection(collection_name) if hide: col.hide_viewport = True @@ -830,6 +830,7 @@ def add_to_collections(cls, obj, collection_name, hide=False): col.objects.link(obj) except RuntimeError as err: pass + col.color_tag = color return col @@ -917,9 +918,9 @@ def restore_obj_mod_from_dic(modifier_dic): modifier.show_viewport = mod_entry["show_viewport"] modifier.show_in_editmode = mod_entry["show_in_editmode"] - @classmethod - def convert_to_mesh(cls, context, object, use_modifiers = False): - mods = cls.store_obj_mod_in_dic(object) + + def convert_to_mesh(self, context, object, use_modifiers=False): + mods = self.store_obj_mod_in_dic(object) for mod in object.modifiers: mod.show_viewport = use_modifiers @@ -928,10 +929,9 @@ def convert_to_mesh(cls, context, object, use_modifiers = False): deg = context.evaluated_depsgraph_get() me = bpy.data.meshes.new_from_object(object.evaluated_get(deg), depsgraph=deg) new_obj = bpy.data.objects.new(object.name + "_mesh", me) - col = cls.add_to_collections(new_obj, 'tmp_mesh', hide=False) - col.color_tag = 'COLOR_03' + col = self.add_to_collections(new_obj, 'tmp_mesh', hide=False, color=self.prefs.col_tmp_collection_color) - cls.restore_obj_mod_from_dic(mods) + self.restore_obj_mod_from_dic(mods) new_obj.matrix_world = object.matrix_world context.view_layer.objects.active = new_obj @@ -949,7 +949,7 @@ def primitive_postprocessing(self, context, bounding_object, base_object_collect if self.prefs.use_col_collection: collection_name = self.prefs.col_collection_name - self.add_to_collections(bounding_object, collection_name) + self.add_to_collections(bounding_object, collection_name, color=self.prefs.col_collection_color) if self.use_remesh: self.add_remesh_modifier(context, bounding_object) @@ -1039,8 +1039,8 @@ def get_pre_processed_mesh_objs(self, context, default_world_spc=True, use_local split_objs = create_objs_from_island(base, use_world=default_world_spc) for split in split_objs: - col = self.add_to_collections(split, 'tmp_mesh', hide=False) - col.color_tag = 'COLOR_03' + col = self.add_to_collections(split, 'tmp_mesh', hide=False, color=self.prefs.col_tmp_collection_color) + col.color_tag = self.prefs.col_tmp_collection_color objs.append((base_ob, split)) self.tmp_meshes.extend(split_objs) diff --git a/preferences/preferences.py b/preferences/preferences.py index 49fecb3..11af8bc 100644 --- a/preferences/preferences.py +++ b/preferences/preferences.py @@ -16,6 +16,17 @@ from ..ui.properties_panels import label_multiline from .keymap import remove_key +collection_colors = [ + ("NONE", "White", "", "OUTLINER_COLLECTION", 0), + ("COLOR_01", "Red", "", "COLLECTION_COLOR_01", 1), + ("COLOR_02", "Orange", "", "COLLECTION_COLOR_02", 2), + ("COLOR_03", "Yellow", "", "COLLECTION_COLOR_03", 3), + ("COLOR_04", "Green", "", "COLLECTION_COLOR_04", 4), + ("COLOR_05", "Blue", "", "COLLECTION_COLOR_05", 5), + ("COLOR_06", "Violet", "", "COLLECTION_COLOR_06", 6), + ("COLOR_07", "Pink", "", "COLLECTION_COLOR_07", 7), + ("COLOR_08", "Brown", "", "COLLECTION_COLOR_08", 8), +] def add_key(self, km, idname, properties_name, collision_pie_type, collision_pie_ctrl, collision_pie_shift, collision_pie_alt, collision_pie_active): kmi = km.keymap_items.new(idname=idname, type=collision_pie_type, value='PRESS', @@ -220,6 +231,17 @@ class CollisionAddonPrefs(bpy.types.AddonPreferences): description='Name of the collider collection newly created collisions are added to', default='Collisions') + col_collection_color: bpy.props.EnumProperty(name='Collection Color', + items=collection_colors, + description='Choose the color for the collider collections.', + default='COLOR_05', + ) + col_tmp_collection_color: bpy.props.EnumProperty(name='Temp Collection Color', + items=collection_colors, + description='Choose the color for the collider collections.', + default='COLOR_03', + ) + ################################################################### # KEYMAP @@ -592,6 +614,8 @@ class CollisionAddonPrefs(bpy.types.AddonPreferences): col_props = [ "use_col_collection", "col_collection_name", + "col_collection_color", + "col_tmp_collection_color", ] ui_col_colors = [