bone_attachment_3d.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**************************************************************************/
  2. /* bone_attachment_3d.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef BONE_ATTACHMENT_3D_H
  31. #define BONE_ATTACHMENT_3D_H
  32. #include "scene/3d/skeleton_3d.h"
  33. #ifdef TOOLS_ENABLED
  34. #include "scene/resources/bone_map.h"
  35. #endif // TOOLS_ENABLED
  36. class BoneAttachment3D : public Node3D {
  37. GDCLASS(BoneAttachment3D, Node3D);
  38. bool bound = false;
  39. String bone_name;
  40. int bone_idx = -1;
  41. bool override_pose = false;
  42. bool _override_dirty = false;
  43. bool overriding = false;
  44. bool use_external_skeleton = false;
  45. NodePath external_skeleton_node;
  46. ObjectID external_skeleton_node_cache;
  47. void _check_bind();
  48. void _check_unbind();
  49. bool updating = false;
  50. void _transform_changed();
  51. void _update_external_skeleton_cache();
  52. protected:
  53. void _validate_property(PropertyInfo &p_property) const;
  54. bool _get(const StringName &p_path, Variant &r_ret) const;
  55. bool _set(const StringName &p_path, const Variant &p_value);
  56. void _get_property_list(List<PropertyInfo> *p_list) const;
  57. void _notification(int p_what);
  58. static void _bind_methods();
  59. #ifndef DISABLE_DEPRECATED
  60. virtual void _on_bone_pose_update_bind_compat_90575(int p_bone_index);
  61. static void _bind_compatibility_methods();
  62. #endif
  63. public:
  64. #ifdef TOOLS_ENABLED
  65. virtual void notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map);
  66. #endif // TOOLS_ENABLED
  67. virtual PackedStringArray get_configuration_warnings() const override;
  68. Skeleton3D *get_skeleton();
  69. void set_bone_name(const String &p_name);
  70. String get_bone_name() const;
  71. void set_bone_idx(const int &p_idx);
  72. int get_bone_idx() const;
  73. void set_override_pose(bool p_override);
  74. bool get_override_pose() const;
  75. void set_use_external_skeleton(bool p_external_skeleton);
  76. bool get_use_external_skeleton() const;
  77. void set_external_skeleton(NodePath p_skeleton);
  78. NodePath get_external_skeleton() const;
  79. virtual void on_skeleton_update();
  80. #ifdef TOOLS_ENABLED
  81. virtual void notify_rebind_required();
  82. #endif
  83. BoneAttachment3D();
  84. };
  85. #endif // BONE_ATTACHMENT_3D_H