Multi-View: fix Multi-View camera suffix test

If we had ambiguity in the SceneRenderView > Suffix matching test, the
first match would be used. And this would happen everytime a
SceneRenderView had an empty camera suffix.

We now take the longest matching suffix instead.
This commit is contained in:
Dalai Felinto 2015-08-19 03:37:58 -03:00
parent cd8581af8e
commit bb479704d0
1 changed files with 4 additions and 2 deletions

View File

@ -846,18 +846,20 @@ static Object *camera_multiview_advanced(Scene *scene, Object *camera, const cha
char name[MAX_NAME];
const char *camera_name = camera->id.name + 2;
const int len_name = strlen(camera_name);
int len_suffix_max = -1;
name[0] = '\0';
/* we need to take the better match, thus the len_suffix_max test */
for (srv = scene->r.views.first; srv; srv = srv->next) {
const int len_suffix = strlen(srv->suffix);
if (len_name < len_suffix)
if ((len_suffix < len_suffix_max) || (len_name < len_suffix))
continue;
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
break;
len_suffix_max = len_suffix;
}
}