From b3e4bc562c07142d48907278f9cc496791ff7b33 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 3 May 2018 17:29:15 -0300 Subject: Skeleton for 2D WIP --- servers/visual/rasterizer.h | 5 +++++ servers/visual/visual_server_canvas.cpp | 6 +++++- servers/visual/visual_server_canvas.h | 4 +--- servers/visual/visual_server_raster.h | 3 ++- servers/visual/visual_server_wrap_mt.h | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) (limited to 'servers/visual') diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 8bf112b0de..c49388436b 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -325,6 +325,7 @@ public: virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0; virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0; virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0; + virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0; /* Light API */ @@ -735,6 +736,8 @@ public: Vector points; Vector uvs; Vector colors; + Vector bones; + Vector weights; RID texture; RID normal_map; int count; @@ -812,6 +815,8 @@ public: mutable bool rect_dirty; mutable Rect2 rect; RID material; + RID skeleton; + Item *next; struct CopyBackBuffer { diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index dd8d07f00d..6439ba8509 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -694,7 +694,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vectorcommands.push_back(polygon); } -void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs, RID p_texture, int p_count, RID p_normal_map) { +void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs, const Vector &p_bones, const Vector &p_weights, RID p_texture, int p_count, RID p_normal_map) { Item *canvas_item = canvas_item_owner.getornull(p_item); ERR_FAIL_COND(!canvas_item); @@ -702,6 +702,8 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector int ps = p_points.size(); ERR_FAIL_COND(!p_colors.empty() && p_colors.size() != ps && p_colors.size() != 1); ERR_FAIL_COND(!p_uvs.empty() && p_uvs.size() != ps); + ERR_FAIL_COND(!p_bones.empty() && p_bones.size() != ps * 4); + ERR_FAIL_COND(!p_weights.empty() && p_weights.size() != ps * 4); Vector indices = p_indices; @@ -726,6 +728,8 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector polygon->points = p_points; polygon->uvs = p_uvs; polygon->colors = p_colors; + polygon->bones = p_bones; + polygon->weights = p_weights; polygon->indices = indices; polygon->count = count; polygon->antialiased = false; diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 6a5a7623b6..4d9398a17e 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -51,8 +51,6 @@ public: Vector child_items; - RID skeleton; - Item() { children_order_dirty = true; E = NULL; @@ -183,7 +181,7 @@ public: void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()); void canvas_item_add_primitive(RID p_item, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()); void canvas_item_add_polygon(RID p_item, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs = Vector(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false); - void canvas_item_add_triangle_array(RID p_item, const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs = Vector(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()); + void canvas_item_add_triangle_array(RID p_item, const Vector &p_indices, const Vector &p_points, const Vector &p_colors, const Vector &p_uvs = Vector(), const Vector &p_bones = Vector(), const Vector &p_weights = Vector(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()); void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_texture = RID(), RID p_normal_map = RID()); void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()); void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal, int p_h_frames, int p_v_frames); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index a94e110b5d..5b7ea34cfe 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -285,6 +285,7 @@ public: BIND2RC(Transform, skeleton_bone_get_transform, RID, int) BIND3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &) BIND2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int) + BIND2(skeleton_set_base_transform_2d, RID, const Transform2D &) /* Light API */ @@ -580,7 +581,7 @@ public: BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID) BIND7(canvas_item_add_primitive, RID, const Vector &, const Vector &, const Vector &, RID, float, RID) BIND7(canvas_item_add_polygon, RID, const Vector &, const Vector &, const Vector &, RID, RID, bool) - BIND8(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, RID, int, RID) + BIND10(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, RID, int, RID) BIND4(canvas_item_add_mesh, RID, const RID &, RID, RID) BIND4(canvas_item_add_multimesh, RID, RID, RID, RID) BIND6(canvas_item_add_particles, RID, RID, RID, RID, int, int) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index b91f80d137..5b163e4ac9 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -221,6 +221,7 @@ public: FUNC2RC(Transform, skeleton_bone_get_transform, RID, int) FUNC3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &) FUNC2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int) + FUNC2(skeleton_set_base_transform_2d, RID, const Transform2D &) /* Light API */ @@ -498,7 +499,7 @@ public: FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID) FUNC7(canvas_item_add_primitive, RID, const Vector &, const Vector &, const Vector &, RID, float, RID) FUNC7(canvas_item_add_polygon, RID, const Vector &, const Vector &, const Vector &, RID, RID, bool) - FUNC8(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, RID, int, RID) + FUNC10(canvas_item_add_triangle_array, RID, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, RID, int, RID) FUNC4(canvas_item_add_mesh, RID, const RID &, RID, RID) FUNC4(canvas_item_add_multimesh, RID, RID, RID, RID) FUNC6(canvas_item_add_particles, RID, RID, RID, RID, int, int) -- cgit v1.2.3