I bumped into a crash when using raycasts under certain conditions:
This code:
local from = vmath.vector3(0, -13200000, 0)
local to = from + vmath.vector3(0, -1, 0)
local groups = {hash("test")}
physics.raycast(from, to, groups)
Together with the game.project setting:
[physics]
scale = 0.01
Causes a crash with this message:
Assertion failed: (r.LengthSquared() > 0.0f), function RayCast, file b2DynamicTree.h, line 232.
Usually when a ray’s vector has 0 length, this warning is displayed instead:
WARNING:PHYSICS: Ray had 0 length when ray casting, ignoring request.
It could have something to do with floating point precision, because of the extreme numbers, coupled with a short ray.
The crash can be avoided, but it may be better to catch it and display the above message instead? I can add a Github issue for this if needed.
Defold 1.9.7. Minimal repro:
RaycastCrash.zip (3.6 KB)