1
This commit is contained in:
parent
ebc75c7de0
commit
170c5c8365
@ -577,7 +577,10 @@ void MapInstance::MarkMapAreaPolys()
|
|||||||
for (int ii = 0; ii < poly->vertCount; ++ii) {
|
for (int ii = 0; ii < poly->vertCount; ++ii) {
|
||||||
const float* vc = &tile->verts[poly->verts[ii]*3];
|
const float* vc = &tile->verts[poly->verts[ii]*3];
|
||||||
grass_pos_hash_.push_back
|
grass_pos_hash_.push_back
|
||||||
(glm::vec3(vc[0], vc[1], vc[2]));
|
(glm::vec3(vc[0] / GetMapMeta()->scale(),
|
||||||
|
vc[1],
|
||||||
|
vc[2] / GetMapMeta()->scale()
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
poly_ext_datas_.push_back(ext_flag);
|
poly_ext_datas_.push_back(ext_flag);
|
||||||
@ -1085,3 +1088,21 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig,
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MapInstance::GetNearestGrass(const glm::vec3& center, glm::vec3& out_pt)
|
||||||
|
{
|
||||||
|
float nearest_distance = FLT_MAX;
|
||||||
|
glm::vec3* nearest_pt = nullptr;
|
||||||
|
for (auto& pt : grass_pos_hash_) {
|
||||||
|
float distance = std::fabs(pt.x - center.x) + std::fabs(pt.z - center.z);
|
||||||
|
if (distance < nearest_distance) {
|
||||||
|
nearest_distance = distance;
|
||||||
|
nearest_pt = & pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nearest_pt) {
|
||||||
|
out_pt = *nearest_pt;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -57,6 +57,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
|||||||
bool PtInHouse(const glm::vec3& pt, glm::vec3& nearest_pt);
|
bool PtInHouse(const glm::vec3& pt, glm::vec3& nearest_pt);
|
||||||
bool SceneRaycast(const glm::vec3& orig, const glm::vec3& dir, float max_distance,
|
bool SceneRaycast(const glm::vec3& orig, const glm::vec3& dir, float max_distance,
|
||||||
glm::vec3& hit_pos, float& ray_length);
|
glm::vec3& hit_pos, float& ray_length);
|
||||||
|
bool GetNearestGrass(const glm::vec3& center, glm::vec3& out_pt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadHouse();
|
void LoadHouse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user