Core/Vmaps: Fix inconsistency of hitInstance and hitModel to cause wrong area ids

Port From (https://github.com/TrinityCore/TrinityCore/commit/6ce66659929cbd680a91dd5caa1a5957f30b0716)
This commit is contained in:
hondacrx
2023-01-05 17:17:13 -05:00
parent 404842681c
commit 0abdfbd279
4 changed files with 15 additions and 3 deletions
+6
View File
@@ -24,6 +24,12 @@ using System.Numerics;
namespace Game.Collision namespace Game.Collision
{ {
public class GroupLocationInfo
{
public GroupModel hitModel;
public int rootId = -1;
}
public class LocationInfo public class LocationInfo
{ {
public LocationInfo() public LocationInfo()
@@ -155,7 +155,9 @@ namespace Game.Collision
Vector3 pModel = iInvRot.Multiply(point - iPos) * iInvScale; Vector3 pModel = iInvRot.Multiply(point - iPos) * iInvScale;
Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f)); Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f));
float zDist; float zDist;
if (iModel.GetLocationInfo(pModel, zDirModel, out zDist, info))
GroupLocationInfo groupInfo = new();
if (iModel.GetLocationInfo(pModel, zDirModel, out zDist, groupInfo))
{ {
Vector3 modelGround = pModel + zDist * zDirModel; Vector3 modelGround = pModel + zDist * zDirModel;
float world_Z = (iInvRot.Multiply(modelGround) * iScale + iPos).Z; float world_Z = (iInvRot.Multiply(modelGround) * iScale + iPos).Z;
@@ -194,7 +194,9 @@ namespace Game.Collision
Vector3 pModel = iInvRot.Multiply(p - iPos) * iInvScale; Vector3 pModel = iInvRot.Multiply(p - iPos) * iInvScale;
Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f)); Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f));
float zDist; float zDist;
if (iModel.GetLocationInfo(pModel, zDirModel, out zDist, info))
GroupLocationInfo groupInfo = new();
if (iModel.GetLocationInfo(pModel, zDirModel, out zDist, groupInfo))
{ {
Vector3 modelGround = pModel + zDist * zDirModel; Vector3 modelGround = pModel + zDist * zDirModel;
// Transform back to world space. Note that: // Transform back to world space. Note that:
@@ -203,6 +205,8 @@ namespace Game.Collision
float world_Z = (iInvRot.Multiply(modelGround * iScale) + iPos).Z; float world_Z = (iInvRot.Multiply(modelGround * iScale) + iPos).Z;
if (info.ground_Z < world_Z) // hm...could it be handled automatically with zDist at intersection? if (info.ground_Z < world_Z) // hm...could it be handled automatically with zDist at intersection?
{ {
info.rootId = groupInfo.rootId;
info.hitModel = groupInfo.hitModel;
info.ground_Z = world_Z; info.ground_Z = world_Z;
info.hitInstance = this; info.hitInstance = this;
return true; return true;
+1 -1
View File
@@ -350,7 +350,7 @@ namespace Game.Collision
return false; return false;
} }
public bool GetLocationInfo(Vector3 p, Vector3 down, out float dist, LocationInfo info) public bool GetLocationInfo(Vector3 p, Vector3 down, out float dist, GroupLocationInfo info)
{ {
dist = 0f; dist = 0f;
if (groupModels.Empty()) if (groupModels.Empty())