Core/vmaps: Removed vmap lookup functions duplicating functionality of each other

This commit is contained in:
Shauren
2024-03-07 00:23:52 +01:00
parent 1f73cf9f19
commit 45ee989c70
25 changed files with 100 additions and 308 deletions

View File

@@ -154,22 +154,6 @@ private:
PhaseShift const& _phaseShift;
};
struct DynamicTreeAreaInfoCallback
{
DynamicTreeAreaInfoCallback(PhaseShift const& phaseShift) : _phaseShift(phaseShift) {}
void operator()(G3D::Vector3 const& p, GameObjectModel const& obj)
{
obj.intersectPoint(p, _areaInfo, _phaseShift);
}
VMAP::AreaInfo const& GetAreaInfo() const { return _areaInfo; }
private:
PhaseShift const& _phaseShift;
VMAP::AreaInfo _areaInfo;
};
struct DynamicTreeLocationInfoCallback
{
DynamicTreeLocationInfoCallback(PhaseShift const& phaseShift) : _phaseShift(phaseShift), _hitModel(nullptr) {}
@@ -264,24 +248,7 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
return -G3D::finf();
}
bool DynamicMapTree::getAreaInfo(float x, float y, float& z, PhaseShift const& phaseShift, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
G3D::Vector3 v(x, y, z + 0.5f);
DynamicTreeAreaInfoCallback intersectionCallBack(phaseShift);
impl->intersectPoint(v, intersectionCallBack);
if (intersectionCallBack.GetAreaInfo().result)
{
flags = intersectionCallBack.GetAreaInfo().flags;
adtId = intersectionCallBack.GetAreaInfo().adtId;
rootId = intersectionCallBack.GetAreaInfo().rootId;
groupId = intersectionCallBack.GetAreaInfo().groupId;
z = intersectionCallBack.GetAreaInfo().ground_Z;
return true;
}
return false;
}
void DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, PhaseShift const& phaseShift, uint8 reqLiquidType, VMAP::AreaAndLiquidData& data) const
bool DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, PhaseShift const& phaseShift, Optional<uint8> reqLiquidType, VMAP::AreaAndLiquidData& data) const
{
G3D::Vector3 v(x, y, z + 0.5f);
DynamicTreeLocationInfoCallback intersectionCallBack(phaseShift);
@@ -291,13 +258,16 @@ void DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, PhaseShift
data.floorZ = intersectionCallBack.GetLocationInfo().ground_Z;
uint32 liquidType = intersectionCallBack.GetLocationInfo().hitModel->GetLiquidType();
float liquidLevel;
if (!reqLiquidType || VMAP::VMapFactory::createOrGetVMapManager()->GetLiquidFlagsPtr(liquidType) & reqLiquidType)
if (!reqLiquidType || VMAP::VMapFactory::createOrGetVMapManager()->GetLiquidFlagsPtr(liquidType) & *reqLiquidType)
if (intersectionCallBack.GetHitModel()->GetLiquidLevel(v, intersectionCallBack.GetLocationInfo(), liquidLevel))
data.liquidInfo.emplace(liquidType, liquidLevel);
data.areaInfo.emplace(intersectionCallBack.GetHitModel()->GetNameSetId(),
data.areaInfo.emplace(intersectionCallBack.GetLocationInfo().hitModel->GetWmoID(),
intersectionCallBack.GetHitModel()->GetNameSetId(),
intersectionCallBack.GetLocationInfo().rootId,
intersectionCallBack.GetLocationInfo().hitModel->GetWmoID(),
intersectionCallBack.GetLocationInfo().hitModel->GetMogpFlags());
intersectionCallBack.GetLocationInfo().hitModel->GetMogpFlags(),
0);
return true;
}
return false;
}