mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Dictionary Node2D::_edit_get_state() const {
|
||||
|
||||
Dictionary state;
|
||||
state["position"] = get_position();
|
||||
state["rotation"] = get_rotation();
|
||||
@@ -47,7 +46,6 @@ Dictionary Node2D::_edit_get_state() const {
|
||||
}
|
||||
|
||||
void Node2D::_edit_set_state(const Dictionary &p_state) {
|
||||
|
||||
pos = p_state["position"];
|
||||
angle = p_state["rotation"];
|
||||
_scale = p_state["scale"];
|
||||
@@ -124,7 +122,6 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
|
||||
#endif
|
||||
|
||||
void Node2D::_update_xform_values() {
|
||||
|
||||
pos = _mat.elements[2];
|
||||
angle = _mat.get_rotation();
|
||||
_scale = _mat.get_scale();
|
||||
@@ -132,7 +129,6 @@ void Node2D::_update_xform_values() {
|
||||
}
|
||||
|
||||
void Node2D::_update_transform() {
|
||||
|
||||
_mat.set_rotation_and_scale(angle, _scale);
|
||||
_mat.elements[2] = pos;
|
||||
|
||||
@@ -145,7 +141,6 @@ void Node2D::_update_transform() {
|
||||
}
|
||||
|
||||
void Node2D::set_position(const Point2 &p_pos) {
|
||||
|
||||
if (_xform_dirty)
|
||||
((Node2D *)this)->_update_xform_values();
|
||||
pos = p_pos;
|
||||
@@ -154,7 +149,6 @@ void Node2D::set_position(const Point2 &p_pos) {
|
||||
}
|
||||
|
||||
void Node2D::set_rotation(float p_radians) {
|
||||
|
||||
if (_xform_dirty)
|
||||
((Node2D *)this)->_update_xform_values();
|
||||
angle = p_radians;
|
||||
@@ -164,12 +158,10 @@ void Node2D::set_rotation(float p_radians) {
|
||||
}
|
||||
|
||||
void Node2D::set_rotation_degrees(float p_degrees) {
|
||||
|
||||
set_rotation(Math::deg2rad(p_degrees));
|
||||
}
|
||||
|
||||
void Node2D::set_scale(const Size2 &p_scale) {
|
||||
|
||||
if (_xform_dirty)
|
||||
((Node2D *)this)->_update_xform_values();
|
||||
_scale = p_scale;
|
||||
@@ -183,7 +175,6 @@ void Node2D::set_scale(const Size2 &p_scale) {
|
||||
}
|
||||
|
||||
Point2 Node2D::get_position() const {
|
||||
|
||||
if (_xform_dirty)
|
||||
((Node2D *)this)->_update_xform_values();
|
||||
return pos;
|
||||
@@ -197,7 +188,6 @@ float Node2D::get_rotation() const {
|
||||
}
|
||||
|
||||
float Node2D::get_rotation_degrees() const {
|
||||
|
||||
return Math::rad2deg(get_rotation());
|
||||
}
|
||||
|
||||
@@ -209,32 +199,26 @@ Size2 Node2D::get_scale() const {
|
||||
}
|
||||
|
||||
Transform2D Node2D::get_transform() const {
|
||||
|
||||
return _mat;
|
||||
}
|
||||
|
||||
void Node2D::rotate(float p_radians) {
|
||||
|
||||
set_rotation(get_rotation() + p_radians);
|
||||
}
|
||||
|
||||
void Node2D::translate(const Vector2 &p_amount) {
|
||||
|
||||
set_position(get_position() + p_amount);
|
||||
}
|
||||
|
||||
void Node2D::global_translate(const Vector2 &p_amount) {
|
||||
|
||||
set_global_position(get_global_position() + p_amount);
|
||||
}
|
||||
|
||||
void Node2D::apply_scale(const Size2 &p_amount) {
|
||||
|
||||
set_scale(get_scale() * p_amount);
|
||||
}
|
||||
|
||||
void Node2D::move_x(float p_delta, bool p_scaled) {
|
||||
|
||||
Transform2D t = get_transform();
|
||||
Vector2 m = t[0];
|
||||
if (!p_scaled)
|
||||
@@ -243,7 +227,6 @@ void Node2D::move_x(float p_delta, bool p_scaled) {
|
||||
}
|
||||
|
||||
void Node2D::move_y(float p_delta, bool p_scaled) {
|
||||
|
||||
Transform2D t = get_transform();
|
||||
Vector2 m = t[1];
|
||||
if (!p_scaled)
|
||||
@@ -252,12 +235,10 @@ void Node2D::move_y(float p_delta, bool p_scaled) {
|
||||
}
|
||||
|
||||
Point2 Node2D::get_global_position() const {
|
||||
|
||||
return get_global_transform().get_origin();
|
||||
}
|
||||
|
||||
void Node2D::set_global_position(const Point2 &p_pos) {
|
||||
|
||||
Transform2D inv;
|
||||
CanvasItem *pi = get_parent_item();
|
||||
if (pi) {
|
||||
@@ -269,12 +250,10 @@ void Node2D::set_global_position(const Point2 &p_pos) {
|
||||
}
|
||||
|
||||
float Node2D::get_global_rotation() const {
|
||||
|
||||
return get_global_transform().get_rotation();
|
||||
}
|
||||
|
||||
void Node2D::set_global_rotation(float p_radians) {
|
||||
|
||||
CanvasItem *pi = get_parent_item();
|
||||
if (pi) {
|
||||
const float parent_global_rot = pi->get_global_transform().get_rotation();
|
||||
@@ -285,22 +264,18 @@ void Node2D::set_global_rotation(float p_radians) {
|
||||
}
|
||||
|
||||
float Node2D::get_global_rotation_degrees() const {
|
||||
|
||||
return Math::rad2deg(get_global_rotation());
|
||||
}
|
||||
|
||||
void Node2D::set_global_rotation_degrees(float p_degrees) {
|
||||
|
||||
set_global_rotation(Math::deg2rad(p_degrees));
|
||||
}
|
||||
|
||||
Size2 Node2D::get_global_scale() const {
|
||||
|
||||
return get_global_transform().get_scale();
|
||||
}
|
||||
|
||||
void Node2D::set_global_scale(const Size2 &p_scale) {
|
||||
|
||||
CanvasItem *pi = get_parent_item();
|
||||
if (pi) {
|
||||
const Size2 parent_global_scale = pi->get_global_transform().get_scale();
|
||||
@@ -311,7 +286,6 @@ void Node2D::set_global_scale(const Size2 &p_scale) {
|
||||
}
|
||||
|
||||
void Node2D::set_transform(const Transform2D &p_transform) {
|
||||
|
||||
_mat = p_transform;
|
||||
_xform_dirty = true;
|
||||
|
||||
@@ -324,7 +298,6 @@ void Node2D::set_transform(const Transform2D &p_transform) {
|
||||
}
|
||||
|
||||
void Node2D::set_global_transform(const Transform2D &p_transform) {
|
||||
|
||||
CanvasItem *pi = get_parent_item();
|
||||
if (pi)
|
||||
set_transform(pi->get_global_transform().affine_inverse() * p_transform);
|
||||
@@ -333,7 +306,6 @@ void Node2D::set_global_transform(const Transform2D &p_transform) {
|
||||
}
|
||||
|
||||
void Node2D::set_z_index(int p_z) {
|
||||
|
||||
ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN);
|
||||
ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX);
|
||||
z_index = p_z;
|
||||
@@ -342,7 +314,6 @@ void Node2D::set_z_index(int p_z) {
|
||||
}
|
||||
|
||||
void Node2D::set_z_as_relative(bool p_enabled) {
|
||||
|
||||
if (z_relative == p_enabled)
|
||||
return;
|
||||
z_relative = p_enabled;
|
||||
@@ -350,17 +321,14 @@ void Node2D::set_z_as_relative(bool p_enabled) {
|
||||
}
|
||||
|
||||
bool Node2D::is_z_relative() const {
|
||||
|
||||
return z_relative;
|
||||
}
|
||||
|
||||
int Node2D::get_z_index() const {
|
||||
|
||||
return z_index;
|
||||
}
|
||||
|
||||
Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const {
|
||||
|
||||
if (p_parent == this)
|
||||
return Transform2D();
|
||||
|
||||
@@ -374,27 +342,22 @@ Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const
|
||||
}
|
||||
|
||||
void Node2D::look_at(const Vector2 &p_pos) {
|
||||
|
||||
rotate(get_angle_to(p_pos));
|
||||
}
|
||||
|
||||
float Node2D::get_angle_to(const Vector2 &p_pos) const {
|
||||
|
||||
return (to_local(p_pos) * get_scale()).angle();
|
||||
}
|
||||
|
||||
Point2 Node2D::to_local(Point2 p_global) const {
|
||||
|
||||
return get_global_transform().affine_inverse().xform(p_global);
|
||||
}
|
||||
|
||||
Point2 Node2D::to_global(Point2 p_local) const {
|
||||
|
||||
return get_global_transform().xform(p_local);
|
||||
}
|
||||
|
||||
void Node2D::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
|
||||
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees);
|
||||
@@ -457,7 +420,6 @@ void Node2D::_bind_methods() {
|
||||
}
|
||||
|
||||
Node2D::Node2D() {
|
||||
|
||||
angle = 0;
|
||||
_scale = Vector2(1, 1);
|
||||
_xform_dirty = false;
|
||||
|
||||
Reference in New Issue
Block a user