Ejemplo n.º 1
0
void LLSurfacePatch::updateCompositionStats()
{
	LLViewerLayer *vlp = mSurfacep->getRegion()->getComposition();

	F32 x, y, width, height, mpg, min, mean, max;

	LLVector3 origin = getOriginAgent() - mSurfacep->getOriginAgent();
	mpg = mSurfacep->getMetersPerGrid();
	x = origin.mV[VX];
	y = origin.mV[VY];
	width = mpg*(mSurfacep->getGridsPerPatchEdge()+1);
	height = mpg*(mSurfacep->getGridsPerPatchEdge()+1);

	mean = 0.f;
	min = vlp->getValueScaled(x, y);
	max= min;
	U32 count = 0;
	F32 i, j;
	for (j = 0; j < height; j += mpg)
	{
		for (i = 0; i < width; i += mpg)
		{
			F32 comp = vlp->getValueScaled(x + i, y + j);
			mean += comp;
			min = llmin(min, comp);
			max = llmax(max, comp);
			count++;
		}
	}
	mean /= count;

	mMinComposition = min;
	mMeanComposition = mean;
	mMaxComposition = max;
}
Ejemplo n.º 2
0
LLVector3 LLSurfacePatch::getPointAgent(const U32 x, const U32 y) const
{
	U32 surface_stride = mSurfacep->getGridsPerEdge();
	U32 point_offset = x + y*surface_stride;
	LLVector3 pos;
	pos = getOriginAgent();
	pos.mV[VX] += x	* mSurfacep->getMetersPerGrid();
	pos.mV[VY] += y * mSurfacep->getMetersPerGrid();
	pos.mV[VZ] = *(mDataZ + point_offset);
	return pos;
}
Ejemplo n.º 3
0
LLVector2 LLSurfacePatch::getTexCoords(const U32 x, const U32 y) const
{
	U32 surface_stride = mSurfacep->getGridsPerEdge();
	U32 point_offset = x + y*surface_stride;
	LLVector3 pos, rel_pos;
	pos = getOriginAgent();
	pos.mV[VX] += x	* mSurfacep->getMetersPerGrid();
	pos.mV[VY] += y * mSurfacep->getMetersPerGrid();
	pos.mV[VZ] = *(mDataZ + point_offset);
	rel_pos = pos - mSurfacep->getOriginAgent();
	rel_pos *= 1.f/surface_stride;
	return LLVector2(rel_pos.mV[VX], rel_pos.mV[VY]);
}
Ejemplo n.º 4
0
void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3 *vertex, LLVector3 *normal,
						  LLVector2 *tex0, LLVector2 *tex1)
{
	if (!mSurfacep || !mSurfacep->getRegion() || !mSurfacep->getGridsPerEdge())
	{
		return; // failsafe
	}
	llassert_always(vertex && normal && tex0 && tex1);
	
	U32 surface_stride = mSurfacep->getGridsPerEdge();
	U32 point_offset = x + y*surface_stride;

	*normal = getNormal(x, y);

	LLVector3 pos_agent = getOriginAgent();
	pos_agent.mV[VX] += x * mSurfacep->getMetersPerGrid();
	pos_agent.mV[VY] += y * mSurfacep->getMetersPerGrid();
	pos_agent.mV[VZ]  = *(mDataZ + point_offset);
	*vertex     = pos_agent;

	LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent();
	LLVector3 tex_pos = rel_pos * (1.f/surface_stride);
	tex0->mV[0]  = tex_pos.mV[0];
	tex0->mV[1]  = tex_pos.mV[1];
	tex1->mV[0] = mSurfacep->getRegion()->getCompositionXY(llfloor(mOriginRegion.mV[0])+x, llfloor(mOriginRegion.mV[1])+y);

	const F32 xyScale = 4.9215f*7.f; //0.93284f;
	const F32 xyScaleInv = (1.f / xyScale)*(0.2222222222f);

	F32 vec[3] = {
					fmod((F32)(mOriginGlobal.mdV[0] + x)*xyScaleInv, 256.f),
					fmod((F32)(mOriginGlobal.mdV[1] + y)*xyScaleInv, 256.f),
					0.f
				};
	F32 rand_val = llclamp(noise2(vec)* 0.75f + 0.5f, 0.f, 1.f);
	tex1->mV[1] = rand_val;


}
Ejemplo n.º 5
0
LLVector3 LLViewerRegion::getPosRegionFromAgent(const LLVector3 &pos_agent) const
{
	return pos_agent - getOriginAgent();
}
Ejemplo n.º 6
0
void LLViewerRegion::updateRenderMatrix()
{
	mRenderMatrix.setTranslation(getOriginAgent());
}