1
This commit is contained in:
parent
9c94c8ec9d
commit
507d264ffc
@ -13,6 +13,8 @@
|
|||||||
#include "mt/Map.h"
|
#include "mt/Map.h"
|
||||||
#include "mt/MapThing.h"
|
#include "mt/MapThing.h"
|
||||||
|
|
||||||
|
static const float GUN_HEIGHT = 3.0f;
|
||||||
|
|
||||||
bool Collision::CheckBullet(IBullet* bullet, Creature* c)
|
bool Collision::CheckBullet(IBullet* bullet, Creature* c)
|
||||||
{
|
{
|
||||||
glm::vec3 bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * bullet->GetHitRadius();
|
glm::vec3 bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * bullet->GetHitRadius();
|
||||||
@ -22,15 +24,15 @@ bool Collision::CheckBullet(IBullet* bullet, Creature* c)
|
|||||||
}
|
}
|
||||||
bool ret = a8::IntersectCylinderCylinder
|
bool ret = a8::IntersectCylinderCylinder
|
||||||
(
|
(
|
||||||
bullet_real_pos, bullet_hit_radius * 1.0, 10,
|
bullet_real_pos, bullet_hit_radius * 1.0, GUN_HEIGHT,
|
||||||
c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10
|
c->GetPos().ToGlmVec3(), c->GetHitRadius(), GUN_HEIGHT
|
||||||
);
|
);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * (bullet->GetHitRadius() - 2);
|
bullet_real_pos = bullet->GetPos().ToGlmVec3() - bullet->GetDir() * (bullet->GetHitRadius() - 2);
|
||||||
ret = a8::IntersectCylinderCylinder
|
ret = a8::IntersectCylinderCylinder
|
||||||
(
|
(
|
||||||
bullet_real_pos, bullet_hit_radius * 1.0, 10,
|
bullet_real_pos, bullet_hit_radius * 1.0, GUN_HEIGHT,
|
||||||
c->GetPos().ToGlmVec3(), c->GetHitRadius(), 10
|
c->GetPos().ToGlmVec3(), c->GetHitRadius(), GUN_HEIGHT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -49,14 +51,14 @@ bool Collision::CheckBullet(IBullet* bullet, Entity* e)
|
|||||||
auto wobj = ob->init_args->Get<std::shared_ptr<mt::WorldObject>>(0);
|
auto wobj = ob->init_args->Get<std::shared_ptr<mt::WorldObject>>(0);
|
||||||
return a8::IntersectCylinderCylinder
|
return a8::IntersectCylinderCylinder
|
||||||
(
|
(
|
||||||
bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
|
bullet_real_pos, bullet->GetHitRadius() * 1.0, GUN_HEIGHT,
|
||||||
e->GetPos().ToGlmVec3(), std::max(wobj->size.x/2.0f, wobj->size.z/2.0f), 10
|
e->GetPos().ToGlmVec3(), std::max(wobj->size.x/2.0f, wobj->size.z/2.0f), GUN_HEIGHT
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return a8::IntersectCylinderCylinder
|
return a8::IntersectCylinderCylinder
|
||||||
(
|
(
|
||||||
bullet_real_pos, bullet->GetHitRadius() * 1.0, 10,
|
bullet_real_pos, bullet->GetHitRadius() * 1.0, GUN_HEIGHT,
|
||||||
e->GetPos().ToGlmVec3(), ob->meta->width(), 10
|
e->GetPos().ToGlmVec3(), ob->meta->width(), GUN_HEIGHT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user