Core/Collision: Fix BIH::intersectRay crash

Assure that BIHWrap::remove(const T& obj) actually removes every reference of obj from BIHWrap.
Also add sanity checks to MDLCallback () functions to avoid array overruns.

Closes #5218

Signed-off-by: Nay <dnpd.dd@gmail.com>
Scripts/ZG: Fix some code style issues and logic errors