1
This commit is contained in:
parent
5b5022c25c
commit
145caa62ee
@ -79,16 +79,15 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
a8::XPrintf("CalcTaretPos old_size:%d\n", {paths_.size()});
|
||||
}
|
||||
#endif
|
||||
glm::vec3 start = owner_->GetPos().ToGlmVec3() * owner_->room->GetMapMeta()->pb->scale();
|
||||
glm::vec3 end = owner_->GetPos() + owner_->GetMoveDir() * distance;
|
||||
glm::vec3 hit_point;
|
||||
glm::vec3 start = owner_->GetPos().ToGlmVec3();
|
||||
glm::vec3 end = owner_->GetPos().AddVec2(owner_->GetMoveDir() * distance).ToGlmVec3();
|
||||
|
||||
bool is_hit = false;
|
||||
MovePathPoint point;
|
||||
if (owner_->HasBuffEffect(kBET_ThroughWall) ||
|
||||
owner_->HasBuffEffect(kBET_Fly) ||
|
||||
owner_->HasBuffEffect(kBET_Jump)) {
|
||||
point.tar_pos = end * 10.f;
|
||||
point.tar_pos = end;
|
||||
if (point.tar_pos.x > owner_->room->GetMapMeta()->pb->map_width() + 10) {
|
||||
point.tar_pos.x = owner_->room->GetMapMeta()->pb->map_width() - 10;
|
||||
}
|
||||
@ -102,12 +101,15 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
point.tar_pos.z = 10;
|
||||
}
|
||||
} else {
|
||||
glm::vec3 hit_point;
|
||||
start *= owner_->room->GetMapMeta()->pb->scale();
|
||||
end *= owner_->room->GetMapMeta()->pb->scale();
|
||||
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
||||
if (ret > 0) {
|
||||
is_hit = true;
|
||||
point.tar_pos = hit_point * 10.f;
|
||||
point.tar_pos = hit_point / owner_->room->GetMapMeta()->pb->scale();
|
||||
} else {
|
||||
point.tar_pos = end * 10.f;
|
||||
point.tar_pos = end / owner_->room->GetMapMeta()->pb->scale();
|
||||
}
|
||||
}
|
||||
a8::Vec2 v2;
|
||||
|
@ -108,3 +108,10 @@ glm::vec3 Position::ToGlmVec3() const
|
||||
v.z = z;
|
||||
return v;
|
||||
}
|
||||
|
||||
const Position& Position::AddVec2(const a8::Vec2& v)
|
||||
{
|
||||
x += v.x;
|
||||
z += v.y;
|
||||
return *this;
|
||||
}
|
||||
|
@ -91,4 +91,6 @@ struct Position
|
||||
a8::Vec3 ToVec3() const;
|
||||
glm::vec2 ToGlmVec2() const;
|
||||
glm::vec3 ToGlmVec3() const;
|
||||
|
||||
const Position& AddVec2(const a8::Vec2& v);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user