Variable Size Regions! Support for prehash RegionSizeX and large patches. (WIP)
Mostly from Ukando, tweaked a bit to be cleaner, and a little less dramatic. decode_patch_header now takes a bool optionally, as third argument. _PREHASH_RegionSizeX is the only used of the two _PREHASH_RegionSize*. llsurface.cpp: Copy the connectNeighbor for variable size regions almost directly from Ukando llsurfacepatch.cpp: Patch code from ukando and voodoo. Changed hardcoded 256 constants and such to width functions in: llglsandbox.cpp, llsurface.cpp, llviewerregion.cpp, llviewerparcelmanager, llviewerparcelmgr.cpp, llvowater.cpp, llworld.cpp Use region specific width in: llagent.cpp, llglsandbox.cpp, llmanip.cpp, llmanipscale.cpp, llpanelobject.cpp, llviewerbject.cpp, llwind.cpp Use 256 in llnetmap.cpp in places... llfloaterregioninfo.cpp: Aurora grid has wacky textures. Add LLViewerParcelMgr::widthUpdate() for updating mParcelsPerEdge given a region's width. Used in llstartup now. Add LLWorld::setWidth() for getting a region's size from LLMessageSystem pointers and setting mWidth and mWidthInMeters, accordingly. Called in llviewermessage.cpp as well.
This commit is contained in:
@@ -172,6 +172,7 @@ void LLSurface::create(const S32 grids_per_edge,
|
||||
mNumberOfPatches = mPatchesPerEdge * mPatchesPerEdge;
|
||||
mMetersPerGrid = width / ((F32)(mGridsPerEdge - 1));
|
||||
mMetersPerEdge = mMetersPerGrid * (mGridsPerEdge - 1);
|
||||
sTextureSize = width;
|
||||
|
||||
mOriginGlobal.setVec(origin_global);
|
||||
|
||||
@@ -295,7 +296,7 @@ void LLSurface::initTextures()
|
||||
mWaterObjp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, mRegionp);
|
||||
gPipeline.createObject(mWaterObjp);
|
||||
LLVector3d water_pos_global = from_region_handle(mRegionp->getHandle());
|
||||
water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT);
|
||||
water_pos_global += LLVector3d(mRegionp->getWidth()/2, mRegionp->getWidth()/2, DEFAULT_WATER_HEIGHT);
|
||||
mWaterObjp->setPositionGlobal(water_pos_global);
|
||||
}
|
||||
}
|
||||
@@ -325,8 +326,8 @@ void LLSurface::setOriginGlobal(const LLVector3d &origin_global)
|
||||
// Hack!
|
||||
if (mWaterObjp.notNull() && mWaterObjp->mDrawable.notNull())
|
||||
{
|
||||
const F64 x = origin_global.mdV[VX] + 128.0;
|
||||
const F64 y = origin_global.mdV[VY] + 128.0;
|
||||
const F64 x = origin_global.mdV[VX] + (F64)mRegionp->getWidth()/2;
|
||||
const F64 y = origin_global.mdV[VY] + (F64)mRegionp->getWidth()/2;
|
||||
const F64 z = mWaterObjp->getPositionGlobal().mdV[VZ];
|
||||
|
||||
LLVector3d water_origin_global(x, y, z);
|
||||
@@ -364,15 +365,49 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
{
|
||||
S32 i;
|
||||
LLSurfacePatch *patchp, *neighbor_patchp;
|
||||
S32 neighborPatchesPerEdge = neighborp->mPatchesPerEdge;
|
||||
|
||||
mNeighbors[direction] = neighborp;
|
||||
neighborp->mNeighbors[gDirOpposite[direction]] = this;
|
||||
|
||||
S32 ppe[2];
|
||||
S32 own_offset[2] = {0, 0};
|
||||
S32 neighbor_offset[2] = {0, 0};
|
||||
U32 own_xpos, own_ypos, neighbor_xpos, neighbor_ypos;
|
||||
|
||||
ppe[0] = (mPatchesPerEdge < neighborPatchesPerEdge) ? mPatchesPerEdge : neighborPatchesPerEdge; // used for x
|
||||
ppe[1] = ppe[0]; // used for y
|
||||
|
||||
from_region_handle(mRegionp->getHandle(), &own_xpos, &own_ypos);
|
||||
from_region_handle(neighborp->getRegion()->getHandle(), &neighbor_xpos, &neighbor_ypos);
|
||||
|
||||
if(own_ypos >= neighbor_ypos)
|
||||
{
|
||||
neighbor_offset[1] = (own_ypos - neighbor_ypos) / mGridsPerPatchEdge;
|
||||
ppe[1] = llmin(mPatchesPerEdge, neighborPatchesPerEdge-neighbor_offset[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
own_offset[1] = (neighbor_ypos - own_ypos) / mGridsPerPatchEdge;
|
||||
ppe[1] = llmin(mPatchesPerEdge-own_offset[1], neighborPatchesPerEdge);
|
||||
}
|
||||
|
||||
if(own_xpos >= neighbor_xpos)
|
||||
{
|
||||
neighbor_offset[0] = (own_xpos - neighbor_xpos) / mGridsPerPatchEdge;
|
||||
ppe[0] = llmin(mPatchesPerEdge, neighborPatchesPerEdge-neighbor_offset[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
own_offset[0] = (neighbor_xpos - own_xpos) / mGridsPerPatchEdge;
|
||||
ppe[0] = llmin(mPatchesPerEdge-own_offset[0], neighborPatchesPerEdge);
|
||||
}
|
||||
|
||||
// Connect patches
|
||||
if (NORTHEAST == direction)
|
||||
{
|
||||
patchp = getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(0, 0);
|
||||
neighbor_patchp = neighborp->getPatch(neighbor_offset[0], neighbor_offset[1]); //0
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -382,8 +417,10 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
}
|
||||
else if (NORTHWEST == direction)
|
||||
{
|
||||
S32 off = mPatchesPerEdge + neighbor_offset[1] - own_offset[1];
|
||||
|
||||
patchp = getPatch(0, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, 0);
|
||||
neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, off); //neighborPatchesPerEdge - 1
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -391,18 +428,20 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
else if (SOUTHWEST == direction)
|
||||
{
|
||||
patchp = getPatch(0, 0);
|
||||
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, neighbor_offset[1] - 1); //neighborPatchesPerEdge - 1
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
|
||||
neighbor_patchp->updateNorthEdge(); // Only update one of north or east.
|
||||
neighbor_patchp->updateEastEdge(); // Only update one of north or east.
|
||||
neighbor_patchp->dirtyZ();
|
||||
}
|
||||
else if (SOUTHEAST == direction)
|
||||
{
|
||||
S32 off = mPatchesPerEdge + neighbor_offset[0] - own_offset[0];
|
||||
|
||||
patchp = getPatch(mPatchesPerEdge - 1, 0);
|
||||
neighbor_patchp = neighborp->getPatch(0, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(off, neighbor_offset[1] - 1); //0
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -410,10 +449,10 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
else if (EAST == direction)
|
||||
{
|
||||
// Do east/west connections, first
|
||||
for (i = 0; i < (S32)mPatchesPerEdge; i++)
|
||||
for (i = 0; i < ppe[1]; i++)
|
||||
{
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i);
|
||||
neighbor_patchp = neighborp->getPatch(0, i);
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(0, i + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -423,19 +462,19 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
}
|
||||
|
||||
// Now do northeast/southwest connections
|
||||
for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
|
||||
for (i = 0; i < ppe[1] - 1; i++)
|
||||
{
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i);
|
||||
neighbor_patchp = neighborp->getPatch(0, i+1);
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(0, i+1 + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, NORTHEAST);
|
||||
neighbor_patchp->connectNeighbor(patchp, SOUTHWEST);
|
||||
}
|
||||
// Now do southeast/northwest connections
|
||||
for (i = 1; i < (S32)mPatchesPerEdge; i++)
|
||||
for (i = 1; i < ppe[1]; i++)
|
||||
{
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i);
|
||||
neighbor_patchp = neighborp->getPatch(0, i-1);
|
||||
patchp = getPatch(mPatchesPerEdge - 1, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(0, i-1 + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, SOUTHEAST);
|
||||
neighbor_patchp->connectNeighbor(patchp, NORTHWEST);
|
||||
@@ -444,10 +483,10 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
else if (NORTH == direction)
|
||||
{
|
||||
// Do north/south connections, first
|
||||
for (i = 0; i < (S32)mPatchesPerEdge; i++)
|
||||
for (i = 0; i < ppe[0]; i++)
|
||||
{
|
||||
patchp = getPatch(i, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i, 0);
|
||||
patchp = getPatch(i + own_offset[0], mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i + neighbor_offset[0], 0);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -457,19 +496,19 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
}
|
||||
|
||||
// Do northeast/southwest connections
|
||||
for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
|
||||
for (i = 0; i < ppe[0] - 1; i++)
|
||||
{
|
||||
patchp = getPatch(i, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i+1, 0);
|
||||
patchp = getPatch(i + own_offset[0], mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i+1 + neighbor_offset[0], 0);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, NORTHEAST);
|
||||
neighbor_patchp->connectNeighbor(patchp, SOUTHWEST);
|
||||
}
|
||||
// Do southeast/northwest connections
|
||||
for (i = 1; i < (S32)mPatchesPerEdge; i++)
|
||||
for (i = 1; i < ppe[0]; i++)
|
||||
{
|
||||
patchp = getPatch(i, mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i-1, 0);
|
||||
patchp = getPatch(i + own_offset[0], mPatchesPerEdge - 1);
|
||||
neighbor_patchp = neighborp->getPatch(i-1 + neighbor_offset[0], 0);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, NORTHWEST);
|
||||
neighbor_patchp->connectNeighbor(patchp, SOUTHEAST);
|
||||
@@ -478,10 +517,10 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
else if (WEST == direction)
|
||||
{
|
||||
// Do east/west connections, first
|
||||
for (i = 0; i < mPatchesPerEdge; i++)
|
||||
for (i = 0; i < ppe[1]; i++)
|
||||
{
|
||||
patchp = getPatch(0, i);
|
||||
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i);
|
||||
patchp = getPatch(0, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -491,20 +530,20 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
}
|
||||
|
||||
// Now do northeast/southwest connections
|
||||
for (i = 1; i < mPatchesPerEdge; i++)
|
||||
for (i = 1; i < ppe[1]; i++)
|
||||
{
|
||||
patchp = getPatch(0, i);
|
||||
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i - 1);
|
||||
patchp = getPatch(0, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i - 1 + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, SOUTHWEST);
|
||||
neighbor_patchp->connectNeighbor(patchp, NORTHEAST);
|
||||
}
|
||||
|
||||
// Now do northwest/southeast connections
|
||||
for (i = 0; i < mPatchesPerEdge - 1; i++)
|
||||
for (i = 0; i < ppe[1] - 1; i++)
|
||||
{
|
||||
patchp = getPatch(0, i);
|
||||
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i + 1);
|
||||
patchp = getPatch(0, i + own_offset[1]);
|
||||
neighbor_patchp = neighborp->getPatch(neighborPatchesPerEdge - 1, i + 1 + neighbor_offset[1]);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, NORTHWEST);
|
||||
neighbor_patchp->connectNeighbor(patchp, SOUTHEAST);
|
||||
@@ -513,10 +552,10 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
else if (SOUTH == direction)
|
||||
{
|
||||
// Do north/south connections, first
|
||||
for (i = 0; i < mPatchesPerEdge; i++)
|
||||
for (i = 0; i < ppe[0]; i++)
|
||||
{
|
||||
patchp = getPatch(i, 0);
|
||||
neighbor_patchp = neighborp->getPatch(i, mPatchesPerEdge - 1);
|
||||
patchp = getPatch(i + own_offset[0], 0);
|
||||
neighbor_patchp = neighborp->getPatch(i + neighbor_offset[0], neighborPatchesPerEdge - 1);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, direction);
|
||||
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
|
||||
@@ -526,19 +565,19 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
|
||||
}
|
||||
|
||||
// Now do northeast/southwest connections
|
||||
for (i = 1; i < mPatchesPerEdge; i++)
|
||||
for (i = 1; i < ppe[0]; i++)
|
||||
{
|
||||
patchp = getPatch(i, 0);
|
||||
neighbor_patchp = neighborp->getPatch(i - 1, mPatchesPerEdge - 1);
|
||||
patchp = getPatch(i + own_offset[0], 0);
|
||||
neighbor_patchp = neighborp->getPatch(i - 1 + neighbor_offset[0], neighborPatchesPerEdge - 1);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, SOUTHWEST);
|
||||
neighbor_patchp->connectNeighbor(patchp, NORTHEAST);
|
||||
}
|
||||
// Now do northeast/southwest connections
|
||||
for (i = 0; i < mPatchesPerEdge - 1; i++)
|
||||
for (i = 0; i < ppe[0] - 1; i++)
|
||||
{
|
||||
patchp = getPatch(i, 0);
|
||||
neighbor_patchp = neighborp->getPatch(i + 1, mPatchesPerEdge - 1);
|
||||
patchp = getPatch(i + own_offset[0], 0);
|
||||
neighbor_patchp = neighborp->getPatch(i + 1 + neighbor_offset[0], neighborPatchesPerEdge - 1);
|
||||
|
||||
patchp->connectNeighbor(neighbor_patchp, SOUTHEAST);
|
||||
neighbor_patchp->connectNeighbor(patchp, NORTHWEST);
|
||||
@@ -700,14 +739,22 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL
|
||||
|
||||
while (1)
|
||||
{
|
||||
decode_patch_header(bitpack, &ph);
|
||||
decode_patch_header(bitpack, &ph, b_large_patch);
|
||||
if (ph.quant_wbits == END_OF_PATCHES)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
i = ph.patchids >> 5;
|
||||
j = ph.patchids & 0x1F;
|
||||
if (b_large_patch)
|
||||
{
|
||||
i = ph.patchids >> 16;
|
||||
j = ph.patchids & 0xFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = ph.patchids >> 5;
|
||||
j = ph.patchids & 0x1F;
|
||||
}
|
||||
|
||||
if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge))
|
||||
{
|
||||
@@ -1229,7 +1276,7 @@ BOOL LLSurface::generateWaterTexture(const F32 x, const F32 y,
|
||||
LLPointer<LLImageRaw> raw = new LLImageRaw(tex_width, tex_height, tex_comps);
|
||||
U8 *rawp = raw->getData();
|
||||
|
||||
F32 scale = 256.f * getMetersPerGrid() / (F32)tex_width;
|
||||
F32 scale = getRegion()->getWidth() * getMetersPerGrid() / (F32)tex_width;
|
||||
F32 scale_inv = 1.f / scale;
|
||||
|
||||
S32 x_begin, y_begin, x_end, y_end;
|
||||
|
||||
Reference in New Issue
Block a user