This commit is contained in:
aozhiwei 2023-01-01 14:49:54 +08:00
parent 73177454cc
commit e908a1e8e9
2 changed files with 15 additions and 0 deletions

View File

@ -362,4 +362,16 @@ namespace a8
}
return true;
}
bool IntersectCylinderCylinder(const glm::vec3& a_pos, float a_rad, float a_height,
const glm::vec3& b_pos, float b_rad, float b_height)
{
glm::vec2 v = glm::vec2(b_pos.x, b_pos.z) - glm::vec2(a_pos.x, a_pos.z);
float n = glm::length(v);
if (n > a_rad + b_rad) {
return false;
}
return (a_pos.y - b_pos.y) < (a_height + b_height) / 2.0f;
}
}

View File

@ -16,6 +16,9 @@ namespace a8
float b_width,
float b_height);
bool IntersectCircleCircle(a8::Vec2 a_pos, float a_rad, a8::Vec2 b_pos, float b_rad);
bool IntersectCylinderCylinder(const glm::vec3& a_pos, float a_rad, float a_height,
const glm::vec3& b_pos, float b_rad, float b_height);
bool IntersectCircleArc(a8::Vec2 a_pos,
float a_rad,
a8::Vec2 b_pos,