Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve non-uniform 3D ray cast selection #172

Open
afritz1 opened this issue Jan 22, 2020 · 4 comments
Open

Improve non-uniform 3D ray cast selection #172

afritz1 opened this issue Jan 22, 2020 · 4 comments

Comments

@afritz1
Copy link
Owner

afritz1 commented Jan 22, 2020

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:

// @todo: this is very likely the cause of ceilingHeight looking wrong (too far above and below Y=1)

void DEBUG_ColorRaycastPixel(Game &game, Renderer &renderer)

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
Copy link
Owner Author

afritz1 commented Jan 23, 2020

Fixed in commit da5b86f.

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
Copy link
Owner Author

afritz1 commented Apr 16, 2020

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
Copy link
Owner Author

afritz1 commented Mar 19, 2023

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
Copy link
Owner Author

afritz1 commented Jul 28, 2024

Made a few significant bug fixes for selecting voxels across chunk boundaries, but there still feel like a couple minor edge cases with the math when selecting diagonally, like sometimes it's easier to select the farther part of a voxel than the nearer part.

The debug pixel coloring seems all correct now, except for the part where SDL 2.0.10 changed the coloring to be batched, so only one color shows per frame :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants