diff options
author | Miika Hamalainen <blender@miikah.org> | 2013-08-01 16:09:12 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2013-08-01 16:09:12 +0400 |
commit | ceaec3c86ad57366639db8bc6ba5353e3680b22a (patch) | |
tree | 5ceb9858f192a7f676beadb13369487a3860ea63 /source | |
parent | 702bf77b3490a6c74cf43236c5795b19d042f11b (diff) |
Fix [#36265]: Smoke doesn't work if domain object has negative scale.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 19 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawvolume.c | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b2c0a45cbc4..789b0ec5823 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -259,7 +259,10 @@ static void smoke_set_domain_from_derivedmesh(SmokeDomainSettings *sds, Object * zero_v3_int(sds->base_res); copy_v3_v3(sds->cell_size, size); } - mul_v3_v3(size, ob->size); + /* apply object scale */ + for (i = 0; i < 3; i++) { + size[i] = fabs(size[i] * ob->size[i]); + } copy_v3_v3(sds->global_size, size); copy_v3_v3(sds->dp0, min); @@ -272,21 +275,21 @@ static void smoke_set_domain_from_derivedmesh(SmokeDomainSettings *sds, Object * /* define grid resolutions from longest domain side */ if (size[0] >= MAX2(size[1], size[2])) { scale = res / size[0]; - sds->scale = size[0] / ob->size[0]; + sds->scale = size[0] / fabs(ob->size[0]); sds->base_res[0] = res; sds->base_res[1] = (int)(size[1] * scale + 0.5f); sds->base_res[2] = (int)(size[2] * scale + 0.5f); } else if (size[1] >= MAX2(size[0], size[2])) { scale = res / size[1]; - sds->scale = size[1] / ob->size[1]; + sds->scale = size[1] / fabs(ob->size[1]); sds->base_res[0] = (int)(size[0] * scale + 0.5f); sds->base_res[1] = res; sds->base_res[2] = (int)(size[2] * scale + 0.5f); } else { scale = res / size[2]; - sds->scale = size[2] / ob->size[2]; + sds->scale = size[2] / fabs(ob->size[2]); sds->base_res[0] = (int)(size[0] * scale + 0.5f); sds->base_res[1] = (int)(size[1] * scale + 0.5f); sds->base_res[2] = res; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 6383440893d..797ba5a2236 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -7053,18 +7053,15 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short mul_mat3_m4_v3(ob->imat, viewnormal); normalize_v3(viewnormal); - /* set dynamic boundaries to draw the volume */ - p0[0] = sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]; - p0[1] = sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]; - p0[2] = sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]; - p1[0] = sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]; - p1[1] = sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]; - p1[2] = sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]; - - /* scale cube to global space to equalize volume slicing on all axises + /* set dynamic boundaries to draw the volume + * also scale cube to global space to equalize volume slicing on all axises * (its scaled back before drawing) */ - mul_v3_v3(p0, ob->size); - mul_v3_v3(p1, ob->size); + p0[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]) * fabs(ob->size[0]); + p0[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]) * fabs(ob->size[1]); + p0[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]) * fabs(ob->size[2]); + p1[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]) * fabs(ob->size[0]); + p1[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]) * fabs(ob->size[1]); + p1[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]) * fabs(ob->size[2]); if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) { smd->domain->tex = NULL; diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 8323e7de9a4..5ac6382bdbe 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -461,7 +461,7 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, glTexCoord3d((points[i * 3 + 0] - min[0]) * cor[0] / size[0], (points[i * 3 + 1] - min[1]) * cor[1] / size[1], (points[i * 3 + 2] - min[2]) * cor[2] / size[2]); - glVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]); + glVertex3f(points[i * 3 + 0] / fabs(ob->size[0]), points[i * 3 + 1] / fabs(ob->size[1]), points[i * 3 + 2] / fabs(ob->size[2])); } glEnd(); @@ -474,7 +474,7 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob, glTexCoord3d((points[i * 3 + 0] - min[0]) * cor[0] / size[0], (points[i * 3 + 1] - min[1]) * cor[1] / size[1], (points[i * 3 + 2] - min[2]) * cor[2] / size[2]); - glVertex3f(points[i * 3 + 0] / ob->size[0], points[i * 3 + 1] / ob->size[1], points[i * 3 + 2] / ob->size[2]); + glVertex3f(points[i * 3 + 0] / fabs(ob->size[0]), points[i * 3 + 1] / fabs(ob->size[1]), points[i * 3 + 2] / fabs(ob->size[2])); } glEnd(); } |