From f1f2db5f5da525a7f45fcd26666903a9dc7d3910 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Tue, 11 Jul 2023 17:46:10 +0300 Subject: [PATCH 1/3] Capsule height multiplier --- collider_shapes/add_bounding_capsule.py | 3 +- collider_shapes/add_bounding_primitive.py | 43 +++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/collider_shapes/add_bounding_capsule.py b/collider_shapes/add_bounding_capsule.py index 7056e1f..0812b5b 100644 --- a/collider_shapes/add_bounding_capsule.py +++ b/collider_shapes/add_bounding_capsule.py @@ -22,6 +22,7 @@ def __init__(self): self.use_global_local_switches = True self.use_capsule_axis = True self.use_capsule_segments = True + self.use_height_multiplier = True self.shape = 'capsule_shape' @@ -162,7 +163,7 @@ def execute(self, context): # Calculate the radius and height of the bounding capsule radius, height = Capsule.calculate_radius_height(verts_loc) - 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") + data = Capsule.create_capsule(longitudes=self.current_settings_dic['capsule_segments'], latitudes=int(self.current_settings_dic['capsule_segments']), radius=radius, depth=height * self.current_settings_dic['height_mult'], uv_profile="FIXED") bm = Capsule.mesh_data_to_bmesh( vs=data["vs"], vts=data["vts"], diff --git a/collider_shapes/add_bounding_primitive.py b/collider_shapes/add_bounding_primitive.py index 35097f2..2a2e0d9 100644 --- a/collider_shapes/add_bounding_primitive.py +++ b/collider_shapes/add_bounding_primitive.py @@ -250,6 +250,13 @@ def draw_viewport_overlay(self, context): item = {'label': label, 'value': value, 'key': '(D)', 'type': 'modal', 'highlight': self.decimate_active} items.append(item) + if self.use_height_multiplier: + label = "Height Multiplier" + value = self.current_settings_dic['height_mult'] + value = '{initial_value:.3f}'.format(initial_value=value) + item = {'label': label, 'value': value, 'key': '(H)', 'type': 'modal', 'highlight': self.height_active} + items.append(item) + if self.use_cylinder_segments: label = "Segments" value = str(self.current_settings_dic['cylinder_segments']) @@ -579,7 +586,7 @@ def collider_name(self, basename='Basename'): user_group = self.collision_groups[self.collision_group_idx] return self.class_collider_name(shape_identifier=self.shape, user_group=user_group, basename=basename) - def collision_dictionary(self, alpha, offset, decimate, sphere_segments, cylinder_segments, capsule_segments, voxel_size): + def collision_dictionary(self, alpha, offset, decimate, sphere_segments, cylinder_segments, capsule_segments, voxel_size, height_mult): dict = {} dict['alpha'] = alpha dict['discplace_offset'] = offset @@ -588,6 +595,7 @@ def collision_dictionary(self, alpha, offset, decimate, sphere_segments, cylinde dict['cylinder_segments'] = cylinder_segments dict['capsule_segments'] = capsule_segments dict['voxel_size'] = voxel_size + dict['height_mult'] = height_mult return dict @@ -1204,6 +1212,7 @@ def __init__(self): self.use_keep_original_materials = False self.use_keep_original_name = False self.use_remesh = False + self.use_height_multiplier = False # default shape init self.shape = '' @@ -1275,6 +1284,8 @@ def invoke(self, context, event): self.remesh_active = False self.remesh_modifiers = [] + self.height_active = False + # Displace self.displace_active = False self.displace_modifiers = [] @@ -1327,9 +1338,10 @@ def invoke(self, context, event): default_decimate = 1.0 default_voxel_size = 0.1 default_offset = 0 + default_height_mult = 1 dict = self.collision_dictionary(default_alpha, default_offset, default_decimate, colSettings.default_sphere_segments, - colSettings.default_cylinder_segments, colSettings.default_capsule_segments, default_voxel_size) + colSettings.default_cylinder_segments, colSettings.default_capsule_segments, default_voxel_size, default_height_mult) self.current_settings_dic = dict.copy() self.ref_settings_dic = dict.copy() @@ -1367,6 +1379,7 @@ def modal(self, context, event): self.decimate_active = False self.cylinder_segments_active = False self.remesh_active = False + self.height_active = False self.sphere_segments_active = False self.capsule_segments_active = False @@ -1511,6 +1524,7 @@ def modal(self, context, event): self.sphere_segments_active = False self.capsule_segments_active = False self.remesh_active = False + self.height_active = False self.mouse_initial_x = event.mouse_x elif event.type == 'D' and event.value == 'RELEASE': @@ -1521,6 +1535,7 @@ def modal(self, context, event): self.sphere_segments_active = False self.capsule_segments_active = False self.remesh_active = False + self.height_active = False self.mouse_initial_x = event.mouse_x self.mouse_position = [event.mouse_x, event.mouse_y] self.draw_callback_px(context) @@ -1533,6 +1548,7 @@ def modal(self, context, event): self.sphere_segments_active = False self.capsule_segments_active = False self.remesh_active = False + self.height_active = False self.mouse_initial_x = event.mouse_x elif event.type == 'E' and event.value == 'RELEASE': @@ -1544,6 +1560,19 @@ def modal(self, context, event): self.capsule_segments_active = False self.mouse_initial_x = event.mouse_x self.remesh_active = False + self.height_active = False + + elif event.type == 'H' and event.value == 'RELEASE': + self.height_active = not self.height_active + self.cylinder_segments_active = False + self.displace_active = False + self.decimate_active = False + self.opacity_active = False + self.sphere_segments_active = False + self.capsule_segments_active = False + self.mouse_initial_x = event.mouse_x + self.remesh_active = False + elif event.type == 'T' and event.value == 'RELEASE': # toggle through display modes @@ -1637,6 +1666,16 @@ def modal(self, context, event): self.current_settings_dic['cylinder_segments'] = segment_count self.execute(context) + if self.height_active: + delta = self.get_delta_value(delta, event, sensibility=0.002, tweak_amount=10, round_precission=1) + height_mult = (self.ref_settings_dic['height_mult'] + delta) + height_mult = numpy.clip(height_mult, 0.01, 1.0) + + if self.current_settings_dic['height_mult'] != height_mult: + self.current_settings_dic['height_mult'] = height_mult + self.execute(context) + + if self.sphere_segments_active: delta = self.get_delta_value(delta, event, sensibility=0.02, tweak_amount=10) segments = int(abs(self.ref_settings_dic['sphere_segments'] - delta)) From 68012d4bf153d370cead5ba6abeb0de79ec313d9 Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Tue, 11 Jul 2023 17:52:57 +0300 Subject: [PATCH 2/3] add capsule beta label --- collider_shapes/add_bounding_capsule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collider_shapes/add_bounding_capsule.py b/collider_shapes/add_bounding_capsule.py index 0812b5b..709cdd2 100644 --- a/collider_shapes/add_bounding_capsule.py +++ b/collider_shapes/add_bounding_capsule.py @@ -12,7 +12,7 @@ class OBJECT_OT_add_bounding_capsule(OBJECT_OT_add_bounding_object, Operator): """Create bounding capsule collider based on the selection""" bl_idname = "mesh.add_bounding_capsule" - bl_label = "Add Capsule" + bl_label = "Add Capsule (Beta)" bl_description = 'Create bounding capsule colliders based on the selection' def __init__(self): From 64567dd203b82d2263049324797d258b3e3ec9aa Mon Sep 17 00:00:00 2001 From: Matthias Patscheider Date: Sun, 13 Aug 2023 19:40:37 +0300 Subject: [PATCH 3/3] #442 --- bmesh_operations/mesh_split_by_island.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bmesh_operations/mesh_split_by_island.py b/bmesh_operations/mesh_split_by_island.py index b11c918..9e3bb02 100644 --- a/bmesh_operations/mesh_split_by_island.py +++ b/bmesh_operations/mesh_split_by_island.py @@ -1,9 +1,11 @@ import bpy import bmesh +import sys # Simple - get all linked faces def get_linked_faces(f): + sys.setrecursionlimit(10**6) if f.tag: # If the face is already tagged, return empty list return []