glTF importer: set empty display size, based on distance parent/children
This commit is contained in:
parent
4d2d118f9a
commit
ec45566f05
|
@ -15,7 +15,7 @@
|
|||
bl_info = {
|
||||
'name': 'glTF 2.0 format',
|
||||
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
|
||||
"version": (1, 8, 9),
|
||||
"version": (1, 8, 10),
|
||||
'blender': (3, 0, 0),
|
||||
'location': 'File > Import-Export',
|
||||
'description': 'Import-Export as glTF 2.0',
|
||||
|
|
|
@ -75,8 +75,10 @@ class BlenderNode():
|
|||
obj = bpy.data.objects.new(name, armature)
|
||||
|
||||
else:
|
||||
# Empty
|
||||
name = vnode.name or vnode.default_name
|
||||
obj = bpy.data.objects.new(name, None)
|
||||
obj.empty_display_size = BlenderNode.calc_empty_display_size(gltf, vnode_id)
|
||||
|
||||
vnode.blender_object = obj
|
||||
|
||||
|
@ -111,6 +113,17 @@ class BlenderNode():
|
|||
|
||||
return obj
|
||||
|
||||
@staticmethod
|
||||
def calc_empty_display_size(gltf, vnode_id):
|
||||
# Use min distance to parent/children to guess size
|
||||
sizes = []
|
||||
vids = [vnode_id] + gltf.vnodes[vnode_id].children
|
||||
for vid in vids:
|
||||
vnode = gltf.vnodes[vid]
|
||||
dist = vnode.trs()[0].length
|
||||
sizes.append(dist * 0.4)
|
||||
return max(min(sizes, default=1), 0.001)
|
||||
|
||||
@staticmethod
|
||||
def create_bones(gltf, arma_id):
|
||||
arma = gltf.vnodes[arma_id]
|
||||
|
|
Loading…
Reference in New Issue