|
@ -42,12 +42,14 @@ import bpy |
|
|
from mathutils import Vector |
|
|
from mathutils import Vector |
|
|
# from mathutils import Euler |
|
|
# from mathutils import Euler |
|
|
|
|
|
|
|
|
ob1 = None |
|
|
def calculate_one(): |
|
|
try: |
|
|
ob1 = None |
|
|
|
|
|
try: |
|
|
ob1 = obj.select_get() |
|
|
ob1 = obj.select_get() |
|
|
except: |
|
|
except: |
|
|
# < 2.8 |
|
|
# < 2.8 |
|
|
ob1 = bpy.context.scene.objects.active |
|
|
ob1 = bpy.context.scene.objects.active |
|
|
|
|
|
calculate_collisionbox(ob1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MessageBox(bpy.types.Operator): |
|
|
class MessageBox(bpy.types.Operator): |
|
@ -79,17 +81,19 @@ bpy.utils.register_class(MessageBox) |
|
|
|
|
|
|
|
|
msgSuffix = "" |
|
|
msgSuffix = "" |
|
|
|
|
|
|
|
|
mesh = None |
|
|
def calculate_collisionbox(ob1): |
|
|
if ob1 is not None: |
|
|
global msgSuffix |
|
|
|
|
|
mesh = None |
|
|
|
|
|
if ob1 is not None: |
|
|
mesh = ob1.data |
|
|
mesh = ob1.data |
|
|
|
|
|
|
|
|
if ob1 is None: |
|
|
if ob1 is None: |
|
|
msg = "Nothing is selected." |
|
|
msg = "Nothing is selected." |
|
|
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg) |
|
|
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg) |
|
|
elif (mesh is not None) and (not hasattr(mesh, 'vertices')): |
|
|
elif (mesh is not None) and (not hasattr(mesh, 'vertices')): |
|
|
msg = "Collision box for armatures cannot be calculated." |
|
|
msg = "Collision box for armatures cannot be calculated." |
|
|
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg) |
|
|
bpy.ops.message.messagebox('INVOKE_DEFAULT', message = msg) |
|
|
else: |
|
|
else: |
|
|
# extents1 = ob1.dimensions.copy() |
|
|
# extents1 = ob1.dimensions.copy() |
|
|
obj1Loc = ob1.location |
|
|
obj1Loc = ob1.location |
|
|
|
|
|
|
|
@ -245,3 +249,5 @@ else: |
|
|
|
|
|
|
|
|
# Unregistering before user clicks the MessageBox will crash Blender! |
|
|
# Unregistering before user clicks the MessageBox will crash Blender! |
|
|
# bpy.utils.unregister_class(MessageBox) |
|
|
# bpy.utils.unregister_class(MessageBox) |
|
|
|
|
|
|
|
|
|
|
|
calculate_one() |
|
|