Fluid: Fix liquid mesh scaling
Fixes issue with .bobj.gz and .obj mesh files not always being scaled correctly in the viewport.
This commit is contained in:
parent
7e0289b618
commit
7f67e3200a
|
@ -3336,17 +3336,13 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obj
|
|||
mverts->co[1] = manta_liquid_get_vertex_y_at(fds->fluid, i);
|
||||
mverts->co[2] = manta_liquid_get_vertex_z_at(fds->fluid, i);
|
||||
|
||||
/* If reading raw data directly from manta, normalize now (e.g. during replay mode).
|
||||
* If reading data from files from disk, omit this normalization. */
|
||||
if (!manta_liquid_mesh_from_file(fds->fluid)) {
|
||||
// normalize to unit cube around 0
|
||||
mverts->co[0] -= ((float)fds->res[0] * fds->mesh_scale) * 0.5f;
|
||||
mverts->co[1] -= ((float)fds->res[1] * fds->mesh_scale) * 0.5f;
|
||||
mverts->co[2] -= ((float)fds->res[2] * fds->mesh_scale) * 0.5f;
|
||||
mverts->co[0] *= fds->dx / fds->mesh_scale;
|
||||
mverts->co[1] *= fds->dx / fds->mesh_scale;
|
||||
mverts->co[2] *= fds->dx / fds->mesh_scale;
|
||||
}
|
||||
/* Adjust coordinates from Mantaflow to match viewport scaling. */
|
||||
float tmp[3] = {(float)fds->res[0], (float)fds->res[1], (float)fds->res[2]};
|
||||
/* Scale to unit cube around 0. */
|
||||
mul_v3_fl(tmp, fds->mesh_scale * 0.5f);
|
||||
sub_v3_v3(mverts->co, tmp);
|
||||
/* Apply scaling of domain object. */
|
||||
mul_v3_fl(mverts->co, fds->dx / fds->mesh_scale);
|
||||
|
||||
mul_v3_v3(mverts->co, co_scale);
|
||||
add_v3_v3(mverts->co, co_offset);
|
||||
|
|
Loading…
Reference in New Issue