9 triangles_ =
binding.triangles();
10 values_.assign(
size_t(
binding.vertexCount()), 0.f);
11 neighbors_.assign(values_.size(), {});
13 if (values_.empty() || triangles_.empty())
return false;
14 for (
const glm::uvec3&
tri : triangles_) {
18 const int other =
ids[(
edge + 1) % 3];
19 if (std::find(list.begin(), list.end(), other) == list.end()) list.push_back(other);
20 auto& reverse = neighbors_[
size_t(other)];
21 if (std::find(reverse.begin(), reverse.end(),
ids[
edge]) == reverse.end())
23 const uint32_t
a = uint32_t(std::min(
ids[
edge], other));
24 const uint32_t
b = uint32_t(std::max(
ids[
edge], other));
25 const std::pair<uint32_t, uint32_t> pair{
a,
b};
26 if (std::find(edges_.begin(), edges_.end(), pair) == edges_.end()) edges_.push_back(pair);
33 if (location.
triangle >= triangles_.size() || amount <= 0.f)
return;
34 const glm::uvec3
tri = triangles_[location.
triangle];
36 values_[
tri.x] += amount *
bary.x;
37 values_[
tri.y] += amount *
bary.y;
38 values_[
tri.z] += amount *
bary.z;
42 if (values_.empty() ||
dt <= 0.f)
return;
43 dt = std::min(
dt, 0.1f);
44 std::vector<float> next = values_;
45 const float diffusion = std::clamp(
params.diffusion *
dt, 0.f, 1.f);
46 const float evaporation = std::exp(-std::max(0.f,
params.evaporation) *
dt);
49 for (
const auto& [
a,
b] : edges_) {
51 const float flux = diffusion * (values_[
b] - values_[
a]) / std::max(1.f,
degree);
55 for (
float&
value : next)
61 if (location.
triangle >= triangles_.size())
return 0.f;
62 const glm::uvec3
tri = triangles_[location.
triangle];
eve::action::ActionVfxBinding binding
Dynamic triangle surface used to bind films and droplets to deforming meshes.
void step(float dt, const SurfaceWetnessParams ¶ms={})
Diffuse and evaporate the field by dt seconds.
void clear()
Reset all wetness to zero.
float sample(const SurfaceLocation &location) const
Sample.
void deposit(const SurfaceLocation &location, float amount)
Deposit a wet trace at a material-space location.
bool build(const FluidSurfaceBinding &binding)
Initialize the field from a surface topology.
Value vector(glm::dvec3 v)
GLSL compute kernels for the GPU surface-flow solver.
Stable material-space address of a point on a triangle surface.
Parameters controlling persistent wet-film traces on a triangle surface.