summaryrefslogtreecommitdiffstats
path: root/scene/3d/bone_attachment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/bone_attachment.cpp')
-rw-r--r--scene/3d/bone_attachment.cpp65
1 files changed, 30 insertions, 35 deletions
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index 1a2680e3b8..d8cb2dfdac 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -28,19 +28,19 @@
/*************************************************************************/
#include "bone_attachment.h"
-bool BoneAttachment::_get(const StringName& p_name,Variant &r_ret) const {
+bool BoneAttachment::_get(const StringName &p_name, Variant &r_ret) const {
- if (String(p_name)=="bone_name") {
+ if (String(p_name) == "bone_name") {
- r_ret=get_bone_name();
+ r_ret = get_bone_name();
return true;
}
return false;
}
-bool BoneAttachment::_set(const StringName& p_name, const Variant& p_value){
+bool BoneAttachment::_set(const StringName &p_name, const Variant &p_value) {
- if (String(p_name)=="bone_name") {
+ if (String(p_name) == "bone_name") {
set_bone_name(p_value);
return true;
@@ -48,40 +48,37 @@ bool BoneAttachment::_set(const StringName& p_name, const Variant& p_value){
return false;
}
-void BoneAttachment::_get_property_list( List<PropertyInfo>* p_list ) const{
+void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
- Skeleton *parent=NULL;
- if(get_parent())
- parent=get_parent()->cast_to<Skeleton>();
+ Skeleton *parent = NULL;
+ if (get_parent())
+ parent = get_parent()->cast_to<Skeleton>();
if (parent) {
String names;
- for(int i=0;i<parent->get_bone_count();i++) {
- if(i>0)
- names+=",";
- names+=parent->get_bone_name(i);
+ for (int i = 0; i < parent->get_bone_count(); i++) {
+ if (i > 0)
+ names += ",";
+ names += parent->get_bone_name(i);
}
- p_list->push_back(PropertyInfo(Variant::STRING,"bone_name",PROPERTY_HINT_ENUM,names));
+ p_list->push_back(PropertyInfo(Variant::STRING, "bone_name", PROPERTY_HINT_ENUM, names));
} else {
- p_list->push_back(PropertyInfo(Variant::STRING,"bone_name"));
-
+ p_list->push_back(PropertyInfo(Variant::STRING, "bone_name"));
}
-
}
-
void BoneAttachment::_check_bind() {
if (get_parent() && get_parent()->cast_to<Skeleton>()) {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
- if (idx!=-1) {
- sk->bind_child_node_to_bone(idx,this);
+ if (idx != -1) {
+ sk->bind_child_node_to_bone(idx, this);
set_transform(sk->get_bone_global_pose(idx));
- bound=true;
+ bound = true;
}
}
}
@@ -93,33 +90,33 @@ void BoneAttachment::_check_unbind() {
if (get_parent() && get_parent()->cast_to<Skeleton>()) {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
- if (idx!=-1) {
- sk->unbind_child_node_from_bone(idx,this);
+ if (idx != -1) {
+ sk->unbind_child_node_from_bone(idx, this);
}
}
- bound=false;
+ bound = false;
}
}
-void BoneAttachment::set_bone_name(const String& p_name) {
+void BoneAttachment::set_bone_name(const String &p_name) {
if (is_inside_tree())
_check_unbind();
- bone_name=p_name;
+ bone_name = p_name;
if (is_inside_tree())
_check_bind();
}
-String BoneAttachment::get_bone_name() const{
+String BoneAttachment::get_bone_name() const {
return bone_name;
}
void BoneAttachment::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -132,13 +129,11 @@ void BoneAttachment::_notification(int p_what) {
}
}
-BoneAttachment::BoneAttachment()
-{
- bound=false;
-
+BoneAttachment::BoneAttachment() {
+ bound = false;
}
-void BoneAttachment::_bind_methods(){
- ClassDB::bind_method(D_METHOD("set_bone_name","bone_name"),&BoneAttachment::set_bone_name);
- ClassDB::bind_method(D_METHOD("get_bone_name"),&BoneAttachment::get_bone_name);
+void BoneAttachment::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name);
+ ClassDB::bind_method(D_METHOD("get_bone_name"), &BoneAttachment::get_bone_name);
}