aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Models/GameObjectModel.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-07-25 15:37:35 +0200
committerShauren <shauren.trinity@gmail.com>2015-07-25 15:37:35 +0200
commita029f97c8231f7be188663d63f95f34dd1b4f9e1 (patch)
tree74b0c8728c8d783944ce3e3d2689a0a709287640 /src/server/collision/Models/GameObjectModel.cpp
parentddcc0352d00b7fa3e77d2c7d4cbf6bc92edf9995 (diff)
Core/Collision: Removed direct GameObject references from collision project
Diffstat (limited to 'src/server/collision/Models/GameObjectModel.cpp')
-rw-r--r--src/server/collision/Models/GameObjectModel.cpp51
1 files changed, 18 insertions, 33 deletions
diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp
index 607460a2784..c40cb22a18c 100644
--- a/src/server/collision/Models/GameObjectModel.cpp
+++ b/src/server/collision/Models/GameObjectModel.cpp
@@ -20,15 +20,9 @@
#include "VMapManager2.h"
#include "VMapDefinitions.h"
#include "WorldModel.h"
-
#include "GameObjectModel.h"
#include "Log.h"
-#include "GameObject.h"
-#include "Creature.h"
-#include "TemporarySummon.h"
-#include "Object.h"
-#include "DBCStores.h"
-#include "World.h"
+#include "Timer.h"
using G3D::Vector3;
using G3D::Ray;
@@ -46,13 +40,11 @@ struct GameobjectModelData
typedef std::unordered_map<uint32, GameobjectModelData> ModelList;
ModelList model_list;
-void LoadGameObjectModelList()
+void LoadGameObjectModelList(std::string const& dataPath)
{
-#ifndef NO_CORE_FUNCS
uint32 oldMSTime = getMSTime();
-#endif
- FILE* model_list_file = fopen((sWorld->GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
+ FILE* model_list_file = fopen((dataPath + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb");
if (!model_list_file)
{
VMAP_ERROR_LOG("misc", "Unable to open '%s' file.", VMAP::GAMEOBJECT_MODELS);
@@ -86,7 +78,7 @@ void LoadGameObjectModelList()
model_list.insert
(
- ModelList::value_type( displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2)) )
+ ModelList::value_type(displayId, GameobjectModelData(std::string(buff, name_length), AABox(v1, v2)))
);
}
@@ -100,9 +92,9 @@ GameObjectModel::~GameObjectModel()
((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->releaseModelInstance(name);
}
-bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayInfoEntry& info)
+bool GameObjectModel::initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath)
{
- ModelList::const_iterator it = model_list.find(info.ID);
+ ModelList::const_iterator it = model_list.find(modelOwner->GetDisplayId());
if (it == model_list.end())
return false;
@@ -114,21 +106,18 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn
return false;
}
- iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(sWorld->GetDataPath() + "vmaps/", it->second.name);
+ iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(dataPath + "vmaps/", it->second.name);
if (!iModel)
return false;
name = it->second.name;
- //flags = VMAP::MOD_M2;
- //adtId = 0;
- //ID = 0;
- iPos = Vector3(go.GetPositionX(), go.GetPositionY(), go.GetPositionZ());
- phasemask = go.GetPhaseMask();
- iScale = go.GetObjectScale();
+ iPos = modelOwner->GetPosition();
+ phasemask = modelOwner->GetPhaseMask();
+ iScale = modelOwner->GetScale();
iInvScale = 1.f / iScale;
- G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(go.GetOrientation(), 0, 0);
+ G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(modelOwner->GetOrientation(), 0, 0);
iInvRot = iRotation.inverse();
// transform bounding box:
mdl_box = AABox(mdl_box.low() * iScale, mdl_box.high() * iScale);
@@ -142,22 +131,18 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn
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);
+ modelOwner->DebugVisualizeCorner(pos);
}
#endif
- owner = &go;
+ owner = std::move(modelOwner);
return true;
}
-GameObjectModel* GameObjectModel::Create(const GameObject& go)
+GameObjectModel* GameObjectModel::Create(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath)
{
- const GameObjectDisplayInfoEntry* info = sGameObjectDisplayInfoStore.LookupEntry(go.GetDisplayId());
- if (!info)
- return NULL;
-
GameObjectModel* mdl = new GameObjectModel();
- if (!mdl->initialize(go, *info))
+ if (!mdl->initialize(std::move(modelOwner), dataPath))
{
delete mdl;
return NULL;
@@ -168,7 +153,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) || !owner->isSpawned())
+ if (!(phasemask & ph_mask) || !owner->IsSpawned())
return false;
float time = ray.intersectionTime(iBound);
@@ -205,7 +190,7 @@ bool GameObjectModel::UpdatePosition()
return false;
}
- iPos = Vector3(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ());
+ iPos = owner->GetPosition();
G3D::Matrix3 iRotation = G3D::Matrix3::fromEulerAnglesZYX(owner->GetOrientation(), 0, 0);
iInvRot = iRotation.inverse();
@@ -221,7 +206,7 @@ bool GameObjectModel::UpdatePosition()
for (int i = 0; i < 8; ++i)
{
Vector3 pos(iBound.corner(i));
- owner->SummonCreature(1, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN);
+ owner->DebugVisualizeCorner(pos);
}
#endif