diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-06-28 12:26:39 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-06-28 12:26:39 +0200 |
commit | 6040f8eb3167ee84cac9de5e6e1a97aeb6a8c569 (patch) | |
tree | a9002f771fa0bb64c555b56341a412c728a629f0 /src/common/Collision/DynamicTree.cpp | |
parent | 623413d08886c74c5a72b55479136b62793f080a (diff) |
Core/Collision: Port new parts for retrieving area/liquid data from gameobjects added when porting 42f9deb21ec68e169f7ed1c8cf14092f144b22da to 3.3.5
Diffstat (limited to 'src/common/Collision/DynamicTree.cpp')
-rw-r--r-- | src/common/Collision/DynamicTree.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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 <G3D/AABox.h> #include <G3D/Ray.h> #include <G3D/Vector3.h> @@ -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::VMapManager2*>(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()); + */} +} |