Commit 9ae1a9ca authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Fix coarse location bugs on opensim var-regions with patch from Ansariel.

parent 66a2d995
......@@ -533,6 +533,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
mWidth(region_width_meters),
mHandle(handle),
mTimeDilation(1.0f),
mWidthScaleFactor(region_width_meters / REGION_WIDTH_METERS),
mName(""),
mZoning(""),
mIsEstateManager(FALSE),
......@@ -2072,8 +2073,8 @@ public:
if(i == target_index)
{
LLVector3d global_pos(region->getOriginGlobal());
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);
}
......@@ -2176,8 +2177,8 @@ 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);
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);
}
......
......@@ -227,7 +227,10 @@ public:
void setCacheID(const LLUUID& id);
F32 getWidth() const { return mWidth; }
F32 getWidthScaleFactor() const { return mWidthScaleFactor; } // Scaling for OpenSim VarRegions
S32 getRegionMaxBakes() const { return mMaxBakes; }
S32 getRegionMaxTEs() const { return mMaxTEs; }
void idleUpdate(F32 max_update_time);
void lightIdleUpdate();
bool addVisibleGroup(LLViewerOctreeGroup* group);
......@@ -515,7 +518,9 @@ private:
U64 mHandle;
F32 mTimeDilation; // time dilation of physics simulation on simulator
S32 mLastUpdate; //last time called idleUpdate()
F32 mWidthScaleFactor; // Scaling for OpenSim VarRegions
S32 mMaxBakes; // store max bakes on the region
S32 mMaxTEs; // store max TEs on the region
// simulator name
std::string mName;
std::string mZoning;
......
......@@ -1337,7 +1337,7 @@ void send_agent_resume()
LLAppViewer::instance()->resumeMainloopTimeout();
}
static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin)
static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3d& region_origin, F32 width_scale_factor)
{
LLVector3d pos_local;
......@@ -1345,6 +1345,9 @@ static LLVector3d unpackLocalToGlobalPosition(U32 compact_local, const LLVector3
pos_local.mdV[VY] = (compact_local >> 8) & 0xFFU;
pos_local.mdV[VX] = (compact_local >> 16) & 0xFFU;
// Scaling for OpenSim VarRegions
pos_local.mdV[VX] *= width_scale_factor;
pos_local.mdV[VY] *= width_scale_factor;
return region_origin + pos_local;
}
......@@ -1396,7 +1399,7 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector<LLVector3d>* positi
{
LLUUID uuid = regionp->mMapAvatarIDs[i];
if (uuid.isNull()) continue;
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global);
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global, regionp->getWidthScaleFactor());
if(dist_vec_squared(pos_global, relative_to) <= radius_squared)
{
// if this avatar doesn't already exist in the list, add it
......@@ -1450,7 +1453,7 @@ void LLWorld::getAvatars(pos_map_t* umap, const LLVector3d& relative_to, F32 rad
LLUUID uuid = regionp->mMapAvatarIDs[i];
if (uuid.isNull()) continue;
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global);
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global, regionp->getWidthScaleFactor());
if(dist_vec_squared(pos_global, relative_to) <= radius_squared)
{
umap->emplace(uuid, pos_global);
......@@ -1497,7 +1500,7 @@ void LLWorld::getAvatars(region_gpos_map_t* umap, const LLVector3d& relative_to,
LLUUID uuid = regionp->mMapAvatarIDs[i];
if (uuid.isNull()) continue;
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global);
LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars[i], origin_global, regionp->getWidthScaleFactor());
if (dist_vec_squared(pos_global, relative_to) <= radius_squared)
{
umap->emplace(uuid, regionp_gpos_pair_t(regionp, pos_global));
......@@ -1525,7 +1528,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;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment