示例#1
0
void LLCloudLayer::decompress(LLBitPack &bitpack, LLGroupHeader *group_headerp)
{
	LLPatchHeader  patch_header;

	init_patch_decompressor(group_headerp->patch_size);

	// Don't use the packed group_header stride because the strides used on
	// simulator and viewer are not equal.
	group_headerp->stride = group_headerp->patch_size; 		// offset required to step up one row
	set_group_of_patch_header(group_headerp);

	decode_patch_header(bitpack, &patch_header, FALSE);
	decode_patch(bitpack, gBuffer);
	decompress_patch(mDensityp, gBuffer, &patch_header); 
}
void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL b_large_patch) 
{

	LLPatchHeader  ph;
	S32 j, i;
	S32 patch[LARGE_PATCH_SIZE*LARGE_PATCH_SIZE];
	LLSurfacePatch *patchp;

	init_patch_decompressor(gopp->patch_size);
	gopp->stride = mGridsPerEdge;
	set_group_of_patch_header(gopp);

	while (1)
	{
// <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;
		}

// <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))
		{
			LL_WARNS() << "Received invalid terrain packet - patch header patch ID incorrect!" 
				<< " patches per edge " << mPatchesPerEdge
				<< " i " << i
				<< " j " << j
				<< " dc_offset " << ph.dc_offset
				<< " range " << (S32)ph.range
				<< " quant_wbits " << (S32)ph.quant_wbits
				<< " patchids " << (S32)ph.patchids
				<< LL_ENDL;
            LLAppViewer::instance()->badNetworkHandler();
			return;
		}

		patchp = &mPatchList[j*mPatchesPerEdge + i];


		decode_patch(bitpack, patch);
		decompress_patch(patchp->getDataZ(), patch, &ph);

		// Update edges for neighbors.  Need to guarantee that this gets done before we generate vertical stats.
		patchp->updateNorthEdge();
		patchp->updateEastEdge();
		if (patchp->getNeighborPatch(WEST))
		{
			patchp->getNeighborPatch(WEST)->updateEastEdge();
		}
		if (patchp->getNeighborPatch(SOUTHWEST))
		{
			patchp->getNeighborPatch(SOUTHWEST)->updateEastEdge();
			patchp->getNeighborPatch(SOUTHWEST)->updateNorthEdge();
		}
		if (patchp->getNeighborPatch(SOUTH))
		{
			patchp->getNeighborPatch(SOUTH)->updateNorthEdge();
		}

		// Dirty patch statistics, and flag that the patch has data.
		patchp->dirtyZ();
		patchp->setHasReceivedData();
	}
示例#3
0
void LLWind::decompress(LLBitPack &bitpack, LLGroupHeader *group_headerp)
{
	static const LLCachedControl<bool> wind_enabled("WindEnabled",false); 
	if (!mCloudDensityp || !wind_enabled)
	{
		return;
	}

	LLPatchHeader  patch_header;
	S32 buffer[16*16];

	init_patch_decompressor(group_headerp->patch_size);

	// Don't use the packed group_header stride because the strides used on
	// simulator and viewer are not equal.
	group_headerp->stride = group_headerp->patch_size;	
	set_group_of_patch_header(group_headerp);

	// X component
	decode_patch_header(bitpack, &patch_header, FALSE); // for var
	//decode_patch_header(bitpack, &patch_header); //non var
	decode_patch(bitpack, buffer);
	decompress_patch(mVelX, buffer, &patch_header);

	// Y component
	decode_patch_header(bitpack, &patch_header, FALSE); // for var
	//decode_patch_header(bitpack, &patch_header); //non var
	decode_patch(bitpack, buffer);
	decompress_patch(mVelY, buffer, &patch_header);



	S32 i, j, k;
	// HACK -- mCloudVelXY is the same as mVelXY, except we add a divergence
	// that is proportional to the gradient of the cloud density 
	// ==> this helps to clump clouds together
	// NOTE ASSUMPTION: cloud density has the same dimensions as the wind field
	// This needs to be fixed... causes discrepency at region boundaries

	for (j=1; j<mSize-1; j++)
	{
		for (i=1; i<mSize-1; i++)
		{
			k = i + j * mSize;
			*(mCloudVelX + k) = *(mVelX + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + 1) - *(mCloudDensityp + k - 1));
			*(mCloudVelY + k) = *(mVelY + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + mSize) - *(mCloudDensityp + k - mSize));
		}
	}

	i = mSize - 1;
	for (j=1; j<mSize-1; j++)
	{
		k = i + j * mSize;
		*(mCloudVelX + k) = *(mVelX + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k) - *(mCloudDensityp + k - 2));
		*(mCloudVelY + k) = *(mVelY + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + mSize) - *(mCloudDensityp + k - mSize));
	}
	i = 0;
	for (j=1; j<mSize-1; j++)
	{
		k = i + j * mSize;
		*(mCloudVelX + k) = *(mVelX + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + 2) - *(mCloudDensityp + k));
		*(mCloudVelY + k) = *(mVelY + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + mSize) - *(mCloudDensityp + k + mSize));
	}
	j = mSize - 1;
	for (i=1; i<mSize-1; i++)
	{
		k = i + j * mSize;
		*(mCloudVelX + k) = *(mVelX + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + 1) - *(mCloudDensityp + k - 1));
		*(mCloudVelY + k) = *(mVelY + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k) - *(mCloudDensityp + k - 2*mSize));
	}
	j = 0;
	for (i=1; i<mSize-1; i++)
	{
		k = i + j * mSize;
		*(mCloudVelX + k) = *(mVelX + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + 1) - *(mCloudDensityp + k -1));
		*(mCloudVelY + k) = *(mVelY + k) + CLOUD_DIVERGENCE_COEF * (*(mCloudDensityp + k + 2*mSize) - *(mCloudDensityp + k));
	}
}
示例#4
0
void LLWind::decompress(LLBitPack &bitpack, LLGroupHeader *group_headerp)
{
	LLPatchHeader  patch_header;
	S32 buffer[16*16];

	init_patch_decompressor(group_headerp->patch_size);

	// Don't use the packed group_header stride because the strides used on
	// simulator and viewer are not equal.
	group_headerp->stride = group_headerp->patch_size;	
	set_group_of_patch_header(group_headerp);

	// X component
	decode_patch_header(bitpack, &patch_header);
	decode_patch(bitpack, buffer);
	decompress_patch(mVelX, buffer, &patch_header);

	// Y component
	decode_patch_header(bitpack, &patch_header);
	decode_patch(bitpack, buffer);
	decompress_patch(mVelY, buffer, &patch_header);

	S32 i, j, k;

	for (j=1; j<mSize-1; j++)
	{
		for (i=1; i<mSize-1; i++)
		{
			k = i + j * mSize;
			*(mVelX + k) = *(mVelX + k);
			*(mVelY + k) = *(mVelY + k);
		}
	}

	i = mSize - 1;
	for (j=1; j<mSize-1; j++)
	{
		k = i + j * mSize;
		*(mVelX + k) = *(mVelX + k);
		*(mVelY + k) = *(mVelY + k);
	}
	i = 0;
	for (j=1; j<mSize-1; j++)
	{
		k = i + j * mSize;
		*(mVelX + k) = *(mVelX + k);
		*(mVelY + k) = *(mVelY + k);
	}
	j = mSize - 1;
	for (i=1; i<mSize-1; i++)
	{
		k = i + j * mSize;
		*(mVelX + k) = *(mVelX + k);
		*(mVelY + k) = *(mVelY + k);
	}
	j = 0;
	for (i=1; i<mSize-1; i++)
	{
		k = i + j * mSize;
		*(mVelX + k) = *(mVelX + k);
		*(mVelY + k) = *(mVelY + k);
	}
}