[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58802] trunk/blender/source/blender: Fix [#36265]: Smoke doesn't work if domain object has negative scale.
Miika Hämäläinen
blender at miikah.org
Thu Aug 1 15:18:48 CEST 2013
Yes, ideally it would use the matrix scale instead to account scale
changes from parents and constraints.
However, smoke has always used ob->size there, so changing it could
possibly break old files. Also I can imagine scaling smoke domain with
constraints is extremely rare, if ever used at all, so it's not really
worth spending time on refactoring it imho.
1.8.2013 15:29, Campbell Barton wrote:
> Are you sure this is correct?
> The old code was using ob->size too, but not sure this is right.
>
> Its not common to use the object scale directly for anything besides
> the animation system since there may be constraints/parenting changing
> the final scale.
>
> With negative scale normally its best to check by using
> is_negative_m4(ob->obmat), (in most cases you don't care which axis is
> negative).
>
> if you really need the scale from the object you can use
> mat4_to_loc_rot_size(loc, rot, size, ob->obmat) and use the scale from
> that.
>
> On Thu, Aug 1, 2013 at 10:09 PM, Miika Hamalainen <blender at miikah.org> wrote:
>> Revision: 58802
>> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58802
>> Author: miikah
>> Date: 2013-08-01 12:09:12 +0000 (Thu, 01 Aug 2013)
>> Log Message:
>> -----------
>> Fix [#36265]: Smoke doesn't work if domain object has negative scale.
>>
>> Modified Paths:
>> --------------
>> trunk/blender/source/blender/blenkernel/intern/smoke.c
>> trunk/blender/source/blender/editors/space_view3d/drawobject.c
>> trunk/blender/source/blender/editors/space_view3d/drawvolume.c
>>
>> Modified: trunk/blender/source/blender/blenkernel/intern/smoke.c
>> ===================================================================
>> --- trunk/blender/source/blender/blenkernel/intern/smoke.c 2013-08-01 03:58:22 UTC (rev 58801)
>> +++ trunk/blender/source/blender/blenkernel/intern/smoke.c 2013-08-01 12:09:12 UTC (rev 58802)
>> @@ -259,7 +259,10 @@
>> 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 @@
>> /* 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;
>>
>> Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
>> ===================================================================
>> --- trunk/blender/source/blender/editors/space_view3d/drawobject.c 2013-08-01 03:58:22 UTC (rev 58801)
>> +++ trunk/blender/source/blender/editors/space_view3d/drawobject.c 2013-08-01 12:09:12 UTC (rev 58802)
>> @@ -7053,18 +7053,15 @@
>> 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;
>>
>> Modified: trunk/blender/source/blender/editors/space_view3d/drawvolume.c
>> ===================================================================
>> --- trunk/blender/source/blender/editors/space_view3d/drawvolume.c 2013-08-01 03:58:22 UTC (rev 58801)
>> +++ trunk/blender/source/blender/editors/space_view3d/drawvolume.c 2013-08-01 12:09:12 UTC (rev 58802)
>> @@ -461,7 +461,7 @@
>> 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 @@
>> 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();
>> }
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
>
More information about the Bf-committers
mailing list