remove redundant null checks and avoid divide by zero in driver evaluation

This commit is contained in:
Campbell Barton 2013-07-13 05:53:14 +00:00
parent fa3699f067
commit edb850c842
4 changed files with 8 additions and 6 deletions

@ -1697,7 +1697,7 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
/* perform operations on the total if appropriate */
if (driver->type == DRIVER_TYPE_AVERAGE)
driver->curval = (value / (float)tot);
driver->curval = tot ? (value / (float)tot) : 0.0f;
else
driver->curval = value;
}

@ -2718,8 +2718,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
re = RE_GetRender(iuser->scene->id.name);
channels = 4;
layer = (iuser) ? iuser->layer : 0;
pass = (iuser) ? iuser->pass : 0;
layer = iuser->layer;
pass = iuser->pass;
if (from_render) {
RE_AcquireResultImage(re, &rres);

@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
if (target && target->type == OB_MESH) {
if (target->type == OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
if (dm) {
use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL);

@ -2051,8 +2051,10 @@ int do_version_tface(Main *main, int fileload)
printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2);
nowarning = 0;
}
else
convert_tfacematerial(main, ma); continue;
else {
convert_tfacematerial(main, ma);
}
continue;
}
/* no conflicts in this material - 90% of cases