Browse Source

Minor typo and style fixes for the IK demo

TwistedTwigleg 5 years ago
parent
commit
fd6e157596
3 changed files with 10 additions and 11 deletions
  1. 2 2
      3d/ik/addons/sade/ik_fabrik.gd
  2. 8 8
      3d/ik/addons/sade/ik_look_at.gd
  3. 0 1
      3d/ik/fabrik_ik.tscn

+ 2 - 2
3d/ik/addons/sade/ik_fabrik.gd

@@ -320,12 +320,12 @@ func chain_apply_rotation():
 				
 				
 				# A bit of a hack. Because we only have two bones, we have to use the previous
 				# A bit of a hack. Because we only have two bones, we have to use the previous
 				# bone to position the last bone in the chain.
 				# bone to position the last bone in the chain.
-				var last_bone = bone_nodes[i-1].global_transform;
+				var last_bone = bone_nodes[i-1].global_transform
 				# Because we know the length of adjacent bone to this bone in the chain, we can
 				# Because we know the length of adjacent bone to this bone in the chain, we can
 				# position this bone by taking the last bone's position plus the length of the
 				# position this bone by taking the last bone's position plus the length of the
 				# bone on the Z axis.
 				# bone on the Z axis.
 				# This will place the position of the bone at the end of the last bone
 				# This will place the position of the bone at the end of the last bone
-				bone_trans.origin = last_bone.origin - last_bone.basis.z.normalized() * bones_in_chain_lengths[i-1];
+				bone_trans.origin = last_bone.origin - last_bone.basis.z.normalized() * bones_in_chain_lengths[i-1]
 		
 		
 		# If this is NOT the last bone in the bone chain, rotate the bone to look at the next
 		# If this is NOT the last bone in the bone chain, rotate the bone to look at the next
 		# bone in the bone chain.
 		# bone in the bone chain.

+ 8 - 8
3d/ik/addons/sade/ik_look_at.gd

@@ -10,14 +10,14 @@ export(bool) var use_our_rotation_y = false
 export(bool) var use_our_rotation_z = false
 export(bool) var use_our_rotation_z = false
 export(bool) var use_negative_our_rot = false
 export(bool) var use_negative_our_rot = false
 export(Vector3) var additional_rotation = Vector3()
 export(Vector3) var additional_rotation = Vector3()
+export (bool) var position_using_additional_bone = false
+export (String) var additional_bone_name = ""
+export (float) var additional_bone_length = 1
 export(bool) var debug_messages = false
 export(bool) var debug_messages = false
 
 
 var skeleton_to_use
 var skeleton_to_use
 var first_call = true
 var first_call = true
-
-export (bool) var position_using_additional_bone = false
-export (String) var additional_bone_name = ""
-export (float) var additional_bone_length = 1
+var _editor_indicator = null
 
 
 
 
 func _ready():
 func _ready():
@@ -131,9 +131,9 @@ func update_skeleton():
 func _setup_for_editor():
 func _setup_for_editor():
 	# So we can see the target in the editor, let's create a mesh instance,
 	# So we can see the target in the editor, let's create a mesh instance,
 	# Add it as our child, and name it
 	# Add it as our child, and name it
-	var indicator = MeshInstance.new()
-	add_child(indicator)
-	indicator.name = "(EditorOnly) Visual indicator"
+	_editor_indicator = MeshInstance.new()
+	add_child(_editor_indicator)
+	_editor_indicator.name = "(EditorOnly) Visual indicator"
 
 
 	# We need to make a mesh for the mesh instance.
 	# We need to make a mesh for the mesh instance.
 	# The code below makes a small sphere mesh
 	# The code below makes a small sphere mesh
@@ -150,7 +150,7 @@ func _setup_for_editor():
 	indicator_material.albedo_texture = preload("editor_gizmo_texture.png")
 	indicator_material.albedo_texture = preload("editor_gizmo_texture.png")
 	indicator_material.albedo_color = Color(1, 0.5, 0, 1)
 	indicator_material.albedo_color = Color(1, 0.5, 0, 1)
 	indicator_mesh.material = indicator_material
 	indicator_mesh.material = indicator_material
-	indicator.mesh = indicator_mesh
+	_editor_indicator.mesh = indicator_mesh
 
 
 
 
 func _set_update(new_value):
 func _set_update(new_value):

+ 0 - 1
3d/ik/fabrik_ik.tscn

@@ -95,7 +95,6 @@ __meta__ = {
 skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
 skeleton_path = NodePath("../../../BattleBot/Armature/Skeleton")
 bones_in_chain = PoolStringArray( "Left_UpperArm", "Left_LowerArm" )
 bones_in_chain = PoolStringArray( "Left_UpperArm", "Left_LowerArm" )
 bones_in_chain_lengths = PoolRealArray( 1.97, 3 )
 bones_in_chain_lengths = PoolRealArray( 1.97, 3 )
-chain_iterations = 10
 limit_chain_iterations = false
 limit_chain_iterations = false
 use_middle_joint_target = true
 use_middle_joint_target = true