OpenTESArena icon indicating copy to clipboard operation
OpenTESArena copied to clipboard

Improve non-uniform 3D ray cast selection

Open afritz1 opened this issue 4 years ago • 3 comments

See #164 and #169.

3D ray cast selection is implemented but it is not completely correct.

Visual debugging code is available at the highest profiler level. Rays are cast out from the camera and draw dots on the screen corresponding to the Y voxel coordinate of the hit. Red dots are Y=0, green are Y=1, etc.. Ideally the dots would perfectly match the visual geometry they are associated with.

Places in code: https://github.com/afritz1/OpenTESArena/blob/ac8b2981a69492b2d486c3695dede22399b8d19b/OpenTESArena/src/Game/Physics.cpp#L999 https://github.com/afritz1/OpenTESArena/blob/ac8b2981a69492b2d486c3695dede22399b8d19b/OpenTESArena/src/Interface/GameWorldPanel.cpp#L106

Other things of note:

  • Seems to look fine when ceilingHeight > 1.0?
  • Sort voxelEntityMap pair.value by projected entity position Z
  • Only check successful door voxel hits if not in LevelData::openDoors vector
  • The world is stretched vertically 20% by SoftwareRenderer::TALL_PIXEL_RATIO

In the picture, the ground should be completely full of red dots, but the ray cast algorithm doesn't register hits everywhere due to bugs in the math calculations, probably deltaDist.

screenshot000

afritz1 avatar Jan 22 '20 08:01 afritz1

Fixed in commit da5b86f64c686b8bffc7bd61ac797129f61a6c61.

Leaving this open until these are done:

  • [ ] Sort voxelEntityMap pair.value by projected entity position Z (can check with trees that overlap each other at certain angles; slightly separate problem: columns that go through the ceiling in the Halls of Colossus)
  • [ ] Only check successful door voxel hits if not in LevelData::openDoors vector

afritz1 avatar Jan 23 '20 03:01 afritz1

The initial ray cast bug seems to still appear on the underside of raised platforms in the wilderness as of current master. Could be because the raised platforms extend outside the voxel they live in. Still need to fix raised platform Y offset and size calculation in wilderness first.

afritz1 avatar Apr 16 '20 05:04 afritz1

Ray cast selection still seems incorrect, i.e. trying to select a voxel face doesn't always work, so this issue is still relevant.

afritz1 avatar Mar 19 '23 18:03 afritz1