Core/Maps: Implemented getting area id from gameobject spawns

Yes, you can now spawn LK platform anywhere and it will treat you as inside Icecrown Citadel
This commit is contained in:
Shauren
2018-03-28 22:01:22 +02:00
parent 95615a4b0d
commit 42f9deb21e
16 changed files with 161 additions and 45 deletions

View File

@@ -17,16 +17,13 @@
*/
#include "DynamicTree.h"
//#include "QuadTree.h"
//#include "RegularGrid.h"
#include "BoundingIntervalHierarchyWrapper.h"
#include "GameObjectModel.h"
#include "Log.h"
#include "MapTree.h"
#include "ModelInstance.h"
#include "RegularGrid.h"
#include "Timer.h"
#include "GameObjectModel.h"
#include "ModelInstance.h"
#include <G3D/AABox.h>
#include <G3D/Ray.h>
#include <G3D/Vector3.h>
@@ -156,6 +153,22 @@ 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;
};
bool DynamicMapTree::getIntersectionTime(G3D::Ray const& ray, G3D::Vector3 const& endPos, PhaseShift const& phaseShift, float& maxDist) const
{
float distance = maxDist;
@@ -230,3 +243,20 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
else
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;
}