Skip to content
Snippets Groups Projects
Verified Commit b555992f authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Corrected epsilon to have stable elastic impact

parent f6bb006a
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
#ifndef PARTICLE_INC #ifndef PARTICLE_INC
#define PARTICLE_INC #define PARTICLE_INC
#define EPSILON 0.00001f #define EPSILON 0.00000001f
struct ParticleMinimal { struct ParticleMinimal {
vec3 position; vec3 position;
......
...@@ -71,7 +71,7 @@ void main() { ...@@ -71,7 +71,7 @@ void main() {
memoryBarrierShared(); memoryBarrierShared();
} }
gridValue.xyz += vec3(0.0f, -9.81f * dts * gridValue.w, 0.0f); gridValue.xyz += vec3(0.0f, -9.81f * dts * gridValue.w * 0.0f, 0.0f);
bvec3 lowerID = lessThanEqual(gl_GlobalInvocationID, ivec3(0)); bvec3 lowerID = lessThanEqual(gl_GlobalInvocationID, ivec3(0));
bvec3 negativeVelocity = lessThan(gridValue.xyz, vec3(0.0f)); bvec3 negativeVelocity = lessThan(gridValue.xyz, vec3(0.0f));
......
...@@ -76,25 +76,35 @@ void main() { ...@@ -76,25 +76,35 @@ void main() {
mat3 F = mat3(particle.deformation); mat3 F = mat3(particle.deformation);
if (abs(determinant(affine_D)) >= EPSILON) { mat3 D_inv = inverse(affine_D);
mat3 D_inv = inverse(affine_D); float D_det = determinant(D_inv);
float J = determinant(F);
if (J > 0.0f) { if ((isnan(D_det)) || (isinf(D_det))) {
float volume = sphere_volume(size); D_inv = mat3(0.0f);
} else {
D_inv *= min(abs(D_det), 1.0f / EPSILON) / abs(D_det);
}
mat3 F_T = transpose(F); float J = max(determinant(F), EPSILON);
mat3 stress = lame2 * (F * F_T - mat3(1.0f)) + lame1 * log(J); float volume = sphere_volume(size);
mls_Q -= dts * volume * stress * D_inv; mat3 F_T = transpose(F);
} mat3 F_T_inv = inverse(F_T);
affine_C = affine_B * D_inv; mat3 P_term_0 = lame2 * (F - F_T_inv);
mls_Q += affine_C * mass; mat3 P_term_1 = lame1 * log(J) * F_T_inv;
F = (mat3(1.0f) + dts * affine_C) * F; mat3 P = P_term_0 + P_term_1;
}
mat3 stress = P * F_T;
mls_Q -= dts * volume * stress * D_inv;
affine_C = affine_B * D_inv;
mls_Q += affine_C * mass;
F = (mat3(1.0f) + dts * affine_C) * F;
position = position + velocity_pic * dts; position = position + velocity_pic * dts;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment