Skip to content

DDA vMapCheck truncation only works in positive axis #82

@BlodgettBenjamin

Description

@BlodgettBenjamin

On line 107:
https://github.com/OneLoneCoder/Javidx9/tree/master/PixelGameEngine/SmallerProjects/OneLoneCoder_PGE_RayCastDDA.cpp

vRayStart is truncated from an olc::vf2d to an olc::vi2d. This works fine in the positive x and y axis, but will lead to issues otherwise. I think a comment should be left to note that the truncation will lead to issues. A component-wise flooring will work as intended for negative values.

here is an example of what will go wrong:
dda_issue
I adapted the olc implementation for 3D, in my voxel game. You can see the perspective camera is not situated in the positive xyz axis, and aiming roughly down the xy plane will lead to an inaccurate selection or no selection returned at all.

here is the same example but using a component-wise flooring instead:
dda_floor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions