Picking and Bounding volumes



  • Hi,

    I'm wirting a little city/traffic simulation program and have thus far hit a bit of a road block regarding picking. I've attempted to use the QObjectPicker and QRayCaster apis, as well as some manual 3d math but nothing so far works well enough to be usable.

    Neither QObjectPicker and QRayCaster seem to be able to identify the exact object that's been hit. They always seem to be off by a bit (or a lot). My best guess is its the hard coded spherical bounding volume testing the code uses. My map is not fully 3D, more like 2.5D+ and spheres really don't make for the best hit method.

    Doing the hit testing myself has so far not worked because I can't seem to get a valid depth buffer value from Qt or GL. I haven't found a Qt3D api that provides a way to capture just a single depth value, and i think the framegraph I have set up using QForwardRenderer clears the depth buffer before I attempt to read it in various locations (eg: input events, or FrameActions) so all I get back is 0.

    Here's a screen shot of what I have rendering:
    0_1561746692215_Screenshot_20190628_122059.png

    Each rectangle surrounded by green lines is a separate QEntity with its own QGeometry data. I have done a fair bit of work to ensure that no vertex data in the entity geometry lives outside its bounding box according to the QuadTree structure. Unfortunately when I get hits back from QRayCaster the positions don't appear to line up, and the incorrect quadrant entities get selected.

    I'm not sure, but I think its related to the sphere bounding. There may also be a disagreement between transforms between what's being rendered and what the raycasting code is expecting. It's strange, the localIntersection coordinates given by the ray cast hits don't appear to line up properly with the rendered scene. almost like the scale is off by a bit?

    I'd appreciate any help or information.


Log in to reply