This commit is contained in:
aozhiwei 2023-04-02 17:12:35 +08:00
parent 4b4fed3a62
commit 673580d178

View File

@ -9,6 +9,9 @@
#include "obstacle.h"
#include "roomobstacle.h"
#include "mt/Map.h"
#include "mt/MapThing.h"
bool Collision::CheckBullet(IBullet* bullet, Creature* c)
{
return a8::IntersectCylinderCylinder
@ -26,6 +29,20 @@ bool Collision::CheckBullet(IBullet* bullet, Entity* e)
if (distance > 300) {
return false;
}
if (ob->init_args) {
auto wobj = ob->init_args->Get<std::shared_ptr<mt::WorldObject>>(0);
return a8::IntersectCylinderCylinder
(
bullet->GetPos().ToGlmVec3(), bullet->GetHitRadius() * 0.6, 10,
e->GetPos().ToGlmVec3(), std::max(wobj->size.x/2.0f, wobj->size.z/2.0f), 10
);
} else {
return a8::IntersectCylinderCylinder
(
bullet->GetPos().ToGlmVec3(), bullet->GetHitRadius() * 0.6, 10,
e->GetPos().ToGlmVec3(), ob->meta->width(), 10
);
}
}
return false;
}