diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-03-23 00:23:30 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2014-03-23 00:23:30 +0100 |
commit | 550cbcad96435dac087dab367a6d143136b4e71c (patch) | |
tree | b02c989235e909d1cd59291132e25abd9b4d36f9 /src/server/collision/Models | |
parent | 3a1a55bb0addc0663be1d0fe2beb2918921c2bbb (diff) |
Core/Transports: Enabled LoS on transports
Diffstat (limited to 'src/server/collision/Models')
-rw-r--r-- | src/server/collision/Models/GameObjectModel.cpp | 48 | ||||
-rw-r--r-- | src/server/collision/Models/GameObjectModel.h | 4 |
2 files changed, 45 insertions, 7 deletions
diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index d254a640279..42584693a13 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -130,17 +130,13 @@ 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 @@ -184,3 +180,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 a1c0942dab4..6088b924343 100644 --- a/src/server/collision/Models/GameObjectModel.h +++ b/src/server/collision/Models/GameObjectModel.h @@ -66,6 +66,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 |