QScreenRayCaster does not hit triangles around size 1.0f and smaller
-
I tried getting a raycast hit on a QPlaneMesh, it receives no hit depite being below the mousepointer. Replacing the Plane by a Torus does let that receive hits but Cuboid and Sphere are out of luck.
Can this be related to the default QPickingSettings method of Bounding Volume? Unfortunately I didn't see a way to set the picking method for a raycast and I don't understand how the QBoundingVolume works having only 2 Points as data rather than being a mesh or a predefined shape so i didn't add a custom bounding volume to the Plane's entity.
application screenshot:
debug output (mousewheeel, mouse x, mouse y):
mouse coordinates fit the viewporttriggered is inside the raycast hit signal:
void mainCore::rayHit(const Qt3DRender::QAbstractRayCaster::Hits &hits) { qDebug() << "triggered"; if(hits.size() > 0) { qDebug() << "hit"; // code } }
ray trigger code:
void mainCore::wheeled(Qt3DInput::QWheelEvent* wheel) { float wheelDir = wheel->angleDelta().y(); if(wheelDir > 0) { this->wheelDir = wheelDir; src->trigger(QPoint(wheel->x(), wheel->y())); } qDebug() << "mouse: " << wheelDir << " " << wheel->x()<< " " << wheel->y(); }
-
apparently my QPlaneMesh was too small, having only had a width and height of each 1.0f.
Now that i increased the size to 100.0f x 100.0f i receive hits.
But i would like to have hits received on "any" size meshes if they are below the mouse pointer. This brings me back to the QPickingSettings I think: how can I set them for a raycast? Should i add them to the same root entity like the raycaster?
-
@uani said in QScreenRayCaster hits Torus Mesh but neither Plane nor Cuboid nor Sphere:
This brings me back to the QPickingSettings I think: how can I set them for a raycast? Should i add them to the same root entity like the raycaster?
is answered here: https://forum.qt.io/topic/80621/how-to-set-3d-object-qcylindermesh-qspheremesh-bounding-volume-to-make-qobjectpicker-work-an-accurate-way/7
i could do
view->renderSettings()->pickingSettings()->setPickMethod(Qt3DRender::QPickingSettings::TrianglePicking);
Still unsolved:
But i would like to have hits received on "any" size meshes if they are below the mouse pointer.
Meshes of width/height 1 (float unit) are not (delivered as) hit.