Browse Source

Store the draw type when exporting empty nodes

Supports using empties as placeholders for collision shapes
Henry Conklin 3 years ago
parent
commit
eaf80e476a

+ 4 - 0
io_scene_godot/converters/simple_nodes.py

@@ -20,6 +20,10 @@ def export_empty_node(escn_file, export_settings, node, parent_gd_node):
         return parent_gd_node
     empty_node = NodeTemplate(node.name, "Spatial", parent_gd_node)
     empty_node['transform'] = node.matrix_local
+    if node.name.endswith('-colonly') or node.name.endswith('-convcolonly'):
+        # For empties marked as collision shapes (name ending in -colonly/-convcolonly) Godot uses the draw/display type to pick a
+        # collision shape
+        empty_node['__meta__'] = '{{ "empty_draw_type": "{}" }}'.format(node.empty_display_type)
     escn_file.add_node(empty_node)
 
     return empty_node

+ 8 - 0
tests/reference_exports/collision_empties/arrow.escn

@@ -0,0 +1,8 @@
+[gd_scene load_steps=1 format=2]
+
+[node type="Spatial" name="Scene"]
+
+[node name="arrow-colonly" type="Spatial" parent="."]
+
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
+__meta__ = { "empty_draw_type": "SINGLE_ARROW" }

+ 8 - 0
tests/reference_exports/collision_empties/cube.escn

@@ -0,0 +1,8 @@
+[gd_scene load_steps=1 format=2]
+
+[node type="Spatial" name="Scene"]
+
+[node name="cube-colonly" type="Spatial" parent="."]
+
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
+__meta__ = { "empty_draw_type": "CUBE" }

+ 8 - 0
tests/reference_exports/collision_empties/image.escn

@@ -0,0 +1,8 @@
+[gd_scene load_steps=1 format=2]
+
+[node type="Spatial" name="Scene"]
+
+[node name="image-colonly" type="Spatial" parent="."]
+
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
+__meta__ = { "empty_draw_type": "IMAGE" }

+ 8 - 0
tests/reference_exports/collision_empties/sphere.escn

@@ -0,0 +1,8 @@
+[gd_scene load_steps=1 format=2]
+
+[node type="Spatial" name="Scene"]
+
+[node name="sphere-colonly" type="Spatial" parent="."]
+
+transform = Transform(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0)
+__meta__ = { "empty_draw_type": "SPHERE" }

BIN
tests/test_scenes/collision_empties/arrow.blend


BIN
tests/test_scenes/collision_empties/cube.blend


BIN
tests/test_scenes/collision_empties/image.blend


BIN
tests/test_scenes/collision_empties/sphere.blend