summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Render/StudioRenderer.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-25 12:21:54 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-25 13:09:24 +0300
commit424bc31512b5ac6b2202ebb39c537bcd1118d9ab (patch)
tree4d2c9fc747340f7d8cd7f2051b5d870c185d98cc /src/Authoring/Studio/Render/StudioRenderer.cpp
parent1ee84df110d3cc6fc4509bc05a5699e199381a22 (diff)
parent0e7e7996a422b47bd371115e6aa4e2998bbda6fb (diff)
Merge branch '2.1' into master
Diffstat (limited to 'src/Authoring/Studio/Render/StudioRenderer.cpp')
-rw-r--r--src/Authoring/Studio/Render/StudioRenderer.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Render/StudioRenderer.cpp b/src/Authoring/Studio/Render/StudioRenderer.cpp
index 9bc45340..1f78f2bc 100644
--- a/src/Authoring/Studio/Render/StudioRenderer.cpp
+++ b/src/Authoring/Studio/Render/StudioRenderer.cpp
@@ -496,15 +496,17 @@ struct SRendererImpl : public IStudioRenderer,
|| m_Translation->GetOrCreateTranslator(theInstance) == nullptr
|| GraphObjectTypes::IsNodeType(
m_Translation->GetOrCreateTranslator(theInstance)->GetGraphObject().m_Type)
- == false)
+ == false) {
theInstance = m_Doc.GetActiveLayer();
+ }
// If we *still* aren't pointed at a node then bail.
if (m_Translation->GetOrCreateTranslator(theInstance) == nullptr
|| GraphObjectTypes::IsNodeType(
m_Translation->GetOrCreateTranslator(theInstance)->GetGraphObject().m_Type)
- == false)
+ == false) {
return;
+ }
SNode &theNode = static_cast<SNode &>(
m_Translation->GetOrCreateTranslator(theInstance)->GetGraphObject());
@@ -523,10 +525,24 @@ struct SRendererImpl : public IStudioRenderer,
}
}
}
- } else
+ } else {
theBounds =
theNode.GetBounds(m_Context->GetBufferManager(), m_Context->GetPathManager());
+ }
+
+ // Fake bounds for non-physical objects
+ if (theBounds.isEmpty()) {
+ const int dim = 50.0f; // Dimensions of a default sized cube
+ theBounds = qt3ds::NVBounds3(QT3DSVec3(-dim, -dim, -dim), QT3DSVec3(dim, dim, dim));
+ }
+
+ // Empty groups don't have proper global transform, so we need to recalculate it.
+ // For simplicity's sake, we recalculate for all groups, not just empty ones.
+ if (theNode.m_Type == GraphObjectTypes::Node)
+ theNode.CalculateGlobalVariables();
+
QT3DSVec3 theCenter = theNode.m_GlobalTransform.transform(theBounds.getCenter());
+
// Center the edit camera so that it points directly at the bounds center point
m_Translation->m_EditCameraInfo.m_Position = theCenter;
// Now we need to adjust the camera's zoom such that the view frustum contains the bounding