1
This commit is contained in:
parent
92c7eb62c0
commit
737f7a056a
@ -460,7 +460,9 @@ void CallFuncBuff::ProcFlashMove()
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result);
|
||||
hit_result,
|
||||
owner->room->map_instance->GetMoveIncludeFlags(),
|
||||
owner->room->map_instance->GetMoveExcludeFlags());
|
||||
if (ret) {
|
||||
owner->room->map_instance->UnScale(hit_point);
|
||||
owner->GetMovement()->ClearPath();
|
||||
@ -905,7 +907,9 @@ void CallFuncBuff::SummonHeroSpecDistance()
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result
|
||||
hit_result,
|
||||
owner->room->map_instance->GetMoveIncludeFlags(),
|
||||
owner->room->map_instance->GetMoveExcludeFlags()
|
||||
)) {
|
||||
owner->room->map_instance->UnScale(hit_point);
|
||||
born_pos = hit_point;
|
||||
@ -1001,7 +1005,9 @@ void CallFuncBuff::SummonObstacleSpecDistance()
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result
|
||||
hit_result,
|
||||
owner->room->map_instance->GetMoveIncludeFlags(),
|
||||
owner->room->map_instance->GetMoveExcludeFlags()
|
||||
)) {
|
||||
owner->room->map_instance->UnScale(hit_point);
|
||||
born_pos = hit_point;
|
||||
|
@ -1055,7 +1055,14 @@ void Bullet::Raycast()
|
||||
glm::vec3 hit_point;
|
||||
sender.Get()->room->map_instance->Scale(start);
|
||||
sender.Get()->room->map_instance->Scale(end);
|
||||
bool ret = sender.Get()->room->map_instance->Raycast(start, end, hit_point, hit_result);
|
||||
bool ret = sender.Get()->room->map_instance->Raycast
|
||||
(start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result,
|
||||
room->map_instance->GetBulletIncludeFlags(),
|
||||
room->map_instance->GetBulletExcludeFlags()
|
||||
);
|
||||
if (ret && hit_result) {
|
||||
raycast_hited = true;
|
||||
sender.Get()->room->map_instance->UnScale(hit_point);
|
||||
|
@ -164,6 +164,7 @@ enum VirtualWeapon_e
|
||||
VW_Gas = 9000000,
|
||||
VW_Explosion = 9000001,
|
||||
VW_Weapon = 9000002,
|
||||
VW_Tower = 9000005,
|
||||
};
|
||||
|
||||
enum VirtualPlayer_e
|
||||
@ -172,6 +173,7 @@ enum VirtualPlayer_e
|
||||
VP_Buff = 9000001,
|
||||
VP_Explosion = 9000002,
|
||||
VP_Water = 9000003,
|
||||
VP_Tower = 9000005,
|
||||
};
|
||||
|
||||
enum EquipType_e
|
||||
@ -430,8 +432,10 @@ enum SamplePolyFlags
|
||||
SAMPLE_POLYFLAGS_SWIM = 0x02, // Ability to swim (water).
|
||||
SAMPLE_POLYFLAGS_DOOR = 0x04, // Ability to move through doors.
|
||||
SAMPLE_POLYFLAGS_JUMP = 0x08, // Ability to jump.
|
||||
SAMPLE_POLYFLAGS_DISABLED = 0x10, // Disabled polygon
|
||||
SAMPLE_POLYFLAGS_GLASS = 0x40, // Disabled polygon
|
||||
SAMPLE_POLYFLAGS_DISABLED = 0x10, // Disabled polygon
|
||||
SAMPLE_POLYFLAGS_HOP = 0x20, // 子弹可以穿
|
||||
SAMPLE_POLYFLAGS_GLASS = 0x40, // Disabled polygon
|
||||
SAMPLE_POLYFLAGS_MAGMA = 0x80, //岩浆
|
||||
SAMPLE_POLYFLAGS_ALL = 0xffff // All abilities.
|
||||
};
|
||||
|
||||
|
@ -2630,7 +2630,7 @@ void Creature::SpecDirMove(glm::vec3 dir, float distance)
|
||||
std::vector<dtPolyRef> spec_polys;
|
||||
|
||||
bool hit_result = false;
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, 0);
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, SAMPLE_POLYFLAGS_HOP);
|
||||
if (ret) {
|
||||
room->map_instance->UnScale(hit_point);
|
||||
GetMutablePos().FromGlmVec3(hit_point);
|
||||
@ -3121,7 +3121,13 @@ void Creature::ShortFindPath()
|
||||
|
||||
glm::vec3 hit_point;
|
||||
bool hit_result = false;
|
||||
bool ret = room->map_instance->Raycast(start, end, hit_point, hit_result);
|
||||
bool ret = room->map_instance->Raycast(start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result,
|
||||
room->map_instance->GetMoveIncludeFlags(),
|
||||
room->map_instance->GetMoveExcludeFlags()
|
||||
);
|
||||
if (ret) {
|
||||
new_point = hit_point;
|
||||
room->map_instance->UnScale(new_point);
|
||||
@ -3214,7 +3220,10 @@ float Creature::GetSkillRaycastDistance()
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result);
|
||||
hit_result,
|
||||
room->map_instance->GetMoveIncludeFlags(),
|
||||
room->map_instance->GetMoveExcludeFlags()
|
||||
);
|
||||
if (ret) {
|
||||
room->map_instance->UnScale(hit_point);
|
||||
|
||||
@ -3716,7 +3725,7 @@ void Creature::ActivateTargetValidPos()
|
||||
std::vector<dtPolyRef> spec_polys;
|
||||
|
||||
bool hit_result = false;
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, 0);
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, SAMPLE_POLYFLAGS_HOP);
|
||||
if (ret) {
|
||||
room->map_instance->UnScale(hit_point);
|
||||
target_valid_pos = hit_point;
|
||||
@ -3733,7 +3742,7 @@ void Creature::ActivateTargetValidPos()
|
||||
std::vector<dtPolyRef> spec_polys;
|
||||
|
||||
bool hit_result = false;
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, 0);
|
||||
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, SAMPLE_POLYFLAGS_HOP);
|
||||
if (ret) {
|
||||
room->map_instance->UnScale(hit_point);
|
||||
target_valid_pos = hit_point;
|
||||
|
@ -270,7 +270,9 @@ glm::vec3 HeroAgent::RandomPoint(const glm::vec3& center, float range)
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result
|
||||
hit_result,
|
||||
owner_->room->map_instance->GetMoveIncludeFlags(),
|
||||
owner_->room->map_instance->GetMoveExcludeFlags()
|
||||
)) {
|
||||
owner_->room->map_instance->UnScale(hit_point);
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ int MapInstance::FindStraightPath(
|
||||
epos[2] = end.z;
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
|
||||
@ -389,7 +389,9 @@ bool MapInstance::RandPoint(const glm::vec3& center, float range, glm::vec3& out
|
||||
start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result
|
||||
hit_result,
|
||||
GetMoveIncludeFlags(),
|
||||
GetMoveExcludeFlags()
|
||||
)) {
|
||||
UnScale(hit_point);
|
||||
out_point = hit_point;
|
||||
@ -406,8 +408,8 @@ bool MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
|
||||
{
|
||||
ConnectableQueryFilter filter;
|
||||
filter.map_instance = this;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
@ -447,7 +449,9 @@ bool MapInstance::FindRandomPointAroundCircle(const glm::vec3& center_pos,
|
||||
}
|
||||
|
||||
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,
|
||||
unsigned short includeFlags,
|
||||
unsigned short excludeFlags)
|
||||
{
|
||||
float spos[3];
|
||||
spos[0] = start.x;
|
||||
@ -461,8 +465,8 @@ bool MapInstance::Raycast(const glm::vec3& start, const glm::vec3& end,
|
||||
|
||||
dtStatus status = 0;
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(includeFlags);
|
||||
filter.setExcludeFlags(excludeFlags);
|
||||
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
{
|
||||
@ -527,8 +531,8 @@ bool MapInstance::FindNearestPoint(const glm::vec3& center, float radius, glm::v
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {radius, 10.0f, radius};
|
||||
float nearestPt[3];
|
||||
@ -555,8 +559,8 @@ bool MapInstance::FindConnectableNearestPoint(const glm::vec3& center, float rad
|
||||
|
||||
ConnectableQueryFilter filter;
|
||||
filter.map_instance = this;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {radius, 10.0f, radius};
|
||||
float nearestPt[3];
|
||||
@ -582,8 +586,8 @@ bool MapInstance::GetPosHeight(const Position& pos, float& out_height)
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
float nearestPt[3];
|
||||
@ -636,8 +640,8 @@ dtPoly* MapInstance::GetPoly(glm::vec3 pos, int& poly_idx)
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
float nearestPt[3];
|
||||
@ -753,7 +757,7 @@ bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
|
||||
|
||||
dtStatus status = 0;
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(exclude_flags);
|
||||
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
@ -1266,8 +1270,8 @@ void MapInstance::AdjustOnLandPoint(glm::vec3& point)
|
||||
|
||||
ConnectableQueryFilter filter;
|
||||
filter.map_instance = this;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
int poly_count = 0;
|
||||
dtStatus status = navmesh_query_->queryPolygons(center,
|
||||
@ -1347,8 +1351,8 @@ void MapInstance::MarkConnectablePolys()
|
||||
glm::vec3 pos = map_meta_->GroundSamplingPos();
|
||||
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
filter.setIncludeFlags(GetMoveIncludeFlags());
|
||||
filter.setExcludeFlags(GetMoveExcludeFlags());
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
float nearestPt[3];
|
||||
@ -1412,3 +1416,23 @@ bool MapInstance::IsValidPos(const glm::vec3& point)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned short MapInstance::GetMoveIncludeFlags()
|
||||
{
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
unsigned short MapInstance::GetMoveExcludeFlags()
|
||||
{
|
||||
return SAMPLE_POLYFLAGS_HOP;
|
||||
}
|
||||
|
||||
unsigned short MapInstance::GetBulletIncludeFlags()
|
||||
{
|
||||
return 0xffff;
|
||||
}
|
||||
|
||||
unsigned short MapInstance::GetBulletExcludeFlags()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
||||
glm::vec3& random_pt);
|
||||
bool RandPoint(const glm::vec3& center, float range, glm::vec3& out_point);
|
||||
bool Raycast(const glm::vec3& start, const glm::vec3& end,
|
||||
glm::vec3& hit_point, bool& hit_result);
|
||||
glm::vec3& hit_point, bool& hit_result,
|
||||
unsigned short includeFlags,
|
||||
unsigned short excludeFlags);
|
||||
bool RaycastEx(const glm::vec3& start, const glm::vec3& end,
|
||||
glm::vec3& hit_point, bool& hit_result,
|
||||
int& same_polys_flags, std::vector<dtPolyRef>& spec_polys,
|
||||
@ -64,6 +66,10 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
|
||||
void AdjustOnLandPoint(glm::vec3& point);
|
||||
bool IsConnectablePoly(dtPolyRef poly_ref);
|
||||
bool IsValidPos(const glm::vec3& point);
|
||||
unsigned short GetMoveIncludeFlags();
|
||||
unsigned short GetMoveExcludeFlags();
|
||||
unsigned short GetBulletIncludeFlags();
|
||||
unsigned short GetBulletExcludeFlags();
|
||||
|
||||
private:
|
||||
void LoadHouse();
|
||||
|
@ -119,7 +119,7 @@ void Movement::CalcTargetPos(float distance)
|
||||
} else {
|
||||
unsigned short exclude_flags = 0;
|
||||
if (owner_->HasBuffEffect(kBET_Driver)) {
|
||||
exclude_flags = SAMPLE_POLYFLAGS_DOOR;
|
||||
exclude_flags = SAMPLE_POLYFLAGS_DOOR | SAMPLE_POLYFLAGS_HOP;
|
||||
}
|
||||
glm::vec3 hit_point;
|
||||
owner_->room->map_instance->Scale(start);
|
||||
|
@ -718,7 +718,12 @@ int Room::CreateLootEx(int equip_id, const glm::vec3& born_pos, const glm::vec3&
|
||||
bool hit_result = false;
|
||||
map_instance->Scale(end);
|
||||
bool need_adjust = true;
|
||||
if (map_instance->Raycast(start, end, hit_point, hit_result)) {
|
||||
if (map_instance->Raycast(start,
|
||||
end,
|
||||
hit_point,
|
||||
hit_result,
|
||||
map_instance->GetMoveIncludeFlags(),
|
||||
map_instance->GetMoveExcludeFlags())) {
|
||||
map_instance->UnScale(hit_point);
|
||||
if (GlmHelper::Norm2D(hit_point - born_pos) > 5) {
|
||||
real_pos = hit_point;
|
||||
@ -3598,7 +3603,12 @@ bool Room::BulletCanReach(const glm::vec3& start, const glm::vec3& end)
|
||||
|
||||
map_instance->Scale(a_start);
|
||||
map_instance->Scale(a_end);
|
||||
if (map_instance->Raycast(a_start, a_end, hit_point, hit_result)) {
|
||||
if (map_instance->Raycast(a_start,
|
||||
a_end,
|
||||
hit_point,
|
||||
hit_result,
|
||||
map_instance->GetBulletIncludeFlags(),
|
||||
map_instance->GetBulletExcludeFlags())) {
|
||||
if (!hit_result) {
|
||||
return true;
|
||||
}
|
||||
@ -3608,7 +3618,24 @@ bool Room::BulletCanReach(const glm::vec3& start, const glm::vec3& end)
|
||||
|
||||
bool Room::MoveCanReach(const glm::vec3& start, const glm::vec3& end)
|
||||
{
|
||||
return BulletCanReach(start, end);
|
||||
glm::vec3 a_start = start;
|
||||
glm::vec3 a_end = end;
|
||||
glm::vec3 hit_point;
|
||||
bool hit_result = false;
|
||||
|
||||
map_instance->Scale(a_start);
|
||||
map_instance->Scale(a_end);
|
||||
if (map_instance->Raycast(a_start,
|
||||
a_end,
|
||||
hit_point,
|
||||
hit_result,
|
||||
map_instance->GetMoveIncludeFlags(),
|
||||
map_instance->GetMoveExcludeFlags())) {
|
||||
if (!hit_result) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Room::IsPvpMasterRankModeRoom()
|
||||
|
Loading…
x
Reference in New Issue
Block a user