aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Models/GameObjectModel.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-03-23 00:23:30 +0100
committerShauren <shauren.trinity@gmail.com>2014-03-23 00:23:30 +0100
commit550cbcad96435dac087dab367a6d143136b4e71c (patch)
treeb02c989235e909d1cd59291132e25abd9b4d36f9 /src/server/collision/Models/GameObjectModel.cpp
parent3a1a55bb0addc0663be1d0fe2beb2918921c2bbb (diff)
Core/Transports: Enabled LoS on transports
Diffstat (limited to 'src/server/collision/Models/GameObjectModel.cpp')
-rw-r--r--src/server/collision/Models/GameObjectModel.cpp48
1 files changed, 42 insertions, 6 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;
+}