mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 20:23:53 +00:00
Fix for #6158. Converting Vector2 to Size2 for scaling functions.
This commit is contained in:
parent
c05ff0577f
commit
aa5ade834c
@ -475,18 +475,18 @@ Matrix32::Matrix32(real_t p_rot, const Vector2& p_pos) {
|
||||
elements[2]=p_pos;
|
||||
}
|
||||
|
||||
Vector2 Matrix32::get_scale() const {
|
||||
Size2 Matrix32::get_scale() const {
|
||||
|
||||
return Vector2( elements[0].length(), elements[1].length() );
|
||||
return Size2( elements[0].length(), elements[1].length() );
|
||||
}
|
||||
|
||||
void Matrix32::scale(const Vector2& p_scale) {
|
||||
void Matrix32::scale(const Size2& p_scale) {
|
||||
|
||||
elements[0]*=p_scale;
|
||||
elements[1]*=p_scale;
|
||||
elements[2]*=p_scale;
|
||||
}
|
||||
void Matrix32::scale_basis(const Vector2& p_scale) {
|
||||
void Matrix32::scale_basis(const Size2& p_scale) {
|
||||
|
||||
elements[0]*=p_scale;
|
||||
elements[1]*=p_scale;
|
||||
@ -501,7 +501,6 @@ void Matrix32::translate( const Vector2& p_translation ) {
|
||||
elements[2]+=basis_xform(p_translation);
|
||||
}
|
||||
|
||||
|
||||
void Matrix32::orthonormalize() {
|
||||
|
||||
// Gram-Schmidt Process
|
||||
@ -550,11 +549,6 @@ void Matrix32::operator*=(const Matrix32& p_transform) {
|
||||
elements[2] = xform(p_transform.elements[2]);
|
||||
|
||||
float x0,x1,y0,y1;
|
||||
/*
|
||||
x0 = p_transform.tdotx(elements[0]);
|
||||
x1 = p_transform.tdoty(elements[0]);
|
||||
y0 = p_transform.tdotx(elements[1]);
|
||||
y1 = p_transform.tdoty(elements[1]);*/
|
||||
|
||||
x0 = tdotx(p_transform.elements[0]);
|
||||
x1 = tdoty(p_transform.elements[0]);
|
||||
@ -576,7 +570,7 @@ Matrix32 Matrix32::operator*(const Matrix32& p_transform) const {
|
||||
|
||||
}
|
||||
|
||||
Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
|
||||
Matrix32 Matrix32::scaled(const Size2& p_scale) const {
|
||||
|
||||
Matrix32 copy=*this;
|
||||
copy.scale(p_scale);
|
||||
@ -584,7 +578,7 @@ Matrix32 Matrix32::scaled(const Vector2& p_scale) const {
|
||||
|
||||
}
|
||||
|
||||
Matrix32 Matrix32::basis_scaled(const Vector2& p_scale) const {
|
||||
Matrix32 Matrix32::basis_scaled(const Size2& p_scale) const {
|
||||
|
||||
Matrix32 copy=*this;
|
||||
copy.scale_basis(p_scale);
|
||||
@ -629,8 +623,8 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons
|
||||
real_t r1 = get_rotation();
|
||||
real_t r2 = p_transform.get_rotation();
|
||||
|
||||
Vector2 s1 = get_scale();
|
||||
Vector2 s2 = p_transform.get_scale();
|
||||
Size2 s1 = get_scale();
|
||||
Size2 s2 = p_transform.get_scale();
|
||||
|
||||
//slerp rotation
|
||||
Vector2 v1(Math::cos(r1), Math::sin(r1));
|
||||
|
@ -553,10 +553,8 @@ struct Rect2i {
|
||||
|
||||
struct Matrix32 {
|
||||
|
||||
|
||||
Vector2 elements[3];
|
||||
|
||||
|
||||
_FORCE_INLINE_ float tdotx(const Vector2& v) const { return elements[0][0] * v.x + elements[1][0] * v.y; }
|
||||
_FORCE_INLINE_ float tdoty(const Vector2& v) const { return elements[0][1] * v.x + elements[1][1] * v.y; }
|
||||
|
||||
@ -577,26 +575,25 @@ struct Matrix32 {
|
||||
_FORCE_INLINE_ void set_rotation_and_scale(real_t p_phi,const Size2& p_scale);
|
||||
void rotate(real_t p_phi);
|
||||
|
||||
void scale(const Vector2& p_scale);
|
||||
void scale_basis(const Vector2& p_scale);
|
||||
void scale(const Size2& p_scale);
|
||||
void scale_basis(const Size2& p_scale);
|
||||
void translate( real_t p_tx, real_t p_ty);
|
||||
void translate( const Vector2& p_translation );
|
||||
|
||||
float basis_determinant() const;
|
||||
|
||||
Vector2 get_scale() const;
|
||||
Size2 get_scale() const;
|
||||
|
||||
_FORCE_INLINE_ const Vector2& get_origin() const { return elements[2]; }
|
||||
_FORCE_INLINE_ void set_origin(const Vector2& p_origin) { elements[2]=p_origin; }
|
||||
|
||||
Matrix32 scaled(const Vector2& p_scale) const;
|
||||
Matrix32 basis_scaled(const Vector2& p_scale) const;
|
||||
Matrix32 scaled(const Size2& p_scale) const;
|
||||
Matrix32 basis_scaled(const Size2& p_scale) const;
|
||||
Matrix32 translated(const Vector2& p_offset) const;
|
||||
Matrix32 rotated(float p_phi) const;
|
||||
|
||||
Matrix32 untranslated() const;
|
||||
|
||||
|
||||
void orthonormalize();
|
||||
Matrix32 orthonormalized() const;
|
||||
|
||||
@ -615,7 +612,6 @@ struct Matrix32 {
|
||||
_FORCE_INLINE_ Rect2 xform(const Rect2& p_vec) const;
|
||||
_FORCE_INLINE_ Rect2 xform_inv(const Rect2& p_vec) const;
|
||||
|
||||
|
||||
operator String() const;
|
||||
|
||||
Matrix32(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
|
||||
@ -630,7 +626,6 @@ struct Matrix32 {
|
||||
|
||||
Matrix32(real_t p_rot, const Vector2& p_pos);
|
||||
Matrix32() { elements[0][0]=1.0; elements[1][1]=1.0; }
|
||||
|
||||
};
|
||||
|
||||
bool Rect2::intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const {
|
||||
|
@ -253,7 +253,7 @@ void Node2D::global_translate(const Vector2& p_amount) {
|
||||
set_global_pos( get_global_pos() + p_amount );
|
||||
}
|
||||
|
||||
void Node2D::scale(const Vector2& p_amount) {
|
||||
void Node2D::scale(const Size2& p_amount) {
|
||||
|
||||
set_scale( get_scale() * p_amount );
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
void move_y(float p_delta,bool p_scaled=false);
|
||||
void translate(const Vector2& p_amount);
|
||||
void global_translate(const Vector2& p_amount);
|
||||
void scale(const Vector2& p_amount);
|
||||
void scale(const Size2& p_amount);
|
||||
|
||||
Point2 get_pos() const;
|
||||
float get_rot() const;
|
||||
@ -110,8 +110,6 @@ public:
|
||||
|
||||
Matrix32 get_relative_transform_to_parent(const Node *p_parent) const;
|
||||
|
||||
|
||||
|
||||
Matrix32 get_transform() const;
|
||||
|
||||
Node2D();
|
||||
|
@ -288,12 +288,12 @@ float Polygon2D::_get_texture_rotationd() const{
|
||||
}
|
||||
|
||||
|
||||
void Polygon2D::set_texture_scale(const Vector2& p_scale){
|
||||
void Polygon2D::set_texture_scale(const Size2& p_scale){
|
||||
|
||||
tex_scale=p_scale;
|
||||
update();
|
||||
}
|
||||
Vector2 Polygon2D::get_texture_scale() const{
|
||||
Size2 Polygon2D::get_texture_scale() const{
|
||||
|
||||
return tex_scale;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class Polygon2D : public Node2D {
|
||||
DVector<Color> vertex_colors;
|
||||
Color color;
|
||||
Ref<Texture> texture;
|
||||
Vector2 tex_scale;
|
||||
Size2 tex_scale;
|
||||
Vector2 tex_ofs;
|
||||
bool tex_tile;
|
||||
float tex_rot;
|
||||
@ -81,8 +81,8 @@ public:
|
||||
void set_texture_rotation(float p_rot);
|
||||
float get_texture_rotation() const;
|
||||
|
||||
void set_texture_scale(const Vector2& p_scale);
|
||||
Vector2 get_texture_scale() const;
|
||||
void set_texture_scale(const Size2& p_scale);
|
||||
Size2 get_texture_scale() const;
|
||||
|
||||
void set_invert(bool p_rot);
|
||||
bool get_invert() const;
|
||||
|
@ -40,7 +40,7 @@ class CanvasLayer : public Node {
|
||||
|
||||
bool locrotscale_dirty;
|
||||
Vector2 ofs;
|
||||
Vector2 scale;
|
||||
Size2 scale;
|
||||
real_t rot;
|
||||
int layer;
|
||||
Matrix32 transform;
|
||||
@ -81,8 +81,8 @@ public:
|
||||
void set_rotationd(real_t p_degrees);
|
||||
real_t get_rotationd() const;
|
||||
|
||||
void set_scale(const Vector2& p_scale);
|
||||
Vector2 get_scale() const;
|
||||
void set_scale(const Size2& p_scale);
|
||||
Size2 get_scale() const;
|
||||
|
||||
Ref<World2D> get_world_2d() const;
|
||||
|
||||
|
@ -136,7 +136,7 @@ bool LineShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_en
|
||||
return true;
|
||||
}
|
||||
|
||||
real_t LineShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
|
||||
real_t LineShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -191,7 +191,7 @@ bool RayShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_end
|
||||
|
||||
}
|
||||
|
||||
real_t RayShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
|
||||
real_t RayShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
|
||||
|
||||
return 0; //rays are mass-less
|
||||
}
|
||||
@ -252,7 +252,7 @@ bool SegmentShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
|
||||
return true;
|
||||
}
|
||||
|
||||
real_t SegmentShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
|
||||
real_t SegmentShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
|
||||
|
||||
Vector2 s[2]={a*p_scale,b*p_scale};
|
||||
|
||||
@ -336,7 +336,7 @@ bool CircleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p_
|
||||
return true;
|
||||
}
|
||||
|
||||
real_t CircleShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
|
||||
real_t CircleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
|
||||
|
||||
return (radius*radius)*(p_scale.x*0.5+p_scale.y*0.5);
|
||||
|
||||
@ -407,7 +407,7 @@ bool RectangleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2&
|
||||
return get_aabb().intersects_segment(p_begin,p_end,&r_point,&r_normal);
|
||||
}
|
||||
|
||||
real_t RectangleShape2DSW::get_moment_of_inertia(float p_mass,const Vector2& p_scale) const {
|
||||
real_t RectangleShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
|
||||
|
||||
Vector2 he2=half_extents*2*p_scale;
|
||||
return p_mass*he2.dot(he2)/12.0f;
|
||||
@ -540,7 +540,7 @@ bool CapsuleShape2DSW::intersect_segment(const Vector2& p_begin,const Vector2& p
|
||||
return collided; //todo
|
||||
}
|
||||
|
||||
real_t CapsuleShape2DSW::get_moment_of_inertia(float p_mass, const Vector2 &p_scale) const {
|
||||
real_t CapsuleShape2DSW::get_moment_of_inertia(float p_mass, const Size2 &p_scale) const {
|
||||
|
||||
Vector2 he2=Vector2(radius*2,height+radius*2)*p_scale;
|
||||
return p_mass*he2.dot(he2)/12.0f;
|
||||
@ -670,7 +670,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
|
||||
return inters; //todo
|
||||
}
|
||||
|
||||
real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Vector2& p_scale) const {
|
||||
real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p_scale) const {
|
||||
|
||||
Rect2 aabb;
|
||||
aabb.pos=points[0].pos*p_scale;
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const=0;
|
||||
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const=0;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const=0;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const=0;
|
||||
virtual void set_data(const Variant& p_data)=0;
|
||||
virtual Variant get_data() const=0;
|
||||
|
||||
@ -175,7 +175,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -218,7 +218,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -266,7 +266,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -304,7 +304,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -344,7 +344,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -432,7 +432,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -495,7 +495,7 @@ public:
|
||||
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const;
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const;
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
@ -584,7 +584,7 @@ public:
|
||||
virtual bool contains_point(const Vector2& p_point) const;
|
||||
virtual bool intersect_segment(const Vector2& p_begin,const Vector2& p_end,Vector2 &r_point, Vector2 &r_normal) const;
|
||||
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Vector2& p_scale) const { return 0; }
|
||||
virtual real_t get_moment_of_inertia(float p_mass,const Size2& p_scale) const { return 0; }
|
||||
|
||||
virtual void set_data(const Variant& p_data);
|
||||
virtual Variant get_data() const;
|
||||
|
Loading…
Reference in New Issue
Block a user