diff --git a/game/addons/bone_editor/BoneEditor.gd b/game/addons/bone_editor/BoneEditor.gd index 4670314b..0bebc38d 100644 --- a/game/addons/bone_editor/BoneEditor.gd +++ b/game/addons/bone_editor/BoneEditor.gd @@ -10,6 +10,8 @@ export(bool) var edit_bone_hierarchy : bool = false export(String) var add_bone_name : String = "" export(bool) var add_bone : bool = false setget set_add_bone, get_add_bone +export(bool) var set_pose_as_rest : bool = false setget set_set_pose_as_rest, get_add_bone + var skeleton:Skeleton = null var animation_player:AnimationPlayer = null var first_call:bool = true @@ -233,3 +235,13 @@ func get_add_bone(): func is_done_editor(): return true + +func set_set_pose_as_rest(val): + if val: + for n in bone_handle_nodes: + n.set_as_rest_pose() + + for n in bone_handle_nodes: + n._ready() + + #load_poses() diff --git a/game/addons/bone_editor/BoneHandle.gd b/game/addons/bone_editor/BoneHandle.gd index 1eedcfe9..897b01a4 100644 --- a/game/addons/bone_editor/BoneHandle.gd +++ b/game/addons/bone_editor/BoneHandle.gd @@ -36,6 +36,12 @@ func set_pose( basis:Basis, origin:Vector3 ): self.transform.origin = self.original_global_rest_origin + self.original_parent_rest.basis.xform( origin ) # printt( self.bone_name, basis, origin ) +func set_as_rest_pose(): + original_rest = self.pose + self.skeleton.set_bone_rest(self.bone_id, original_rest) + self.skeleton.set_bone_pose( self.bone_id, Transform( )) + + func _process( delta:float ): if self.skeleton == null or self.bone_id == -1: return