aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/DynamicTree.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-03-07 00:23:52 +0100
committerShauren <shauren.trinity@gmail.com>2024-03-07 00:23:52 +0100
commit45ee989c70682c001d4467d97bf1ecedcf7dbcc3 (patch)
treee36b3b8bf55bab550598ef87d3420aba0332793c /src/common/Collision/DynamicTree.cpp
parent1f73cf9f19679f5b888f9df475b94c9405f2d746 (diff)
Core/vmaps: Removed vmap lookup functions duplicating functionality of each other
Diffstat (limited to 'src/common/Collision/DynamicTree.cpp')
-rw-r--r--src/common/Collision/DynamicTree.cpp46
1 files changed, 8 insertions, 38 deletions
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<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;
}