Skip to content

Commit

Permalink
#71 Support Meta, Surface, Text
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Jun 26, 2023
1 parent 483ced6 commit 57fe948
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 27 deletions.
6 changes: 3 additions & 3 deletions auto_Convex/add_bounding_auto_convex.py
Expand Up @@ -144,9 +144,9 @@ def execute(self, context):
# skip if invalid object
if not self.is_valid_object(obj):
continue
if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

context.view_layer.objects.active = obj

if self.obj_mode == "EDIT":
Expand Down
4 changes: 2 additions & 2 deletions collider_conversion/conversion_operators.py
Expand Up @@ -129,8 +129,8 @@ def execute(self, context):
# skip if invalid object
if not self.is_valid_object(obj):
continue
if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

new_collider = obj.copy()
new_collider.data = obj.data.copy()
Expand Down
5 changes: 3 additions & 2 deletions collider_shapes/add_bounding_box.py
Expand Up @@ -127,8 +127,9 @@ def execute(self, context):
if not self.is_valid_object(obj):
continue

if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
print('ZZZZZZZZZZZZZZZZZZZZZZZZZ')
obj = self.convert_to_mesh(context, obj)

context.view_layer.objects.active = obj
bounding_box_data = {}
Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_bounding_capsule.py
Expand Up @@ -87,8 +87,8 @@ def execute(self, context):
if not self.is_valid_object(obj):
continue

if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

context.view_layer.objects.active = obj
bounding_capsule_data = {}
Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_bounding_convex_hull.py
Expand Up @@ -55,8 +55,8 @@ def execute(self, context):
if not self.is_valid_object(obj):
continue

if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

convex_collision_data = {}

Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_bounding_cylinder.py
Expand Up @@ -264,8 +264,8 @@ def execute(self, context):
if not self.is_valid_object(obj):
continue

if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

bounding_cylinder_data = {}

Expand Down
17 changes: 9 additions & 8 deletions collider_shapes/add_bounding_primitive.py
Expand Up @@ -779,10 +779,9 @@ def mesh_from_selection(obj, use_modifiers=False):

return mesh

@staticmethod
def is_valid_object(obj):
def is_valid_object(self, obj):
"""Is the object valid to be used as a base mesh for collider generation"""
if obj is None or obj.type not in ["MESH","CURVE"]:
if obj is None or obj.type not in self.valid_object_types:
return False
return True

Expand Down Expand Up @@ -854,14 +853,14 @@ def print_generation_time(shape, time):
print(shape)
print("Time elapsed: ", str(time))

def curve_to_mesh(self, context, curve):
def convert_to_mesh(self, context, object):
deg = context.evaluated_depsgraph_get()
me = bpy.data.meshes.new_from_object(curve.evaluated_get(deg), depsgraph=deg)
me = bpy.data.meshes.new_from_object(object.evaluated_get(deg), depsgraph=deg)

new_obj = bpy.data.objects.new(curve.name + "_mesh", me)
new_obj = bpy.data.objects.new(object.name + "_mesh", me)
context.collection.objects.link(new_obj)

new_obj.matrix_world = curve.matrix_world
new_obj.matrix_world = object.matrix_world
context.view_layer.objects.active = new_obj

return new_obj
Expand Down Expand Up @@ -1069,11 +1068,13 @@ def __init__(self):
self.use_recenter_origin = False
self.use_custom_rotation = False

self.valid_object_types = ['CURVE', 'SURFACE', 'FONT', 'META']

@classmethod
def poll(cls, context):
count = 0
for obj in context.selected_objects:
if obj.type in ['MESH','CURVE']:
if obj.type in ['MESH', 'CURVE', 'SURFACE', 'FONT', 'META']:
count = count + 1
return count > 0

Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_bounding_sphere.py
Expand Up @@ -174,8 +174,8 @@ def execute(self, context):
if not self.is_valid_object(obj):
continue

if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

initial_mod_state = {}
context.view_layer.objects.active = obj
Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_collision_mesh.py
Expand Up @@ -59,8 +59,8 @@ def execute(self, context):
# skip if invalid object
if not self.is_valid_object(obj):
continue
if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

mesh_collider_data = {}

Expand Down
4 changes: 2 additions & 2 deletions collider_shapes/add_minimum_bounding_box.py
Expand Up @@ -153,8 +153,8 @@ def execute(self, context):
# skip if invalid object
if not self.is_valid_object(obj):
continue
if obj and obj.type == 'CURVE':
obj = self.curve_to_mesh(context, obj)
if obj and obj.type in self.valid_object_types:
obj = self.convert_to_mesh(context, obj)

bounding_box_data = {}

Expand Down

0 comments on commit 57fe948

Please sign in to comment.