Update fountain to use boolean rather than ints for true/false.

Change-Id: I5e8334f53239c869caeaff45e611309cea5ba284
This commit is contained in:
Jason Sams
2010-06-25 15:09:45 -07:00
parent eeeaccc899
commit 61d10a4e43
5 changed files with 15 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ int root() {
return 1;
}
void addParticles(int rate, float x, float y, int newColor)
void addParticles(int rate, float x, float y, bool newColor)
{
if (newColor) {
partColor.x = rsRand(0.5f, 1.0f);

View File

@@ -51,7 +51,7 @@ public class FountainRS {
boolean holdingColor = false;
public void newTouchPosition(int x, int y, int rate) {
if (rate > 0) {
mScript.invoke_addParticles(rate, x, y, !holdingColor ? 1 : 0);
mScript.invoke_addParticles(rate, x, y, !holdingColor);
holdingColor = true;
} else {
holdingColor = false;

View File

@@ -50,12 +50,13 @@ public class ScriptC_Fountain extends ScriptC {
}
private final static int mExportFuncIdx_addParticles = 0;
public void invoke_addParticles(int rate, float x, float y, int newColor) {
public void invoke_addParticles(int rate, float x, float y, boolean newColor) {
FieldPacker addParticles_fp = new FieldPacker(16);
addParticles_fp.addI32(rate);
addParticles_fp.addF32(x);
addParticles_fp.addF32(y);
addParticles_fp.addI32(newColor);
addParticles_fp.addBoolean(newColor);
addParticles_fp.skip(3);
invoke(mExportFuncIdx_addParticles, addParticles_fp);
}

View File

@@ -38,17 +38,18 @@ public class ScriptField_Point extends android.renderscript.Script.FieldBase {
private Item mItemArray[];
private FieldPacker mIOBuffer;
public static Element createElement(RenderScript rs) {
Element.Builder eb = new Element.Builder(rs);
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "delta");
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "position");
eb.add(Element.createVector(rs, Element.DataType.UNSIGNED_8, 4), "color");
return eb.create();
}
public ScriptField_Point(RenderScript rs, int count) {
mItemArray = null;
mIOBuffer = null;
{
Element.Builder eb = new Element.Builder(rs);
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "delta");
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "position");
eb.add(Element.createVector(rs, Element.DataType.UNSIGNED_8, 4), "color");
mElement = eb.create();
}
mElement = createElement(rs);
init(rs, count);
}
@@ -65,7 +66,7 @@ public class ScriptField_Point extends android.renderscript.Script.FieldBase {
mItemArray[index] = i;
if (copyNow) {
copyToArray(i, index);
mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
mAllocation.subData1D(index, 1, mIOBuffer.getData());
}
}