Fix T73979: Wrong location of fluid mesh when domain origin is not in center

Reviewers: sebbas

Differential Revision: https://developer.blender.org/D7802
This commit is contained in:
Jacques Lucke 2020-05-20 16:52:03 +02:00
parent c1545c9a9d
commit b44101950d
Notes: blender-bot 2023-06-12 00:52:52 +02:00
Referenced by issue #73979, Wrong location of FLIP fluid mesh after editing domain mesh
Referenced by issue #72644, [Mantaflow] Wrong fluid mesh position
1 changed files with 13 additions and 3 deletions

View File

@ -3330,6 +3330,16 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *mds, Mesh *orgmesh, Obj
/* Biggest dimension will be used for upscaling. */
float max_size = MAX3(size[0], size[1], size[2]);
float co_scale[3];
co_scale[0] = max_size / ob->scale[0];
co_scale[1] = max_size / ob->scale[1];
co_scale[2] = max_size / ob->scale[2];
float co_offset[3];
co_offset[0] = (mds->p0[0] + mds->p1[0]) / 2.0f;
co_offset[1] = (mds->p0[1] + mds->p1[1]) / 2.0f;
co_offset[2] = (mds->p0[2] + mds->p1[2]) / 2.0f;
/* Normals. */
normals = MEM_callocN(sizeof(short) * num_normals * 3, "Fluidmesh_tmp_normals");
@ -3353,9 +3363,9 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *mds, Mesh *orgmesh, Obj
mverts->co[2] *= mds->dx / mds->mesh_scale;
}
mverts->co[0] *= max_size / fabsf(ob->scale[0]);
mverts->co[1] *= max_size / fabsf(ob->scale[1]);
mverts->co[2] *= max_size / fabsf(ob->scale[2]);
mul_v3_v3(mverts->co, co_scale);
add_v3_v3(mverts->co, co_offset);
# ifdef DEBUG_PRINT
/* Debugging: Print coordinates of vertices. */
printf("mverts->co[0]: %f, mverts->co[1]: %f, mverts->co[2]: %f\n",