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()});
|
a8::XPrintf("CalcTaretPos old_size:%d\n", {paths_.size()});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
glm::vec3 start = owner_->GetPos().ToGlmVec3() * owner_->room->GetMapMeta()->pb->scale();
|
glm::vec3 start = owner_->GetPos().ToGlmVec3();
|
||||||
glm::vec3 end = owner_->GetPos() + owner_->GetMoveDir() * distance;
|
glm::vec3 end = owner_->GetPos().AddVec2(owner_->GetMoveDir() * distance).ToGlmVec3();
|
||||||
glm::vec3 hit_point;
|
|
||||||
|
|
||||||
bool is_hit = false;
|
bool is_hit = false;
|
||||||
MovePathPoint point;
|
MovePathPoint point;
|
||||||
if (owner_->HasBuffEffect(kBET_ThroughWall) ||
|
if (owner_->HasBuffEffect(kBET_ThroughWall) ||
|
||||||
owner_->HasBuffEffect(kBET_Fly) ||
|
owner_->HasBuffEffect(kBET_Fly) ||
|
||||||
owner_->HasBuffEffect(kBET_Jump)) {
|
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) {
|
if (point.tar_pos.x > owner_->room->GetMapMeta()->pb->map_width() + 10) {
|
||||||
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;
|
point.tar_pos.z = 10;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
is_hit = true;
|
is_hit = true;
|
||||||
point.tar_pos = hit_point * 10.f;
|
point.tar_pos = hit_point / owner_->room->GetMapMeta()->pb->scale();
|
||||||
} else {
|
} else {
|
||||||
point.tar_pos = end * 10.f;
|
point.tar_pos = end / owner_->room->GetMapMeta()->pb->scale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 v2;
|
a8::Vec2 v2;
|
||||||
|
@ -108,3 +108,10 @@ glm::vec3 Position::ToGlmVec3() const
|
|||||||
v.z = z;
|
v.z = z;
|
||||||
return v;
|
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;
|
a8::Vec3 ToVec3() const;
|
||||||
glm::vec2 ToGlmVec2() const;
|
glm::vec2 ToGlmVec2() const;
|
||||||
glm::vec3 ToGlmVec3() const;
|
glm::vec3 ToGlmVec3() const;
|
||||||
|
|
||||||
|
const Position& AddVec2(const a8::Vec2& v);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user