1
This commit is contained in:
parent
99aeb06d16
commit
0efe12e24f
@ -2394,10 +2394,10 @@ void Creature::SpecDirMove(glm::vec3 dir, float distance)
|
|||||||
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->map_instance->CheckTerrain(this, same_polys_flags, spec_polys);
|
||||||
}
|
}
|
||||||
|
|
||||||
room->grid_service->MoveCreature(this);
|
room->grid_service->MoveCreature(this);
|
||||||
//CheckSpecObject();
|
|
||||||
GetMovement()->ClearPath();
|
GetMovement()->ClearPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "mapmgr.h"
|
#include "mapmgr.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "entityfactory.h"
|
#include "entityfactory.h"
|
||||||
|
#include "creature.h"
|
||||||
#include "mt/MetaMgr.h"
|
#include "mt/MetaMgr.h"
|
||||||
#include "mt/Param.h"
|
#include "mt/Param.h"
|
||||||
#include "mt/Map.h"
|
#include "mt/Map.h"
|
||||||
@ -695,7 +696,31 @@ bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapInstance::GetPolyFlags(Creature* c, int same_polys_flags, const std::vector<dtPolyRef>& spec_polys)
|
void MapInstance::CheckTerrain(Creature* c, int same_poly_flags, const std::vector<dtPolyRef>& spec_polys)
|
||||||
{
|
{
|
||||||
|
if (same_poly_flags) {
|
||||||
|
c->CheckSpecObject(same_poly_flags);
|
||||||
|
} else {
|
||||||
|
if (spec_polys.empty()) {
|
||||||
|
c->CheckSpecObject(0);
|
||||||
|
} else {
|
||||||
|
float pos[3];
|
||||||
|
pos[0] = c->GetPos().x;
|
||||||
|
pos[1] = c->GetPos().y;
|
||||||
|
pos[2] = c->GetPos().z;
|
||||||
|
float closest[3];
|
||||||
|
for (auto& poly_ref : spec_polys) {
|
||||||
|
dtStatus status = navmesh_query_->closestPointOnPolyBoundary(poly_ref, pos, closest);
|
||||||
|
if (dtStatusSucceed(status) &&
|
||||||
|
std::fabs(closest[0] - c->GetPos().x) <= 0.3f &&
|
||||||
|
std::fabs(closest[2] - c->GetPos().z) <= 0.3f) {
|
||||||
|
unsigned short flags = 0;
|
||||||
|
if (dtStatusSucceed(navmesh_->getPolyFlags(poly_ref, &flags))) {
|
||||||
|
c->CheckSpecObject(flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +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);
|
void CheckTerrain(Creature* c, int same_poly_flags, const std::vector<dtPolyRef>& spec_polys);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateThings();
|
void CreateThings();
|
||||||
|
@ -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_->room->map_instance->CheckTerrain(owner_, curr_point.same_polys_flags, curr_point.spec_polys);
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user