diff options
| author | Rémi Verschelde | 2017-07-24 22:24:34 +0200 |
|---|---|---|
| committer | GitHub | 2017-07-24 22:24:34 +0200 |
| commit | 0a74fb625e55743e32aa0977191d936e94df235c (patch) | |
| tree | 4e3f6b33ee11917b4fef48a4f0cb527782d8e6b1 /scene/3d/spatial.cpp | |
| parent | e6336a52a89e900201f5b6e784f0dec153229a19 (diff) | |
| parent | 140f189a65f991d5b44d49ad6b710f7512862d16 (diff) | |
| download | godot-0a74fb625e55743e32aa0977191d936e94df235c.tar.gz godot-0a74fb625e55743e32aa0977191d936e94df235c.tar.zst godot-0a74fb625e55743e32aa0977191d936e94df235c.zip | |
Diffstat (limited to 'scene/3d/spatial.cpp')
| -rw-r--r-- | scene/3d/spatial.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 25e906463..6106b0904 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -674,6 +674,16 @@ void Spatial::look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, co set_global_transform(lookat); } +Vector3 Spatial::to_local(Vector3 p_global) const { + + return get_global_transform().affine_inverse().xform(p_global); +} + +Vector3 Spatial::to_global(Vector3 p_local) const { + + return get_global_transform().xform(p_local); +} + void Spatial::set_notify_transform(bool p_enable) { data.notify_transform = p_enable; } @@ -756,6 +766,9 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("look_at", "target", "up"), &Spatial::look_at); ClassDB::bind_method(D_METHOD("look_at_from_pos", "pos", "target", "up"), &Spatial::look_at_from_pos); + ClassDB::bind_method(D_METHOD("to_local", "global_point"), &Spatial::to_local); + ClassDB::bind_method(D_METHOD("to_global", "local_point"), &Spatial::to_global); + BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED); BIND_CONSTANT(NOTIFICATION_ENTER_WORLD); BIND_CONSTANT(NOTIFICATION_EXIT_WORLD); |
