1
This commit is contained in:
parent
4498d8d556
commit
a3a321069d
@ -499,3 +499,17 @@ bool MapInstance::GetPosHeight(const Position& pos, float& out_height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MapInstance::Scale(glm::vec3& v)
|
||||
{
|
||||
float old_y = v.y;
|
||||
v *= GetMapMeta()->pb->scale();
|
||||
v.y = old_y;
|
||||
}
|
||||
|
||||
void MapInstance::UnScale(glm::vec3& v)
|
||||
{
|
||||
float old_y = v.y;
|
||||
v /= GetMapMeta()->pb->scale();
|
||||
v.y = old_y;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ class MapInstance
|
||||
int Raycast(int layer, const glm::vec3& start, const glm::vec3& end, glm::vec3& hit_point);
|
||||
bool FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec3& nearestPt);
|
||||
bool GetPosHeight(const Position& pos, float& out_height);
|
||||
void Scale(glm::vec3& v);
|
||||
void UnScale(glm::vec3& v);
|
||||
|
||||
private:
|
||||
void CreateThings();
|
||||
|
@ -76,14 +76,14 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
}
|
||||
} else {
|
||||
glm::vec3 hit_point;
|
||||
start *= owner_->room->GetMapMeta()->pb->scale();
|
||||
end *= owner_->room->GetMapMeta()->pb->scale();
|
||||
owner_->room->map_instance->Scale(start);
|
||||
owner_->room->map_instance->Scale(end);
|
||||
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
||||
if (ret > 0) {
|
||||
is_hit = true;
|
||||
point.tar_pos.FromGlmVec3(hit_point / owner_->room->GetMapMeta()->pb->scale());
|
||||
owner_->room->map_instance->UnScale(hit_point);
|
||||
} else {
|
||||
point.tar_pos.FromGlmVec3(end / owner_->room->GetMapMeta()->pb->scale());
|
||||
owner_->room->map_instance->UnScale(end);
|
||||
}
|
||||
}
|
||||
point.distance = owner_->GetPos().Distance2D2(point.tar_pos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user