diff options
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/path_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/path_3d.h | 2 | ||||
-rw-r--r-- | scene/3d/skeleton_3d.cpp | 14 | ||||
-rw-r--r-- | scene/3d/skeleton_3d.h | 14 |
4 files changed, 25 insertions, 11 deletions
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index dcfdf8efcf..40d988ff9f 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -77,15 +77,11 @@ void Path3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_curve", "curve"), &Path3D::set_curve); ClassDB::bind_method(D_METHOD("get_curve"), &Path3D::get_curve); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), "set_curve", "get_curve"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_curve", "get_curve"); ADD_SIGNAL(MethodInfo("curve_changed")); } -Path3D::Path3D() { - set_curve(Ref<Curve3D>(memnew(Curve3D))); //create one by default -} - ////////////// void PathFollow3D::_update_transform() { diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index 5a33016bc6..7f227a8a6f 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -49,7 +49,7 @@ public: void set_curve(const Ref<Curve3D> &p_curve); Ref<Curve3D> get_curve() const; - Path3D(); + Path3D() {} }; class PathFollow3D : public Node3D { diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index a09424fa17..6723ca04b9 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -67,6 +67,8 @@ SkinReference::~SkinReference() { RS::get_singleton()->free(skeleton); } +/////////////////////////////////////// + bool Skeleton3D::_set(const StringName &p_path, const Variant &p_value) { String path = p_path; @@ -853,6 +855,15 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { return skin_ref; } +// helper functions +Transform Skeleton3D::bone_transform_to_world_transform(Transform p_bone_transform) { + return get_global_transform() * p_bone_transform; +} + +Transform Skeleton3D::world_transform_to_bone_transform(Transform p_world_transform) { + return get_global_transform().affine_inverse() * p_world_transform; +} + void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone_process_orders"), &Skeleton3D::get_bone_process_orders); ClassDB::bind_method(D_METHOD("add_bone", "name"), &Skeleton3D::add_bone); @@ -892,6 +903,9 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton3D::get_bone_custom_pose); ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton3D::set_bone_custom_pose); + ClassDB::bind_method(D_METHOD("bone_transform_to_world_transform", "bone_transform"), &Skeleton3D::bone_transform_to_world_transform); + ClassDB::bind_method(D_METHOD("world_transform_to_bone_transform", "world_transform"), &Skeleton3D::world_transform_to_bone_transform); + #ifndef _3D_DISABLED ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton3D::set_animate_physical_bones); diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index 66706a9450..a21891a32e 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -71,10 +71,6 @@ class Skeleton3D : public Node3D { private: friend class SkinReference; - Set<SkinReference *> skin_bindings; - - void _skin_changed(); - struct Bone { String name; @@ -116,6 +112,10 @@ private: } }; + Set<SkinReference *> skin_bindings; + + void _skin_changed(); + bool animate_physical_bones; Vector<Bone> bones; Vector<int> process_order; @@ -200,6 +200,10 @@ public: Ref<SkinReference> register_skin(const Ref<Skin> &p_skin); + // Helper functions + Transform bone_transform_to_world_transform(Transform p_transform); + Transform world_transform_to_bone_transform(Transform p_transform); + #ifndef _3D_DISABLED // Physical bone API @@ -213,7 +217,7 @@ public: PhysicalBone3D *get_physical_bone_parent(int p_bone); private: - /// This is a slow API os it's cached + /// This is a slow API, so it's cached PhysicalBone3D *_get_physical_bone_parent(int p_bone); void _rebuild_physical_bones_cache(); |