Skip to content

Commit

Permalink
Fixed collision bounding boxes being assigned to the wrong animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Five-Damned-Dollarz committed Feb 17, 2021
1 parent eb31467 commit 7a6fd44
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ def from_armature(armature_object):
print("Processing animation %s" % action.name)
animation = Animation()
animation.name = action.name
animation.bounds_min=Vector(mesh_object.bound_box[0]) # will using mesh_object here break if there's multiple mesh
animation.bounds_max=Vector(mesh_object.bound_box[6]) # objects using the same armature as a parent? DON'T DO THAT

armature_object.animation_data.action = action

Expand Down Expand Up @@ -254,11 +252,18 @@ def from_armature(armature_object):
for time in keyframe_timings[model.nodes[0].name]['rotation_quaternion']:
# Expand our time
scaled_time = time * (1.0/0.024)
bpy.context.scene.frame_set(time, subframe=time-floor(time))

keyframe = Animation.Keyframe()
keyframe.time = scaled_time
animation.keyframes.append(keyframe)

keyframe.bounds_min=Vector(mesh_object.bound_box[0]) # will using mesh_object here break if there's multiple mesh
keyframe.bounds_max=Vector(mesh_object.bound_box[6]) # objects using the same armature as a parent? DON'T DO THAT

animation.bounds_min=animation.keyframes[-1].bounds_min # if this doesn't get what we want, maybe doing
animation.bounds_max=animation.keyframes[-1].bounds_max # some math on the bounds of every keyframe will

# Okay let's start processing our transforms!
for node_index, (node, pose_bone) in enumerate(zip(model.nodes, armature_object.pose.bones)):
transforms = list()
Expand Down

0 comments on commit 7a6fd44

Please sign in to comment.