mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Bone hierarchy editing support.
This commit is contained in:
parent
6c32deb131
commit
242321fd7a
@ -5,6 +5,8 @@ export(NodePath) var control_skeleton:NodePath setget set_control_skeleton
|
||||
export(NodePath) var edit_animation_player:NodePath setget set_edit_animation_player
|
||||
export(bool) var enabled:bool = true
|
||||
|
||||
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
|
||||
|
||||
@ -171,6 +173,14 @@ func _save_poses_to_animation( animation:Animation ):
|
||||
)
|
||||
print( "* added new key for ", target_bone.name )
|
||||
|
||||
func set_bone_parent(bone_id, parent_bone_id):
|
||||
ensure_nodes()
|
||||
|
||||
if !skeleton:
|
||||
return
|
||||
|
||||
skeleton.set_bone_parent(bone_id, parent_bone_id)
|
||||
|
||||
func ensure_nodes():
|
||||
if !skeleton:
|
||||
skeleton = get_node(control_skeleton)
|
||||
@ -220,3 +230,6 @@ func set_add_bone(val):
|
||||
|
||||
func get_add_bone():
|
||||
return false
|
||||
|
||||
func is_done_editor():
|
||||
return true
|
||||
|
@ -46,3 +46,32 @@ func _process( delta:float ):
|
||||
t.origin = self.original_parent_rest.basis.xform_inv( self.transform.origin - self.original_global_rest_origin )
|
||||
self.skeleton.set_bone_pose( self.bone_id, t )
|
||||
self.pose = t
|
||||
|
||||
func ensure_bone_editor():
|
||||
if !bone_editor:
|
||||
var n : Node = get_parent()
|
||||
|
||||
while n:
|
||||
if n.has_method("is_done_editor"):
|
||||
bone_editor = n
|
||||
return
|
||||
|
||||
n = n.get_parent()
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_PARENTED:
|
||||
ensure_bone_editor()
|
||||
|
||||
if !bone_editor:
|
||||
return
|
||||
|
||||
if !bone_editor.edit_bone_hierarchy:
|
||||
return
|
||||
|
||||
var n : Node = get_parent()
|
||||
|
||||
if n == bone_editor:
|
||||
bone_editor.set_bone_parent(bone_id, -1)
|
||||
else:
|
||||
bone_editor.set_bone_parent(bone_id, n.bone_id)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user