From 45ee989c70682c001d4467d97bf1ecedcf7dbcc3 Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 7 Mar 2024 00:23:52 +0100 Subject: Core/vmaps: Removed vmap lookup functions duplicating functionality of each other --- src/common/Collision/DynamicTree.cpp | 46 +++++++----------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) (limited to 'src/common/Collision/DynamicTree.cpp') diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp index 8d46455b16b..c2d84e06864 100644 --- a/src/common/Collision/DynamicTree.cpp +++ b/src/common/Collision/DynamicTree.cpp @@ -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 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; } -- cgit v1.2.3