2023-01-05 13:25:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  skeleton_3d.cpp                                                       */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                         This file is part of:                          */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                             GODOT ENGINE                               */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                        https://godotengine.org                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* a copy of this software and associated documentation files (the        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* the following conditions:                                              */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* The above copyright notice and this permission notice shall be         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* included in all copies or substantial portions of the Software.        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
									
										
										
										
											2018-01-05 00:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "skeleton_3d.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-02-24 17:44:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "skeleton_3d.compat.inc" 
  
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-06 23:13:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "scene/3d/skeleton_modifier_3d.h" 
  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "scene/3d/physical_bone_simulator_3d.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  SkinReference : : _skin_changed ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( skeleton_node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										skeleton_node - > _make_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skeleton_version  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  SkinReference : : _bind_methods ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_skeleton " ) ,  & SkinReference : : get_skeleton ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_skin " ) ,  & SkinReference : : get_skin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								RID  SkinReference : : get_skeleton ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  skeleton ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Ref < Skin >  SkinReference : : get_skin ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  skin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								SkinReference : : ~ SkinReference ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-12-12 12:42:37 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_NULL ( RenderingServer : : get_singleton ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( skeleton_node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										skeleton_node - > skin_bindings . erase ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									RS : : get_singleton ( ) - > free ( skeleton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-26 14:17:11 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								///////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  Skeleton3D : : _set ( const  StringName  & p_path ,  const  Variant  & p_value )  {  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( p_path  = =  SNAME ( " animate_physical_bones " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										set_animate_physical_bones ( p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  path  =  p_path ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! path . begins_with ( " bones/ " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  which  =  path . get_slicec ( ' / ' ,  1 ) . to_int ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  what  =  path . get_slicec ( ' / ' ,  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-23 10:35:05 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( which  = =  bones . size ( )  & &  what  = =  " name " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										add_bone ( p_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_UNSIGNED_INDEX_V ( which ,  bones . size ( ) ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( what  = =  " parent " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										set_bone_parent ( which ,  p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " rest " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										set_bone_rest ( which ,  p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " enabled " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										set_bone_enabled ( which ,  p_value ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " position " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_bone_pose_position ( which ,  p_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " rotation " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_bone_pose_rotation ( which ,  p_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " scale " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_bone_pose_scale ( which ,  p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " bone_meta " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_bone_meta ( which ,  path . get_slicec ( ' / ' ,  3 ) ,  p_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-10 08:56:04 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
									
										
										
										
											2024-02-05 23:35:16 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " pose "  | |  what  = =  " bound_children " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-10 08:56:04 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Kept for compatibility from 3.x to 4.x.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										WARN_DEPRECATED_MSG ( " Skeleton uses old pose format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene. "  + 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												( is_inside_tree ( )  ?  vformat ( "  Path:  \" %s \" " ,  get_path ( ) )  :  String ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-05 23:35:16 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( what  = =  " pose " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Old Skeleton poses were relative to rest, new ones are absolute, so we need to recompute the pose.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Skeleton3D nodes were always written with rest before pose, so this *SHOULD* work...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Transform3D  rest  =  get_bone_rest ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Transform3D  pose  =  rest  *  ( Transform3D ) p_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set_bone_pose_position ( which ,  pose . origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set_bone_pose_rotation ( which ,  pose . basis . get_rotation_quaternion ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set_bone_pose_scale ( which ,  pose . basis . get_scale ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  {  // bound_children
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// This handles the case where the pose was set to the rest position; the pose property would == Transform() and would not be saved to the scene by default.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// However, the bound_children property was always saved regardless of value, and it was always saved after both pose and rest.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// We don't do anything else with bound_children, as it's not present on Skeleton3D.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Vector3  pos  =  get_bone_pose_position ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Quaternion  rot  =  get_bone_pose_rotation ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Vector3  scale  =  get_bone_pose_scale ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Transform3D  rest  =  get_bone_rest ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( rest  ! =  Transform3D ( )  & &  pos  = =  Vector3 ( )  & &  rot  = =  Quaternion ( )  & &  scale  = =  Vector3 ( 1 ,  1 ,  1 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set_bone_pose_position ( which ,  rest . origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set_bone_pose_rotation ( which ,  rest . basis . get_rotation_quaternion ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set_bone_pose_scale ( which ,  rest . basis . get_scale ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-10 08:56:04 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  Skeleton3D : : _get ( const  StringName  & p_path ,  Variant  & r_ret )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( p_path  = =  SNAME ( " animate_physical_bones " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r_ret  =  get_animate_physical_bones ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2024-08-04 12:28:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  path  =  p_path ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! path . begins_with ( " bones/ " ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  which  =  path . get_slicec ( ' / ' ,  1 ) . to_int ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  what  =  path . get_slicec ( ' / ' ,  2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_UNSIGNED_INDEX_V ( which ,  bones . size ( ) ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( what  = =  " name " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r_ret  =  get_bone_name ( which ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " parent " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r_ret  =  get_bone_parent ( which ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " rest " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r_ret  =  get_bone_rest ( which ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " enabled " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										r_ret  =  is_bone_enabled ( which ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " position " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_ret  =  get_bone_pose_position ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " rotation " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_ret  =  get_bone_pose_rotation ( which ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " scale " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_ret  =  get_bone_pose_scale ( which ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( what  = =  " bone_meta " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_ret  =  get_bone_meta ( which ,  path . get_slicec ( ' / ' ,  3 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _get_property_list ( List < PropertyInfo >  * p_list )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-26 22:07:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  String  prep  =  vformat ( " %s/%d/ " ,  " bones " ,  i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : STRING ,  prep  +  " name " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : INT ,  prep  +  " parent " ,  PROPERTY_HINT_RANGE ,  " -1, "  +  itos ( bones . size ( )  -  1 )  +  " ,1 " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : TRANSFORM3D ,  prep  +  " rest " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : BOOL ,  prep  +  " enabled " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : VECTOR3 ,  prep  +  " position " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : QUATERNION ,  prep  +  " rotation " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( PropertyInfo ( Variant : : VECTOR3 ,  prep  +  " scale " ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( const  KeyValue < StringName ,  Variant >  & K  :  bones [ i ] . metadata )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-26 22:07:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PropertyInfo  pi  =  PropertyInfo ( bones [ i ] . metadata [ K . key ] . get_type ( ) ,  prep  +  " bone_meta/ "  +  K . key ,  PROPERTY_HINT_NONE ,  " " ,  PROPERTY_USAGE_NO_EDITOR ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											p_list - > push_back ( pi ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( PropertyInfo  & E  :  * p_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_validate_property ( E ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _validate_property ( PropertyInfo  & p_property )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PackedStringArray  split  =  p_property . name . split ( " / " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( split . size ( )  = =  3  & &  split [ 0 ]  = =  " bones " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( split [ 2 ]  = =  " rest " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( is_show_rest_only ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " enabled " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " position " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " rotation " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " scale " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else  if  ( ! is_bone_enabled ( split [ 1 ] . to_int ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " position " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " rotation " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-16 10:04:09 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( split [ 2 ]  = =  " scale " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-12 23:57:11 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												p_property . usage  | =  PROPERTY_USAGE_READ_ONLY ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-14 06:35:35 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _update_process_order ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! process_order_dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Bone  * bonesptr  =  bones . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  len  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									parentless_bones . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-17 08:31:38 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  len ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bonesptr [ i ] . child_bones . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  len ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( bonesptr [ i ] . parent  > =  len )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Validate this just in case.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-06 17:03:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ERR_PRINT ( " Bone  "  +  itos ( i )  +  "  has invalid parent:  "  +  itos ( bonesptr [ i ] . parent ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											bonesptr [ i ] . parent  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( bonesptr [ i ] . parent  ! =  - 1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											int  parent_bone_idx  =  bonesptr [ i ] . parent ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Check to see if this node is already added to the parent.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-06 16:20:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( ! bonesptr [ parent_bone_idx ] . child_bones . has ( i ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// Add the child node.
 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												bonesptr [ parent_bone_idx ] . child_bones . push_back ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ERR_PRINT ( " Skeleton3D parenthood graph is cyclic " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											parentless_bones . push_back ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-09 12:47:48 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									concatenated_bone_names  =  StringName ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_update_bones_nested_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									process_order_dirty  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const_cast < Skeleton3D  * > ( this ) - > emit_signal ( " bone_list_changed " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-09 12:47:48 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _update_bone_names ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									String  names ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-09 12:47:48 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( i  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											names  + =  " , " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										names  + =  bones [ i ] . name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									concatenated_bone_names  =  StringName ( names ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								StringName  Skeleton3D : : get_concatenated_bone_names ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( concatenated_bone_names  = =  StringName ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_update_bone_names ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  concatenated_bone_names ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : setup_simulator ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-04-25 03:08:49 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( simulator  & &  simulator - > get_parent ( )  = =  this )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										remove_child ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										simulator - > queue_free ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  memnew ( PhysicalBoneSimulator3D ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									simulator  =  sim ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > is_compat  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > set_active ( false ) ;  // Don't run unneeded process.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-07 11:38:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									add_child ( simulator ,  false ,  INTERNAL_MODE_BACK ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 09:20:40 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									set_animate_physical_bones ( animate_physical_bones ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _notification ( int  p_what )  {  
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									switch  ( p_what )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-10 18:45:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  NOTIFICATION_ENTER_TREE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											_process_changed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											_make_modifiers_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											force_update_all_dirty_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setup_simulator ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
									
										
										
										
											2024-10-09 16:38:32 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											update_flags  =  UPDATE_FLAG_POSE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											_notification ( NOTIFICATION_UPDATE_SKELETON ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-12 07:04:55 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef TOOLS_ENABLED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_EDITOR_PRE_SAVE :  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:57:37 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											saving  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_EDITOR_POST_SAVE :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											saving  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-12 07:04:55 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // TOOLS_ENABLED
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_UPDATE_SKELETON :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Update bone transforms to apply unprocessed poses.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											force_update_all_dirty_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											updating  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Bone  * bonesptr  =  bones . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											int  len  =  bones . size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											thread_local  LocalVector < bool >  bone_global_pose_dirty_backup ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Process modifiers.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 15:04:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											thread_local  LocalVector < BonePoseBackup >  bones_backup ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											_find_modifiers ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ! modifiers . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 15:04:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												bones_backup . resize ( bones . size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// Store unmodified bone poses.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-08 15:04:52 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													bones_backup [ i ] . save ( bonesptr [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// Store dirty flags for global bone poses.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												bone_global_pose_dirty_backup  =  bone_global_pose_dirty ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												_process_modifiers ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Abort if pose is not changed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ! ( update_flags  &  UPDATE_FLAG_POSE ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												updating  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												update_flags  =  UPDATE_FLAG_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:01:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											emit_signal ( SceneStringName ( skeleton_updated ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 20:39:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Update skins.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											RenderingServer  * rs  =  RenderingServer : : get_singleton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											for  ( SkinReference  * E  :  skin_bindings )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												const  Skin  * skin  =  E - > skin . operator - > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												RID  skeleton  =  E - > skeleton ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												uint32_t  bind_count  =  skin - > get_bind_count ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( E - > bind_count  ! =  bind_count )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-09 13:19:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													RS : : get_singleton ( ) - > skeleton_allocate_data ( skeleton ,  bind_count ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													E - > bind_count  =  bind_count ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													E - > skin_bone_indices . resize ( bind_count ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													E - > skin_bone_indices_ptrs  =  E - > skin_bone_indices . ptrw ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( E - > skeleton_version  ! =  version )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													for  ( uint32_t  i  =  0 ;  i  <  bind_count ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														StringName  bind_name  =  skin - > get_bind_name ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  ( bind_name  ! =  StringName ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															// Bind name used, use this.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															bool  found  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															for  ( int  j  =  0 ;  j  <  len ;  j + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																if  ( bonesptr [ j ] . name  = =  bind_name )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	E - > skin_bone_indices_ptrs [ i ]  =  j ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																	found  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															if  ( ! found )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-19 11:48:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																ERR_PRINT ( " Skin bind # "  +  itos ( i )  +  "  contains named bind ' "  +  String ( bind_name )  +  " ' but Skeleton3D has no bone by that name. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																E - > skin_bone_indices_ptrs [ i ]  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														}  else  if  ( skin - > get_bind_bone ( i )  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															int  bind_index  =  skin - > get_bind_bone ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															if  ( bind_index  > =  len )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																ERR_PRINT ( " Skin bind # "  +  itos ( i )  +  "  contains bone index bind:  "  +  itos ( bind_index )  +  "  , which is greater than the skeleton bone count:  "  +  itos ( len )  +  " . " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																E - > skin_bone_indices_ptrs [ i ]  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																E - > skin_bone_indices_ptrs [ i ]  =  bind_index ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															ERR_PRINT ( " Skin bind # "  +  itos ( i )  +  "  does not contain a name nor a bone index. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															E - > skin_bone_indices_ptrs [ i ]  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													E - > skeleton_version  =  version ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												for  ( uint32_t  i  =  0 ;  i  <  bind_count ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													uint32_t  bone_index  =  E - > skin_bone_indices_ptrs [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													ERR_CONTINUE ( bone_index  > =  ( uint32_t ) len ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													rs - > skeleton_bone_set_transform ( skeleton ,  i ,  bonesptr [ bone_index ] . global_pose  *  skin - > get_bind_pose ( i ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 09:52:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( ! modifiers . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// Restore unmodified bone poses.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													bones_backup [ i ] . restore ( bones [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 09:52:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// Restore dirty flags for global bone poses.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												bone_global_pose_dirty  =  bone_global_pose_dirty_backup ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 09:52:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											updating  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											update_flags  =  UPDATE_FLAG_NONE ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  NOTIFICATION_INTERNAL_PROCESS : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  NOTIFICATION_INTERNAL_PHYSICS_PROCESS :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											_find_modifiers ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ! modifiers . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												_update_deferred ( UPDATE_FLAG_MODIFIER ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 09:52:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_modifier_callback_mode_process ( Skeleton3D : : ModifierCallbackModeProcess  p_mode )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( modifier_callback_mode_process  = =  p_mode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-24 09:59:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									modifier_callback_mode_process  =  p_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_process_changed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-24 09:59:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Skeleton3D : : ModifierCallbackModeProcess  Skeleton3D : : get_modifier_callback_mode_process ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  modifier_callback_mode_process ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-27 22:54:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _process_changed ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( modifier_callback_mode_process  = =  MODIFIER_CALLBACK_MODE_PROCESS_IDLE )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_process_internal ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_physics_process_internal ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( modifier_callback_mode_process  = =  MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_process_internal ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										set_physics_process_internal ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : _make_modifiers_dirty ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									modifiers_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_update_deferred ( UPDATE_FLAG_MODIFIER ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _update_bones_nested_set ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nested_set_offset_to_bone_index . resize ( bones . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bone_global_pose_dirty . resize ( bones . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_make_bone_global_poses_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  offset  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  bone  :  parentless_bones )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										offset  + =  _update_bone_nested_set ( bone ,  offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  Skeleton3D : : _update_bone_nested_set ( int  p_bone ,  int  p_offset )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Bone  & bone  =  bones [ p_bone ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  offset  =  p_offset  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  span  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  child_bone  :  bone . child_bones )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  subspan  =  _update_bone_nested_set ( child_bone ,  offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										offset  + =  subspan ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										span  + =  subspan ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nested_set_offset_to_bone_index [ p_offset ]  =  p_bone ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bone . nested_set_offset  =  p_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bone . nested_set_span  =  span ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  span ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _make_bone_global_poses_dirty ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  bone_global_pose_dirty . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bone_global_pose_dirty [ i ]  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _make_bone_global_pose_subtree_dirty ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( process_order_dirty )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  Bone  & bone  =  bones [ p_bone ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  span_offset  =  bone . nested_set_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// No need to make subtree dirty when bone is already dirty.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( bone_global_pose_dirty [ span_offset ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Make global poses of subtree dirty.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  span_end  =  span_offset  +  bone . nested_set_span ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  span_offset ;  i  <  span_end ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bone_global_pose_dirty [ i ]  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _update_bone_global_pose ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_update_process_order ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Global pose is already calculated.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  nested_set_offset  =  bones [ p_bone ] . nested_set_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! bone_global_pose_dirty [ nested_set_offset ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									thread_local  LocalVector < int >  bone_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bone_list . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Transform3D  global_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create list of parent bones for which the global pose needs to be recalculated.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  bone  =  p_bone ;  bone  > =  0 ;  bone  =  bones [ bone ] . parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  offset  =  bones [ bone ] . nested_set_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Stop searching when global pose is not dirty.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! bone_global_pose_dirty [ offset ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											global_pose  =  bones [ bone ] . global_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bone_list . push_back ( bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Calculate global poses for all parent bones and the current bone.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  bone_list . size ( )  -  1 ;  i  > =  0 ;  i - - )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  bone_idx  =  bone_list [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Bone  & bone  =  bones [ bone_idx ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bool  bone_enabled  =  bone . enabled  & &  ! show_rest_only ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Transform3D  bone_pose  =  bone_enabled  ?  get_bone_pose ( bone_idx )  :  get_bone_rest ( bone_idx ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										global_pose  * =  bone_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( bone . global_pose_override_amount  > =  CMP_EPSILON )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											global_pose  =  global_pose . interpolate_with ( bone . global_pose_override ,  bone . global_pose_override_amount ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bone . global_pose  =  global_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bone_global_pose_dirty [ bone . nested_set_offset ]  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-17 01:08:21 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_global_pose ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_update_bone_global_pose ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  bones [ p_bone ] . global_pose ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-14 10:31:38 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_global_pose ( int  p_bone ,  const  Transform3D  & p_pose )  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Transform3D  pt ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( bones [ p_bone ] . parent  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										pt  =  get_bone_global_pose ( bones [ p_bone ] . parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 13:07:17 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Transform3D  t  =  pt . affine_inverse ( )  *  p_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set_bone_pose ( p_bone ,  t ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 13:07:17 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:48:08 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_motion_scale ( float  p_motion_scale )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( p_motion_scale  < =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										motion_scale  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ERR_FAIL_MSG ( " Motion scale must be larger than 0. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									motion_scale  =  p_motion_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								float  Skeleton3D : : get_motion_scale ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( motion_scale  < =  0 ,  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  motion_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Skeleton creation api
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-09 16:32:36 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint64_t  Skeleton3D : : get_version ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  version ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-24 17:44:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  Skeleton3D : : add_bone ( const  String  & p_name )  {  
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( p_name . is_empty ( )  | |  p_name . contains_char ( ' : ' )  | |  p_name . contains_char ( ' / ' ) ,  - 1 ,  vformat ( " Bone name cannot be empty or contain ':' or '/'. " ,  p_name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-24 17:44:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( name_to_bone_index . has ( p_name ) ,  - 1 ,  vformat ( " Skeleton3D  \" %s \"  already has a bone with name  \" %s \" . " ,  to_string ( ) ,  p_name ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-23 10:35:05 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									Bone  b ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									b . name  =  p_name ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									bones . push_back ( b ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-24 17:44:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  new_idx  =  bones . size ( )  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									name_to_bone_index . insert ( p_name ,  new_idx ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									process_order_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									version + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									rest_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-23 16:49:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									update_gizmos ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-24 17:44:26 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  new_idx ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  Skeleton3D : : find_bone ( const  String  & p_name )  const  {  
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:42:32 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  * bone_index_ptr  =  name_to_bone_index . getptr ( p_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bone_index_ptr  ! =  nullptr  ?  * bone_index_ptr  :  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								String  Skeleton3D : : get_bone_name ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  " " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:42:32 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 07:53:18 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_name ( int  p_bone ,  const  String  & p_name )  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 07:53:18 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:42:32 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  * bone_index_ptr  =  name_to_bone_index . getptr ( p_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( bone_index_ptr  ! =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ERR_FAIL_COND_MSG ( * bone_index_ptr  ! =  p_bone ,  " Skeleton3D: ' "  +  get_name ( )  +  " ', bone name:  ' "  +  p_name  +  " ' already exists. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ;  // No need to rename, the bone already has the given name.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 07:53:18 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:42:32 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									name_to_bone_index . erase ( bones [ p_bone ] . name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . name  =  p_name ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:42:32 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									name_to_bone_index . insert ( p_name ,  p_bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-09 16:32:36 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									version + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 07:53:18 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Variant  Skeleton3D : : get_bone_meta ( int  p_bone ,  const  StringName  & p_key )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Variant ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! bones [ p_bone ] . metadata . has ( p_key ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  Variant ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . metadata [ p_key ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								TypedArray < StringName >  Skeleton3D : : _get_bone_meta_list_bind ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  TypedArray < StringName > ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									TypedArray < StringName >  _metaret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  KeyValue < StringName ,  Variant >  & K  :  bones [ p_bone ] . metadata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_metaret . push_back ( K . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  _metaret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : get_bone_meta_list ( int  p_bone ,  List < StringName >  * p_list )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  KeyValue < StringName ,  Variant >  & K  :  bones [ p_bone ] . metadata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										p_list - > push_back ( K . key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  Skeleton3D : : has_bone_meta ( int  p_bone ,  const  StringName  & p_key )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . metadata . has ( p_key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_meta ( int  p_bone ,  const  StringName  & p_key ,  const  Variant  & p_value )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( p_value . get_type ( )  = =  Variant : : NIL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( bones [ p_bone ] . metadata . has ( p_key ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bones [ p_bone ] . metadata . erase ( p_key ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . metadata . insert ( p_key ,  p_value ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  Skeleton3D : : is_bone_parent_of ( int  p_bone ,  int  p_parent_bone_id )  const  {  
						 
					
						
							
								
									
										
										
										
											2018-05-10 13:23:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  parent_of_bone  =  get_bone_parent ( p_bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( - 1  = =  parent_of_bone )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-10 13:23:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-10 13:23:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( parent_of_bone  = =  p_parent_bone_id )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-10 13:23:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-10 13:23:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  is_bone_parent_of ( parent_of_bone ,  p_parent_bone_id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  Skeleton3D : : get_bone_count ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_parent ( int  p_bone ,  int  p_parent )  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND ( p_parent  ! =  - 1  & &  ( p_parent  <  0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 11:30:45 +09:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND ( p_bone  = =  p_parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . parent  =  p_parent ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									process_order_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									rest_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : unparent_bone_and_rest ( int  p_bone )  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 18:06:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_update_process_order ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  parent  =  bones [ p_bone ] . parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( parent  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										bones [ p_bone ] . rest  =  bones [ parent ] . rest  *  bones [ p_bone ] . rest ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										parent  =  bones [ parent ] . parent ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 18:06:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . parent  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									process_order_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 18:06:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									rest_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 18:06:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  Skeleton3D : : get_bone_parent ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( process_order_dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_update_process_order ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < int >  Skeleton3D : : get_bone_children ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Vector < int > ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( process_order_dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_update_process_order ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  bones [ p_bone ] . child_bones ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < int >  Skeleton3D : : get_parentless_bones ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( process_order_dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_update_process_order ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-30 22:48:06 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  parentless_bones ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_rest ( int  p_bone ,  const  Transform3D  & p_rest )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . rest  =  p_rest ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									rest_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_rest ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  bones [ p_bone ] . rest ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_global_rest ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( rest_dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_force_update_all_bone_transforms ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . global_rest ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_enabled ( int  p_bone ,  bool  p_enabled )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . enabled  =  p_enabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:01:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									emit_signal ( SceneStringName ( bone_enabled_changed ) ,  p_bone ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  Skeleton3D : : is_bone_enabled ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . enabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_show_rest_only ( bool  p_enabled )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									show_rest_only  =  p_enabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:01:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									emit_signal ( SceneStringName ( show_rest_only_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_bone_global_poses_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  Skeleton3D : : is_show_rest_only ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  show_rest_only ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : clear_bones ( )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									bones . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 11:55:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									name_to_bone_index . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									process_order_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-21 07:27:48 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									version + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Posing api
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_pose ( int  p_bone ,  const  Transform3D  & p_pose )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_position  =  p_pose . origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_rotation  =  p_pose . basis . get_rotation_quaternion ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_scale  =  p_pose . basis . get_scale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_cache_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_pose_position ( int  p_bone ,  const  Vector3  & p_position )  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_position  =  p_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_cache_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-13 15:19:26 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-13 15:19:26 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_pose_rotation ( int  p_bone ,  const  Quaternion  & p_rotation )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_rotation  =  p_rotation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_cache_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_pose_scale ( int  p_bone ,  const  Vector3  & p_scale )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_scale  =  p_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . pose_cache_dirty  =  true ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Vector3  Skeleton3D : : get_bone_pose_position ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Vector3 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . pose_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Quaternion  Skeleton3D : : get_bone_pose_rotation ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Quaternion ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . pose_rotation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Vector3  Skeleton3D : : get_bone_pose_scale ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Vector3 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . pose_scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:46:28 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : reset_bone_pose ( int  p_bone )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set_bone_pose_position ( p_bone ,  bones [ p_bone ] . rest . origin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set_bone_pose_rotation ( p_bone ,  bones [ p_bone ] . rest . basis . get_rotation_quaternion ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									set_bone_pose_scale ( p_bone ,  bones [ p_bone ] . rest . basis . get_scale ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : reset_bone_poses ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:46:28 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										reset_bone_pose ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-17 01:08:21 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_pose ( int  p_bone )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . update_pose_cache ( ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  bones [ p_bone ] . pose_cache ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _make_dirty ( )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( dirty )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									dirty  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_update_deferred ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _update_deferred ( UpdateFlag  p_update_flag )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( is_inside_tree ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:57:37 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef TOOLS_ENABLED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( saving )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											update_flags  | =  p_update_flag ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											_notification ( NOTIFICATION_UPDATE_SKELETON ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  //TOOLS_ENABLED
  
						 
					
						
							
								
									
										
										
										
											2024-06-23 15:15:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( update_flags  = =  UPDATE_FLAG_NONE  & &  ! updating )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											notify_deferred_thread_group ( NOTIFICATION_UPDATE_SKELETON ) ;  // It must never be called more than once in a single frame.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										update_flags  | =  p_update_flag ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-10 18:45:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : localize_rests ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < int >  bones_to_process  =  get_parentless_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( bones_to_process . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  current_bone_idx  =  bones_to_process [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bones_to_process . erase ( current_bone_idx ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-19 11:48:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( bones [ current_bone_idx ] . parent  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											set_bone_rest ( current_bone_idx ,  bones [ bones [ current_bone_idx ] . parent ] . rest . affine_inverse ( )  *  bones [ current_bone_idx ] . rest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Add the bone's children to the list of bones to be processed.
 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										int  child_bone_size  =  bones [ current_bone_idx ] . child_bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  i  =  0 ;  i  <  child_bone_size ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bones_to_process . push_back ( bones [ current_bone_idx ] . child_bones [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-06 22:35:09 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _skin_changed ( )  {  
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-03 12:23:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < Skin >  Skeleton3D : : create_skin_from_rest_transforms ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < Skin >  skin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									skin . instantiate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									skin - > set_bind_count ( bones . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Pose changed, rebuild cache of inverses.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  Bone  * bonesptr  =  bones . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  len  =  bones . size ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Calculate global rests and invert them.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LocalVector < int >  bones_to_process ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones_to_process  =  get_parentless_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( bones_to_process . size ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  current_bone_idx  =  bones_to_process [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  Bone  & b  =  bonesptr [ current_bone_idx ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bones_to_process . erase ( current_bone_idx ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										LocalVector < int >  child_bones_vector ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										child_bones_vector  =  get_bone_children ( current_bone_idx ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										int  child_bones_size  =  child_bones_vector . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( b . parent  <  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											skin - > set_bind_pose ( current_bone_idx ,  b . rest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  i  =  0 ;  i  <  child_bones_size ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											int  child_bone_idx  =  child_bones_vector [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											const  Bone  & cb  =  bonesptr [ child_bone_idx ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											skin - > set_bind_pose ( child_bone_idx ,  skin - > get_bind_pose ( current_bone_idx )  *  cb . rest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Add the bone's children to the list of bones to be processed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											bones_to_process . push_back ( child_bones_vector [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  len ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// The inverse is what is actually required.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										skin - > set_bind_bone ( i ,  i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										skin - > set_bind_pose ( i ,  skin - > get_bind_pose ( i ) . affine_inverse ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  skin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Ref < SkinReference >  Skeleton3D : : register_skin ( const  Ref < Skin >  & p_skin )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( p_skin . is_null ( ) ,  Ref < SkinReference > ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  SkinReference  * E  :  skin_bindings )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( E - > skin  = =  p_skin )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  Ref < SkinReference > ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < SkinReference >  skin_ref ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skin_ref . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									skin_ref - > skeleton_node  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									skin_ref - > bind_count  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 15:21:27 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skin_ref - > skeleton  =  RenderingServer : : get_singleton ( ) - > skeleton_create ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skin_ref - > skeleton_node  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skin_ref - > skin  =  p_skin ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									skin_bindings . insert ( skin_ref . operator - > ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-03 21:29:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									skin_ref - > skin - > connect_changed ( callable_mp ( skin_ref . operator - > ( ) ,  & SkinReference : : _skin_changed ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-25 16:44:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ;  // Skin needs to be updated, so update skeleton.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-25 16:44:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  skin_ref ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-03 12:23:03 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-26 06:31:51 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : force_update_deferred ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : force_update_all_dirty_bones ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_force_update_all_dirty_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : _force_update_all_dirty_bones ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! dirty )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_force_update_all_bone_transforms ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : force_update_all_bone_transforms ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_force_update_all_bone_transforms ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : _force_update_all_bone_transforms ( )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_update_process_order ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  parentless_bones . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										_force_update_bone_children_transforms ( parentless_bones [ i ] ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 06:00:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( rest_dirty )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										rest_dirty  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const_cast < Skeleton3D  * > ( this ) - > emit_signal ( SNAME ( " rest_updated " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 06:00:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										rest_dirty  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									dirty  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( updating )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const_cast < Skeleton3D  * > ( this ) - > emit_signal ( SceneStringName ( pose_updated ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : force_update_bone_children_transforms ( int  p_bone_idx )  {  
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_force_update_bone_children_transforms ( p_bone_idx ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : _force_update_bone_children_transforms ( int  p_bone_idx )  const  {  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone_idx ,  bone_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Bone  * bonesptr  =  bones . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Loop through nested set.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  offset  =  0 ;  offset  <  bone_size ;  offset + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! bone_global_pose_dirty [ offset ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										int  current_bone_idx  =  nested_set_offset_to_bone_index [ offset ] ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Bone  & b  =  bonesptr [ current_bone_idx ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										bool  bone_enabled  =  b . enabled  & &  ! show_rest_only ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( bone_enabled )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											b . update_pose_cache ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Transform3D  pose  =  b . pose_cache ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( b . parent  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												b . global_pose  =  bonesptr [ b . parent ] . global_pose  *  pose ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												b . global_pose  =  pose ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( b . parent  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												b . global_pose  =  bonesptr [ b . parent ] . global_pose  *  b . rest ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												b . global_pose  =  b . rest ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( rest_dirty )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											b . global_rest  =  b . parent  > =  0  ?  bonesptr [ b . parent ] . global_rest  *  b . rest  :  b . rest ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( bone_enabled )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Transform3D  pose  =  b . pose_cache ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( b . parent  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												b . pose_global_no_override  =  bonesptr [ b . parent ] . pose_global_no_override  *  pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												b . pose_global_no_override  =  pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( b . parent  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												b . pose_global_no_override  =  bonesptr [ b . parent ] . pose_global_no_override  *  b . rest ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												b . pose_global_no_override  =  b . rest ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( b . global_pose_override_amount  > =  CMP_EPSILON )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											b . global_pose  =  b . global_pose . interpolate_with ( b . global_pose_override ,  b . global_pose_override_amount ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( b . global_pose_override_reset )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											b . global_pose_override_amount  =  0.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										bone_global_pose_dirty [ offset ]  =  false ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _find_modifiers ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! modifiers_dirty )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									modifiers . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  get_child_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SkeletonModifier3D  * c  =  Object : : cast_to < SkeletonModifier3D > ( get_child ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( c )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											modifiers . push_back ( c - > get_instance_id ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									modifiers_dirty  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : _process_modifiers ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  ObjectID  & oid  :  modifiers )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Object  * t_obj  =  ObjectDB : : get_instance ( oid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! t_obj )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SkeletonModifier3D  * mod  =  cast_to < SkeletonModifier3D > ( t_obj ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! mod )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-26 00:57:37 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef TOOLS_ENABLED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( saving  & &  ! mod - > is_processed_on_saving ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  //TOOLS_ENABLED
  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										real_t  influence  =  mod - > get_influence ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( influence  <  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											LocalVector < Transform3D >  old_poses ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( int  i  =  0 ;  i  <  get_bone_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												old_poses . push_back ( get_bone_pose ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											mod - > process_modification ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											LocalVector < Transform3D >  new_poses ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( int  i  =  0 ;  i  <  get_bone_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												new_poses . push_back ( get_bone_pose ( i ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( int  i  =  0 ;  i  <  get_bone_count ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( old_poses [ i ]  = =  new_poses [ i ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													continue ;  // Avoid unneeded calculation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set_bone_pose ( i ,  old_poses [ i ] . interpolate_with ( new_poses [ i ] ,  influence ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											mod - > process_modification ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										force_update_all_dirty_bones ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : add_child_notify ( Node  * p_child )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( Object : : cast_to < SkeletonModifier3D > ( p_child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_modifiers_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : move_child_notify ( Node  * p_child )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( Object : : cast_to < SkeletonModifier3D > ( p_child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_modifiers_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : remove_child_notify ( Node  * p_child )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( Object : : cast_to < SkeletonModifier3D > ( p_child ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_make_modifiers_dirty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  Skeleton3D : : _bind_methods ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " add_bone " ,  " name " ) ,  & Skeleton3D : : add_bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " find_bone " ,  " name " ) ,  & Skeleton3D : : find_bone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_name " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-15 07:53:18 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_name " ,  " bone_idx " ,  " name " ) ,  & Skeleton3D : : set_bone_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-30 22:40:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_meta " ,  " bone_idx " ,  " key " ) ,  & Skeleton3D : : get_bone_meta ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_meta_list " ,  " bone_idx " ) ,  & Skeleton3D : : _get_bone_meta_list_bind ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " has_bone_meta " ,  " bone_idx " ,  " key " ) ,  & Skeleton3D : : has_bone_meta ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_meta " ,  " bone_idx " ,  " key " ,  " value " ) ,  & Skeleton3D : : set_bone_meta ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-09 12:47:48 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_concatenated_bone_names " ) ,  & Skeleton3D : : get_concatenated_bone_names ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_parent " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_parent " ,  " bone_idx " ,  " parent_idx " ) ,  & Skeleton3D : : set_bone_parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_count " ) ,  & Skeleton3D : : get_bone_count ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-09 16:32:36 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_version " ) ,  & Skeleton3D : : get_version ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " unparent_bone_and_rest " ,  " bone_idx " ) ,  & Skeleton3D : : unparent_bone_and_rest ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_children " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_children ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_parentless_bones " ) ,  & Skeleton3D : : get_parentless_bones ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_rest " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_rest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_rest " ,  " bone_idx " ,  " rest " ) ,  & Skeleton3D : : set_bone_rest ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 21:07:46 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_global_rest " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_global_rest ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 18:06:15 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-13 09:37:40 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " create_skin_from_rest_transforms " ) ,  & Skeleton3D : : create_skin_from_rest_transforms ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " register_skin " ,  " skin " ) ,  & Skeleton3D : : register_skin ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " localize_rests " ) ,  & Skeleton3D : : localize_rests ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-16 11:38:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " clear_bones " ) ,  & Skeleton3D : : clear_bones ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_pose " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_pose ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_pose " ,  " bone_idx " ,  " pose " ) ,  & Skeleton3D : : set_bone_pose ) ; 
							 
						 
					
						
							
								
									
										
										
											
												Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
											 
										 
										
											2021-10-11 19:20:58 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_pose_position " ,  " bone_idx " ,  " position " ) ,  & Skeleton3D : : set_bone_pose_position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_pose_rotation " ,  " bone_idx " ,  " rotation " ) ,  & Skeleton3D : : set_bone_pose_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_pose_scale " ,  " bone_idx " ,  " scale " ) ,  & Skeleton3D : : set_bone_pose_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_pose_position " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_pose_position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_pose_rotation " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_pose_rotation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_pose_scale " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_pose_scale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-09 00:00:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:46:28 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " reset_bone_pose " ,  " bone_idx " ) ,  & Skeleton3D : : reset_bone_pose ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " reset_bone_poses " ) ,  & Skeleton3D : : reset_bone_poses ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " is_bone_enabled " ,  " bone_idx " ) ,  & Skeleton3D : : is_bone_enabled ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_enabled " ,  " bone_idx " ,  " enabled " ) ,  & Skeleton3D : : set_bone_enabled ,  DEFVAL ( true ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_global_pose " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_global_pose ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_global_pose " ,  " bone_idx " ,  " pose " ) ,  & Skeleton3D : : set_bone_global_pose ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " force_update_all_bone_transforms " ) ,  & Skeleton3D : : force_update_all_bone_transforms ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " force_update_bone_child_transform " ,  " bone_idx " ) ,  & Skeleton3D : : force_update_bone_children_transforms ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:48:08 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_motion_scale " ,  " motion_scale " ) ,  & Skeleton3D : : set_motion_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_motion_scale " ) ,  & Skeleton3D : : get_motion_scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 23:26:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_show_rest_only " ,  " enabled " ) ,  & Skeleton3D : : set_show_rest_only ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " is_show_rest_only " ) ,  & Skeleton3D : : is_show_rest_only ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_modifier_callback_mode_process " ,  " mode " ) ,  & Skeleton3D : : set_modifier_callback_mode_process ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_modifier_callback_mode_process " ) ,  & Skeleton3D : : get_modifier_callback_mode_process ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-03 18:49:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-26 18:48:08 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : FLOAT ,  " motion_scale " ,  PROPERTY_HINT_RANGE ,  " 0.001,10,0.001,or_greater " ) ,  " set_motion_scale " ,  " get_motion_scale " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL ,  " show_rest_only " ) ,  " set_show_rest_only " ,  " is_show_rest_only " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ADD_GROUP ( " Modifier " ,  " modifier_ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : INT ,  " modifier_callback_mode_process " ,  PROPERTY_HINT_ENUM ,  " Physics,Idle " ) ,  " set_modifier_callback_mode_process " ,  " get_modifier_callback_mode_process " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-01 11:54:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-05 06:00:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " rest_updated " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-19 11:48:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " pose_updated " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 20:39:39 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " skeleton_updated " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " bone_enabled_changed " ,  PropertyInfo ( Variant : : INT ,  " bone_idx " ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " bone_list_changed " ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ADD_SIGNAL ( MethodInfo ( " show_rest_only_changed " ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												New and improved IK system for Skeleton3D
This PR and commit adds a new IK system for 3D with the Skeleton3D node
that adds several new IK solvers, as well as additional changes and functionality
for making bone manipulation in Godot easier.
This work was sponsored by GSoC 2020 and TwistedTwigleg
Full list of changes:
* Adds a SkeletonModification3D resource
  * This resource is the base where all IK code is written and executed
* Adds a SkeletonModificationStack3D resource
  * This node oversees the execution of the modifications and acts as a bridge of sorts for the modifications to the Skeleton3D node
* Adds SkeletonModification3D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in it's own file
* Several changes to Skeletons, listed below:
  * Added local_pose_override, which acts just like global_pose_override but keeps bone-child relationships intract
    * So if you move a bone using local_pose_override, all of the bones that are children will also be moved. This is different than global_pose_override, which only affects the individual bone
  * Internally bones keep track of their children. This removes the need of a processing list, makes it possible to update just a few select bones at a time, and makes it easier to traverse down the bone chain
  * Additional functions added for converting from world transform to global poses, global poses to local poses, and all the same changes but backwards (local to global, global to world). This makes it much easier to work with bone transforms without needing to think too much about how to convert them.
  * New signal added, bone_pose_changed, that can be used to tell if a specific bone changed its transform. Needed for BoneAttachment3D
  * Added functions for getting the forward position of a bone
* BoneAttachment3D node refactored heavily
  * BoneAttachment3D node is now completely standalone in its functionality.
    * This makes the code easier and less interconnected, as well as allowing them to function properly without being direct children of Skeleton3D nodes
  * BoneAttachment3D now can be set either using the index or the bone name.
  * BoneAttachment3D nodes can now set the bone transform instead of just following it. This is disabled by default for compatibility
  * BoneAttachment3D now shows a warning when not configured correctly
* Added rotate_to_align function in Basis
* Added class reference documentation for all changes
											 
										 
										
											2020-08-03 17:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-05 16:44:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									BIND_CONSTANT ( NOTIFICATION_UPDATE_SKELETON ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									BIND_ENUM_CONSTANT ( MODIFIER_CALLBACK_MODE_PROCESS_IDLE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " clear_bones_global_pose_override " ) ,  & Skeleton3D : : clear_bones_global_pose_override ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_bone_global_pose_override " ,  " bone_idx " ,  " pose " ,  " amount " ,  " persistent " ) ,  & Skeleton3D : : set_bone_global_pose_override ,  DEFVAL ( false ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_global_pose_override " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_global_pose_override ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_bone_global_pose_no_override " ,  " bone_idx " ) ,  & Skeleton3D : : get_bone_global_pose_no_override ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " set_animate_physical_bones " ,  " enabled " ) ,  & Skeleton3D : : set_animate_physical_bones ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " get_animate_physical_bones " ) ,  & Skeleton3D : : get_animate_physical_bones ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " physical_bones_stop_simulation " ) ,  & Skeleton3D : : physical_bones_stop_simulation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " physical_bones_start_simulation " ,  " bones " ) ,  & Skeleton3D : : physical_bones_start_simulation_on ,  DEFVAL ( Array ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " physical_bones_add_collision_exception " ,  " exception " ) ,  & Skeleton3D : : physical_bones_add_collision_exception ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClassDB : : bind_method ( D_METHOD ( " physical_bones_remove_collision_exception " ,  " exception " ) ,  & Skeleton3D : : physical_bones_remove_collision_exception ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 09:20:40 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ADD_GROUP ( " Deprecated " ,  " " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ADD_PROPERTY ( PropertyInfo ( Variant : : BOOL ,  " animate_physical_bones " ) ,  " set_animate_physical_bones " ,  " get_animate_physical_bones " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifndef DISABLE_DEPRECATED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : clear_bones_global_pose_override ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( uint32_t  i  =  0 ;  i  <  bones . size ( ) ;  i  + =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bones [ i ] . global_pose_override_amount  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										bones [ i ] . global_pose_override_reset  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_bone_global_poses_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : set_bone_global_pose_override ( int  p_bone ,  const  Transform3D  & p_pose ,  real_t  p_amount ,  bool  p_persistent )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX ( p_bone ,  bone_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-29 19:36:56 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bones [ p_bone ] . global_pose_override_amount  =  p_amount ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . global_pose_override  =  p_pose ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bones [ p_bone ] . global_pose_override_reset  =  ! p_persistent ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_dirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-21 18:54:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_make_bone_global_pose_subtree_dirty ( p_bone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_global_pose_override ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  bones [ p_bone ] . global_pose_override ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Transform3D  Skeleton3D : : get_bone_global_pose_no_override ( int  p_bone )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  int  bone_size  =  bones . size ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_INDEX_V ( p_bone ,  bone_size ,  Transform3D ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-29 21:23:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_force_update_all_dirty_bones ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  bones [ p_bone ] . pose_global_no_override ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Node  * Skeleton3D : : get_simulator ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  simulator ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : set_animate_physical_bones ( bool  p_enabled )  {  
						 
					
						
							
								
									
										
										
										
											2024-07-13 09:20:40 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									animate_physical_bones  =  p_enabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  cast_to < PhysicalBoneSimulator3D > ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! sim )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 16:05:04 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									sim - > set_active ( animate_physical_bones  | |  sim - > is_simulating_physics ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  Skeleton3D : : get_animate_physical_bones ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2024-06-23 16:05:04 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  animate_physical_bones ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : physical_bones_stop_simulation ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  cast_to < PhysicalBoneSimulator3D > ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! sim )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > physical_bones_stop_simulation ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 16:05:04 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									sim - > set_active ( animate_physical_bones  | |  sim - > is_simulating_physics ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : physical_bones_start_simulation_on ( const  TypedArray < StringName >  & p_bones )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  cast_to < PhysicalBoneSimulator3D > ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! sim )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > set_active ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > physical_bones_start_simulation_on ( p_bones ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : physical_bones_add_collision_exception ( RID  p_exception )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  cast_to < PhysicalBoneSimulator3D > ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! sim )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > physical_bones_add_collision_exception ( p_exception ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  Skeleton3D : : physical_bones_remove_collision_exception ( RID  p_exception )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PhysicalBoneSimulator3D  * sim  =  cast_to < PhysicalBoneSimulator3D > ( simulator ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! sim )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sim - > physical_bones_remove_collision_exception ( p_exception ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2024-01-28 09:11:43 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif  // _DISABLE_DEPRECATED
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Skeleton3D : : Skeleton3D ( )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-26 18:49:16 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Skeleton3D : : ~ Skeleton3D ( )  {  
						 
					
						
							
								
									
										
										
										
											2021-02-04 17:20:26 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Some skins may remain bound.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( SkinReference  * E  :  skin_bindings )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										E - > skeleton_node  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-18 19:46:32 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}