Skip to content

Commit 6608abb

Browse files
committed
[ui][qml] Viewer2D: PhongImageViewer limit to node images and external images
1 parent aacd24a commit 6608abb

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

meshroom/ui/qml/Viewer/Viewer2D.qml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -652,31 +652,39 @@ FocusScope {
652652
property int previousOrientationTag: 1
653653

654654
function getAlbedoFile() {
655+
// get the image file from an external URL
656+
if (useExternal) {
657+
var externalFile = Filepath.urlToString(sourceExternal)
658+
if(externalFile.includes("_normals"))
659+
return Filepath.stringToUrl(externalFile.replace("_normals", "_albedo"))
660+
return sourceExternal
661+
}
655662

663+
// get the image file from selected node albedo attribute
656664
if(vp && selectedNode && selectedNode.hasAttribute("albedo"))
657665
return Filepath.stringToUrl(Filepath.resolve(selectedNode.attribute("albedo").value, vp))
658666

659-
const imageFileUrl = getImageFile()
660-
var imageFile = Filepath.urlToString(imageFileUrl)
661-
662-
if(imageFile.includes("_normals"))
663-
return Filepath.stringToUrl(imageFile.replace("_normals", "_albedo"))
664-
665-
return imageFileUrl
667+
// no valid image file, return empty url
668+
return ""
666669
}
667670

668671
function getNormalFile() {
672+
// get the image file from an external URL
673+
if (useExternal) {
674+
var externalFile = Filepath.urlToString(sourceExternal)
675+
if(externalFile.includes("_normals"))
676+
return sourceExternal
677+
if(externalFile.includes("_albedo"))
678+
return Filepath.stringToUrl(externalFile.replace("_albedo", "_normals"))
679+
return "" // invalid external file
680+
}
669681

682+
// get the image file from selected node normals attribute
670683
if(vp && selectedNode && selectedNode.hasAttribute("normals"))
671684
return Filepath.stringToUrl(Filepath.resolve(selectedNode.attribute("normals").value, vp))
672-
673-
const imageFileUrl = getImageFile()
674-
var imageFile = Filepath.urlToString(imageFileUrl)
675-
676-
if(imageFile.includes("_albedo"))
677-
return Filepath.stringToUrl(imageFile.replace("_albedo", "_normals"))
678-
679-
return imageFileUrl
685+
686+
// no valid image file, return empty url
687+
return ""
680688
}
681689

682690
onWidthChanged: {

0 commit comments

Comments
 (0)