Skip to content

Commit

Permalink
#340 Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Apr 13, 2023
1 parent 1dbccac commit cc92800
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions collider_shapes/add_bounding_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ def draw_viewport_overlay(self, context):
# mode check is here because keep original mesh doesn't work for EDIT mode atm.
if self.use_keep_original_materials:
label = "Keep Original Materials"
value = str(self.keep_original_material)

value = str(self.keep_original_material)
# Currently only supported in OBJECT mode
type = 'bool' if self.obj_mode == 'OBJECT' else 'disabled'
if self.obj_mode == 'OBJECT':
type = 'bool'
else:
type = 'disabled'

i = draw_modal_item(self, font_id, i, vertical_px_offset, left_margin, label, value=value, key='(O)', type=type)

label = "Toggle X Ray "
Expand Down Expand Up @@ -773,8 +777,7 @@ def primitive_postprocessing(self, context, bounding_object, base_object_collect
else: # No default material is selected
mat_name = self.prefs.physics_material_name

# The or self.obj_mode == 'OBJECT' is here because the keep_original_material is currently not supported for 'EDIT' mode.
if self.keep_original_material == False or self.obj_mode != 'OBJECT':
if self.use_keep_original_materials == False or self.keep_original_material == False:
set_physics_material(bounding_object, mat_name)

bounding_object['isCollider'] = True
Expand Down Expand Up @@ -1140,7 +1143,7 @@ def modal(self, context, event):
self.creation_mode_idx = (self.creation_mode_idx + 1) % len(self.creation_mode)
self.execute(context)

elif event.type == 'O' and event.value == 'RELEASE' and self.use_keep_original_materials == True and self.obj_mode == 'OBJECT':
elif event.type == 'O' and event.value == 'RELEASE' and self.use_keep_original_materials == True:
self.keep_original_material = not self.keep_original_material
self.execute(context)

Expand Down
4 changes: 4 additions & 0 deletions collider_shapes/add_collision_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def execute(self, context):
if context.object not in self.selected_objects:
self.selected_objects.append(context.object)

# Keep original material is currently not supported for EDIT mode.
if self.obj_mode != 'OBJECT':
self.keep_original_material = False

collider_data = []

for obj in self.selected_objects:
Expand Down

0 comments on commit cc92800

Please sign in to comment.