Initial set rest pose implementation for the bone editor. Doesn't work properly yet.

This commit is contained in:
Relintai 2021-09-12 23:18:05 +02:00
parent 242321fd7a
commit d9e0ed3741
2 changed files with 18 additions and 0 deletions

View File

@ -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()

View File

@ -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