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:
@@ -846,18 +846,20 @@ static Object *camera_multiview_advanced(Scene *scene, Object *camera, const cha
|
|||||||
char name[MAX_NAME];
|
char name[MAX_NAME];
|
||||||
const char *camera_name = camera->id.name + 2;
|
const char *camera_name = camera->id.name + 2;
|
||||||
const int len_name = strlen(camera_name);
|
const int len_name = strlen(camera_name);
|
||||||
|
int len_suffix_max = -1;
|
||||||
|
|
||||||
name[0] = '\0';
|
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) {
|
for (srv = scene->r.views.first; srv; srv = srv->next) {
|
||||||
const int len_suffix = strlen(srv->suffix);
|
const int len_suffix = strlen(srv->suffix);
|
||||||
|
|
||||||
if (len_name < len_suffix)
|
if ((len_suffix < len_suffix_max) || (len_name < len_suffix))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
|
if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) {
|
||||||
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
|
BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix);
|
||||||
break;
|
len_suffix_max = len_suffix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user