Core/Vmaps: Fix inconsistency of hitInstance and hitModel to cause wrong area ids (#28632)

Closes #28326

Co-authored-by: Gosha <284210+Lordron@users.noreply.github.com>
This commit is contained in:
ModoXandGosha authored and Ovahlord committed 2022-12-31 15:37:13 +01:00
1 parent ad0a3ecad9
commit 8a7dfbbd1d
4 files changed
+14 -3

No files matched your search

+6
View File
@@ -31,6 +31,12 @@ namespace VMAP
enum class LoadResult : uint8;
enum class ModelIgnoreFlags : uint32;
struct GroupLocationInfo
{
const GroupModel* hitModel = nullptr;
int32 rootId = -1;
};
struct TC_COMMON_API LocationInfo
{
LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
@@ -116,7 +116,9 @@ namespace VMAP
Vector3 pModel = iInvRot * (p - iPos) * iInvScale;
Vector3 zDirModel = iInvRot * Vector3(0.f, 0.f, -1.f);
float zDist;
if (iModel->GetLocationInfo(pModel, zDirModel, zDist, info))
GroupLocationInfo groupInfo;
if (iModel->GetLocationInfo(pModel, zDirModel, zDist, groupInfo))
{
Vector3 modelGround = pModel + zDist * zDirModel;
// Transform back to world space. Note that:
@@ -125,6 +127,8 @@ namespace VMAP
float world_Z = ((modelGround * iInvRot) * iScale + iPos).z;
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.hitInstance = this;
return true;
+1 -1
View File
@@ -547,7 +547,7 @@ namespace VMAP
return false;
}
bool WorldModel::GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const
bool WorldModel::GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, GroupLocationInfo& info) const
{
if (groupModels.empty())
return false;
+2 -1
View File
@@ -31,6 +31,7 @@ namespace VMAP
class TreeNode;
struct AreaInfo;
struct LocationInfo;
struct GroupLocationInfo;
enum class ModelIgnoreFlags : uint32;
class TC_COMMON_API MeshTriangle
@@ -113,7 +114,7 @@ namespace VMAP
void setRootWmoID(uint32 id) { RootWMOID = id; }
bool IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit, ModelIgnoreFlags ignoreFlags) const;
bool IntersectPoint(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, AreaInfo &info) const;
bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const;
bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, GroupLocationInfo& info) const;
bool writeFile(const std::string &filename);
bool readFile(const std::string &filename);
void getGroupModels(std::vector<GroupModel>& outGroupModels);