mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-04-09 05:21:49 +02: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(NodePath) var edit_animation_player:NodePath setget set_edit_animation_player
|
||||||
export(bool) var enabled:bool = true
|
export(bool) var enabled:bool = true
|
||||||
|
|
||||||
|
export(bool) var edit_bone_hierarchy : bool = false
|
||||||
|
|
||||||
export(String) var add_bone_name : String = ""
|
export(String) var add_bone_name : String = ""
|
||||||
export(bool) var add_bone : bool = false setget set_add_bone, get_add_bone
|
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 )
|
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():
|
func ensure_nodes():
|
||||||
if !skeleton:
|
if !skeleton:
|
||||||
skeleton = get_node(control_skeleton)
|
skeleton = get_node(control_skeleton)
|
||||||
@ -220,3 +230,6 @@ func set_add_bone(val):
|
|||||||
|
|
||||||
func get_add_bone():
|
func get_add_bone():
|
||||||
return false
|
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 )
|
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.skeleton.set_bone_pose( self.bone_id, t )
|
||||||
self.pose = 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