1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Merge pull request #9791 from bojidar-bg/6087-add-global-local-conv

Add .to_local/.to_global methods on Node2D and Spatial
This commit is contained in:
Rémi Verschelde
2017-07-24 22:24:34 +02:00
committed by GitHub
4 changed files with 32 additions and 0 deletions

View File

@@ -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);