afritz1 / OpenTESArena

Open-source re-implementation of The Elder Scrolls: Arena.
MIT License
915 stars 68 forks source link

Improve non-uniform 3D ray cast selection #172

Open afritz1 opened 4 years ago

afritz1 commented 4 years ago

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:

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 commented 4 years ago

Fixed in commit da5b86f64c686b8bffc7bd61ac797129f61a6c61.

Leaving this open until these are done:

afritz1 commented 4 years ago

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 commented 1 year ago

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