diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 4d80d53a79fc4e12fa00629795e31d73e2dda0e3..6ea91fbfc7d98fe5e98e57ad1433c1e3c631d5e0 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -41,12 +41,14 @@ static const U32 MAX_SKY_DETAIL = 180; inline U32 LLVOWLSky::getNumStacks(void) { - return llmin(MAX_SKY_DETAIL, llmax(MIN_SKY_DETAIL, gSavedSettings.getU32("WLSkyDetail"))); + static LLCachedControl<U32> sky_detail(gSavedSettings, "WLSkyDetail"); + return llclamp(sky_detail(), MIN_SKY_DETAIL, MAX_SKY_DETAIL); } inline U32 LLVOWLSky::getNumSlices(void) { - return 2 * llmin(MAX_SKY_DETAIL, llmax(MIN_SKY_DETAIL, gSavedSettings.getU32("WLSkyDetail"))); + static LLCachedControl<U32> sky_detail(gSavedSettings, "WLSkyDetail"); + return 2 * llclamp(sky_detail(), MIN_SKY_DETAIL, MAX_SKY_DETAIL); } inline U32 LLVOWLSky::getStripsNumVerts(void) @@ -97,13 +99,13 @@ LLDrawable * LLVOWLSky::createDrawable(LLPipeline * pipeline) return mDrawable; } -inline F32 LLVOWLSky::calcPhi(U32 i) +inline F32 LLVOWLSky::calcPhi(U32 i, const U32 num_stacks) { // Calc: PI/8 * 1-((1-t^4)*(1-t^4)) { 0<t<1 } // Demos: \pi/8*\left(1-((1-x^{4})*(1-x^{4}))\right)\ \left\{0<x\le1\right\} // i should range from [0..SKY_STACKS] so t will range from [0.f .. 1.f] - F32 t = float(i) / float(getNumStacks()); + F32 t = float(i) / float(num_stacks); // ^4 the parameter of the tesselation to bias things toward 0 (the dome's apex) t *= t; @@ -189,7 +191,8 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) } { - const U32 max_buffer_bytes = gSavedSettings.getS32("RenderMaxVBOSize")*1024; + static LLCachedControl<S32> max_vbo_size(gSavedSettings, "RenderMaxVBOSize", 512); + const U32 max_buffer_bytes = max_vbo_size*1024; const U32 data_mask = LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK; const U32 max_verts = max_buffer_bytes / LLVertexBuffer::calcVertexSize(data_mask); @@ -211,7 +214,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) LLTimer timer; timer.start(); - const F32 DOME_RADIUS = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); + const F32 dome_radius = LLEnvironment::instance().getCurrentSky()->getDomeRadius(); for (U32 i = 0; i < strips_segments ;++i) { @@ -257,7 +260,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) U32 index_count = 0; // fill it - buildStripsBuffer(begin_stack, end_stack, vertex_count, index_count, vertices, texCoords, indices, DOME_RADIUS); + buildStripsBuffer(begin_stack, end_stack, vertex_count, index_count, vertices, texCoords, indices, verts_per_stack, total_stacks, dome_radius); // and unlock the buffer segment->flush(); @@ -371,18 +374,17 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, LLStrider<LLVector3> & vertices, LLStrider<LLVector2> & texCoords, LLStrider<U16> & indices, - const F32 RADIUS) + const U32 num_slices, + const U32 num_stacks, + const F32 dome_radius) { - U32 i, j, num_slices, num_stacks; + U32 i, j; F32 phi0, theta, x0, y0, z0; // paranoia checking for SL-55986/SL-55833 U32 count_verts = 0; U32 count_indices = 0; - num_slices = getNumSlices(); - num_stacks = getNumStacks(); - llassert(end_stack <= num_stacks); // stacks are iterated one-indexed since phi(0) was handled by the fan above @@ -392,7 +394,7 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, for(i = begin_stack + 1; i <= end_stack+1; ++i) #endif { - phi0 = calcPhi(i); + phi0 = calcPhi(i, num_stacks); for(j = 0; j < num_slices; ++j) { @@ -405,19 +407,19 @@ void LLVOWLSky::buildStripsBuffer(U32 begin_stack, z0 = sin(phi0) * sin(theta); #if NEW_TESS - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); + *vertices++ = LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius); #else if (i == num_stacks-2) { - *vertices++ = LLVector3(x0*RADIUS, y0*RADIUS-1024.f*2.f, z0*RADIUS); + *vertices++ = LLVector3(x0* dome_radius, y0*dome_radius-1024.f*2.f, z0* dome_radius); } else if (i == num_stacks-1) { - *vertices++ = LLVector3(0, y0*RADIUS-1024.f*2.f, 0); + *vertices++ = LLVector3(0, y0* dome_radius -1024.f*2.f, 0); } else { - *vertices++ = LLVector3(x0 * RADIUS, y0 * RADIUS, z0 * RADIUS); + *vertices++ = LLVector3(x0 * dome_radius, y0 * dome_radius, z0 * dome_radius); } #endif diff --git a/indra/newview/llvowlsky.h b/indra/newview/llvowlsky.h index 8f072f94bf26653c29812bec5671b915fb67cf42..92e1d2ea05471faee3190b0ec005241782686779 100644 --- a/indra/newview/llvowlsky.h +++ b/indra/newview/llvowlsky.h @@ -56,7 +56,7 @@ class LLVOWLSky final : public LLStaticViewerObject { private: // a tiny helper function for controlling the sky dome tesselation. - static F32 calcPhi(U32 i); + static F32 calcPhi(U32 i, const U32 num_stacks); // helper function for initializing the stars. void initStars(); @@ -71,7 +71,9 @@ class LLVOWLSky final : public LLStaticViewerObject { LLStrider<LLVector3> & vertices, LLStrider<LLVector2> & texCoords, LLStrider<U16> & indices, - const F32 RADIUS); + const U32 num_slices, + const U32 num_stacks, + const F32 radius); // helper function for updating the stars colors. void updateStarColors();