mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Remove using directive from header files (It will eventually lead to name collisions)
This commit is contained in:
@@ -18,6 +18,12 @@
|
||||
|
||||
#include "BoundingIntervalHierarchy.h"
|
||||
|
||||
#if defined __APPLE__
|
||||
#define isnan std::isnan
|
||||
#elif defined _MSC_VER
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
|
||||
void BIH::buildHierarchy(std::vector<uint32> &tempTree, buildData &dat, BuildStats &stats)
|
||||
{
|
||||
// create space for the first node
|
||||
@@ -51,7 +57,7 @@ void BIH::subdivide(int left, int right, std::vector<uint32> &tempTree, buildDat
|
||||
prevAxis = axis;
|
||||
prevSplit = split;
|
||||
// perform quick consistency checks
|
||||
Vector3 d( gridBox.hi - gridBox.lo );
|
||||
G3D::Vector3 d( gridBox.hi - gridBox.lo );
|
||||
if (d.x < 0 || d.y < 0 || d.z < 0)
|
||||
throw std::logic_error("negative node extents");
|
||||
for (int i = 0; i < 3; i++)
|
||||
@@ -255,11 +261,11 @@ bool BIH::writeToFile(FILE* wf) const
|
||||
bool BIH::readFromFile(FILE* rf)
|
||||
{
|
||||
uint32 treeSize;
|
||||
Vector3 lo, hi;
|
||||
G3D::Vector3 lo, hi;
|
||||
uint32 check=0, count=0;
|
||||
check += fread(&lo, sizeof(float), 3, rf);
|
||||
check += fread(&hi, sizeof(float), 3, rf);
|
||||
bounds = AABox(lo, hi);
|
||||
bounds = G3D::AABox(lo, hi);
|
||||
check += fread(&treeSize, sizeof(uint32), 1, rf);
|
||||
tree.resize(treeSize);
|
||||
check += fread(&tree[0], sizeof(uint32), treeSize, rf);
|
||||
|
||||
@@ -31,20 +31,8 @@
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define isnan(x) ( std::isnan(x) )
|
||||
#endif
|
||||
|
||||
#define MAX_STACK_SIZE 64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define isnan(x) _isnan(x)
|
||||
#endif
|
||||
|
||||
using G3D::Vector3;
|
||||
using G3D::AABox;
|
||||
using G3D::Ray;
|
||||
|
||||
static inline uint32 floatToRawIntBits(float f)
|
||||
{
|
||||
union
|
||||
@@ -69,7 +57,7 @@ static inline float intBitsToFloat(uint32 i)
|
||||
|
||||
struct AABound
|
||||
{
|
||||
Vector3 lo, hi;
|
||||
G3D::Vector3 lo, hi;
|
||||
};
|
||||
|
||||
/** Bounding Interval Hierarchy Class.
|
||||
@@ -105,12 +93,11 @@ class BIH
|
||||
dat.maxPrims = leafSize;
|
||||
dat.numPrims = primitives.size();
|
||||
dat.indices = new uint32[dat.numPrims];
|
||||
dat.primBound = new AABox[dat.numPrims];
|
||||
dat.primBound = new G3D::AABox[dat.numPrims];
|
||||
getBounds(primitives[0], bounds);
|
||||
for (uint32 i=0; i<dat.numPrims; ++i)
|
||||
{
|
||||
dat.indices[i] = i;
|
||||
AABox tb;
|
||||
getBounds(primitives[i], dat.primBound[i]);
|
||||
bounds.merge(dat.primBound[i]);
|
||||
}
|
||||
@@ -131,13 +118,13 @@ class BIH
|
||||
uint32 primCount() const { return objects.size(); }
|
||||
|
||||
template<typename RayCallback>
|
||||
void intersectRay(const Ray &r, RayCallback& intersectCallback, float &maxDist, bool stopAtFirst=false) const
|
||||
void intersectRay(const G3D::Ray &r, RayCallback& intersectCallback, float &maxDist, bool stopAtFirst=false) const
|
||||
{
|
||||
float intervalMin = -1.f;
|
||||
float intervalMax = -1.f;
|
||||
Vector3 org = r.origin();
|
||||
Vector3 dir = r.direction();
|
||||
Vector3 invDir;
|
||||
G3D::Vector3 org = r.origin();
|
||||
G3D::Vector3 dir = r.direction();
|
||||
G3D::Vector3 invDir;
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
invDir[i] = 1.f / dir[i];
|
||||
@@ -270,7 +257,7 @@ class BIH
|
||||
}
|
||||
|
||||
template<typename IsectCallback>
|
||||
void intersectPoint(const Vector3 &p, IsectCallback& intersectCallback) const
|
||||
void intersectPoint(const G3D::Vector3 &p, IsectCallback& intersectCallback) const
|
||||
{
|
||||
if (!bounds.contains(p))
|
||||
return;
|
||||
@@ -353,12 +340,12 @@ class BIH
|
||||
protected:
|
||||
std::vector<uint32> tree;
|
||||
std::vector<uint32> objects;
|
||||
AABox bounds;
|
||||
G3D::AABox bounds;
|
||||
|
||||
struct buildData
|
||||
{
|
||||
uint32 *indices;
|
||||
AABox *primBound;
|
||||
G3D::AABox *primBound;
|
||||
uint32 numPrims;
|
||||
int maxPrims;
|
||||
};
|
||||
@@ -410,4 +397,4 @@ class BIH
|
||||
void subdivide(int left, int right, std::vector<uint32> &tempTree, buildData &dat, AABound &gridBox, AABound &nodeBox, int nodeIndex, int depth, BuildStats &stats);
|
||||
};
|
||||
|
||||
#endif // _BIH_H
|
||||
#endif // _BIH_H
|
||||
|
||||
@@ -37,7 +37,7 @@ class BIHWrap
|
||||
|
||||
MDLCallback(RayCallback& callback, const T* const* objects_array, uint32 objects_size ) : objects(objects_array), _callback(callback), objects_size(objects_size) {}
|
||||
|
||||
bool operator() (const Ray& ray, uint32 Idx, float& MaxDist, bool /*stopAtFirst*/)
|
||||
bool operator() (const G3D::Ray& ray, uint32 Idx, float& MaxDist, bool /*stopAtFirst*/)
|
||||
{
|
||||
if (Idx >= objects_size)
|
||||
return false;
|
||||
@@ -46,7 +46,7 @@ class BIHWrap
|
||||
return false;
|
||||
}
|
||||
|
||||
void operator() (const Vector3& p, uint32 Idx)
|
||||
void operator() (const G3D::Vector3& p, uint32 Idx)
|
||||
{
|
||||
if (Idx >= objects_size)
|
||||
return false;
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename RayCallback>
|
||||
void intersectRay(const Ray& ray, RayCallback& intersectCallback, float& maxDist)
|
||||
void intersectRay(const G3D::Ray& ray, RayCallback& intersectCallback, float& maxDist)
|
||||
{
|
||||
balance();
|
||||
MDLCallback<RayCallback> temp_cb(intersectCallback, m_objects.getCArray(), m_objects.size());
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename IsectCallback>
|
||||
void intersectPoint(const Vector3& point, IsectCallback& intersectCallback)
|
||||
void intersectPoint(const G3D::Vector3& point, IsectCallback& intersectCallback)
|
||||
{
|
||||
balance();
|
||||
MDLCallback<IsectCallback> callback(intersectCallback, m_objects.getCArray(), m_objects.size());
|
||||
|
||||
@@ -27,15 +27,24 @@
|
||||
#include "GameObjectModel.h"
|
||||
#include "ModelInstance.h"
|
||||
|
||||
#include <G3D/AABox.h>
|
||||
#include <G3D/Ray.h>
|
||||
#include <G3D/Vector3.h>
|
||||
|
||||
using VMAP::ModelInstance;
|
||||
using G3D::Ray;
|
||||
|
||||
namespace {
|
||||
|
||||
int CHECK_TREE_PERIOD = 200;
|
||||
|
||||
} // namespace
|
||||
|
||||
template<> struct HashTrait< GameObjectModel>{
|
||||
static size_t hashCode(const GameObjectModel& g) { return (size_t)(void*)&g; }
|
||||
};
|
||||
|
||||
template<> struct PositionTrait< GameObjectModel> {
|
||||
static void getPosition(const GameObjectModel& g, Vector3& p) { p = g.getPosition(); }
|
||||
static void getPosition(const GameObjectModel& g, G3D::Vector3& p) { p = g.getPosition(); }
|
||||
};
|
||||
|
||||
template<> struct BoundsTrait< GameObjectModel> {
|
||||
@@ -49,11 +58,6 @@ static bool operator == (const GameObjectModel& mdl, const GameObjectModel& mdl2
|
||||
}
|
||||
*/
|
||||
|
||||
int valuesPerNode = 5, numMeanSplits = 3;
|
||||
|
||||
int UNBALANCED_TIMES_LIMIT = 5;
|
||||
int CHECK_TREE_PERIOD = 200;
|
||||
|
||||
typedef RegularGrid2D<GameObjectModel, BIHWrap<GameObjectModel> > ParentTree;
|
||||
|
||||
struct DynTreeImpl : public ParentTree/*, public Intersectable*/
|
||||
@@ -103,43 +107,43 @@ struct DynTreeImpl : public ParentTree/*, public Intersectable*/
|
||||
int unbalanced_times;
|
||||
};
|
||||
|
||||
DynamicMapTree::DynamicMapTree() : impl(*new DynTreeImpl())
|
||||
DynamicMapTree::DynamicMapTree() : impl(new DynTreeImpl())
|
||||
{
|
||||
}
|
||||
|
||||
DynamicMapTree::~DynamicMapTree()
|
||||
{
|
||||
delete &impl;
|
||||
delete impl;
|
||||
}
|
||||
|
||||
void DynamicMapTree::insert(const GameObjectModel& mdl)
|
||||
{
|
||||
impl.insert(mdl);
|
||||
impl->insert(mdl);
|
||||
}
|
||||
|
||||
void DynamicMapTree::remove(const GameObjectModel& mdl)
|
||||
{
|
||||
impl.remove(mdl);
|
||||
impl->remove(mdl);
|
||||
}
|
||||
|
||||
bool DynamicMapTree::contains(const GameObjectModel& mdl) const
|
||||
{
|
||||
return impl.contains(mdl);
|
||||
return impl->contains(mdl);
|
||||
}
|
||||
|
||||
void DynamicMapTree::balance()
|
||||
{
|
||||
impl.balance();
|
||||
impl->balance();
|
||||
}
|
||||
|
||||
int DynamicMapTree::size() const
|
||||
{
|
||||
return impl.size();
|
||||
return impl->size();
|
||||
}
|
||||
|
||||
void DynamicMapTree::update(uint32 t_diff)
|
||||
{
|
||||
impl.update(t_diff);
|
||||
impl->update(t_diff);
|
||||
}
|
||||
|
||||
struct DynamicTreeIntersectionCallback
|
||||
@@ -147,7 +151,7 @@ struct DynamicTreeIntersectionCallback
|
||||
bool did_hit;
|
||||
uint32 phase_mask;
|
||||
DynamicTreeIntersectionCallback(uint32 phasemask) : did_hit(false), phase_mask(phasemask) {}
|
||||
bool operator()(const Ray& r, const GameObjectModel& obj, float& distance)
|
||||
bool operator()(const G3D::Ray& r, const GameObjectModel& obj, float& distance)
|
||||
{
|
||||
did_hit = obj.intersectRay(r, distance, true, phase_mask);
|
||||
return did_hit;
|
||||
@@ -163,7 +167,7 @@ struct DynamicTreeIntersectionCallback_WithLogger
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "Dynamic Intersection log");
|
||||
}
|
||||
bool operator()(const Ray& r, const GameObjectModel& obj, float& distance)
|
||||
bool operator()(const G3D::Ray& r, const GameObjectModel& obj, float& distance)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "testing intersection with %s", obj.name.c_str());
|
||||
bool hit = obj.intersectRay(r, distance, true, phase_mask);
|
||||
@@ -177,17 +181,20 @@ struct DynamicTreeIntersectionCallback_WithLogger
|
||||
bool didHit() const { return did_hit;}
|
||||
};
|
||||
|
||||
bool DynamicMapTree::getIntersectionTime(const uint32 phasemask, const G3D::Ray& ray, const Vector3& endPos, float& maxDist) const
|
||||
bool DynamicMapTree::getIntersectionTime(const uint32 phasemask, const G3D::Ray& ray,
|
||||
const G3D::Vector3& endPos, float& maxDist) const
|
||||
{
|
||||
float distance = maxDist;
|
||||
DynamicTreeIntersectionCallback callback(phasemask);
|
||||
impl.intersectRay(ray, callback, distance, endPos);
|
||||
impl->intersectRay(ray, callback, distance, endPos);
|
||||
if (callback.didHit())
|
||||
maxDist = distance;
|
||||
return callback.didHit();
|
||||
}
|
||||
|
||||
bool DynamicMapTree::getObjectHitPos(const uint32 phasemask, const Vector3& startPos, const Vector3& endPos, Vector3& resultHit, float modifyDist) const
|
||||
bool DynamicMapTree::getObjectHitPos(const uint32 phasemask, const G3D::Vector3& startPos,
|
||||
const G3D::Vector3& endPos, G3D::Vector3& resultHit,
|
||||
float modifyDist) const
|
||||
{
|
||||
bool result = false;
|
||||
float maxDist = (endPos - startPos).magnitude();
|
||||
@@ -199,7 +206,7 @@ bool DynamicMapTree::getObjectHitPos(const uint32 phasemask, const Vector3& star
|
||||
resultHit = endPos;
|
||||
return false;
|
||||
}
|
||||
Vector3 dir = (endPos - startPos)/maxDist; // direction with length of 1
|
||||
G3D::Vector3 dir = (endPos - startPos)/maxDist; // direction with length of 1
|
||||
G3D::Ray ray(startPos, dir);
|
||||
float dist = maxDist;
|
||||
if (getIntersectionTime(phasemask, ray, endPos, dist))
|
||||
@@ -227,26 +234,26 @@ bool DynamicMapTree::getObjectHitPos(const uint32 phasemask, const Vector3& star
|
||||
|
||||
bool DynamicMapTree::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const
|
||||
{
|
||||
Vector3 v1(x1, y1, z1), v2(x2, y2, z2);
|
||||
G3D::Vector3 v1(x1, y1, z1), v2(x2, y2, z2);
|
||||
|
||||
float maxDist = (v2 - v1).magnitude();
|
||||
|
||||
if (!G3D::fuzzyGt(maxDist, 0) )
|
||||
return true;
|
||||
|
||||
Ray r(v1, (v2-v1) / maxDist);
|
||||
G3D::Ray r(v1, (v2-v1) / maxDist);
|
||||
DynamicTreeIntersectionCallback callback(phasemask);
|
||||
impl.intersectRay(r, callback, maxDist, v2);
|
||||
impl->intersectRay(r, callback, maxDist, v2);
|
||||
|
||||
return !callback.did_hit;
|
||||
}
|
||||
|
||||
float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
|
||||
{
|
||||
Vector3 v(x, y, z);
|
||||
Ray r(v, Vector3(0, 0, -1));
|
||||
G3D::Vector3 v(x, y, z);
|
||||
G3D::Ray r(v, G3D::Vector3(0, 0, -1));
|
||||
DynamicTreeIntersectionCallback callback(phasemask);
|
||||
impl.intersectZAllignedRay(r, callback, maxSearchDist);
|
||||
impl->intersectZAllignedRay(r, callback, maxSearchDist);
|
||||
|
||||
if (callback.didHit())
|
||||
return v.z - maxSearchDist;
|
||||
|
||||
@@ -20,34 +20,36 @@
|
||||
#ifndef _DYNTREE_H
|
||||
#define _DYNTREE_H
|
||||
|
||||
#include <G3D/Matrix3.h>
|
||||
#include <G3D/Vector3.h>
|
||||
#include <G3D/AABox.h>
|
||||
#include <G3D/Ray.h>
|
||||
|
||||
//#include "ModelInstance.h"
|
||||
#include "Define.h"
|
||||
//#include "GameObjectModel.h"
|
||||
|
||||
namespace G3D
|
||||
{
|
||||
class Ray;
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
using G3D::Vector3;
|
||||
class GameObjectModel;
|
||||
struct DynTreeImpl;
|
||||
|
||||
class DynamicMapTree
|
||||
{
|
||||
struct DynTreeImpl& impl;
|
||||
DynTreeImpl *impl;
|
||||
|
||||
public:
|
||||
|
||||
DynamicMapTree();
|
||||
~DynamicMapTree();
|
||||
|
||||
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const;
|
||||
bool getIntersectionTime(uint32 phasemask, const G3D::Ray& ray, const Vector3& endPos, float& maxDist) const;
|
||||
bool getObjectHitPos(uint32 phasemask, const Vector3& pPos1, const Vector3& pPos2, Vector3& pResultHitPos, float pModifyDist) const;
|
||||
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2,
|
||||
float z2, uint32 phasemask) const;
|
||||
|
||||
bool getIntersectionTime(uint32 phasemask, const G3D::Ray& ray,
|
||||
const G3D::Vector3& endPos, float& maxDist) const;
|
||||
|
||||
bool getObjectHitPos(uint32 phasemask, const G3D::Vector3& pPos1,
|
||||
const G3D::Vector3& pPos2, G3D::Vector3& pResultHitPos,
|
||||
float pModifyDist) const;
|
||||
|
||||
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const;
|
||||
|
||||
void insert(const GameObjectModel&);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace VMAP
|
||||
bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist) const;
|
||||
float getHeight(const G3D::Vector3& pPos, float maxSearchDist) const;
|
||||
bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;
|
||||
bool GetLocationInfo(const Vector3 &pos, LocationInfo &info) const;
|
||||
bool GetLocationInfo(const G3D::Vector3 &pos, LocationInfo &info) const;
|
||||
|
||||
bool InitMap(const std::string &fname, VMapManager2* vm);
|
||||
void UnloadMap(VMapManager2* vm);
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace VMAP
|
||||
class WmoLiquid
|
||||
{
|
||||
public:
|
||||
WmoLiquid(uint32 width, uint32 height, const Vector3 &corner, uint32 type);
|
||||
WmoLiquid(uint32 width, uint32 height, const G3D::Vector3 &corner, uint32 type);
|
||||
WmoLiquid(const WmoLiquid &other);
|
||||
~WmoLiquid();
|
||||
WmoLiquid& operator=(const WmoLiquid &other);
|
||||
bool GetLiquidHeight(const Vector3 &pos, float &liqHeight) const;
|
||||
bool GetLiquidHeight(const G3D::Vector3 &pos, float &liqHeight) const;
|
||||
uint32 GetType() const { return iType; }
|
||||
float *GetHeightStorage() { return iHeight; }
|
||||
uint8 *GetFlagsStorage() { return iFlags; }
|
||||
@@ -60,14 +60,14 @@ namespace VMAP
|
||||
static bool readFromFile(FILE* rf, WmoLiquid* &liquid);
|
||||
private:
|
||||
WmoLiquid(): iHeight(0), iFlags(0) {};
|
||||
uint32 iTilesX; //!< number of tiles in x direction, each
|
||||
uint32 iTilesX; //!< number of tiles in x direction, each
|
||||
uint32 iTilesY;
|
||||
Vector3 iCorner; //!< the lower corner
|
||||
uint32 iType; //!< liquid type
|
||||
float *iHeight; //!< (tilesX + 1)*(tilesY + 1) height values
|
||||
uint8 *iFlags; //!< info if liquid tile is used
|
||||
G3D::Vector3 iCorner; //!< the lower corner
|
||||
uint32 iType; //!< liquid type
|
||||
float *iHeight; //!< (tilesX + 1)*(tilesY + 1) height values
|
||||
uint8 *iFlags; //!< info if liquid tile is used
|
||||
public:
|
||||
void getPosInfo(uint32 &tilesX, uint32 &tilesY, Vector3 &corner) const;
|
||||
void getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const;
|
||||
};
|
||||
|
||||
/*! holding additional info for WMO group files */
|
||||
@@ -76,16 +76,16 @@ namespace VMAP
|
||||
public:
|
||||
GroupModel(): iLiquid(0) {}
|
||||
GroupModel(const GroupModel &other);
|
||||
GroupModel(uint32 mogpFlags, uint32 groupWMOID, const AABox &bound):
|
||||
GroupModel(uint32 mogpFlags, uint32 groupWMOID, const G3D::AABox &bound):
|
||||
iBound(bound), iMogpFlags(mogpFlags), iGroupWMOID(groupWMOID), iLiquid(0) {}
|
||||
~GroupModel() { delete iLiquid; }
|
||||
|
||||
//! pass mesh data to object and create BIH. Passed vectors get get swapped with old geometry!
|
||||
void setMeshData(std::vector<Vector3> &vert, std::vector<MeshTriangle> &tri);
|
||||
void setMeshData(std::vector<G3D::Vector3> &vert, std::vector<MeshTriangle> &tri);
|
||||
void setLiquidData(WmoLiquid*& liquid) { iLiquid = liquid; liquid = NULL; }
|
||||
bool IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit) const;
|
||||
bool IsInsideObject(const Vector3 &pos, const Vector3 &down, float &z_dist) const;
|
||||
bool GetLiquidLevel(const Vector3 &pos, float &liqHeight) const;
|
||||
bool IsInsideObject(const G3D::Vector3 &pos, const G3D::Vector3 &down, float &z_dist) const;
|
||||
bool GetLiquidLevel(const G3D::Vector3 &pos, float &liqHeight) const;
|
||||
uint32 GetLiquidType() const;
|
||||
bool writeToFile(FILE* wf);
|
||||
bool readFromFile(FILE* rf);
|
||||
@@ -96,12 +96,12 @@ namespace VMAP
|
||||
G3D::AABox iBound;
|
||||
uint32 iMogpFlags;// 0x8 outdor; 0x2000 indoor
|
||||
uint32 iGroupWMOID;
|
||||
std::vector<Vector3> vertices;
|
||||
std::vector<G3D::Vector3> vertices;
|
||||
std::vector<MeshTriangle> triangles;
|
||||
BIH meshTree;
|
||||
WmoLiquid* iLiquid;
|
||||
public:
|
||||
void getMeshData(std::vector<Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid);
|
||||
void getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid);
|
||||
};
|
||||
/*! Holds a model (converted M2 or WMO) in its original coordinate space */
|
||||
class WorldModel
|
||||
|
||||
@@ -3,18 +3,12 @@
|
||||
|
||||
|
||||
#include <G3D/Ray.h>
|
||||
#include <G3D/AABox.h>
|
||||
#include <G3D/Table.h>
|
||||
#include <G3D/BoundsTrait.h>
|
||||
#include <G3D/PositionTrait.h>
|
||||
|
||||
#include "Errors.h"
|
||||
|
||||
using G3D::Vector2;
|
||||
using G3D::Vector3;
|
||||
using G3D::AABox;
|
||||
using G3D::Ray;
|
||||
|
||||
template<class Node>
|
||||
struct NodeCreator{
|
||||
static Node * makeNode(int /*x*/, int /*y*/) { return new Node();}
|
||||
@@ -54,7 +48,7 @@ public:
|
||||
|
||||
void insert(const T& value)
|
||||
{
|
||||
Vector3 pos;
|
||||
G3D::Vector3 pos;
|
||||
PositionFunc::getPosition(value, pos);
|
||||
Node& node = getGridFor(pos.x, pos.y);
|
||||
node.insert(value);
|
||||
@@ -109,13 +103,13 @@ public:
|
||||
}
|
||||
|
||||
template<typename RayCallback>
|
||||
void intersectRay(const Ray& ray, RayCallback& intersectCallback, float max_dist)
|
||||
void intersectRay(const G3D::Ray& ray, RayCallback& intersectCallback, float max_dist)
|
||||
{
|
||||
intersectRay(ray, intersectCallback, max_dist, ray.origin() + ray.direction() * max_dist);
|
||||
}
|
||||
|
||||
template<typename RayCallback>
|
||||
void intersectRay(const Ray& ray, RayCallback& intersectCallback, float& max_dist, const Vector3& end)
|
||||
void intersectRay(const G3D::Ray& ray, RayCallback& intersectCallback, float& max_dist, const G3D::Vector3& end)
|
||||
{
|
||||
Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
|
||||
if (!cell.isValid())
|
||||
@@ -191,7 +185,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename IsectCallback>
|
||||
void intersectPoint(const Vector3& point, IsectCallback& intersectCallback)
|
||||
void intersectPoint(const G3D::Vector3& point, IsectCallback& intersectCallback)
|
||||
{
|
||||
Cell cell = Cell::ComputeCell(point.x, point.y);
|
||||
if (!cell.isValid())
|
||||
@@ -202,7 +196,7 @@ public:
|
||||
|
||||
// Optimized verson of intersectRay function for rays with vertical directions
|
||||
template<typename RayCallback>
|
||||
void intersectZAllignedRay(const Ray& ray, RayCallback& intersectCallback, float& max_dist)
|
||||
void intersectZAllignedRay(const G3D::Ray& ray, RayCallback& intersectCallback, float& max_dist)
|
||||
{
|
||||
Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y);
|
||||
if (!cell.isValid())
|
||||
|
||||
@@ -1920,10 +1920,10 @@ bool Map::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, floa
|
||||
|
||||
bool Map::getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist)
|
||||
{
|
||||
Vector3 startPos = Vector3(x1, y1, z1);
|
||||
Vector3 dstPos = Vector3(x2, y2, z2);
|
||||
G3D::Vector3 startPos(x1, y1, z1);
|
||||
G3D::Vector3 dstPos(x2, y2, z2);
|
||||
|
||||
Vector3 resultPos;
|
||||
G3D::Vector3 resultPos;
|
||||
bool result = _dynamicTree.getObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
|
||||
|
||||
rx = resultPos.x;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
@@ -674,14 +674,14 @@ namespace MMAP
|
||||
// transform data
|
||||
float scale = instance.iScale;
|
||||
G3D::Matrix3 rotation = G3D::Matrix3::fromEulerAnglesXYZ(G3D::pi()*instance.iRot.z/-180.f, G3D::pi()*instance.iRot.x/-180.f, G3D::pi()*instance.iRot.y/-180.f);
|
||||
Vector3 position = instance.iPos;
|
||||
G3D::Vector3 position = instance.iPos;
|
||||
position.x -= 32*GRID_SIZE;
|
||||
position.y -= 32*GRID_SIZE;
|
||||
|
||||
for (std::vector<GroupModel>::iterator it = groupModels.begin(); it != groupModels.end(); ++it)
|
||||
{
|
||||
std::vector<Vector3> tempVertices;
|
||||
std::vector<Vector3> transformedVertices;
|
||||
std::vector<G3D::Vector3> tempVertices;
|
||||
std::vector<G3D::Vector3> transformedVertices;
|
||||
std::vector<MeshTriangle> tempTriangles;
|
||||
WmoLiquid* liquid = NULL;
|
||||
|
||||
@@ -698,10 +698,10 @@ namespace MMAP
|
||||
// now handle liquid data
|
||||
if (liquid)
|
||||
{
|
||||
std::vector<Vector3> liqVerts;
|
||||
std::vector<G3D::Vector3> liqVerts;
|
||||
std::vector<int> liqTris;
|
||||
uint32 tilesX, tilesY, vertsX, vertsY;
|
||||
Vector3 corner;
|
||||
G3D::Vector3 corner;
|
||||
liquid->getPosInfo(tilesX, tilesY, corner);
|
||||
vertsX = tilesX + 1;
|
||||
vertsY = tilesY + 1;
|
||||
@@ -730,11 +730,11 @@ namespace MMAP
|
||||
// tile = x*tilesY+y
|
||||
// flag = y*tilesY+x
|
||||
|
||||
Vector3 vert;
|
||||
G3D::Vector3 vert;
|
||||
for (uint32 x = 0; x < vertsX; ++x)
|
||||
for (uint32 y = 0; y < vertsY; ++y)
|
||||
{
|
||||
vert = Vector3(corner.x + x * GRID_PART_SIZE, corner.y + y * GRID_PART_SIZE, data[y*vertsX + x]);
|
||||
vert = G3D::Vector3(corner.x + x * GRID_PART_SIZE, corner.y + y * GRID_PART_SIZE, data[y*vertsX + x]);
|
||||
vert = vert * rotation * scale + position;
|
||||
vert.x *= -1.f;
|
||||
vert.y *= -1.f;
|
||||
@@ -785,12 +785,12 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::transform(std::vector<Vector3> &source, std::vector<Vector3> &transformedVertices, float scale, G3D::Matrix3 &rotation, Vector3 &position)
|
||||
void TerrainBuilder::transform(std::vector<G3D::Vector3> &source, std::vector<G3D::Vector3> &transformedVertices, float scale, G3D::Matrix3 &rotation, G3D::Vector3 &position)
|
||||
{
|
||||
for (std::vector<Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
// apply tranform, then mirror along the horizontal axes
|
||||
Vector3 v((*it) * rotation * scale + position);
|
||||
G3D::Vector3 v((*it) * rotation * scale + position);
|
||||
v.x *= -1.f;
|
||||
v.y *= -1.f;
|
||||
transformedVertices.push_back(v);
|
||||
@@ -798,9 +798,9 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
void TerrainBuilder::copyVertices(std::vector<Vector3> &source, G3D::Array<float> &dest)
|
||||
void TerrainBuilder::copyVertices(std::vector<G3D::Vector3> &source, G3D::Array<float> &dest)
|
||||
{
|
||||
for (std::vector<Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
for (std::vector<G3D::Vector3>::iterator it = source.begin(); it != source.end(); ++it)
|
||||
{
|
||||
dest.push_back((*it).y);
|
||||
dest.push_back((*it).z);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace VMAP
|
||||
}
|
||||
|
||||
// declared in src/shared/vmap/WorldModel.h
|
||||
void GroupModel::getMeshData(std::vector<Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid)
|
||||
void GroupModel::getMeshData(std::vector<G3D::Vector3> &vertices, std::vector<MeshTriangle> &triangles, WmoLiquid* &liquid)
|
||||
{
|
||||
vertices = this->vertices;
|
||||
triangles = this->triangles;
|
||||
@@ -61,7 +61,7 @@ namespace VMAP
|
||||
}
|
||||
|
||||
// declared in src/shared/vmap/WorldModel.h
|
||||
void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, Vector3 &corner) const
|
||||
void WmoLiquid::getPosInfo(uint32 &tilesX, uint32 &tilesY, G3D::Vector3 &corner) const
|
||||
{
|
||||
tilesX = iTilesX;
|
||||
tilesY = iTilesY;
|
||||
|
||||
Reference in New Issue
Block a user