fix broken laser collision after merging #151
also add a parameter to rect_rect_intersect{,ion} to specify whether to register shader corners/vertices as intersections. previously these would be unconditionally discarded.
This commit is contained in:
parent
0dcdfcb101
commit
9844f5dd9b
3 changed files with 15 additions and 15 deletions
|
@ -345,7 +345,7 @@ static void reimu_dream_bullet_warp(Projectile *p, int t) {
|
|||
gap_bbox.top_left = min(creal(p0), creal(p1)) + I * min(cimag(p0), cimag(p1));
|
||||
gap_bbox.bottom_right = max(creal(p0), creal(p1)) + I * max(cimag(p0), cimag(p1));
|
||||
|
||||
if(rect_rect_intersection(p_bbox, gap_bbox, true, &overlap)) {
|
||||
if(rect_rect_intersection(p_bbox, gap_bbox, true, false, &overlap)) {
|
||||
complex o = (overlap.top_left + overlap.bottom_right) / 2;
|
||||
double fract;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static bool segment_ellipse_nonintersection_heuristic(LineSegment seg, Ellipse e
|
|||
.bottom_right = e.origin + largest_radius + I*largest_radius
|
||||
};
|
||||
|
||||
return !rect_rect_intersect(seg_bbox, e_bbox, true);
|
||||
return !rect_rect_intersect(seg_bbox, e_bbox, true, true);
|
||||
}
|
||||
|
||||
// Is the point of shortest distance between the line through a and b
|
||||
|
@ -82,8 +82,8 @@ static double lineseg_circle_intersect_fallback(LineSegment seg, Circle c) {
|
|||
}
|
||||
|
||||
bool lineseg_ellipse_intersect(LineSegment seg, Ellipse e) {
|
||||
if (segment_ellipse_nonintersection_heuristic(seg, e)) {
|
||||
return 0;
|
||||
if(segment_ellipse_nonintersection_heuristic(seg, e)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Transform the coordinate system so that the ellipse becomes a circle
|
||||
|
@ -106,10 +106,10 @@ bool lineseg_ellipse_intersect(LineSegment seg, Ellipse e) {
|
|||
|
||||
double lineseg_circle_intersect(LineSegment seg, Circle c) {
|
||||
Ellipse e = { .origin = c.origin, .axes = 2*c.radius + I*2*c.radius };
|
||||
if (segment_ellipse_nonintersection_heuristic(seg, e)) {
|
||||
return 0;
|
||||
if(segment_ellipse_nonintersection_heuristic(seg, e)) {
|
||||
return -1;
|
||||
}
|
||||
return lineseg_circle_intersect_fallback(seg, c) >= 0;
|
||||
return lineseg_circle_intersect_fallback(seg, c);
|
||||
}
|
||||
|
||||
bool rect_in_rect(Rect inner, Rect outer) {
|
||||
|
@ -120,7 +120,7 @@ bool rect_in_rect(Rect inner, Rect outer) {
|
|||
rect_bottom(inner) <= rect_bottom(outer);
|
||||
}
|
||||
|
||||
bool rect_rect_intersect(Rect r1, Rect r2, bool edges) {
|
||||
bool rect_rect_intersect(Rect r1, Rect r2, bool edges, bool corners) {
|
||||
if(
|
||||
rect_bottom(r1) < rect_top(r2) ||
|
||||
rect_top(r1) > rect_bottom(r2) ||
|
||||
|
@ -141,12 +141,12 @@ bool rect_rect_intersect(Rect r1, Rect r2, bool edges) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(
|
||||
if(!corners && (
|
||||
(rect_left(r1) == rect_right(r2) && rect_bottom(r1) == rect_top(r2)) ||
|
||||
(rect_left(r1) == rect_right(r2) && rect_bottom(r2) == rect_top(r1)) ||
|
||||
(rect_left(r2) == rect_right(r1) && rect_bottom(r1) == rect_top(r2)) ||
|
||||
(rect_left(r2) == rect_right(r1) && rect_bottom(r2) == rect_top(r1))
|
||||
) {
|
||||
)) {
|
||||
// Discard corner intersects
|
||||
return false;
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ bool rect_rect_intersect(Rect r1, Rect r2, bool edges) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool rect_rect_intersection(Rect r1, Rect r2, bool edges, Rect *out) {
|
||||
if(!rect_rect_intersect(r1, r2, edges)) {
|
||||
bool rect_rect_intersection(Rect r1, Rect r2, bool edges, bool corners, Rect *out) {
|
||||
if(!rect_rect_intersect(r1, r2, edges, corners)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool rect_join(Rect *r1, Rect r2) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if(!rect_rect_intersect(*r1, r2, true)) {
|
||||
if(!rect_rect_intersect(*r1, r2, true, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ void rect_move(Rect *r, complex pos) {
|
|||
}
|
||||
|
||||
bool rect_in_rect(Rect inner, Rect outer) attr_const;
|
||||
bool rect_rect_intersect(Rect r1, Rect r2, bool edges) attr_const;
|
||||
bool rect_rect_intersection(Rect r1, Rect r2, bool edges, Rect *out) attr_pure attr_nonnull(4);
|
||||
bool rect_rect_intersect(Rect r1, Rect r2, bool edges, bool corners) attr_const;
|
||||
bool rect_rect_intersection(Rect r1, Rect r2, bool edges, bool corners, Rect *out) attr_pure attr_nonnull(5);
|
||||
bool rect_join(Rect *r1, Rect r2) attr_pure attr_nonnull(1);
|
||||
void rect_set_xywh(Rect *rect, double x, double y, double w, double h) attr_nonnull(1);
|
||||
|
|
Loading…
Reference in a new issue