Compare commits

...

2 Commits

Author SHA1 Message Date
Benoit D.-M. - oslandia
75f4322f07
Merge ca5ac9329097353b57833fb620ed44f416f34981 into 74549aad26c3358101e88477d9dfa1caae013d72 2025-07-01 12:12:11 +02:00
bdm-oslandia
ca5ac93290 fix: 3d point instanciated objects are wrongly oriented
Previous orientation fix was missplaced and replaced by widget data.
2025-06-12 09:00:11 +02:00
6 changed files with 21 additions and 8 deletions

View File

@ -41,10 +41,6 @@ QgsPoint3DSymbol::QgsPoint3DSymbol()
: mMaterialSettings( std::make_unique<QgsPhongMaterialSettings>() )
{
setBillboardSymbol( static_cast<QgsMarkerSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) );
// our built-in 3D geometries (e.g. cylinder, plane, ...) assume Y axis going "up",
// let's rotate them by default so that their Z axis goes "up" (like the rest of the scene)
mTransform.rotate( QQuaternion::fromAxisAndAngle( QVector3D( 1, 0, 0 ), 90 ) );
}
QgsPoint3DSymbol::QgsPoint3DSymbol( const QgsPoint3DSymbol &other )

View File

@ -249,8 +249,15 @@ QgsMaterial *QgsInstancedPoint3DSymbolHandler::material( const QgsPoint3DSymbol
technique->graphicsApiFilter()->setMajorVersion( 3 );
technique->graphicsApiFilter()->setMinorVersion( 2 );
const QMatrix4x4 transformMatrix = symbol->transform();
QMatrix3x3 normalMatrix = transformMatrix.normalMatrix(); // transponed inverse of 3x3 sub-matrix
const QMatrix4x4 tempTransformMatrix = symbol->transform();
// our built-in 3D geometries (e.g. cylinder, plane, ...) assume Y axis going "up",
// let's rotate them by default so that their Z axis goes "up" (like the rest of the scene)
QMatrix4x4 id;
id.rotate( QQuaternion::fromAxisAndAngle( QVector3D( 1, 0, 0 ), 90 ) );
QMatrix4x4 transformMatrix = tempTransformMatrix * id;
// transponed inverse of 3x3 sub-matrix
QMatrix3x3 normalMatrix = transformMatrix.normalMatrix();
// QMatrix3x3 is not supported for passing to shaders, so we pass QMatrix4x4
float *n = normalMatrix.data();

View File

@ -1731,10 +1731,15 @@ void TestQgs3DRendering::testInstancedRendering()
cylinder3DSymbol->setShape( Qgis::Point3DShape::Cylinder );
QVariantMap vmCylinder;
vmCylinder[QStringLiteral( "radius" )] = 20.0f;
vmCylinder[QStringLiteral( "length" )] = 200.0f;
vmCylinder[QStringLiteral( "length" )] = 300.0f;
cylinder3DSymbol->setShapeProperties( vmCylinder );
cylinder3DSymbol->setMaterialSettings( materialSettings.clone() );
// simulate call to set transform as the symbol widget will do
QMatrix4x4 id;
id.translate( 10.0, 0.0, 10.0 );
cylinder3DSymbol->setTransform( id );
layerPointsZ->setRenderer3D( new QgsVectorLayer3DRenderer( cylinder3DSymbol ) );
scene->cameraController()->setLookingAtPoint( QgsVector3D( 0, 0, 0 ), 2500, 60, 0 );
@ -1818,10 +1823,15 @@ void TestQgs3DRendering::testInstancedRenderingClipping()
cylinder3DSymbol->setShape( Qgis::Point3DShape::Cylinder );
QVariantMap vmCylinder;
vmCylinder[QStringLiteral( "radius" )] = 20.0f;
vmCylinder[QStringLiteral( "length" )] = 200.0f;
vmCylinder[QStringLiteral( "length" )] = 300.0f;
cylinder3DSymbol->setShapeProperties( vmCylinder );
cylinder3DSymbol->setMaterialSettings( materialSettings.clone() );
// simulate call to set transform as the symbol widget will do
QMatrix4x4 id;
id.translate( 10.0, 0.0, 10.0 );
cylinder3DSymbol->setTransform( id );
layerPointsZ->setRenderer3D( new QgsVectorLayer3DRenderer( cylinder3DSymbol ) );
scene->cameraController()->setLookingAtPoint( QgsVector3D( 0, 0, 0 ), 2500, 60, 0 );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB