summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@qt.io>2018-03-08 10:16:11 +0100
committerAndy Nichols <andy.nichols@qt.io>2018-03-08 11:11:33 +0000
commit0a9f5004691cc547b622a9c89cf217809c64e98c (patch)
treefdc2bba0f92891251edb728f78ead178e4c55525
parent74c7f57f8d8c532d3074ec3a02dbd35d18a9b59f (diff)
Don't assume position attribute uses default name in visitPrimitives
It is not ok to assume that the position attribute has the default position attribute. It should be the fallback behavior like it is in calculateLocalBoundingVolume. In this case we should try and query the boundingPositionAttribute if it is set. If anything this could have been called just "positionAttribute" since we need to introspect mesh data in a few places and need to know the positionAttribute. The previous logic meant that meshes used by Qt 3D Studio could not take advantage of advanced picking (anything other than bounding spheres) because it does not use the built-in materials or default attribute names (they are optional after all). Change-Id: I5b02a0532add1582ae48121cdc6a7b3040ad1cdd Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r--src/render/backend/visitorutils_p.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/render/backend/visitorutils_p.h b/src/render/backend/visitorutils_p.h
index 452cf153b..084358a14 100644
--- a/src/render/backend/visitorutils_p.h
+++ b/src/render/backend/visitorutils_p.h
@@ -112,12 +112,14 @@ void visitPrimitives(NodeManagers *manager, const GeometryRenderer *renderer, Vi
Buffer *indexBuffer = nullptr;
if (geom) {
+ positionAttribute = manager->lookupResource<Attribute, AttributeManager>(geom->boundingPositionAttribute());
+
Qt3DRender::Render::Attribute *attribute = nullptr;
const auto attrIds = geom->attributes();
for (const Qt3DCore::QNodeId attrId : attrIds) {
attribute = manager->lookupResource<Attribute, AttributeManager>(attrId);
if (attribute){
- if (attribute->name() == QAttribute::defaultPositionAttributeName())
+ if (!positionAttribute && attribute->name() == QAttribute::defaultPositionAttributeName())
positionAttribute = attribute;
else if (attribute->attributeType() == QAttribute::IndexAttribute)
indexAttribute = attribute;