summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2020-04-02 14:03:24 +0300
committerJanne Kangas <janne.kangas@qt.io>2020-04-07 04:45:05 +0000
commita05990a7d083ead234b5ef443afdfd3f83fe78ed (patch)
treea55dd009a7519cfa68202e0e808244f72870448f
parent2a53b02190c15f4e63ff982c9c07616db99b2e8e (diff)
Make attributes referenced for custom materials
Mark custom material attributes as referenced always in order to make it possible to use setAttribute. Also fix file path error for images used in custom materials that also have "controlledproperty" attribute (=datainput controller) set. Task-id: QT3DS-4091 Task-id: QT3DS-4092 Task-id: QT3DS-4072 Change-Id: Icf39269ac3fed3f615cb5f7d52cd4e28176f5350 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp4
-rw-r--r--src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp27
-rw-r--r--src/uipparser/Qt3DSUIPParserImpl.cpp3
3 files changed, 25 insertions, 9 deletions
diff --git a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
index 086453c..1dd352c 100644
--- a/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
+++ b/src/runtimerender/graphobjects/Qt3DSRenderDynamicObject.cpp
@@ -125,8 +125,8 @@ void SDynamicObject::SetStrPropertyValueT(dynamic::SPropertyDefinition &inDefini
if (inProjectDir == NULL)
inProjectDir = "";
if (CFileTools::RequiresCombineBaseAndRelative(inValue)) {
- QString absolute = QDir(inProjectDir).filePath(inValue);
- ioWorkspace.assign(absolute.toLatin1().constData());
+ QString path = QDir(inProjectDir).cleanPath(inValue);
+ ioWorkspace.assign(path.toLatin1().constData());
SetPropertyValueT(inDefinition, inStrTable.RegisterStr(ioWorkspace.c_str()));
// We also adjust the image path in the definition
// I could not find a better place
diff --git a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
index 3d0781d..38d021a 100644
--- a/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
+++ b/src/runtimerender/resourcemanager/Qt3DSRenderBufferManager.cpp
@@ -399,16 +399,31 @@ struct SBufferManager : public IBufferManager
if (!theLoadedImage) {
if (QDir(inImagePath.c_str()).isRelative()) {
QString searchPath = inImagePath.c_str();
- if (searchPath.startsWith(QLatin1String("./")))
- searchPath.prepend(QLatin1Char('.'));
- int loops = 0;
- while (!theLoadedImage && ++loops <= 3) {
+
+ // Trying relative to search directories.
+ if (searchPath.startsWith(QLatin1String("../"))) {
+ auto searchPathRel = searchPath.right(searchPath.length() - 3);
theLoadedImage = SLoadedTexture::Load(
- searchPath.toUtf8(), m_Context->GetFoundation(),
+ searchPathRel.toUtf8(), m_Context->GetFoundation(),
*m_InputStreamFactory, true, false,
m_Context->GetRenderContextType(), false, this);
- searchPath.prepend(QLatin1String("../"));
}
+
+ if (!theLoadedImage) {
+ if (searchPath.startsWith(QLatin1String("./")))
+ searchPath.prepend(QLatin1Char('.'));
+
+ int loops = 0;
+ while (!theLoadedImage && ++loops <= 3) {
+ theLoadedImage = SLoadedTexture::Load(
+ searchPath.toUtf8(), m_Context->GetFoundation(),
+ *m_InputStreamFactory, true, false,
+ m_Context->GetRenderContextType(), false, this);
+ searchPath.prepend(QLatin1String("../"));
+ }
+ }
+
+
} else {
// Some textures, for example environment maps for custom materials,
// have absolute path at this point. It points to the wrong place with
diff --git a/src/uipparser/Qt3DSUIPParserImpl.cpp b/src/uipparser/Qt3DSUIPParserImpl.cpp
index 6503dbe..02bd3ad 100644
--- a/src/uipparser/Qt3DSUIPParserImpl.cpp
+++ b/src/uipparser/Qt3DSUIPParserImpl.cpp
@@ -1212,7 +1212,8 @@ void CUIPParserImpl::CacheGraphRequiredAttributes(qt3dsdm::IDOMReader &inReader)
m_ParseElementManager.MarkAttributeAsReferenced(theData, "observedproperty");
// Behaviors need all attributes possible on the object on them all the time.
- if (AreEqual(theType, "Behavior") || AreEqual(theType, "RenderPlugin")) {
+ if (AreEqual(theType, "Behavior") || AreEqual(theType, "RenderPlugin")
+ || AreEqual(theType, "CustomMaterial")) {
m_ParseElementManager.MarkAllAttributesAsReferenced(theData);
}