Skip to content

Commit 1f545d2

Browse files
committed
Fix fluid
1 parent 5e3c0c4 commit 1f545d2

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/scripts/fluid/fluid.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export class Fluid extends GPUAbstractRunner {
145145
this.div.GetCommandBuffer(),
146146
this.poisson.GetCommandBuffer(),
147147
this.project.GetCommandBuffer(),
148-
this.scene.GetCommandBuffer(),
148+
149+
//this.scene.GetCommandBuffer(),
149150
//this.light.GetCommandBuffer(),
150151
])
151152
//await GPU.Render(this.transport.texturea);
@@ -197,7 +198,7 @@ export class Fluid extends GPUAbstractRunner {
197198
}
198199

199200
async InitCell() {
200-
let flags = new Uint32Array(this.width * this.height*4);
201+
let flags = new Int32Array(this.width * this.height);
201202

202203
const F = 0x0001 // is Fluid
203204
const B_u = 0x0002 // obstacle cells adjacent to fluid cells
@@ -207,27 +208,27 @@ export class Fluid extends GPUAbstractRunner {
207208

208209
for (let j = 0; j < this.height; j++)
209210
for (let i = 0; i < this.width; i++) {
210-
flags[(j * this.width + i)*4] = 0;
211+
flags[j * this.width + i] = 0;
211212
}
212213

213214
// is fluid
214215
for (let j = 1; j < this.height-1; j++)
215216
for (let i = 1; i < this.width-1; i++) {
216-
flags[(j * this.width + i)*4] = F; // is fluid
217+
flags[j * this.width + i] = F; // is fluid
217218
}
218219

219220
for (let i = 1; i < this.width - 1; i++) {
220221
let j = 1;
221-
flags[(j * this.width + i)] |= B_d;
222+
flags[j * this.width + i] |= B_d;
222223
j = this.height - 2;
223-
flags[(j * this.width + i)] |= B_u;
224+
flags[j * this.width + i] |= B_u;
224225
}
225226

226227
for (let j = 1; j < this.height - 1; j++) {
227228
let i = 1;
228-
flags[(j * this.width + i)] |= B_l;
229+
flags[j * this.width + i] |= B_l;
229230
i = this.width - 2;
230-
flags[(j * this.width + i)] |= B_r;
231+
flags[j * this.width + i] |= B_r;
231232
}
232233

233234
this.flags = await GPU.CreateTextureFromArrayBuffer(this.width, this.height, "r32sint", flags.buffer);

src/scripts/fluid/poisson/poisson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Poisson {
2828
async Init() {
2929
let shader = await GPU.CreateShaderFromURL("scripts/fluid/poisson/jacobi.wgsl")
3030

31-
await this.InitScaler();
31+
//await this.InitScaler();
3232
this.pressurea = GPU.CreateTexture(this.width, this.height, "r32float");
3333
this.pressureb = GPU.CreateTexture(this.width, this.height, "r32float");
3434

0 commit comments

Comments
 (0)