2
0

bone_constraint_3d.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**************************************************************************/
  2. /* bone_constraint_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. #pragma once
  31. #include "scene/3d/skeleton_modifier_3d.h"
  32. class BoneConstraint3D : public SkeletonModifier3D {
  33. GDCLASS(BoneConstraint3D, SkeletonModifier3D);
  34. public:
  35. struct BoneConstraint3DSetting {
  36. float amount = 1.0;
  37. String apply_bone_name;
  38. int apply_bone = -1;
  39. String reference_bone_name;
  40. int reference_bone = -1;
  41. };
  42. protected:
  43. Vector<BoneConstraint3DSetting *> settings;
  44. bool _get(const StringName &p_path, Variant &r_ret) const;
  45. bool _set(const StringName &p_path, const Variant &p_value);
  46. // Define get_property_list() instead of _get_property_list()
  47. // to merge child class properties into parent class array inspector.
  48. void get_property_list(List<PropertyInfo> *p_list) const; // Will be called by child classes.
  49. virtual void _validate_bone_names() override;
  50. static void _bind_methods();
  51. virtual void _process_modification(double p_delta) override;
  52. virtual void _process_constraint(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount);
  53. virtual void _validate_setting(int p_index);
  54. public:
  55. void set_amount(int p_index, float p_amount);
  56. float get_amount(int p_index) const;
  57. void set_apply_bone_name(int p_index, const String &p_bone_name);
  58. String get_apply_bone_name(int p_index) const;
  59. void set_apply_bone(int p_index, int p_bone);
  60. int get_apply_bone(int p_index) const;
  61. void set_reference_bone_name(int p_index, const String &p_bone_name);
  62. String get_reference_bone_name(int p_index) const;
  63. void set_reference_bone(int p_index, int p_bone);
  64. int get_reference_bone(int p_index) const;
  65. void set_setting_count(int p_count);
  66. int get_setting_count() const;
  67. void clear_settings();
  68. static double symmetrize_angle(double p_angle); // Helper to make angle 0->TAU become -PI->PI.
  69. static double get_roll_angle(const Quaternion &p_rotation, const Vector3 &p_roll_axis);
  70. ~BoneConstraint3D();
  71. };