Simplify raincloud particle effect

The 'flags' field is going away soon (per public SkSL minimum spec), and
the only use of that feature was for this one example. The alternative
is simpler to understand, too.

Bug: skia:11093
Change-Id: I18a85bd48316301edc44c691fbe20f93da243e2f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/346776
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2020-12-22 14:38:33 -05:00 committed by Skia Commit-Bot
parent 7689319271
commit ba2c246259
2 changed files with 3 additions and 21 deletions

View File

@ -21,18 +21,9 @@
" p.vel.y = 50;",
"}",
"",
"bool once(bool cond, inout uint flags, uint flag) {",
" bool result = false;",
" if (cond && (flags & flag) == 0) {",
" flags |= flag;",
" result = true;",
" }",
" return result;",
"}",
"",
"void update(inout Particle p) {",
" p.vel.y += 20 * dt;",
" if (once(p.pos.y > 150, p.flags, 0x1)) {",
" if (p.pos.y > 150 && p.scale > 0) {",
" p.scale = 0;",
" splash(false);",
" }",

View File

@ -65,7 +65,7 @@ Samples
<figure>
<canvas id=raincloud width=400 height=400></canvas>
<figcaption>
<a href="https://particles.skia.org/47f49494cb9bdfef2691369428c6d672"
<a href="https://particles.skia.org/aecf2ff6e1d11fbf56e0cf6ec734893d"
target=_blank rel=noopener>Raincloud</a>
</figcaption>
</figure>
@ -404,18 +404,9 @@ const raincloud = {
" p.vel.y = 50;",
"}",
"",
"bool once(bool cond, inout uint flags, uint flag) {",
" bool result = false;",
" if (cond && (flags & flag) == 0) {",
" flags |= flag;",
" result = true;",
" }",
" return result;",
"}",
"",
"void update(inout Particle p) {",
" p.vel.y += 20 * dt;",
" if (once(p.pos.y > 150, p.flags, 0x1)) {",
" if (p.pos.y > 150 && p.scale > 0) {",
" p.scale = 0;",
" splash(false);",
" }",