fenomas / noa

Experimental voxel game engine.
MIT License
608 stars 86 forks source link

getEntitiesInAABB incorrectly adds world offsets #163

Closed MCArth closed 2 years ago

MCArth commented 2 years ago

The code in getEntitiesInAABB adds worldoffset:

        var testExtents = [
            box.base[0] + off[0], box.base[1] + off[1], box.base[2] + off[2],
            box.max[0] + off[0], box.max[1] + off[1], box.max[2] + off[2],
        ]

instead of subtracting as should be done to correctly convert from global to local co-ordinates:

        var testExtents = [
            box.base[0] - off[0], box.base[1] - off[1], box.base[2] - off[2],
            box.max[0] - off[0], box.max[1] - off[1], box.max[2] - off[2],
        ]

testExtents is tested against positionComponent._extents which is in local co-ordinates, so should also be local.

fenomas commented 2 years ago

Right you are, thanks very much!