This commit is contained in:
aozhiwei 2023-04-20 21:13:53 +08:00
parent a7c031c126
commit ca3c796c51

View File

@ -15,11 +15,20 @@
bool Collision::CheckBullet(IBullet* bullet, Creature* c)
{
glm::vec3 bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * bullet->GetHitRadius();
return a8::IntersectCylinderCylinder
bool ret = a8::IntersectCylinderCylinder
(
bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10
);
if (!ret) {
bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * (bullet->GetHitRadius() - 2);
ret = a8::IntersectCylinderCylinder
(
bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10
);
}
return ret;
}
bool Collision::CheckBullet(IBullet* bullet, Entity* e)