Smoke viewport: remove dead code.
authorKévin Dietrich <kevin.dietrich@mailoo.org>
Fri, 9 Sep 2016 04:05:58 +0000 (06:05 +0200)
committerKévin Dietrich <kevin.dietrich@mailoo.org>
Fri, 9 Sep 2016 04:05:58 +0000 (06:05 +0200)
OCD commit, but cleans the code a bit:
- the first `if 0` block was supposed to draw collision objects but is
vastly outdated as most of the SmokeCollisionSettings member variables
were removed a few years ago and collision objects are drawn like other
objects anyway. Also it was committed already commented out back in
2009.
- the second `if 0` block was doing pretty much the same thing as the
few lines above it.

source/blender/editors/space_view3d/drawobject.c

index 6ae2229af8e3effaed12df59faf7f75aad63e90d..4af84589eb8fd4886541c081af0a71b01b8c1985 100644 (file)
@@ -7845,122 +7845,79 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                }
        }
 
-       /* draw code for smoke */
-       if (smd) {
-#if 0
-               /* draw collision objects */
-               if ((smd->type & MOD_SMOKE_TYPE_COLL) && smd->coll) {
-                       SmokeCollSettings *scs = smd->coll;
-                       if (scs->points) {
-                               size_t i;
-
-                               glLoadMatrixf(rv3d->viewmat);
-
-                               if (col || (ob->flag & SELECT)) cpack(0xFFFFFF);
-                               glDepthMask(GL_FALSE);
-                               glEnable(GL_BLEND);
-                               
-
-                               // glPointSize(3.0);
-                               glBegin(GL_POINTS);
+       /* draw code for smoke, only draw domains */
+       if (smd && smd->domain) {
+               SmokeDomainSettings *sds = smd->domain;
+               float viewnormal[3];
 
-                               for (i = 0; i < scs->numpoints; i++)
-                               {
-                                       glVertex3fv(&scs->points[3 * i]);
-                               }
+               glLoadMatrixf(rv3d->viewmat);
+               glMultMatrixf(ob->obmat);
 
-                               glEnd();
+               if (!render_override) {
+                       BoundBox bb;
+                       float p0[3], p1[3];
 
-                               glMultMatrixf(ob->obmat);
-                               glDisable(GL_BLEND);
-                               glDepthMask(GL_TRUE);
-                               if (col) cpack(col);
+                       /* draw max domain bounds */
+                       if ((sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)) {
+                               VECSUBFAC(p0, sds->p0, sds->cell_size, sds->adapt_res);
+                               VECADDFAC(p1, sds->p1, sds->cell_size, sds->adapt_res);
+                               BKE_boundbox_init_from_minmax(&bb, p0, p1);
+                               draw_box(bb.vec, false);
                        }
-               }
-#endif
 
-               /* only draw domains */
-               if (smd->domain) {
-                       SmokeDomainSettings *sds = smd->domain;
-                       float viewnormal[3];
+                       /* draw a single voxel to hint the user about the resolution of the fluid */
+                       copy_v3_v3(p0, sds->p0);
 
-                       glLoadMatrixf(rv3d->viewmat);
-                       glMultMatrixf(ob->obmat);
-
-                       if (!render_override) {
-                               BoundBox bb;
-                               float p0[3], p1[3];
-
-                               /* draw adaptive domain bounds */
-                               if ((sds->flags & MOD_SMOKE_ADAPTIVE_DOMAIN)) {
-                                       /* draw domain max bounds */
-                                       VECSUBFAC(p0, sds->p0, sds->cell_size, sds->adapt_res);
-                                       VECADDFAC(p1, sds->p1, sds->cell_size, sds->adapt_res);
-                                       BKE_boundbox_init_from_minmax(&bb, p0, p1);
-                                       draw_box(bb.vec, false);
-                               }
+                       if (sds->flags & MOD_SMOKE_HIGHRES) {
+                               madd_v3_v3v3fl(p1, p0, sds->cell_size, 1.0f / (sds->amplify + 1));
+                       }
+                       else {
+                               add_v3_v3v3(p1, p0, sds->cell_size);
+                       }
 
-#if 0
-                               /* draw base resolution bounds */
-                               BKE_boundbox_init_from_minmax(&bb, sds->p0, sds->p1);
-                               draw_box(bb.vec);
-#endif
+                       BKE_boundbox_init_from_minmax(&bb, p0, p1);
+                       draw_box(bb.vec, false);
+               }
 
+               /* don't show smoke before simulation starts, this could be made an option in the future */
+               if (sds->fluid && CFRA >= sds->point_cache[0]->startframe) {
+                       float p0[3], p1[3];
 
-                               /* draw a single voxel to hint the user about the resolution of the fluid */
-                               copy_v3_v3(p0, sds->p0);
+                       /* get view vector */
+                       invert_m4_m4(ob->imat, ob->obmat);
+                       mul_v3_mat3_m4v3(viewnormal, ob->imat, rv3d->viewinv[2]);
+                       normalize_v3(viewnormal);
 
-                               if (sds->flags & MOD_SMOKE_HIGHRES) {
-                                       madd_v3_v3v3fl(p1, p0, sds->cell_size, 1.0f / (sds->amplify + 1));
-                               }
-                               else {
-                                       add_v3_v3v3(p1, p0, sds->cell_size);
-                               }
+                       /* set dynamic boundaries to draw the volume
+                        * also scale cube to global space to equalize volume slicing on all axes
+                        *  (it's scaled back before drawing) */
+                       p0[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
+                       p0[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
+                       p0[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
+                       p1[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
+                       p1[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
+                       p1[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
 
-                               BKE_boundbox_init_from_minmax(&bb, p0, p1);
-                               draw_box(bb.vec, false);
+                       if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+                               sds->tex = NULL;
+                               GPU_create_smoke(smd, 0);
+                               draw_smoke_volume(sds, ob, p0, p1, viewnormal);
+                               GPU_free_smoke(smd);
+                       }
+                       else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
+                               sds->tex = NULL;
+                               GPU_create_smoke(smd, 1);
+                               draw_smoke_volume(sds, ob, p0, p1, viewnormal);
+                               GPU_free_smoke(smd);
                        }
 
-                       /* don't show smoke before simulation starts, this could be made an option in the future */
-                       if (sds->fluid && CFRA >= sds->point_cache[0]->startframe) {
-                               float p0[3], p1[3];
-
-                               /* get view vector */
-                               invert_m4_m4(ob->imat, ob->obmat);
-                               mul_v3_mat3_m4v3(viewnormal, ob->imat, rv3d->viewinv[2]);
-                               normalize_v3(viewnormal);
-
-                               /* set dynamic boundaries to draw the volume
-                                * also scale cube to global space to equalize volume slicing on all axes
-                                *  (it's scaled back before drawing) */
-                               p0[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_min[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
-                               p0[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_min[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
-                               p0[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_min[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
-                               p1[0] = (sds->p0[0] + sds->cell_size[0] * sds->res_max[0] + sds->obj_shift_f[0]) * fabsf(ob->size[0]);
-                               p1[1] = (sds->p0[1] + sds->cell_size[1] * sds->res_max[1] + sds->obj_shift_f[1]) * fabsf(ob->size[1]);
-                               p1[2] = (sds->p0[2] + sds->cell_size[2] * sds->res_max[2] + sds->obj_shift_f[2]) * fabsf(ob->size[2]);
-
-                               if (!sds->wt || !(sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
-                                       sds->tex = NULL;
-                                       GPU_create_smoke(smd, 0);
-                                       draw_smoke_volume(sds, ob, p0, p1, viewnormal);
-                                       GPU_free_smoke(smd);
-                               }
-                               else if (sds->wt && (sds->viewsettings & MOD_SMOKE_VIEW_SHOWBIG)) {
-                                       sds->tex = NULL;
-                                       GPU_create_smoke(smd, 1);
-                                       draw_smoke_volume(sds, ob, p0, p1, viewnormal);
-                                       GPU_free_smoke(smd);
-                               }
-
-                               /* smoke debug render */
+                       /* smoke debug render */
 #ifdef SMOKE_DEBUG_VELOCITY
-                               draw_smoke_velocity(smd->domain, ob);
+                       draw_smoke_velocity(smd->domain, ob);
 #endif
 #ifdef SMOKE_DEBUG_HEAT
-                               draw_smoke_heat(smd->domain, ob);
+                       draw_smoke_heat(smd->domain, ob);
 #endif
-                       }
                }
        }