From 6040f8eb3167ee84cac9de5e6e1a97aeb6a8c569 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 28 Jun 2020 12:26:39 +0200 Subject: Core/Collision: Port new parts for retrieving area/liquid data from gameobjects added when porting 42f9deb21ec68e169f7ed1c8cf14092f144b22da to 3.3.5 --- src/common/Collision/DynamicTree.cpp | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/common/Collision/DynamicTree.cpp') diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp index aac78545524..ae215e0db4f 100644 --- a/src/common/Collision/DynamicTree.cpp +++ b/src/common/Collision/DynamicTree.cpp @@ -24,6 +24,9 @@ #include "ModelInstance.h" #include "RegularGrid.h" #include "Timer.h" +#include "VMapFactory.h" +#include "VMapManager2.h" +#include "WorldModel.h" #include #include #include @@ -169,6 +172,25 @@ private: VMAP::AreaInfo _areaInfo; }; +struct DynamicTreeLocationInfoCallback +{ + DynamicTreeLocationInfoCallback(PhaseShift const& phaseShift) : _phaseShift(phaseShift), _hitModel(nullptr) {} + + void operator()(G3D::Vector3 const& p, GameObjectModel const& obj) + { + if (obj.GetLocationInfo(p, _locationInfo, _phaseShift)) + _hitModel = &obj; + } + + VMAP::LocationInfo& GetLocationInfo() { return _locationInfo; } + GameObjectModel const* GetHitModel() const { return _hitModel; } + +private: + PhaseShift const& _phaseShift; + VMAP::LocationInfo _locationInfo; + GameObjectModel const* _hitModel; +}; + bool DynamicMapTree::getIntersectionTime(G3D::Ray const& ray, G3D::Vector3 const& endPos, PhaseShift const& phaseShift, float& maxDist) const { float distance = maxDist; @@ -260,3 +282,24 @@ bool DynamicMapTree::getAreaInfo(float x, float y, float& z, PhaseShift const& p } return false; } + +void DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, PhaseShift const& phaseShift, uint8 /*reqLiquidType*/, VMAP::AreaAndLiquidData& /*data*/) const +{ + G3D::Vector3 v(x, y, z + 0.5f); + DynamicTreeLocationInfoCallback intersectionCallBack(phaseShift); + impl->intersectPoint(v, intersectionCallBack); + if (intersectionCallBack.GetLocationInfo().hitModel) + {/* For future use (needs cherry-pick f6c849729b27b77228704b595de3adaf24da2c10) + data.floorZ = intersectionCallBack.GetLocationInfo().ground_Z; + uint32 liquidType = intersectionCallBack.GetLocationInfo().hitModel->GetLiquidType(); + float liquidLevel; + if (!reqLiquidType || (dynamic_cast(VMAP::VMapFactory::createOrGetVMapManager())->GetLiquidFlagsPtr(liquidType) & reqLiquidType)) + if (intersectionCallBack.GetHitModel()->GetLiquidLevel(v, intersectionCallBack.GetLocationInfo(), liquidLevel)) + data.liquidInfo = boost::in_place(liquidType, liquidLevel); + + data.areaInfo = boost::in_place(intersectionCallBack.GetHitModel()->GetNameSetId(), + intersectionCallBack.GetLocationInfo().rootId, + intersectionCallBack.GetLocationInfo().hitModel->GetWmoID(), + intersectionCallBack.GetLocationInfo().hitModel->GetMogpFlags()); + */} +} -- cgit v1.2.3