summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-09-24 18:06:15 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-09-24 18:06:15 -0300
commit82a3304458738b410a5aff8994ce587413aeb464 (patch)
treeb54672bc649a80ebbe1e11b0488c7dfdc6c109e7 /scene
parent59e1ad27731e66c58a3d5ee9d783eac74a1d48d9 (diff)
Added ability to set custom mouse cursors. Not hardware accelerated yet.
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/skeleton.cpp99
-rw-r--r--scene/3d/skeleton.h8
2 files changed, 89 insertions, 18 deletions
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 9df29f70ec..4712ba308a 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -187,30 +187,59 @@ void Skeleton::_notification(int p_what) {
Bone &b=bonesptr[i];
- if (b.enabled) {
+ if (b.disable_rest) {
+ if (b.enabled) {
- Transform pose=b.pose;
- if (b.custom_pose_enable) {
+ Transform pose=b.pose;
+ if (b.custom_pose_enable) {
- pose = b.custom_pose * pose;
- }
+ pose = b.custom_pose * pose;
+ }
+
+ if (b.parent>=0) {
+
+ b.pose_global=bonesptr[b.parent].pose_global * pose;
+ } else {
- if (b.parent>=0) {
-
- b.pose_global=bonesptr[b.parent].pose_global * (b.rest * pose);
+ b.pose_global=pose;
+ }
} else {
-
- b.pose_global=b.rest * pose;
+
+ if (b.parent>=0) {
+
+ b.pose_global=bonesptr[b.parent].pose_global;
+ } else {
+
+ b.pose_global=Transform();
+ }
}
+
} else {
-
- if (b.parent>=0) {
-
- b.pose_global=bonesptr[b.parent].pose_global * b.rest;
+ if (b.enabled) {
+
+ Transform pose=b.pose;
+ if (b.custom_pose_enable) {
+
+ pose = b.custom_pose * pose;
+ }
+
+ if (b.parent>=0) {
+
+ b.pose_global=bonesptr[b.parent].pose_global * (b.rest * pose);
+ } else {
+
+ b.pose_global=b.rest * pose;
+ }
} else {
-
- b.pose_global=b.rest;
- }
+
+ if (b.parent>=0) {
+
+ b.pose_global=bonesptr[b.parent].pose_global * b.rest;
+ } else {
+
+ b.pose_global=b.rest;
+ }
+ }
}
vs->skeleton_bone_set_transform( skeleton, i, b.pose_global * b.rest_global_inverse );
@@ -315,6 +344,37 @@ void Skeleton::set_bone_parent(int p_bone, int p_parent) {
_make_dirty();
}
+void Skeleton::unparent_bone_and_rest(int p_bone) {
+
+ ERR_FAIL_INDEX( p_bone, bones.size() );
+
+ int parent=bones[p_bone].parent;
+ while(parent>=0) {
+ bones[p_bone].rest = bones[parent].rest * bones[p_bone].rest;
+ parent=bones[parent].parent;
+ }
+
+ bones[p_bone].parent=-1;
+ bones[p_bone].rest_global_inverse=bones[p_bone].rest.affine_inverse(); //same thing
+
+ _make_dirty();
+
+}
+
+void Skeleton::set_bone_disable_rest(int p_bone, bool p_disable) {
+
+ ERR_FAIL_INDEX( p_bone, bones.size() );
+ bones[p_bone].disable_rest=p_disable;
+
+}
+
+bool Skeleton::is_bone_rest_disabled(int p_bone) const {
+
+ ERR_FAIL_INDEX_V( p_bone, bones.size(), false );
+ return bones[p_bone].disable_rest;
+}
+
+
int Skeleton::get_bone_parent(int p_bone) const {
ERR_FAIL_INDEX_V( p_bone, bones.size(), -1 );
@@ -522,9 +582,14 @@ void Skeleton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
+ ObjectTypeDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
+
ObjectTypeDB::bind_method(_MD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
ObjectTypeDB::bind_method(_MD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
+ ObjectTypeDB::bind_method(_MD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
+ ObjectTypeDB::bind_method(_MD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
+
ObjectTypeDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
ObjectTypeDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
ObjectTypeDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index b7f84f44c9..6678722d12 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -46,6 +46,7 @@ class Skeleton : public Spatial {
bool enabled;
int parent;
+ bool disable_rest;
Transform rest;
Transform rest_global_inverse;
@@ -57,7 +58,7 @@ class Skeleton : public Spatial {
List<uint32_t> nodes_bound;
- Bone() { parent=-1; enabled=true; custom_pose_enable=false; }
+ Bone() { parent=-1; enabled=true; custom_pose_enable=false; disable_rest=false; }
};
bool rest_global_inverse_dirty;
@@ -111,6 +112,11 @@ public:
void set_bone_parent(int p_bone, int p_parent);
int get_bone_parent(int p_bone) const;
+ void unparent_bone_and_rest(int p_idx);
+
+ void set_bone_disable_rest(int p_bone, bool p_disable);
+ bool is_bone_rest_disabled(int p_bone) const;
+
int get_bone_count() const;
void set_bone_rest(int p_bone, const Transform& p_rest);