Skip to content

Commit

Permalink
Converter: Do not crash if Bullet is not available
Browse files Browse the repository at this point in the history
Instead, issue a warning about not converting physics shapes and move
on.
  • Loading branch information
Moguri committed Apr 21, 2017
1 parent 5e44d37 commit 7ef342f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import struct

from panda3d.core import *
from panda3d import bullet
try:
from panda3d import bullet
HAVE_BULLET = True
except ImportError:
HAVE_BULLET = False


class Converter():
def __init__(self):
Expand Down Expand Up @@ -92,7 +97,7 @@ def add_node(root, gltf_scene, nodeid):
if isinstance(light, Light):
root.set_light(lnp)
if 'extensions' in gltf_node:
if 'BLENDER_physics' in gltf_node['extensions']:
if HAVE_BULLET and 'BLENDER_physics' in gltf_node['extensions']:
phy = gltf_node['extensions']['BLENDER_physics']
shape = None
radius = max(phy['dimensions'][0], phy['dimensions'][1]) / 2.0
Expand Down Expand Up @@ -138,6 +143,8 @@ def add_node(root, gltf_scene, nodeid):
phynode.set_mass(phy['mass'])
else:
print("Could not create collision shape for object ({})".format(nodeid))
elif not HAVE_BULLET:
print("Bullet is unavailable, not converting collision shape for object ({})".format(nodeid))


for child_nodeid in gltf_node['children']:
Expand Down

0 comments on commit 7ef342f

Please sign in to comment.