aboutsummaryrefslogtreecommitdiff
path: root/src/common/Collision/DynamicTree.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2018-03-28 22:01:22 +0200
committerShauren <shauren.trinity@gmail.com>2018-03-28 22:01:22 +0200
commit42f9deb21ec68e169f7ed1c8cf14092f144b22da (patch)
treee022243733903be45592138354d1f49342c811a4 /src/common/Collision/DynamicTree.cpp
parent95615a4b0d9af431b559bcca68ce9f9f38381397 (diff)
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
Diffstat (limited to 'src/common/Collision/DynamicTree.cpp')
-rw-r--r--src/common/Collision/DynamicTree.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/common/Collision/DynamicTree.cpp b/src/common/Collision/DynamicTree.cpp
index e31bccff507..2fbdfe05b52 100644
--- a/src/common/Collision/DynamicTree.cpp
+++ b/src/common/Collision/DynamicTree.cpp
@@ -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;
+}