Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. QScreenRayCaster does not hit triangles around size 1.0f and smaller
Forum Updated to NodeBB v4.3 + New Features

QScreenRayCaster does not hit triangles around size 1.0f and smaller

Scheduled Pinned Locked Moved Unsolved Game Development
4 Posts 1 Posters 875 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • uaniU Offline
    uaniU Offline
    uani
    wrote on last edited by uani
    #1

    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:
    0085919e-aed2-4e67-843a-4abc2e81733e-image.png

    debug output (mousewheeel, mouse x, mouse y):
    8312f9f6-76b7-47cf-a00f-b51eea002ccd-image.png
    mouse coordinates fit the viewport

    triggered 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();
    }
    
    1 Reply Last reply
    0
    • uaniU Offline
      uaniU Offline
      uani
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • uaniU Offline
        uaniU Offline
        uani
        wrote on last edited by uani
        #3

        @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.

        1 Reply Last reply
        0
        • uaniU Offline
          uaniU Offline
          uani
          wrote on last edited by
          #4

          appears to have been due to single precision floating point used by Qt3D internally.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved