Stop dividing by zero

This commit is contained in:
Andras Schmelczer 2026-06-10 21:36:13 +01:00
parent 9a06d92ed7
commit bd2307f782
5 changed files with 20 additions and 10 deletions

View file

@ -39,7 +39,7 @@ export const RotatedRectangleFactory = (
vec2 top = rotatedRectangleTopCenters[i];
vec2 bottom = rotatedRectangleBottomCenters[i];
float height = length(bottom - top);
vec2 d = (bottom - top) / height;
vec2 d = height > 0.00000001 ? (bottom - top) / height : vec2(0.0, 1.0);
vec2 q = (target - (top + bottom) * 0.5);
q = mat2(d.x, -d.y, d.y, d.x) * q;