diff options
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/camera_2d.cpp | 16 | ||||
-rw-r--r-- | scene/2d/camera_2d.h | 2 | ||||
-rw-r--r-- | scene/2d/canvas_item.cpp | 24 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 14 | ||||
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 10 | ||||
-rw-r--r-- | scene/2d/collision_object_2d.h | 8 | ||||
-rw-r--r-- | scene/2d/collision_polygon_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/joints_2d.cpp | 4 | ||||
-rw-r--r-- | scene/2d/light_occluder_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/navigation2d.cpp | 4 | ||||
-rw-r--r-- | scene/2d/navigation2d.h | 6 | ||||
-rw-r--r-- | scene/2d/navigation_polygon.cpp | 2 | ||||
-rw-r--r-- | scene/2d/node_2d.cpp | 26 | ||||
-rw-r--r-- | scene/2d/node_2d.h | 10 | ||||
-rw-r--r-- | scene/2d/parallax_background.cpp | 2 | ||||
-rw-r--r-- | scene/2d/parallax_background.h | 2 | ||||
-rw-r--r-- | scene/2d/particles_2d.cpp | 12 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 14 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.h | 2 | ||||
-rw-r--r-- | scene/2d/polygon_2d.cpp | 8 | ||||
-rw-r--r-- | scene/2d/ray_cast_2d.cpp | 4 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 36 | ||||
-rw-r--r-- | scene/2d/tile_map.h | 14 |
23 files changed, 112 insertions, 112 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 3276f3f004..6c387c610f 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -47,7 +47,7 @@ void Camera2D::_update_scroll() { ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) ); - Matrix32 xform = get_camera_transform(); + Transform2D xform = get_camera_transform(); if (viewport) { viewport->set_canvas_transform( xform ); @@ -71,12 +71,12 @@ Vector2 Camera2D::get_zoom() const { }; -Matrix32 Camera2D::get_camera_transform() { +Transform2D Camera2D::get_camera_transform() { if (!get_tree()) - return Matrix32(); + return Transform2D(); - ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Matrix32() ); + ERR_FAIL_COND_V( custom_viewport && !ObjectDB::get_instance(custom_viewport_id), Transform2D() ); Size2 screen_size = viewport->get_visible_rect().size; @@ -201,7 +201,7 @@ Matrix32 Camera2D::get_camera_transform() { camera_screen_center=screen_rect.pos+screen_rect.size*0.5; - Matrix32 xform; + Transform2D xform; if(rotating){ xform.set_rotation(angle); } @@ -272,7 +272,7 @@ void Camera2D::_notification(int p_what) { if (is_current()) { if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) { - viewport->set_canvas_transform( Matrix32() ); + viewport->set_canvas_transform( Transform2D() ); } } remove_from_group(group_name); @@ -290,7 +290,7 @@ void Camera2D::_notification(int p_what) { if(current) area_axis_width = 3; - Matrix32 inv_camera_transform = get_camera_transform().affine_inverse(); + Transform2D inv_camera_transform = get_camera_transform().affine_inverse(); Size2 screen_size = get_viewport_rect().size; Vector2 screen_endpoints[4]= { @@ -300,7 +300,7 @@ void Camera2D::_notification(int p_what) { inv_camera_transform.xform(Vector2(0, screen_size.height)) }; - Matrix32 inv_transform = get_global_transform().affine_inverse(); // undo global space + Transform2D inv_transform = get_global_transform().affine_inverse(); // undo global space for(int i=0;i<4;i++) { draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i+1)%4]), area_axis_color, area_axis_width); diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index da36b04924..85d90b225a 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -80,7 +80,7 @@ protected: void _set_old_smoothing(float p_enable); protected: - virtual Matrix32 get_camera_transform(); + virtual Transform2D get_camera_transform(); void _notification(int p_what); static void _bind_methods(); public: diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index d42743afc2..b7d9ba7860 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -325,10 +325,10 @@ void CanvasItem::_update_callback() { pending_update=false; // don't change to false until finished drawing (avoid recursive update) } -Matrix32 CanvasItem::get_global_transform_with_canvas() const { +Transform2D CanvasItem::get_global_transform_with_canvas() const { const CanvasItem *ci = this; - Matrix32 xform; + Transform2D xform; const CanvasItem *last_valid=NULL; while(ci) { @@ -346,7 +346,7 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const { return xform; } -Matrix32 CanvasItem::get_global_transform() const { +Transform2D CanvasItem::get_global_transform() const { if (global_invalid) { @@ -691,12 +691,12 @@ void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const S ERR_FAIL(); } - Matrix32 xform(p_rot,p_offset); + Transform2D xform(p_rot,p_offset); xform.scale_basis(p_scale); VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform); } -void CanvasItem::draw_set_transform_matrix(const Matrix32& p_matrix) { +void CanvasItem::draw_set_transform_matrix(const Transform2D& p_matrix) { if (!drawing) { ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal."); @@ -892,7 +892,7 @@ Vector2 CanvasItem::make_canvas_pos_local(const Vector2& screen_point) const { ERR_FAIL_COND_V(!is_inside_tree(),screen_point); - Matrix32 local_matrix = (get_canvas_transform() * + Transform2D local_matrix = (get_canvas_transform() * get_global_transform()).affine_inverse(); return local_matrix.xform(screen_point); @@ -972,8 +972,8 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false)); ClassDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box); ClassDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0)); - ClassDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant())); - ClassDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant())); + ClassDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant())); + ClassDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(PoolVector2Array()),DEFVAL(Variant())); ClassDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1)); ClassDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1))); @@ -1041,9 +1041,9 @@ void CanvasItem::_bind_methods() { } -Matrix32 CanvasItem::get_canvas_transform() const { +Transform2D CanvasItem::get_canvas_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(),Matrix32()); + ERR_FAIL_COND_V(!is_inside_tree(),Transform2D()); if (canvas_layer) return canvas_layer->get_transform(); @@ -1054,9 +1054,9 @@ Matrix32 CanvasItem::get_canvas_transform() const { } -Matrix32 CanvasItem::get_viewport_transform() const { +Transform2D CanvasItem::get_viewport_transform() const { - ERR_FAIL_COND_V(!is_inside_tree(),Matrix32()); + ERR_FAIL_COND_V(!is_inside_tree(),Transform2D()); if (canvas_layer) { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index d0dd5be5a3..fded547275 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -120,7 +120,7 @@ private: Ref<CanvasItemMaterial> material; - mutable Matrix32 global_transform; + mutable Transform2D global_transform; mutable bool global_invalid; @@ -207,7 +207,7 @@ public: float draw_char(const Ref<Font>& p_font,const Point2& p_pos, const String& p_char,const String& p_next="",const Color& p_modulate=Color(1,1,1)); void draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale); - void draw_set_transform_matrix(const Matrix32& p_matrix); + void draw_set_transform_matrix(const Transform2D& p_matrix); /* RECT / TRANSFORM */ @@ -220,10 +220,10 @@ public: CanvasItem *get_parent_item() const; virtual Rect2 get_item_rect() const=0; - virtual Matrix32 get_transform() const=0; + virtual Transform2D get_transform() const=0; - virtual Matrix32 get_global_transform() const; - virtual Matrix32 get_global_transform_with_canvas() const; + virtual Transform2D get_global_transform() const; + virtual Transform2D get_global_transform_with_canvas() const; Rect2 get_item_and_children_rect() const; @@ -234,8 +234,8 @@ public: bool is_block_transform_notify_enabled() const; - Matrix32 get_canvas_transform() const; - Matrix32 get_viewport_transform() const; + Transform2D get_canvas_transform() const; + Transform2D get_viewport_transform() const; Rect2 get_viewport_rect() const; RID get_viewport_rid() const; RID get_canvas() const; diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 90ca59d780..817651f57c 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -221,7 +221,7 @@ void CollisionObject2D::_update_pickable() { void CollisionObject2D::_bind_methods() { - ClassDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Matrix32())); + ClassDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Transform2D())); ClassDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count); ClassDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape); ClassDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform); @@ -249,7 +249,7 @@ void CollisionObject2D::_bind_methods() { } -void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform) { +void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform) { ERR_FAIL_COND(p_shape.is_null()); @@ -285,7 +285,7 @@ void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape) // _update_shapes(); } -void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_transform) { +void CollisionObject2D::set_shape_transform(int p_shape_idx, const Transform2D& p_transform) { ERR_FAIL_INDEX(p_shape_idx,shapes.size()); shapes[p_shape_idx].xform=p_transform; @@ -304,9 +304,9 @@ Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const { return shapes[p_shape_idx].shape; } -Matrix32 CollisionObject2D::get_shape_transform(int p_shape_idx) const { +Transform2D CollisionObject2D::get_shape_transform(int p_shape_idx) const { - ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Matrix32()); + ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Transform2D()); return shapes[p_shape_idx].xform; } diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 6f6d3520da..429b4fafe6 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -41,7 +41,7 @@ class CollisionObject2D : public Node2D { bool pickable; struct ShapeData { - Matrix32 xform; + Transform2D xform; Ref<Shape2D> shape; bool trigger; @@ -78,12 +78,12 @@ public: - void add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform=Matrix32()); + void add_shape(const Ref<Shape2D>& p_shape, const Transform2D& p_transform=Transform2D()); int get_shape_count() const; void set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape); - void set_shape_transform(int p_shape_idx, const Matrix32& p_transform); + void set_shape_transform(int p_shape_idx, const Transform2D& p_transform); Ref<Shape2D> get_shape(int p_shape_idx) const; - Matrix32 get_shape_transform(int p_shape_idx) const; + Transform2D get_shape_transform(int p_shape_idx) const; void set_shape_as_trigger(int p_shape_idx, bool p_trigger); bool is_shape_set_as_trigger(int p_shape_idx) const; void remove_shape(int p_shape_idx); diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index 46baa7c184..04f096f229 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -330,7 +330,7 @@ void CollisionPolygon2D::_bind_methods() { ClassDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape); ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger")); diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 0d83509f37..987672df38 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -283,7 +283,7 @@ RID GrooveJoint2D::_configure_joint(){ else Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 groove_A1 = gt.get_origin(); Vector2 groove_A2 = gt.xform( Vector2(0,length) ); Vector2 anchor_B = gt.xform( Vector2(0,initial_offset) ); @@ -384,7 +384,7 @@ RID DampedSpringJoint2D::_configure_joint(){ else Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid()); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 anchor_A = gt.get_origin(); Vector2 anchor_B = gt.xform( Vector2(0,length) ); diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index b7b280d902..8d447c3e8b 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -89,7 +89,7 @@ void OccluderPolygon2D::_bind_methods() { ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); BIND_CONSTANT(CULL_DISABLED); BIND_CONSTANT(CULL_CLOCKWISE); diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index be68c61bd8..2d0fbf1cfc 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -212,7 +212,7 @@ void Navigation2D::_navpoly_unlink(int p_id) { } -int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Matrix32& p_xform, Object *p_owner) { +int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Transform2D& p_xform, Object *p_owner) { int id = last_id++; NavMesh nm; @@ -227,7 +227,7 @@ int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Mat return id; } -void Navigation2D::navpoly_set_transform(int p_id, const Matrix32& p_xform){ +void Navigation2D::navpoly_set_transform(int p_id, const Transform2D& p_xform){ ERR_FAIL_COND(!navpoly_map.has(p_id)); NavMesh &nm=navpoly_map[p_id]; diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index c1c1600291..63827ebb6d 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -119,7 +119,7 @@ class Navigation2D : public Node2D { struct NavMesh { Object *owner; - Matrix32 xform; + Transform2D xform; bool linked; Ref<NavigationPolygon> navpoly; List<Polygon> polygons; @@ -164,8 +164,8 @@ protected: public: //API should be as dynamic as possible - int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Matrix32& p_xform,Object* p_owner=NULL); - void navpoly_set_transform(int p_id, const Matrix32& p_xform); + int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Transform2D& p_xform,Object* p_owner=NULL); + void navpoly_set_transform(int p_id, const Transform2D& p_xform); void navpoly_remove(int p_id); Vector<Vector2> get_simple_path(const Vector2& p_start, const Vector2& p_end,bool p_optimize=true); diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index add3a183ef..5c1837ad65 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -270,7 +270,7 @@ void NavigationPolygon::_bind_methods() { ClassDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines); ClassDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices")); + ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices")); ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons")); ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_outlines"),_SCS("_get_outlines")); } diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 800435d4c3..fb71a5b536 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -92,7 +92,7 @@ void Node2D::edit_set_rect(const Rect2& p_edit_rect) { Point2 new_pos = p_edit_rect.pos + p_edit_rect.size*zero_offset;//p_edit_rect.pos - r.pos; - Matrix32 postxf; + Transform2D postxf; postxf.set_rotation_and_scale(angle,_scale); new_pos = postxf.xform(new_pos); @@ -124,7 +124,7 @@ void Node2D::_update_xform_values() { void Node2D::_update_transform() { - Matrix32 mat(angle,pos); + Transform2D mat(angle,pos); _mat.set_rotation_and_scale(angle,_scale); _mat.elements[2]=pos; @@ -222,7 +222,7 @@ void Node2D::_notification(int p_what) { } } -Matrix32 Node2D::get_transform() const { +Transform2D Node2D::get_transform() const { return _mat; } @@ -261,7 +261,7 @@ void Node2D::scale(const Size2& p_amount) { void Node2D::move_x(float p_delta,bool p_scaled){ - Matrix32 t = get_transform(); + Transform2D t = get_transform(); Vector2 m = t[0]; if (!p_scaled) m.normalize(); @@ -270,7 +270,7 @@ void Node2D::move_x(float p_delta,bool p_scaled){ void Node2D::move_y(float p_delta,bool p_scaled){ - Matrix32 t = get_transform(); + Transform2D t = get_transform(); Vector2 m = t[1]; if (!p_scaled) m.normalize(); @@ -285,7 +285,7 @@ Point2 Node2D::get_global_position() const { void Node2D::set_global_position(const Point2& p_pos) { - Matrix32 inv; + Transform2D inv; CanvasItem *pi = get_parent_item(); if (pi) { inv = pi->get_global_transform().affine_inverse(); @@ -342,7 +342,7 @@ void Node2D::set_global_scale(const Size2& p_scale) { } -void Node2D::set_transform(const Matrix32& p_transform) { +void Node2D::set_transform(const Transform2D& p_transform) { _mat=p_transform; _xform_dirty=true; @@ -355,7 +355,7 @@ void Node2D::set_transform(const Matrix32& p_transform) { _notify_transform(); } -void Node2D::set_global_transform(const Matrix32& p_transform) { +void Node2D::set_global_transform(const Transform2D& p_transform) { CanvasItem *pi = get_parent_item(); if (pi) @@ -394,14 +394,14 @@ int Node2D::get_z() const{ return z; } -Matrix32 Node2D::get_relative_transform_to_parent(const Node *p_parent) const { +Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const { if (p_parent==this) - return Matrix32(); + return Transform2D(); Node2D *parent_2d = get_parent()->cast_to<Node2D>(); - ERR_FAIL_COND_V(!parent_2d,Matrix32()); + ERR_FAIL_COND_V(!parent_2d,Transform2D()); if (p_parent==parent_2d) return get_transform(); else @@ -473,13 +473,13 @@ void Node2D::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_rotation"),_SCS("get_rotation")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"rotation_deg",PROPERTY_HINT_RANGE,"-1440,1440,0.1",PROPERTY_USAGE_EDITOR),_SCS("set_rotation_in_degrees"),_SCS("get_rotation_in_degrees")); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale")); - ADD_PROPERTY(PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_NONE,"",0),_SCS("set_transform"),_SCS("get_transform")); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"transform",PROPERTY_HINT_NONE,"",0),_SCS("set_transform"),_SCS("get_transform")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_position",PROPERTY_HINT_NONE,"",0),_SCS("set_global_position"),_SCS("get_global_position")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation"),_SCS("get_global_rotation")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_rotation_deg",PROPERTY_HINT_NONE,"",0),_SCS("set_global_rotation_in_degrees"),_SCS("get_global_rotation_in_degrees")); ADD_PROPERTY(PropertyInfo(Variant::REAL,"global_scale",PROPERTY_HINT_NONE,"",0),_SCS("set_global_scale"),_SCS("get_global_scale")); - ADD_PROPERTY(PropertyInfo(Variant::MATRIX32,"global_transform",PROPERTY_HINT_NONE,"",0),_SCS("set_global_transform"),_SCS("get_global_transform")); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D,"global_transform",PROPERTY_HINT_NONE,"",0),_SCS("set_global_transform"),_SCS("get_global_transform")); ADD_GROUP("Z",""); ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z")); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 15dfd703fe..2cceef0f06 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -41,7 +41,7 @@ class Node2D : public CanvasItem { int z; bool z_relative; - Matrix32 _mat; + Transform2D _mat; bool _xform_dirty; @@ -92,8 +92,8 @@ public: Size2 get_global_scale() const; virtual Rect2 get_item_rect() const; - void set_transform(const Matrix32& p_transform); - void set_global_transform(const Matrix32& p_transform); + void set_transform(const Transform2D& p_transform); + void set_global_transform(const Transform2D& p_transform); void set_global_position(const Point2& p_pos); void set_global_rotation(float p_radians); void set_global_rotation_in_degrees(float p_degrees); @@ -108,9 +108,9 @@ public: void set_z_as_relative(bool p_enabled); bool is_z_relative() const; - Matrix32 get_relative_transform_to_parent(const Node *p_parent) const; + Transform2D get_relative_transform_to_parent(const Node *p_parent) const; - Matrix32 get_transform() const; + Transform2D get_transform() const; Node2D(); }; diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index 022e31760b..1e6a449fce 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -50,7 +50,7 @@ void ParallaxBackground::_notification(int p_what) { } -void ParallaxBackground::_camera_moved(const Matrix32& p_transform) { +void ParallaxBackground::_camera_moved(const Transform2D& p_transform) { set_scroll_offset(p_transform.get_origin()); diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index 9eafc07fd6..caef4962e8 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -50,7 +50,7 @@ class ParallaxBackground : public CanvasLayer { void _update_scroll(); protected: - void _camera_moved(const Matrix32& p_transform); + void _camera_moved(const Transform2D& p_transform); void _notification(int p_what); static void _bind_methods(); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index f8747d54b7..cb866165ff 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -270,7 +270,7 @@ void Particles2D::_process_particles(float p_delta) { Particle *pdata=&particles[0]; int particle_count=particles.size(); - Matrix32 xform; + Transform2D xform; if (!local_space) xform=get_global_transform(); @@ -293,7 +293,7 @@ void Particles2D::_process_particles(float p_delta) { } int idx=0; - Matrix32 m; + Transform2D m; if (local_space) { m= get_global_transform().affine_inverse(); } @@ -391,7 +391,7 @@ void Particles2D::_process_particles(float p_delta) { float orbitvel = (param[PARAM_ORBIT_VELOCITY]+param[PARAM_ORBIT_VELOCITY]*randomness[PARAM_ORBIT_VELOCITY]*_rand_from_seed(&rand_seed)); if (orbitvel!=0) { Vector2 rel = p.pos - xform.elements[2]; - Matrix32 rot(orbitvel*frame_time,Vector2()); + Transform2D rot(orbitvel*frame_time,Vector2()); p.pos = rot.xform(rel) + xform.elements[2]; } @@ -507,7 +507,7 @@ void Particles2D::_notification(int p_what) { if (texture.is_valid()) texrid = texture->get_rid(); - Matrix32 invxform; + Transform2D invxform; if (!local_space) invxform=get_global_transform().affine_inverse(); @@ -573,7 +573,7 @@ void Particles2D::_notification(int p_what) { //Rect2 r = Rect2(Vecto,rectsize); - Matrix32 xform; + Transform2D xform; if (p.rot) { @@ -1125,7 +1125,7 @@ void Particles2D::_bind_methods() { ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),_SCS("set_color"),_SCS("get_color")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),_SCS("set_color_ramp"),_SCS("get_color_ramp")); - ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points")); + ADD_PROPERTYNZ(PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points")); BIND_CONSTANT( PARAM_DIRECTION ); BIND_CONSTANT( PARAM_SPREAD ); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 6be5689f1d..0c2aa002c4 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -226,7 +226,7 @@ void StaticBody2D::_update_xform() { setting=true; - Matrix32 new_xform = get_global_transform(); //obtain the new one + Transform2D new_xform = get_global_transform(); //obtain the new one set_block_transform_notify(true); Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion! @@ -1046,7 +1046,7 @@ Variant KinematicBody2D::_get_collider() const { void KinematicBody2D::revert_motion() { - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]-=travel; travel=Vector2(); set_global_transform(gt); @@ -1062,7 +1062,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { #if 1 - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Physics2DServer::MotionResult result; colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(),gt,p_motion,margin,&result); @@ -1152,7 +1152,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]+=recover_motion; set_global_transform(gt); @@ -1203,7 +1203,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { } else { //it collided, let's get the rest info in unsafe advance - Matrix32 ugt = get_global_transform(); + Transform2D ugt = get_global_transform(); ugt.elements[2]+=p_motion*unsafe; Physics2DDirectSpaceState::ShapeRestInfo rest_info; bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask); @@ -1227,7 +1227,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { } Vector2 motion=p_motion*safe; - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); gt.elements[2]+=motion; set_global_transform(gt); @@ -1318,7 +1318,7 @@ Vector2 KinematicBody2D::move_to(const Vector2& p_position) { return move(p_position-get_global_position()); } -bool KinematicBody2D::test_move(const Matrix32& p_from,const Vector2& p_motion) { +bool KinematicBody2D::test_move(const Transform2D& p_from,const Vector2& p_motion) { ERR_FAIL_COND_V(!is_inside_tree(),false); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 240def543d..2637238c04 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -319,7 +319,7 @@ public: Vector2 move(const Vector2& p_motion); Vector2 move_to(const Vector2& p_position); - bool test_move(const Matrix32 &p_from, const Vector2& p_motion); + bool test_move(const Transform2D &p_from, const Vector2& p_motion); bool is_colliding() const; Vector2 get_travel() const; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 948c8b0818..30e22a8437 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -148,7 +148,7 @@ void Polygon2D::_notification(int p_what) { if (texture.is_valid()) { - Matrix32 texmat(tex_rot,tex_ofs); + Transform2D texmat(tex_rot,tex_ofs); texmat.scale(tex_scale); Size2 tex_size=Vector2(1,1); @@ -372,10 +372,10 @@ void Polygon2D::_bind_methods() { - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); - ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv")); ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color")); - ADD_PROPERTY( PropertyInfo(Variant::COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors")); + ADD_PROPERTY( PropertyInfo(Variant::POOL_COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors")); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset")); ADD_GROUP("Texture",""); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture")); diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 572575e4ec..14dfc10d9f 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -161,7 +161,7 @@ void RayCast2D::_notification(int p_what) { if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) break; - Matrix32 xf; + Transform2D xf; xf.rotate(cast_to.angle()); xf.translate(Vector2(0,cast_to.length())); @@ -201,7 +201,7 @@ void RayCast2D::_update_raycast_state() { Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space()); ERR_FAIL_COND( !dss ); - Matrix32 gt = get_global_transform(); + Transform2D gt = get_global_transform(); Vector2 to = cast_to; if (to==Vector2()) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index dbbc261b48..7bd3a5d932 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -114,16 +114,16 @@ void TileMap::_update_quadrant_transform() { if (!is_inside_tree()) return; - Matrix32 global_transform = get_global_transform(); + Transform2D global_transform = get_global_transform(); - Matrix32 nav_rel; + Transform2D nav_rel; if (navigation) nav_rel = get_relative_transform_to_parent(navigation); for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) { Quadrant &q=E->get(); - Matrix32 xform; + Transform2D xform; xform.set_origin( q.pos ); xform = global_transform * xform; Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform); @@ -218,7 +218,7 @@ bool TileMap::get_center_y() const { return center_y; } -void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) { +void TileMap::_fix_cell_transform(Transform2D& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) { Size2 s=p_sc; Vector2 offset = p_offset; @@ -277,7 +277,7 @@ void TileMap::_update_dirty_quadrants() { Physics2DServer *ps = Physics2DServer::get_singleton(); Vector2 tofs = get_cell_draw_offset(); Vector2 tcenter = cell_size/2; - Matrix32 nav_rel; + Transform2D nav_rel; if (navigation) nav_rel = get_relative_transform_to_parent(navigation); @@ -348,7 +348,7 @@ void TileMap::_update_dirty_quadrants() { if (mat.is_valid()) vs->canvas_item_set_material(canvas_item,mat->get_rid()); vs->canvas_item_set_parent( canvas_item, get_canvas_item() ); - Matrix32 xform; + Transform2D xform; xform.set_origin( q.pos ); vs->canvas_item_set_transform( canvas_item, xform ); vs->canvas_item_set_light_mask(canvas_item,get_light_mask()); @@ -472,7 +472,7 @@ void TileMap::_update_dirty_quadrants() { if (shape.is_valid()) { Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()); _fix_cell_transform(xform,c,shape_ofs+center_ofs,s); @@ -489,14 +489,14 @@ void TileMap::_update_dirty_quadrants() { } if (debug_canvas_item.is_valid()) { - vs->canvas_item_add_set_transform(debug_canvas_item,Matrix32()); + vs->canvas_item_add_set_transform(debug_canvas_item,Transform2D()); } if (navigation) { Ref<NavigationPolygon> navpoly = tile_set->tile_get_navigation_polygon(c.id); if (navpoly.is_valid()) { Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()+q.pos); _fix_cell_transform(xform,c,npoly_ofs+center_ofs,s); @@ -515,7 +515,7 @@ void TileMap::_update_dirty_quadrants() { if (occluder.is_valid()) { Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id); - Matrix32 xform; + Transform2D xform; xform.set_origin(offset.floor()+q.pos); _fix_cell_transform(xform,c,occluder_ofs+center_ofs,s); @@ -598,7 +598,7 @@ void TileMap::_recompute_rect_cache() { Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey& p_qk) { - Matrix32 xform; + Transform2D xform; //xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size); Quadrant q; q.pos = _map_to_world(p_qk.x*_get_quadrant_size(),p_qk.y*_get_quadrant_size()); @@ -1034,13 +1034,13 @@ TileMap::HalfOffset TileMap::get_half_offset() const { return half_offset; } -Matrix32 TileMap::get_cell_transform() const { +Transform2D TileMap::get_cell_transform() const { switch(mode) { case MODE_SQUARE: { - Matrix32 m; + Transform2D m; m[0]*=cell_size.x; m[1]*=cell_size.y; return m; @@ -1049,7 +1049,7 @@ Matrix32 TileMap::get_cell_transform() const { //isometric only makes sense when y is positive in both x and y vectors, otherwise //the drawing of tiles will overlap - Matrix32 m; + Transform2D m; m[0]=Vector2(cell_size.x*0.5,cell_size.y*0.5); m[1]=Vector2(-cell_size.x*0.5,cell_size.y*0.5); return m; @@ -1061,10 +1061,10 @@ Matrix32 TileMap::get_cell_transform() const { } break; } - return Matrix32(); + return Transform2D(); } -void TileMap::set_custom_transform(const Matrix32& p_xform) { +void TileMap::set_custom_transform(const Transform2D& p_xform) { _clear_quadrants(); custom_transform=p_xform; @@ -1073,7 +1073,7 @@ void TileMap::set_custom_transform(const Matrix32& p_xform) { } -Matrix32 TileMap::get_custom_transform() const{ +Transform2D TileMap::get_custom_transform() const{ return custom_transform; } @@ -1265,7 +1265,7 @@ void TileMap::_bind_methods() { ADD_GROUP("Cell","cell_"); ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size")); - ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell_custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform")); + ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM2D,"cell_custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset")); ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),_SCS("set_tile_origin"),_SCS("get_tile_origin")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell_y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled")); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index f863c0b2ea..ba6de62f8e 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -66,7 +66,7 @@ private: int quadrant_size; bool center_x,center_y; Mode mode; - Matrix32 custom_transform; + Transform2D custom_transform; HalfOffset half_offset; bool use_kinematic; Navigation2D *navigation; @@ -114,12 +114,12 @@ private: struct NavPoly { int id; - Matrix32 xform; + Transform2D xform; }; struct Occluder { RID id; - Matrix32 xform; + Transform2D xform; }; @@ -153,7 +153,7 @@ private: int occluder_light_mask; - void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); + void _fix_cell_transform(Transform2D& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc); Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk); void _erase_quadrant(Map<PosKey,Quadrant>::Element *Q); @@ -240,10 +240,10 @@ public: void set_tile_origin(TileOrigin p_tile_origin); TileOrigin get_tile_origin() const; - void set_custom_transform(const Matrix32& p_xform); - Matrix32 get_custom_transform() const; + void set_custom_transform(const Transform2D& p_xform); + Transform2D get_custom_transform() const; - Matrix32 get_cell_transform() const; + Transform2D get_cell_transform() const; Vector2 get_cell_draw_offset() const; Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const; |