diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-06-28 12:26:39 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-06-28 12:26:39 +0200 |
commit | 6040f8eb3167ee84cac9de5e6e1a97aeb6a8c569 (patch) | |
tree | a9002f771fa0bb64c555b56341a412c728a629f0 /src/common/Collision/Models/GameObjectModel.cpp | |
parent | 623413d08886c74c5a72b55479136b62793f080a (diff) |
Core/Collision: Port new parts for retrieving area/liquid data from gameobjects added when porting 42f9deb21ec68e169f7ed1c8cf14092f144b22da to 3.3.5
Diffstat (limited to 'src/common/Collision/Models/GameObjectModel.cpp')
-rw-r--r-- | src/common/Collision/Models/GameObjectModel.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/common/Collision/Models/GameObjectModel.cpp b/src/common/Collision/Models/GameObjectModel.cpp index c1f7f9e1bb1..d81ccee9c5a 100644 --- a/src/common/Collision/Models/GameObjectModel.cpp +++ b/src/common/Collision/Models/GameObjectModel.cpp @@ -212,6 +212,51 @@ void GameObjectModel::intersectPoint(G3D::Vector3 const& point, VMAP::AreaInfo& } } +bool GameObjectModel::GetLocationInfo(G3D::Vector3 const& point, VMAP::LocationInfo& info, PhaseShift const& phaseShift) const +{ + if (!isCollisionEnabled() || !owner->IsSpawned() || !isMapObject()) + return false; + + if (!owner->IsInPhase(phaseShift)) + return false; + + if (!iBound.contains(point)) + return false; + + // child bounds are defined in object space: + Vector3 pModel = iInvRot * (point - iPos) * iInvScale; + Vector3 zDirModel = iInvRot * Vector3(0.f, 0.f, -1.f); + float zDist; + if (iModel->GetLocationInfo(pModel, zDirModel, zDist, info)) + { + Vector3 modelGround = pModel + zDist * zDirModel; + float world_Z = ((modelGround * iInvRot) * iScale + iPos).z; + if (info.ground_Z < world_Z) + { + info.ground_Z = world_Z; + return true; + } + } + + return false; +} + +bool GameObjectModel::GetLiquidLevel(G3D::Vector3 const& point, VMAP::LocationInfo& info, float& liqHeight) const +{ + // child bounds are defined in object space: + Vector3 pModel = iInvRot * (point - iPos) * iInvScale; + //Vector3 zDirModel = iInvRot * Vector3(0.f, 0.f, -1.f); + float zDist; + if (info.hitModel->GetLiquidLevel(pModel, zDist)) + { + // calculate world height (zDist in model coords): + // assume WMO not tilted (wouldn't make much sense anyway) + liqHeight = zDist * iScale + iPos.z; + return true; + } + return false; +} + bool GameObjectModel::UpdatePosition() { if (!iModel) |