diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-05-04 16:46:32 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-05-04 16:46:32 -0300 |
commit | bf561c49468c9a4d5c47ba7bc53204a51270855f (patch) | |
tree | a389de4158322cb6a20fab46ab9147bb20a062d3 /scene | |
parent | e68cbec1fa76ea082671682dcc309d47cf812e7a (diff) |
Made bone handling for actual Bone2D a special case. Make custom bones appear like a custom (less important) option now.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/skeleton_2d.cpp | 15 | ||||
-rw-r--r-- | scene/2d/skeleton_2d.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/2d/skeleton_2d.cpp b/scene/2d/skeleton_2d.cpp index 9197127235..2363c791fa 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/scene/2d/skeleton_2d.cpp @@ -56,7 +56,11 @@ void Bone2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_skeleton_rest"), &Bone2D::get_skeleton_rest); ClassDB::bind_method(D_METHOD("get_index_in_skeleton"), &Bone2D::get_index_in_skeleton); + ClassDB::bind_method(D_METHOD("set_default_length", "default_length"), &Bone2D::set_default_length); + ClassDB::bind_method(D_METHOD("get_default_length"), &Bone2D::get_default_length); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"rest"),"set_rest","get_rest"); + ADD_PROPERTY(PropertyInfo(Variant::REAL,"default_length",PROPERTY_HINT_RANGE,"1,1024,1"),"set_default_length","get_default_length"); } void Bone2D::set_rest(const Transform2D &p_rest) { @@ -84,6 +88,16 @@ void Bone2D::apply_rest() { set_transform(rest); } +void Bone2D::set_default_length(float p_length) { + + default_length=p_length; + +} + +float Bone2D::get_default_length() const { + return default_length; +} + int Bone2D::get_index_in_skeleton() const { ERR_FAIL_COND_V(!skeleton,-1); skeleton->_update_bone_setup(); @@ -118,6 +132,7 @@ Bone2D::Bone2D() { skeleton = NULL; parent_bone = NULL; skeleton_index=-1; + default_length=16; set_notify_local_transform(true); //this is a clever hack so the bone knows no rest has been set yet, allowing to show an error. for(int i=0;i<3;i++) { diff --git a/scene/2d/skeleton_2d.h b/scene/2d/skeleton_2d.h index 9ae74b56d3..cd270dac85 100644 --- a/scene/2d/skeleton_2d.h +++ b/scene/2d/skeleton_2d.h @@ -11,6 +11,7 @@ class Bone2D : public Node2D { Bone2D *parent_bone; Skeleton2D *skeleton; Transform2D rest; + float default_length; friend class Skeleton2D; int skeleton_index; @@ -27,6 +28,9 @@ public: String get_configuration_warning() const; + void set_default_length(float p_length); + float get_default_length() const; + int get_index_in_skeleton() const; Bone2D(); |