From 4ef3081fcafa188c726f738c7540229b3ad95bbb Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 7 Jul 2016 13:46:00 +0200 Subject: [PATCH] FIRE-19563: Add support for OpenSim VarRegion width scaling in CoarseLocationUpdate message This should have no effect on default 256m x 256m sized regions. Regions that are not using the standard size are currently broken anyway, so the result will just be a different form of broken if the region is running on a simulator not supporting this feature yet. --- indra/newview/llavataractions.cpp | 4 ++-- indra/newview/llviewerregion.cpp | 19 ++++++++++++++----- indra/newview/llviewerregion.h | 2 ++ indra/newview/llworld.cpp | 11 ++++++++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index c68067896f..c2e2c1a431 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -1634,7 +1634,7 @@ void LLAvatarActions::getScriptInfo(const LLUUID& idAgent) // Defined in llworld.cpp -LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin); +LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin, F32 width_scale_factorscale_factor); // static - Checked: 2010-12-03 (Catznip-2.4.0g) | Added: Catznip-2.4.0g bool getRegionAndPosGlobalFromAgentID(const LLUUID& idAgent, const LLViewerRegion** ppRegion, LLVector3d* pPosGlobal) @@ -1663,7 +1663,7 @@ bool getRegionAndPosGlobalFromAgentID(const LLUUID& idAgent, const LLViewerRegio if (ppRegion) *ppRegion = pRegion; if (pPosGlobal) - *pPosGlobal = unpackLocalToGlobalPosition(pRegion->mMapAvatars.at(idxRegionAgent), pRegion->getOriginGlobal()); + *pPosGlobal = unpackLocalToGlobalPosition(pRegion->mMapAvatars.at(idxRegionAgent), pRegion->getOriginGlobal(), pRegion->getWidthScaleFactor()); return (NULL != pRegion); } } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 6435d19a53..ed6fd33065 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -551,7 +551,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mInvisibilityCheckHistory(-1), mPaused(FALSE), // Aurora Sim - mWidth(region_width_meters) + mWidth(region_width_meters), + mWidthScaleFactor(region_width_meters / REGION_WIDTH_METERS) // FIRE-19563: Scaling for OpenSim VarRegions { // Moved this up... -> mWidth = region_width_meters; // @@ -2176,8 +2177,12 @@ public: if(i == target_index) { LLVector3d global_pos(region->getOriginGlobal()); - global_pos.mdV[VX] += (F64)x; - global_pos.mdV[VY] += (F64)y; + // FIRE-19563: Scaling for OpenSim VarRegions + //global_pos.mdV[VX] += (F64)x; + //global_pos.mdV[VY] += (F64)y; + global_pos.mdV[VX] += (F64)x * region->getWidthScaleFactor(); + global_pos.mdV[VY] += (F64)y * region->getWidthScaleFactor(); + // global_pos.mdV[VZ] += (F64)z * 4.0; LLAvatarTracker::instance().setTrackedCoarseLocation(global_pos); } @@ -2251,8 +2256,12 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg) if(i == target_index) { LLVector3d global_pos(mImpl->mOriginGlobal); - global_pos.mdV[VX] += (F64)(x_pos); - global_pos.mdV[VY] += (F64)(y_pos); + // FIRE-19563: Scaling for OpenSim VarRegions + //global_pos.mdV[VX] += (F64)(x_pos); + //global_pos.mdV[VY] += (F64)(y_pos); + global_pos.mdV[VX] += (F64)(x_pos) * mWidthScaleFactor; + global_pos.mdV[VY] += (F64)(y_pos) * mWidthScaleFactor; + // global_pos.mdV[VZ] += (F64)(z_pos) * 4.0; LLAvatarTracker::instance().setTrackedCoarseLocation(global_pos); } diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 075f6c4496..2fe9be3f02 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -240,6 +240,7 @@ public: void setCacheID(const LLUUID& id); F32 getWidth() const { return mWidth; } + F32 getWidthScaleFactor() const { return mWidthScaleFactor; } // FIRE-19563: Scaling for OpenSim VarRegions void idleUpdate(F32 max_update_time); void lightIdleUpdate(); @@ -495,6 +496,7 @@ private: U64 mHandle; F32 mTimeDilation; // time dilation of physics simulation on simulator S32 mLastUpdate; //last time called idleUpdate() + F32 mWidthScaleFactor; // FIRE-19563: Scaling for OpenSim VarRegions // simulator name std::string mName; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 641ca5c2af..accd54e129 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1746,7 +1746,7 @@ void send_agent_resume() //static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin) // [SL:KB] - Patch: UI-SidepanelPeople | Checked: 2010-12-03 (Catznip-2.4.0g) | Added: Catznip-2.4.0g -LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin) +LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin, F32 width_scale_factor) // [/SL:KB] { LLVector3d pos_local; @@ -1755,6 +1755,11 @@ LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& regi pos_local.mdV[VY] = (compact_local >> 8) & 0xFFU; pos_local.mdV[VX] = (compact_local >> 16) & 0xFFU; + // FIRE-19563: Scaling for OpenSim VarRegions + pos_local.mdV[VX] *= width_scale_factor; + pos_local.mdV[VY] *= width_scale_factor; + // + return region_origin + pos_local; } @@ -1817,7 +1822,7 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector* positi // //LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.at(i), origin_global); U32 compact_local = regionp->mMapAvatars.at(i); - LLVector3d pos_global = unpackLocalToGlobalPosition(compact_local, origin_global); + LLVector3d pos_global = unpackLocalToGlobalPosition(compact_local, origin_global, regionp->getWidthScaleFactor()); // if(dist_vec_squared(pos_global, relative_to) <= radius_squared) { @@ -1874,7 +1879,7 @@ bool LLWorld::getAvatar(const LLUUID& idAvatar, LLVector3d& posAvatar) const { if (idAvatar == pRegion->mMapAvatarIDs[idxAgent]) { - posAvatar = unpackLocalToGlobalPosition(pRegion->mMapAvatars[idxAgent], pRegion->getOriginGlobal()); + posAvatar = unpackLocalToGlobalPosition(pRegion->mMapAvatars[idxAgent], pRegion->getOriginGlobal(), pRegion->getWidthScaleFactor()); return true; } }