Aurora var region support

Firestorm patch by Cinders
Adopted from Angstrom viewer with assistance of nhede Core
and Revolution Smythe.
This commit is contained in:
Latif Khalifa
2013-09-26 04:09:01 +02:00
parent 6c1ea557b5
commit ad8ea07a7a
34 changed files with 901 additions and 174 deletions

View File

@@ -172,6 +172,9 @@ void LLSurface::create(const S32 grids_per_edge,
mNumberOfPatches = mPatchesPerEdge * mPatchesPerEdge;
mMetersPerGrid = width / ((F32)(mGridsPerEdge - 1));
mMetersPerEdge = mMetersPerGrid * (mGridsPerEdge - 1);
// <FS:CR> Aurora Sim
sTextureSize = width;
// </FS:CR> Aurora Sim
mOriginGlobal.setVec(origin_global);
@@ -295,7 +298,31 @@ 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);
// <FS:CR> Aurora Sim
//water_pos_global += LLVector3d(128.0, 128.0, DEFAULT_WATER_HEIGHT); // region doesn't have a valid water height yet
water_pos_global += LLVector3d(mRegionp->getWidth()/2, mRegionp->getWidth()/2, DEFAULT_WATER_HEIGHT);
mWaterObjp->setPositionGlobal(water_pos_global);
}
}
void LLSurface::rebuildWater()
{
BOOL renderwater = gSavedSettings.getBOOL("RenderWater");
BOOL prev_renderwater = !mWaterObjp.isNull();
if(prev_renderwater && !renderwater)
{
gObjectList.killObject(mWaterObjp);
}
if (!prev_renderwater && renderwater)
{
createWaterTexture();
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(mRegionp->getWidth()/2, mRegionp->getWidth()/2, DEFAULT_WATER_HEIGHT);
// </FS:CR> Aurora Sim
mWaterObjp->setPositionGlobal(water_pos_global);
}
}
@@ -325,8 +352,12 @@ 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;
// <FS:CR> Aurora Sim
//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;
// </FS:CR> Aurora Sim
const F64 z = mWaterObjp->getPositionGlobal().mdV[VZ];
LLVector3d water_origin_global(x, y, z);
@@ -364,15 +395,52 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
{
S32 i;
LLSurfacePatch *patchp, *neighbor_patchp;
// <FS:CR> Aurora Sim
S32 neighborPatchesPerEdge = neighborp->mPatchesPerEdge;
// </FS:CR> Aurora Sim
mNeighbors[direction] = neighborp;
neighborp->mNeighbors[gDirOpposite[direction]] = this;
// <FS:CR> Aurora Sim
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);
}
// <FS:CR> Aurora Sim
// Connect patches
if (NORTHEAST == direction)
{
patchp = getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(0, 0);
// <FS:CR> Aurora Sim
//neighbor_patchp = neighborp->getPatch(0, 0);
neighbor_patchp = neighborp->getPatch(neighbor_offset[0], neighbor_offset[1]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -382,8 +450,14 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
}
else if (NORTHWEST == direction)
{
// <FS:CR> Aurora Sim
S32 off = mPatchesPerEdge + neighbor_offset[1] - own_offset[1];
// </FS:CR> Aurora Sim
patchp = getPatch(0, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, 0);
// <FS:CR> Aurora Sim
//neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, 0);
neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, off); //neighborPatchesPerEdge - 1
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -391,18 +465,31 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
else if (SOUTHWEST == direction)
{
patchp = getPatch(0, 0);
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1);
// <FS:CR> Aurora Sim
//neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(neighbor_offset[0] - 1, neighbor_offset[1] - 1);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
neighbor_patchp->updateNorthEdge(); // Only update one of north or east.
// <FS:CR> Aurora Sim
//neighbor_patchp->updateNorthEdge(); // Only update one of north or east.
neighbor_patchp->updateEastEdge(); // Only update one of north or east.
// </FS:CR> Aurora Sim
neighbor_patchp->dirtyZ();
}
else if (SOUTHEAST == direction)
{
// <FS:CR> Aurora Sim
S32 off = mPatchesPerEdge + neighbor_offset[0] - own_offset[0];
// </FS:CR> Aurora Sim
patchp = getPatch(mPatchesPerEdge - 1, 0);
neighbor_patchp = neighborp->getPatch(0, mPatchesPerEdge - 1);
// <FS:CR> Aurora Sim
//neighbor_patchp = neighborp->getPatch(0, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(off, neighbor_offset[1] - 1); //0
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -410,10 +497,17 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
else if (EAST == direction)
{
// Do east/west connections, first
for (i = 0; i < (S32)mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < (S32)mPatchesPerEdge; i++)
for (i = 0; i < ppe[1]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(mPatchesPerEdge - 1, i);
neighbor_patchp = neighborp->getPatch(0, i);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -423,19 +517,33 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
}
// Now do northeast/southwest connections
for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
for (i = 0; i < ppe[1] - 1; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(mPatchesPerEdge - 1, i);
neighbor_patchp = neighborp->getPatch(0, i+1);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, NORTHEAST);
neighbor_patchp->connectNeighbor(patchp, SOUTHWEST);
}
// Now do southeast/northwest connections
for (i = 1; i < (S32)mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 1; i < (S32)mPatchesPerEdge; i++)
for (i = 1; i < ppe[1]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(mPatchesPerEdge - 1, i);
neighbor_patchp = neighborp->getPatch(0, i-1);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, SOUTHEAST);
neighbor_patchp->connectNeighbor(patchp, NORTHWEST);
@@ -444,10 +552,17 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
else if (NORTH == direction)
{
// Do north/south connections, first
for (i = 0; i < (S32)mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < (S32)mPatchesPerEdge; i++)
for (i = 0; i < ppe[0]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(i, 0);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -457,19 +572,33 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
}
// Do northeast/southwest connections
for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < (S32)mPatchesPerEdge - 1; i++)
for (i = 0; i < ppe[0] - 1; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(i+1, 0);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, NORTHEAST);
neighbor_patchp->connectNeighbor(patchp, SOUTHWEST);
}
// Do southeast/northwest connections
for (i = 1; i < (S32)mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 1; i < (S32)mPatchesPerEdge; i++)
for (i = 1; i < ppe[0]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, mPatchesPerEdge - 1);
neighbor_patchp = neighborp->getPatch(i-1, 0);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, NORTHWEST);
neighbor_patchp->connectNeighbor(patchp, SOUTHEAST);
@@ -478,10 +607,17 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
else if (WEST == direction)
{
// Do east/west connections, first
for (i = 0; i < mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < mPatchesPerEdge; i++)
for (i = 0; i < ppe[1]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(0, i);
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -491,20 +627,34 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
}
// Now do northeast/southwest connections
for (i = 1; i < mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 1; i < mPatchesPerEdge; i++)
for (i = 1; i < ppe[1]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(0, i);
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i - 1);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, SOUTHWEST);
neighbor_patchp->connectNeighbor(patchp, NORTHEAST);
}
// Now do northwest/southeast connections
for (i = 0; i < mPatchesPerEdge - 1; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < mPatchesPerEdge - 1; i++)
for (i = 0; i < ppe[1] - 1; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(0, i);
neighbor_patchp = neighborp->getPatch(mPatchesPerEdge - 1, i + 1);
// <FS:CR> Aurora Sim
//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]);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, NORTHWEST);
neighbor_patchp->connectNeighbor(patchp, SOUTHEAST);
@@ -513,10 +663,17 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
else if (SOUTH == direction)
{
// Do north/south connections, first
for (i = 0; i < mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < mPatchesPerEdge; i++)
for (i = 0; i < ppe[0]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, 0);
neighbor_patchp = neighborp->getPatch(i, mPatchesPerEdge - 1);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, direction);
neighbor_patchp->connectNeighbor(patchp, gDirOpposite[direction]);
@@ -526,19 +683,33 @@ void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
}
// Now do northeast/southwest connections
for (i = 1; i < mPatchesPerEdge; i++)
// <FS:CR> Aurora Sim
//for (i = 1; i < mPatchesPerEdge; i++)
for (i = 1; i < ppe[0]; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, 0);
neighbor_patchp = neighborp->getPatch(i - 1, mPatchesPerEdge - 1);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, SOUTHWEST);
neighbor_patchp->connectNeighbor(patchp, NORTHEAST);
}
// Now do northeast/southwest connections
for (i = 0; i < mPatchesPerEdge - 1; i++)
// <FS:CR> Aurora Sim
//for (i = 0; i < mPatchesPerEdge - 1; i++)
for (i = 0; i < ppe[0] - 1; i++)
// </FS:CR> Aurora Sim
{
patchp = getPatch(i, 0);
neighbor_patchp = neighborp->getPatch(i + 1, mPatchesPerEdge - 1);
// <FS:CR> Aurora Sim
//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);
// </FS:CR> Aurora Sim
patchp->connectNeighbor(neighbor_patchp, SOUTHEAST);
neighbor_patchp->connectNeighbor(patchp, NORTHWEST);
@@ -700,14 +871,29 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL
while (1)
{
decode_patch_header(bitpack, &ph);
// <FS:CR> Aurora Sim
//decode_patch_header(bitpack, &ph);
decode_patch_header(bitpack, &ph, b_large_patch);
// </FS:CR> Aurora Sim
if (ph.quant_wbits == END_OF_PATCHES)
{
break;
}
i = ph.patchids >> 5;
j = ph.patchids & 0x1F;
// <FS:CR> Aurora Sim
//i = ph.patchids >> 5;
//j = ph.patchids & 0x1F;
if (b_large_patch)
{
i = ph.patchids >> 16; //x
j = ph.patchids & 0xFFFF; //y
}
else
{
i = ph.patchids >> 5; //x
j = ph.patchids & 0x1F; //y
}
// </FS:CR> Aurora Sim
if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge))
{
@@ -1229,7 +1415,10 @@ 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;
// <FS:CR> Aurora Sim
//F32 scale = 256.f * getMetersPerGrid() / (F32)tex_width;
F32 scale = getRegion()->getWidth() * getMetersPerGrid() / (F32)tex_width;
// <FS:CR> Aurora Sim
F32 scale_inv = 1.f / scale;
S32 x_begin, y_begin, x_end, y_end;