Files
workinf_Blender_Wasm/blender-5.2.0/extern/mantaflow/patches/liquid-performance.patch
2026-08-12 04:47:48 -04:00

74 lines
2.5 KiB
Diff

diff --git a/extern/mantaflow/preprocessed/fastmarch.cpp b/extern/mantaflow/preprocessed/fastmarch.cpp
index 31e43483b49..9856d84a8b1 100644
--- a/extern/mantaflow/preprocessed/fastmarch.cpp
+++ b/extern/mantaflow/preprocessed/fastmarch.cpp
@@ -306,25 +306,24 @@ struct knExtrapolateMACSimple : public KernelBase {
const int d,
const int c) const
{
- static const Vec3i nb[6] = {Vec3i(1, 0, 0),
- Vec3i(-1, 0, 0),
- Vec3i(0, 1, 0),
- Vec3i(0, -1, 0),
- Vec3i(0, 0, 1),
- Vec3i(0, 0, -1)};
- const int dim = (vel.is3D() ? 3 : 2);
-
if (tmp(i, j, k) != 0)
return;
+ const Vec3i nb[6] = {Vec3i(i+1, j, k),
+ Vec3i(i-1, j, k),
+ Vec3i(i, j+1, k),
+ Vec3i(i, j-1, k),
+ Vec3i(i, j, k+1),
+ Vec3i(i, j, k-1)};
+ const int dim = (vel.is3D() ? 3 : 2);
// copy from initialized neighbors
Vec3i p(i, j, k);
int nbs = 0;
Real avgVel = 0.;
for (int n = 0; n < 2 * dim; ++n) {
- if (tmp(p + nb[n]) == d) {
+ if (tmp(nb[n]) == d) {
// vel(p)[c] = (c+1.)*0.1;
- avgVel += vel(p + nb[n])[c];
+ avgVel += vel(nb[n])[c];
nbs++;
}
}
@@ -714,24 +713,23 @@ struct knExtrapolateMACFromWeight : public KernelBase {
const int d,
const int c) const
{
- static const Vec3i nb[6] = {Vec3i(1, 0, 0),
- Vec3i(-1, 0, 0),
- Vec3i(0, 1, 0),
- Vec3i(0, -1, 0),
- Vec3i(0, 0, 1),
- Vec3i(0, 0, -1)};
- const int dim = (vel.is3D() ? 3 : 2);
-
if (weight(i, j, k)[c] != 0)
return;
+ const Vec3i nb[6] = {Vec3i(i+1, j, k),
+ Vec3i(i-1, j, k),
+ Vec3i(i, j+1, k),
+ Vec3i(i, j-1, k),
+ Vec3i(i, j, k+1),
+ Vec3i(i, j, k-1)};
+ const int dim = (vel.is3D() ? 3 : 2);
// copy from initialized neighbors
Vec3i p(i, j, k);
int nbs = 0;
Real avgVel = 0.;
for (int n = 0; n < 2 * dim; ++n) {
- if (weight(p + nb[n])[c] == d) {
- avgVel += vel(p + nb[n])[c];
+ if (weight(nb[n])[c] == d) {
+ avgVel += vel(nb[n])[c];
nbs++;
}
}