diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-06-21 16:25:45 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-06-21 16:26:26 -0300 |
commit | 95560e02c5eed3561996ed2b1d1e47e26e8bb81c (patch) | |
tree | 8e53927435484e10e444e6e2f745b2ddc19029e6 /servers | |
parent | 3c1fd26bb0c2e97b927343e5488aa6d646e2e27c (diff) |
2D GPU Particles working..
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 20 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.cpp | 19 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.h | 1 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 4 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 2 | ||||
-rw-r--r-- | servers/visual_server.h | 3 |
6 files changed, 48 insertions, 1 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 07d6542b62..43452b714c 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -612,6 +612,7 @@ public: TYPE_POLYGON, TYPE_MESH, TYPE_MULTIMESH, + TYPE_PARTICLES, TYPE_CIRCLE, TYPE_TRANSFORM, TYPE_CLIP_IGNORE, @@ -707,6 +708,16 @@ public: CommandMultiMesh() { type = TYPE_MULTIMESH; } }; + struct CommandParticles : public Command { + + RID particles; + RID texture; + RID normal_map; + int h_frames; + int v_frames; + CommandParticles() { type = TYPE_PARTICLES; } + }; + struct CommandCircle : public Command { Point2 pos; @@ -845,6 +856,15 @@ public: r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); } break; + case Item::Command::TYPE_PARTICLES: { + + const Item::CommandParticles *particles_cmd = static_cast<const Item::CommandParticles *>(c); + if (particles_cmd->particles.is_valid()) { + Rect3 aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles); + r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); + } + + } break; case Item::Command::TYPE_CIRCLE: { const Item::CommandCircle *circle = static_cast<const Item::CommandCircle *>(c); diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 2ef1fd417b..616990b311 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -637,6 +637,25 @@ void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID canvas_item->commands.push_back(m); } +void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal, int p_h_frames, int p_v_frames) { + + Item *canvas_item = canvas_item_owner.getornull(p_item); + ERR_FAIL_COND(!canvas_item); + + Item::CommandParticles *part = memnew(Item::CommandParticles); + ERR_FAIL_COND(!part); + part->particles = p_particles; + part->texture = p_texture; + part->normal_map = p_normal; + part->h_frames = p_h_frames; + part->v_frames = p_v_frames; + + //take the chance and request processing for them, at least once until they become visible again + VSG::storage->particles_request_process(p_particles); + + canvas_item->commands.push_back(part); +} + void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton) { Item *canvas_item = canvas_item_owner.getornull(p_item); diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 2c86b14c70..f78ef635f4 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -173,6 +173,7 @@ public: void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), 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_skeleton = RID()); void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = 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); void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform); void canvas_item_add_clip_ignore(RID p_item, bool p_ignore); void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index c48bee7fa4..03af60dcd5 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -877,7 +877,8 @@ public: BIND2(particles_set_draw_passes, RID, int) BIND3(particles_set_draw_pass_mesh, RID, int, RID) - BIND1R(Rect3, particles_get_current_aabb, RID); + BIND1R(Rect3, particles_get_current_aabb, RID) + BIND2(particles_set_emission_transform, RID, const Transform &) #undef BINDBASE //from now on, calls forwarded to this singleton @@ -1049,6 +1050,7 @@ public: BIND8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID) BIND3(canvas_item_add_mesh, RID, const RID &, RID) BIND3(canvas_item_add_multimesh, RID, RID, RID) + BIND6(canvas_item_add_particles, RID, RID, RID, RID, int, int) BIND2(canvas_item_add_set_transform, RID, const Transform2D &) BIND2(canvas_item_add_clip_ignore, RID, bool) BIND2(canvas_item_set_sort_children_by_y, RID, bool) diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 94cbfc815e..79a7805472 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -320,6 +320,7 @@ public: FUNC2(particles_set_draw_passes, RID, int) FUNC3(particles_set_draw_pass_mesh, RID, int, RID) + FUNC2(particles_set_emission_transform, RID, const Transform &) FUNC1R(Rect3, particles_get_current_aabb, RID) @@ -476,6 +477,7 @@ public: FUNC8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID) FUNC3(canvas_item_add_mesh, RID, const RID &, RID) FUNC3(canvas_item_add_multimesh, RID, RID, RID) + FUNC6(canvas_item_add_particles, RID, RID, RID, RID, int, int) FUNC2(canvas_item_add_set_transform, RID, const Transform2D &) FUNC2(canvas_item_add_clip_ignore, RID, bool) FUNC2(canvas_item_set_sort_children_by_y, RID, bool) diff --git a/servers/visual_server.h b/servers/visual_server.h index 589fa80084..bc72c8a5a1 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -501,6 +501,8 @@ public: virtual Rect3 particles_get_current_aabb(RID p_particles) = 0; + virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; //this is only used for 2D, in 3D it's automatic + /* CAMERA API */ virtual RID camera_create() = 0; @@ -793,6 +795,7 @@ public: virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()) = 0; virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID()) = 0; virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID()) = 0; + virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, int p_h_frames, int p_v_frames) = 0; virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0; virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore) = 0; virtual void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) = 0; |