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:
@@ -36,6 +36,7 @@
|
||||
#include "timing.h"
|
||||
#include "llsky.h"
|
||||
#include "llviewercamera.h"
|
||||
#include "llregionhandle.h" // <FS:CR> Aurora Sim
|
||||
|
||||
// For getting composition values
|
||||
#include "llviewerregion.h"
|
||||
@@ -231,8 +232,8 @@ void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3
|
||||
const F32 xyScaleInv = (1.f / xyScale)*(0.2222222222f);
|
||||
|
||||
F32 vec[3] = {
|
||||
(F32)fmod((F32)(mOriginGlobal.mdV[0] + x)*xyScaleInv, 256.f),
|
||||
(F32)fmod((F32)(mOriginGlobal.mdV[1] + y)*xyScaleInv, 256.f),
|
||||
(F32)fmod((F32)(mOriginGlobal.mdV[0] + x)*xyScaleInv, 256.f), // <FS:ND/> Added (F32) for proper array initialization
|
||||
(F32)fmod((F32)(mOriginGlobal.mdV[1] + y)*xyScaleInv, 256.f), // <FS:ND/> Added (F32) for proper array initialization
|
||||
0.f
|
||||
};
|
||||
F32 rand_val = llclamp(noise2(vec)* 0.75f + 0.5f, 0.f, 1.f);
|
||||
@@ -249,18 +250,33 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
|
||||
const F32 mpg = mSurfacep->getMetersPerGrid() * stride;
|
||||
|
||||
S32 poffsets[2][2][2];
|
||||
// <FS:CR> Aurora Sim
|
||||
//S32 poffsets[2][2][2];
|
||||
S32 poffsets[2][2][3];
|
||||
// </FS:CR> Aurora Sim
|
||||
poffsets[0][0][0] = x - stride;
|
||||
poffsets[0][0][1] = y - stride;
|
||||
// <FS:CR> Aurora Sim
|
||||
poffsets[0][0][2] = surface_stride;
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
poffsets[0][1][0] = x - stride;
|
||||
poffsets[0][1][1] = y + stride;
|
||||
// <FS:CR> Aurora Sim
|
||||
poffsets[0][1][2] = surface_stride;
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
poffsets[1][0][0] = x + stride;
|
||||
poffsets[1][0][1] = y - stride;
|
||||
// <FS:CR> Aurora Sim
|
||||
poffsets[1][0][2] = surface_stride;
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
poffsets[1][1][0] = x + stride;
|
||||
poffsets[1][1][1] = y + stride;
|
||||
// <FS:CR> Aurora Sim
|
||||
poffsets[1][1][2] = surface_stride;
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
const LLSurfacePatch *ppatches[2][2];
|
||||
|
||||
@@ -284,8 +300,11 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
}
|
||||
else
|
||||
{
|
||||
poffsets[i][j][0] += patch_width;
|
||||
// <FS:CR> Aurora Sim
|
||||
ppatches[i][j] = ppatches[i][j]->getNeighborPatch(WEST);
|
||||
poffsets[i][j][0] += patch_width;
|
||||
poffsets[i][j][2] = ppatches[i][j]->getSurface()->getGridsPerEdge();
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
if (poffsets[i][j][1] < 0)
|
||||
@@ -296,8 +315,11 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
}
|
||||
else
|
||||
{
|
||||
poffsets[i][j][1] += patch_width;
|
||||
// <FS:CR> Aurora Sim
|
||||
ppatches[i][j] = ppatches[i][j]->getNeighborPatch(SOUTH);
|
||||
poffsets[i][j][1] += patch_width;
|
||||
poffsets[i][j][2] = ppatches[i][j]->getSurface()->getGridsPerEdge();
|
||||
// </FS>CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
if (poffsets[i][j][0] >= (S32)patch_width)
|
||||
@@ -308,8 +330,11 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
}
|
||||
else
|
||||
{
|
||||
poffsets[i][j][0] -= patch_width;
|
||||
// <FS:CR> Aurora Sim
|
||||
ppatches[i][j] = ppatches[i][j]->getNeighborPatch(EAST);
|
||||
poffsets[i][j][0] -= patch_width;
|
||||
poffsets[i][j][2] = ppatches[i][j]->getSurface()->getGridsPerEdge();
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
if (poffsets[i][j][1] >= (S32)patch_width)
|
||||
@@ -320,8 +345,11 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
}
|
||||
else
|
||||
{
|
||||
poffsets[i][j][1] -= patch_width;
|
||||
// <FS:CR> Aurora Sim
|
||||
ppatches[i][j] = ppatches[i][j]->getNeighborPatch(NORTH);
|
||||
poffsets[i][j][1] -= patch_width;
|
||||
poffsets[i][j][2] = ppatches[i][j]->getSurface()->getGridsPerEdge();
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,19 +358,31 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
|
||||
LLVector3 p00(-mpg,-mpg,
|
||||
*(ppatches[0][0]->mDataZ
|
||||
+ poffsets[0][0][0]
|
||||
+ poffsets[0][0][1]*surface_stride));
|
||||
// <FS:CR> Aurora Sim
|
||||
//+ poffsets[0][0][1]*surface_stride));
|
||||
+ poffsets[0][0][1]*poffsets[0][0][2]));
|
||||
// </FS:CR> Aurora Sim
|
||||
LLVector3 p01(-mpg,+mpg,
|
||||
*(ppatches[0][1]->mDataZ
|
||||
+ poffsets[0][1][0]
|
||||
+ poffsets[0][1][1]*surface_stride));
|
||||
// <FS:CR> Aurora Sim
|
||||
//+ poffsets[0][1][1]*surface_stride));
|
||||
+ poffsets[0][1][1]*poffsets[0][1][2]));
|
||||
// </FS:CR> Aurora Sim
|
||||
LLVector3 p10(+mpg,-mpg,
|
||||
*(ppatches[1][0]->mDataZ
|
||||
+ poffsets[1][0][0]
|
||||
+ poffsets[1][0][1]*surface_stride));
|
||||
// <FS:CR> Aurora Sim
|
||||
//+ poffsets[1][0][1]*surface_stride));
|
||||
+ poffsets[1][0][1]*poffsets[1][0][2]));
|
||||
// </FS:CR> Aurora Sim
|
||||
LLVector3 p11(+mpg,+mpg,
|
||||
*(ppatches[1][1]->mDataZ
|
||||
+ poffsets[1][1][0]
|
||||
+ poffsets[1][1][1]*surface_stride));
|
||||
// <FS:CR> Aurora Sim
|
||||
//+ poffsets[1][1][1]*surface_stride));
|
||||
+ poffsets[1][1][1]*poffsets[1][1][2]));
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
LLVector3 c1 = p11 - p00;
|
||||
LLVector3 c2 = p01 - p10;
|
||||
@@ -480,6 +520,18 @@ void LLSurfacePatch::updateNormals()
|
||||
// update the north edge
|
||||
if (mNormalsInvalid[NORTHEAST] || mNormalsInvalid[NORTH] || mNormalsInvalid[NORTHWEST])
|
||||
{
|
||||
// <FS:CR> Aurora Sim
|
||||
/*
|
||||
if(!getNeighborPatch(EAST) && getNeighborPatch(NORTHEAST))
|
||||
{
|
||||
if(getNeighborPatch(NORTHEAST)->getHasReceivedData())
|
||||
{
|
||||
*(getNeighborPatch(NORTHEAST)->mDataZ) = 100.0f;
|
||||
}
|
||||
}
|
||||
*/
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
for (i = 0; i <= grids_per_patch_edge; i++)
|
||||
{
|
||||
calcNormal(i, grids_per_patch_edge, 2);
|
||||
@@ -493,6 +545,16 @@ void LLSurfacePatch::updateNormals()
|
||||
// update the west edge
|
||||
if (mNormalsInvalid[NORTHWEST] || mNormalsInvalid[WEST] || mNormalsInvalid[SOUTHWEST])
|
||||
{
|
||||
// <FS:CR> Aurora Sim
|
||||
if(!getNeighborPatch(NORTH) && getNeighborPatch(NORTHWEST))
|
||||
{
|
||||
if(getNeighborPatch(NORTHWEST)->getHasReceivedData())
|
||||
{
|
||||
*(mDataZ + grids_per_patch_edge*grids_per_edge) = *(getNeighborPatch(NORTHWEST)->mDataZ + grids_per_patch_edge);
|
||||
}
|
||||
}
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
for (j = 0; j < grids_per_patch_edge; j++)
|
||||
{
|
||||
calcNormal(0, j, 2);
|
||||
@@ -504,6 +566,17 @@ void LLSurfacePatch::updateNormals()
|
||||
// update the south edge
|
||||
if (mNormalsInvalid[SOUTHWEST] || mNormalsInvalid[SOUTH] || mNormalsInvalid[SOUTHEAST])
|
||||
{
|
||||
// <FS:CR> Aurora Sim
|
||||
if(!getNeighborPatch(EAST) && getNeighborPatch(SOUTHEAST))
|
||||
{
|
||||
if(getNeighborPatch(SOUTHEAST)->getHasReceivedData())
|
||||
{
|
||||
*(mDataZ + grids_per_patch_edge) =
|
||||
*(getNeighborPatch(SOUTHEAST)->mDataZ + grids_per_patch_edge * getNeighborPatch(SOUTHEAST)->getSurface()->getGridsPerEdge());
|
||||
}
|
||||
}
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
for (i = 0; i < grids_per_patch_edge; i++)
|
||||
{
|
||||
calcNormal(i, 0, 2);
|
||||
@@ -532,7 +605,10 @@ void LLSurfacePatch::updateNormals()
|
||||
{
|
||||
// East, but not north. Pull from your east neighbor's northwest point.
|
||||
*(mDataZ + grids_per_patch_edge + grids_per_patch_edge*grids_per_edge) =
|
||||
*(getNeighborPatch(EAST)->mDataZ + (grids_per_patch_edge - 1)*grids_per_edge);
|
||||
// <FS:CR> Aurora Sim
|
||||
//*(getNeighborPatch(EAST)->mDataZ + (grids_per_patch_edge - 1)*grids_per_edge);
|
||||
*(getNeighborPatch(EAST)->mDataZ + (getNeighborPatch(EAST)->getSurface()->getGridsPerPatchEdge() - 1)*getNeighborPatch(EAST)->getSurface()->getGridsPerEdge());
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -557,7 +633,10 @@ void LLSurfacePatch::updateNormals()
|
||||
{
|
||||
// North, but not east. Pull from your north neighbor's southeast corner.
|
||||
*(mDataZ + grids_per_patch_edge + grids_per_patch_edge*grids_per_edge) =
|
||||
*(getNeighborPatch(NORTH)->mDataZ + (grids_per_patch_edge - 1));
|
||||
// <FS:CR> Aurora Sim
|
||||
//*(getNeighborPatch(NORTH)->mDataZ + (grids_per_patch_edge - 1));
|
||||
*(getNeighborPatch(NORTH)->mDataZ + (getNeighborPatch(NORTH)->getSurface()->getGridsPerPatchEdge() - 1));
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -574,8 +653,25 @@ void LLSurfacePatch::updateNormals()
|
||||
&&
|
||||
(!getNeighborPatch(EAST) || (getNeighborPatch(EAST)->mSurfacep != mSurfacep)))
|
||||
{
|
||||
// <FS:CR> Aurora Sim
|
||||
U32 own_xpos, own_ypos, neighbor_xpos, neighbor_ypos;
|
||||
S32 own_offset = 0, neighbor_offset = 0;
|
||||
from_region_handle(mSurfacep->getRegion()->getHandle(), &own_xpos, &own_ypos);
|
||||
from_region_handle(getNeighborPatch(NORTHEAST)->mSurfacep->getRegion()->getHandle(), &neighbor_xpos, &neighbor_ypos);
|
||||
if(own_ypos >= neighbor_ypos) {
|
||||
neighbor_offset = own_ypos - neighbor_ypos;
|
||||
}
|
||||
else {
|
||||
own_offset = neighbor_ypos - own_ypos;
|
||||
}
|
||||
// </FS:CR> Aurora Sim
|
||||
|
||||
*(mDataZ + grids_per_patch_edge + grids_per_patch_edge*grids_per_edge) =
|
||||
*(getNeighborPatch(NORTHEAST)->mDataZ);
|
||||
*(getNeighborPatch(NORTHEAST)->mDataZ +
|
||||
// <FS:CR> Aurora Sim
|
||||
(grids_per_edge + neighbor_offset - own_offset - 1) *
|
||||
getNeighborPatch(NORTHEAST)->getSurface()->getGridsPerEdge() );
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -618,8 +714,12 @@ void LLSurfacePatch::updateEastEdge()
|
||||
{
|
||||
U32 grids_per_patch_edge = mSurfacep->getGridsPerPatchEdge();
|
||||
U32 grids_per_edge = mSurfacep->getGridsPerEdge();
|
||||
// <FS:CR> Aurora Sim
|
||||
U32 grids_per_edge_east = grids_per_edge;
|
||||
|
||||
U32 j, k;
|
||||
//U32 j, k;
|
||||
U32 j, k, h;
|
||||
// <FS:CR> Aurora Sim
|
||||
F32 *west_surface, *east_surface;
|
||||
|
||||
if (!getNeighborPatch(EAST))
|
||||
@@ -631,6 +731,9 @@ void LLSurfacePatch::updateEastEdge()
|
||||
{
|
||||
west_surface = mDataZ + grids_per_patch_edge;
|
||||
east_surface = getNeighborPatch(EAST)->mDataZ;
|
||||
// <FS:CR> Aurora Sim
|
||||
grids_per_edge_east = getNeighborPatch(EAST)->getSurface()->getGridsPerEdge();
|
||||
// <FS:CR> Aurora Sim
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -642,7 +745,11 @@ void LLSurfacePatch::updateEastEdge()
|
||||
for (j=0; j < grids_per_patch_edge; j++)
|
||||
{
|
||||
k = j * grids_per_edge;
|
||||
*(west_surface + k) = *(east_surface + k); // update buffer Z
|
||||
// <FS:CR> Aurora Sim
|
||||
h = j * grids_per_edge_east;
|
||||
*(west_surface + k) = *(east_surface + h); // update buffer Z
|
||||
//*(west_surface + k) = *(east_surface + k); // update buffer Z
|
||||
// </FS:CR> Aurora Sim
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,13 +778,12 @@ void LLSurfacePatch::updateNorthEdge()
|
||||
}
|
||||
|
||||
// Update patchp's north edge ...
|
||||
for (i=0; i<grids_per_patch_edge; i++)
|
||||
for (i = 0; i<grids_per_patch_edge; i++)
|
||||
{
|
||||
*(south_surface + i) = *(north_surface + i); // update buffer Z
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL LLSurfacePatch::updateTexture()
|
||||
{
|
||||
if (mSTexUpdate) // Update texture as needed
|
||||
|
||||
Reference in New Issue
Block a user