This commit is contained in:
aozhiwei 2023-01-03 17:10:06 +08:00
parent 4ae336db3b
commit 23d0e70f93
2 changed files with 10 additions and 2 deletions

View File

@ -53,6 +53,14 @@ bool GlmHelper::IsZero(const glm::vec3& v)
float GlmHelper::CalcAngle(const glm::vec3& v1, const glm::vec3& v2)
{
#if 1
glm::vec3 v3 = v1;
glm::vec3 v4 = v2;
v3.y = 0.0f;
v4.y = 0.0f;
float angle = acos(glm::dot(v3, v4) / Norm(v3) / Norm(v4));
#else
float angle = acos(glm::dot(v1, v2) / Norm(v1) / Norm(v2));
#endif
return angle / 3.1415926f;
}

View File

@ -423,7 +423,7 @@ void InternalShot(Creature* c,
bool is_player = c->IsPlayer();
bool is_car = c->IsCar();
float bullet_born_angle = GlmHelper::CalcAngle(c->GetAttackDir(), GlmHelper::RIGHT);
if (c->GetAttackDir().y > 0.00001f) {
if (c->GetAttackDir().z > 0.00001f) {
bullet_born_angle = -bullet_born_angle;
}
float old_bullet_born_angle = bullet_born_angle;
@ -435,7 +435,7 @@ void InternalShot(Creature* c,
glm::vec4 gun_muzzle_position(0.0, 0.0, 0.0, 0.0);
CalcGunMuzzlePosition(c, weapon_meta, shot_animi, gun_muzzle_position, bulletIdx, bulletNum);
glm::vec4 v = transform * gun_muzzle_position;
bullet_born_offset = glm::vec3(v.z *10*1, 0.0f, v.x*10*-1);
bullet_born_offset = glm::vec3(v.z *10*1, v.y, v.x*10*-1);
bullet_born_pos = c->GetPos().ToGlmVec3() + bullet_born_offset;
if (c->IsPlayer() || c->IsCar()) {
#ifdef DEBUG