This commit is contained in:
aozhiwei 2023-02-03 16:02:07 +08:00
parent ddcded1ada
commit 99aeb06d16
6 changed files with 26 additions and 18 deletions

View File

@ -979,7 +979,7 @@ void Bullet::Raycast()
glm::vec3 hit_point; glm::vec3 hit_point;
sender.Get()->room->map_instance->Scale(start); sender.Get()->room->map_instance->Scale(start);
sender.Get()->room->map_instance->Scale(end); sender.Get()->room->map_instance->Scale(end);
bool ret = sender.Get()->room->map_instance->Raycast(0, start, end, hit_point, hit_result); bool ret = sender.Get()->room->map_instance->Raycast(start, end, hit_point, hit_result);
if (ret && hit_result) { if (ret && hit_result) {
raycast_hited = true; raycast_hited = true;
sender.Get()->room->map_instance->UnScale(hit_point); sender.Get()->room->map_instance->UnScale(hit_point);

View File

@ -1411,8 +1411,9 @@ void Creature::DecInventory(int slot_id, int num)
inventory_[slot_id].num -= num; inventory_[slot_id].num -= num;
} }
void Creature::CheckSpecObject() void Creature::CheckSpecObject(int new_poly_flags)
{ {
#if 0
int old_poly_ext_flags = poly_ext_flags_; int old_poly_ext_flags = poly_ext_flags_;
poly_ext_flags_ = 0; poly_ext_flags_ = 0;
{ {
@ -1461,6 +1462,7 @@ void Creature::CheckSpecObject()
} }
} }
} }
#endif
} }
void Creature::SummonObstacle(Buff* buff, int id, const Position& target_pos) void Creature::SummonObstacle(Buff* buff, int id, const Position& target_pos)
@ -2384,15 +2386,18 @@ void Creature::SpecDirMove(glm::vec3 dir, float distance)
room->map_instance->Scale(start); room->map_instance->Scale(start);
room->map_instance->Scale(end); room->map_instance->Scale(end);
int same_polys_flags = 0;
std::vector<dtPolyRef> spec_polys;
bool hit_result = false; bool hit_result = false;
bool ret = room->map_instance->Raycast(0, start, end, hit_point, hit_result); bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys);
if (ret) { if (ret) {
room->map_instance->UnScale(hit_point); room->map_instance->UnScale(hit_point);
GetMutablePos().FromGlmVec3(hit_point); GetMutablePos().FromGlmVec3(hit_point);
} }
room->grid_service->MoveCreature(this); room->grid_service->MoveCreature(this);
CheckSpecObject(); //CheckSpecObject();
GetMovement()->ClearPath(); GetMovement()->ClearPath();
} }

View File

@ -223,7 +223,7 @@ class Creature : public MoveableEntity
bool HasSpecMove(); bool HasSpecMove();
void _UpdateSpecMove(); void _UpdateSpecMove();
void CheckSpecObject(); void CheckSpecObject(int new_poly_flags);
void SummonObstacle(Buff* buff, int id, const Position& target_pos); void SummonObstacle(Buff* buff, int id, const Position& target_pos);
void SummonHero(Buff* buff, const Position& pos, const glm::vec3& dir); void SummonHero(Buff* buff, const Position& pos, const glm::vec3& dir);
void FillSkillCasterState(SkillCasterState* caster_state); void FillSkillCasterState(SkillCasterState* caster_state);

View File

@ -210,7 +210,7 @@ int MapInstance::AllocUniid()
return current_uniid_; return current_uniid_;
} }
int MapInstance::FindStraightPath(int layer, int MapInstance::FindStraightPath(
const glm::vec3& start, const glm::vec3& start,
const glm::vec3& end, const glm::vec3& end,
std::vector<glm::vec3>& paths) std::vector<glm::vec3>& paths)
@ -292,8 +292,7 @@ int MapInstance::FindStraightPath(int layer,
return pos; return pos;
} }
int MapInstance::FindRandomPointAroundCircle(int layer, int MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
const glm::vec3& center_pos,
float max_radius, float max_radius,
glm::vec3& random_pt) glm::vec3& random_pt)
{ {
@ -337,7 +336,7 @@ int MapInstance::FindRandomPointAroundCircle(int layer,
} }
} }
bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& end, bool MapInstance::Raycast(const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result) glm::vec3& hit_point, bool& hit_result)
{ {
float spos[3]; float spos[3];
@ -591,7 +590,7 @@ void MapInstance::MarkMapAreaPolys()
} }
} }
bool MapInstance::RaycastEx(int layer, const glm::vec3& start, const glm::vec3& end, bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result, glm::vec3& hit_point, bool& hit_result,
int& same_polys_flags, std::vector<dtPolyRef>& spec_polys) int& same_polys_flags, std::vector<dtPolyRef>& spec_polys)
{ {
@ -695,3 +694,8 @@ bool MapInstance::RaycastEx(int layer, const glm::vec3& start, const glm::vec3&
return true; return true;
} }
int MapInstance::GetPolyFlags(Creature* c, int same_polys_flags, const std::vector<dtPolyRef>& spec_polys)
{
}

View File

@ -26,17 +26,15 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
dtNavMesh* GetNavMesh() { return navmesh_; }; dtNavMesh* GetNavMesh() { return navmesh_; };
dtNavMeshQuery* GetNavMeshQuery() { return navmesh_query_; }; dtNavMeshQuery* GetNavMeshQuery() { return navmesh_query_; };
int FindStraightPath(int layer, int FindStraightPath(const glm::vec3& start,
const glm::vec3& start,
const glm::vec3& end, const glm::vec3& end,
std::vector<glm::vec3>& paths); std::vector<glm::vec3>& paths);
int FindRandomPointAroundCircle(int layer, int FindRandomPointAroundCircle(const glm::vec3& center_pos,
const glm::vec3& center_pos,
float max_radius, float max_radius,
glm::vec3& random_pt); glm::vec3& random_pt);
bool Raycast(int layer, const glm::vec3& start, const glm::vec3& end, bool Raycast(const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result); glm::vec3& hit_point, bool& hit_result);
bool RaycastEx(int layer, const glm::vec3& start, const glm::vec3& end, bool RaycastEx(const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result, glm::vec3& hit_point, bool& hit_result,
int& same_polys_flags, std::vector<dtPolyRef>& spec_polys); int& same_polys_flags, std::vector<dtPolyRef>& spec_polys);
bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt); bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt);
@ -45,6 +43,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
void Scale(glm::vec3& v); void Scale(glm::vec3& v);
void UnScale(glm::vec3& v); void UnScale(glm::vec3& v);
glm::vec3 UnScaleEx(const glm::vec3& v); glm::vec3 UnScaleEx(const glm::vec3& v);
int GetPolyFlags(Creature* c, int same_polys_flags, const std::vector<dtPolyRef>& spec_polys);
private: private:
void CreateThings(); void CreateThings();

View File

@ -27,7 +27,7 @@ bool Movement::UpdatePosition()
{ {
curr_point.curr_pos.AddGlmVec3(curr_point.dir * owner_->GetSpeed()); curr_point.curr_pos.AddGlmVec3(curr_point.dir * owner_->GetSpeed());
owner_->SetPos(curr_point.curr_pos); owner_->SetPos(curr_point.curr_pos);
owner_->CheckSpecObject(); //owner_->CheckSpecObject();
} }
if (owner_->GetPos().Distance2D2(curr_point.src_pos) - curr_point.distance >= 0.0001f) { if (owner_->GetPos().Distance2D2(curr_point.src_pos) - curr_point.distance >= 0.0001f) {
curr_point.tar_pos.y = curr_point.curr_pos.y; curr_point.tar_pos.y = curr_point.curr_pos.y;
@ -83,7 +83,7 @@ void Movement::CalcTargetPos(float distance)
glm::vec3 hit_point; glm::vec3 hit_point;
owner_->room->map_instance->Scale(start); owner_->room->map_instance->Scale(start);
owner_->room->map_instance->Scale(end); owner_->room->map_instance->Scale(end);
bool ret = owner_->room->map_instance->Raycast(0, start, end, hit_point, hit_result); bool ret = owner_->room->map_instance->Raycast(start, end, hit_point, hit_result);
if (ret) { if (ret) {
owner_->room->map_instance->UnScale(hit_point); owner_->room->map_instance->UnScale(hit_point);
point.tar_pos.FromGlmVec3(hit_point); point.tar_pos.FromGlmVec3(hit_point);