diff options
Diffstat (limited to 'src/server/collision')
| -rw-r--r-- | src/server/collision/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/server/collision/Management/MMapFactory.h | 3 | ||||
| -rw-r--r-- | src/server/collision/Management/MMapManager.h | 10 | ||||
| -rw-r--r-- | src/server/collision/Management/VMapManager2.h | 8 | ||||
| -rw-r--r-- | src/server/collision/Maps/MapTree.cpp | 3 | ||||
| -rw-r--r-- | src/server/collision/Maps/MapTree.h | 10 | ||||
| -rw-r--r-- | src/server/collision/Models/GameObjectModel.cpp | 53 | ||||
| -rw-r--r-- | src/server/collision/Models/GameObjectModel.h | 7 | ||||
| -rw-r--r-- | src/server/collision/Models/WorldModel.h | 6 |
9 files changed, 74 insertions, 27 deletions
diff --git a/src/server/collision/CMakeLists.txt b/src/server/collision/CMakeLists.txt index a83bb9dad1c..a2024bff7cb 100644 --- a/src/server/collision/CMakeLists.txt +++ b/src/server/collision/CMakeLists.txt @@ -34,6 +34,7 @@ include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/dep/g3dlite/include ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour + ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour/Include ${CMAKE_SOURCE_DIR}/src/server/shared ${CMAKE_SOURCE_DIR}/src/server/shared/Configuration ${CMAKE_SOURCE_DIR}/src/server/shared/Debugging diff --git a/src/server/collision/Management/MMapFactory.h b/src/server/collision/Management/MMapFactory.h index 837c893f038..4b883d43613 100644 --- a/src/server/collision/Management/MMapFactory.h +++ b/src/server/collision/Management/MMapFactory.h @@ -19,11 +19,12 @@ #ifndef _MMAP_FACTORY_H #define _MMAP_FACTORY_H +#include "Define.h" #include "MMapManager.h" -#include "UnorderedMap.h" #include "DetourAlloc.h" #include "DetourNavMesh.h" #include "DetourNavMeshQuery.h" +#include <unordered_map> namespace MMAP { diff --git a/src/server/collision/Management/MMapManager.h b/src/server/collision/Management/MMapManager.h index 8b0d42b83cd..798d0206538 100644 --- a/src/server/collision/Management/MMapManager.h +++ b/src/server/collision/Management/MMapManager.h @@ -19,16 +19,18 @@ #ifndef _MMAP_MANAGER_H #define _MMAP_MANAGER_H -#include "UnorderedMap.h" +#include "Define.h" #include "DetourAlloc.h" #include "DetourNavMesh.h" #include "DetourNavMeshQuery.h" +#include <string> +#include <unordered_map> // move map related classes namespace MMAP { - typedef UNORDERED_MAP<uint32, dtTileRef> MMapTileSet; - typedef UNORDERED_MAP<uint32, dtNavMeshQuery*> NavMeshQuerySet; + typedef std::unordered_map<uint32, dtTileRef> MMapTileSet; + typedef std::unordered_map<uint32, dtNavMeshQuery*> NavMeshQuerySet; // dummy struct to hold map's mmap data struct MMapData @@ -51,7 +53,7 @@ namespace MMAP }; - typedef UNORDERED_MAP<uint32, MMapData*> MMapDataSet; + typedef std::unordered_map<uint32, MMapData*> MMapDataSet; // singleton class // holds all all access to mmap loading unloading and meshes diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h index abddd5d7cc3..711025e67c0 100644 --- a/src/server/collision/Management/VMapManager2.h +++ b/src/server/collision/Management/VMapManager2.h @@ -19,9 +19,9 @@ #ifndef _VMAPMANAGER2_H #define _VMAPMANAGER2_H -#include "IVMapManager.h" -#include "Dynamic/UnorderedMap.h" #include "Define.h" +#include "IVMapManager.h" +#include <unordered_map> #include <ace/Thread_Mutex.h> //=========================================================== @@ -63,8 +63,8 @@ namespace VMAP int iRefCount; }; - typedef UNORDERED_MAP<uint32, StaticMapTree*> InstanceTreeMap; - typedef UNORDERED_MAP<std::string, ManagedModel> ModelFileMap; + typedef std::unordered_map<uint32, StaticMapTree*> InstanceTreeMap; + typedef std::unordered_map<std::string, ManagedModel> ModelFileMap; class VMapManager2 : public IVMapManager { diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index bb57079c389..d592d795125 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -157,8 +157,7 @@ namespace VMAP { float maxDist = (pos2 - pos1).magnitude(); // return false if distance is over max float, in case of cheater teleporting to the end of the universe - if (maxDist == std::numeric_limits<float>::max() || - maxDist == std::numeric_limits<float>::infinity()) + if (maxDist == std::numeric_limits<float>::max() || !std::isfinite(maxDist)) return false; // valid map coords should *never ever* produce float overflow, but this would produce NaNs too diff --git a/src/server/collision/Maps/MapTree.h b/src/server/collision/Maps/MapTree.h index 90d61cbb88b..05351b74019 100644 --- a/src/server/collision/Maps/MapTree.h +++ b/src/server/collision/Maps/MapTree.h @@ -20,8 +20,8 @@ #define _MAPTREE_H #include "Define.h" -#include "Dynamic/UnorderedMap.h" #include "BoundingIntervalHierarchy.h" +#include <unordered_map> namespace VMAP { @@ -39,8 +39,8 @@ namespace VMAP class StaticMapTree { - typedef UNORDERED_MAP<uint32, bool> loadedTileMap; - typedef UNORDERED_MAP<uint32, uint32> loadedSpawnMap; + typedef std::unordered_map<uint32, bool> loadedTileMap; + typedef std::unordered_map<uint32, uint32> loadedSpawnMap; private: uint32 iMapID; bool iIsTiled; @@ -81,6 +81,10 @@ namespace VMAP bool isTiled() const { return iIsTiled; } uint32 numLoadedTiles() const { return iLoadedTiles.size(); } void getModelInstances(ModelInstance* &models, uint32 &count); + + private: + StaticMapTree(StaticMapTree const& right) = delete; + StaticMapTree& operator=(StaticMapTree const& right) = delete; }; struct AreaInfo diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index d254a640279..de97943bb37 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -43,7 +43,7 @@ struct GameobjectModelData std::string name; }; -typedef UNORDERED_MAP<uint32, GameobjectModelData> ModelList; +typedef std::unordered_map<uint32, GameobjectModelData> ModelList; ModelList model_list; void LoadGameObjectModelList() @@ -130,20 +130,17 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn for (int i = 0; i < 8; ++i) rotated_bounds.merge(iRotation * mdl_box.corner(i)); - this->iBound = rotated_bounds + iPos; + iBound = rotated_bounds + iPos; #ifdef SPAWN_CORNERS // test: for (int i = 0; i < 8; ++i) { Vector3 pos(iBound.corner(i)); - if (Creature* c = const_cast<GameObject&>(go).SummonCreature(24440, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN)) - { - c->setFaction(35); - c->SetObjectScale(0.1f); - } + go.SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN); } #endif + owner = &go; return true; } @@ -165,7 +162,7 @@ GameObjectModel* GameObjectModel::Create(const GameObject& go) bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const { - if (!(phasemask & ph_mask)) + if (!(phasemask & ph_mask) || !owner->isSpawned()) return false; float time = ray.intersectionTime(iBound); @@ -184,3 +181,43 @@ bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool Sto } return hit; } + +bool GameObjectModel::Relocate(const GameObject& go) +{ + if (!iModel) + return false; + + ModelList::const_iterator it = model_list.find(go.GetDisplayId()); + if (it == model_list.end()) + return false; + + G3D::AABox mdl_box(it->second.bound); + // ignore models with no bounds + if (mdl_box == G3D::AABox::zero()) + { + VMAP_ERROR_LOG("misc", "GameObject model %s has zero bounds, loading skipped", it->second.name.c_str()); + return false; + } + + iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ()); + + G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0); + iInvRot = iRotation.inverse(); + // transform bounding box: + mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale); + AABox rotated_bounds; + for (int i = 0; i < 8; ++i) + rotated_bounds.merge(iRotation * mdl_box.corner(i)); + + iBound = rotated_bounds + iPos; +#ifdef SPAWN_CORNERS + // test: + for (int i = 0; i < 8; ++i) + { + Vector3 pos(iBound.corner(i)); + go.SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN); + } +#endif + + return true; +} diff --git a/src/server/collision/Models/GameObjectModel.h b/src/server/collision/Models/GameObjectModel.h index 06a74cc6eb0..99c9b1337b3 100644 --- a/src/server/collision/Models/GameObjectModel.h +++ b/src/server/collision/Models/GameObjectModel.h @@ -44,8 +44,9 @@ class GameObjectModel /*, public Intersectable*/ float iInvScale; float iScale; VMAP::WorldModel* iModel; + GameObject const* owner; - GameObjectModel() : phasemask(0), iModel(NULL) { } + GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(NULL), owner(NULL) { } bool initialize(const GameObject& go, const GameObjectDisplayInfoEntry& info); public: @@ -66,6 +67,8 @@ public: bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const; static GameObjectModel* Create(const GameObject& go); + + bool Relocate(GameObject const& go); }; -#endif // _GAMEOBJECT_MODEL_H
\ No newline at end of file +#endif // _GAMEOBJECT_MODEL_H diff --git a/src/server/collision/Models/WorldModel.h b/src/server/collision/Models/WorldModel.h index 8778998a6b7..da1f58a79c6 100644 --- a/src/server/collision/Models/WorldModel.h +++ b/src/server/collision/Models/WorldModel.h @@ -59,7 +59,7 @@ namespace VMAP bool writeToFile(FILE* wf); static bool readFromFile(FILE* rf, WmoLiquid* &liquid); private: - WmoLiquid(): iTilesX(0), iTilesY(0), iType(0), iHeight(0), iFlags(0) { } + WmoLiquid() : iTilesX(0), iTilesY(0), iCorner(), iType(0), iHeight(NULL), iFlags(NULL) { } uint32 iTilesX; //!< number of tiles in x direction, each uint32 iTilesY; G3D::Vector3 iCorner; //!< the lower corner @@ -74,10 +74,10 @@ namespace VMAP class GroupModel { public: - GroupModel(): iMogpFlags(0), iGroupWMOID(0), iLiquid(0) { } + GroupModel() : iBound(), iMogpFlags(0), iGroupWMOID(0), iLiquid(NULL) { } GroupModel(const GroupModel &other); GroupModel(uint32 mogpFlags, uint32 groupWMOID, const G3D::AABox &bound): - iBound(bound), iMogpFlags(mogpFlags), iGroupWMOID(groupWMOID), iLiquid(0) { } + iBound(bound), iMogpFlags(mogpFlags), iGroupWMOID(groupWMOID), iLiquid(NULL) { } ~GroupModel() { delete iLiquid; } //! pass mesh data to object and create BIH. Passed vectors get get swapped with old geometry! |
