Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Aug 13, 2023
2 parents 4139461 + 5583329 commit e6b828b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bmesh_operations/mesh_split_by_island.py
Original file line number Diff line number Diff line change
@@ -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 []
Expand Down
5 changes: 3 additions & 2 deletions collider_shapes/add_bounding_capsule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'


Expand Down Expand Up @@ -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"],
Expand Down
43 changes: 41 additions & 2 deletions collider_shapes/add_bounding_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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':
Expand All @@ -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)
Expand All @@ -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':
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit e6b828b

Please sign in to comment.