diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp index 5850fed08..aeaf79f33 100644 --- a/indra/llappearance/llpolymorph.cpp +++ b/indra/llappearance/llpolymorph.cpp @@ -77,9 +77,11 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) : { const S32 numVertices = mNumIndices; - mCoords = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); - mNormals = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); - mBinormals = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); + U32 size = sizeof(LLVector4a)*numVertices; + + mCoords = static_cast( ll_aligned_malloc_16(size) ); + mNormals = static_cast( ll_aligned_malloc_16(size) ); + mBinormals = static_cast( ll_aligned_malloc_16(size) ); mTexCoords = new LLVector2[numVertices]; mVertexIndices = new U32[numVertices]; @@ -125,9 +127,13 @@ BOOL LLPolyMorphData::loadBinary(LLFILE *fp, LLPolyMeshSharedData *mesh) //------------------------------------------------------------------------- // allocate vertices //------------------------------------------------------------------------- - mCoords = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); - mNormals = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); - mBinormals = static_cast(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a))); + + U32 size = sizeof(LLVector4a)*numVertices; + + mCoords = static_cast(ll_aligned_malloc_16(size)); + mNormals = static_cast(ll_aligned_malloc_16(size)); + mBinormals = static_cast(ll_aligned_malloc_16(size)); + mTexCoords = new LLVector2[numVertices]; // Actually, we are allocating more space than we need for the skiplist mVertexIndices = new U32[numVertices]; @@ -889,17 +895,29 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) norm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR); scaled_normals[vert_index_mesh].add(norm); norm = scaled_normals[vert_index_mesh]; + + // guard against degenerate input data before we create NaNs below! + // norm.normalize3fast(); normals[vert_index_mesh] = norm; // calculate new binormals LLVector4a binorm = mMorphData->mBinormals[vert_index_morph]; + + // guard against degenerate input data before we create NaNs below! + // + if (!binorm.isFinite3() || (binorm.dot3(binorm).getF32() <= F_APPROXIMATELY_ZERO)) + { + binorm.set(1,0,0,1); + } + binorm.mul(delta_weight*maskWeight*NORMAL_SOFTEN_FACTOR); scaled_binormals[vert_index_mesh].add(binorm); LLVector4a tangent; tangent.setCross3(scaled_binormals[vert_index_mesh], norm); LLVector4a& normalized_binormal = binormals[vert_index_mesh]; - normalized_binormal.setCross3(norm, tangent); + + normalized_binormal.setCross3(norm, tangent); normalized_binormal.normalize3fast(); tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight; diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 3aac66dd7..b5252d055 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -636,7 +636,10 @@ public: parent = node->getOctParent(); } - node->insert(data); + if(node != this) + { + node->insert(data); + } } return false; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 65a7fda5e..7b890c57a 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -858,14 +858,25 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { //dump every 128 lines LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl; - ostr.str(""); - ostr.clear(); + ostr = std::stringstream(); } } LL_WARNS("ShaderLoading") << "\n" << ostr.str() << llendl; -#endif // LL_WINDOWS +#else + std::string str; + + for (GLuint i = 0; i < count; i++) { + str.append(text[i]); + + if (i % 128 == 0) + { + LL_WARNS("ShaderLoading") << str << llendl; + str = ""; + } + } +#endif glDeleteObjectARB(ret); //no longer need handle ret = 0; } diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index bdce7b2b3..cfe40d8fd 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -112,41 +112,6 @@ void planarProjection(LLVector2 &tc, const LLVector4a& normal, tc.mV[0] = 1.0f+((binormal.dot3(vec).getF32())*2 - 0.5f); } -void sphericalProjection(LLVector2 &tc, const LLVector4a& normal, - const LLVector4a &mCenter, const LLVector4a& vec) -{ //BROKEN - /*tc.mV[0] = acosf(vd.mNormal * LLVector3(1,0,0))/3.14159f; - - tc.mV[1] = acosf(vd.mNormal * LLVector3(0,0,1))/6.284f; - if (vd.mNormal.mV[1] > 0) - { - tc.mV[1] = 1.0f-tc.mV[1]; - }*/ -} - -void cylindricalProjection(LLVector2 &tc, const LLVector4a& normal, const LLVector4a &mCenter, const LLVector4a& vec) -{ //BROKEN - /*LLVector3 binormal; - float d = vd.mNormal * LLVector3(1,0,0); - if (d >= 0.5f || d <= -0.5f) - { - binormal = LLVector3(0,1,0); - } - else{ - binormal = LLVector3(1,0,0); - } - LLVector3 tangent = binormal % vd.mNormal; - - tc.mV[1] = -((tangent*vec)*2 - 0.5f); - - tc.mV[0] = acosf(vd.mNormal * LLVector3(1,0,0))/6.284f; - - if (vd.mNormal.mV[1] < 0) - { - tc.mV[0] = 1.0f-tc.mV[0]; - }*/ -} - //////////////////// // // LLFace implementation @@ -942,20 +907,10 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position, volume_normal.load3(mDrawablep->getVOVolume()->agentDirectionToVolume(normal).mV); volume_normal.normalize3fast(); - switch (texgen) + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { - case LLTextureEntry::TEX_GEN_PLANAR: planarProjection(tc, volume_normal, center, volume_position); - break; - case LLTextureEntry::TEX_GEN_SPHERICAL: - sphericalProjection(tc, volume_normal, center, volume_position); - break; - case LLTextureEntry::TEX_GEN_CYLINDRICAL: - cylindricalProjection(tc, volume_normal, center, volume_position); - break; - default: - break; - } + } } if (mTextureMatrix) // if we have a texture matrix, use it @@ -1644,7 +1599,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (!do_bump) { //not in atlas or not bump mapped, might be able to do a cheap update - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount); + mVertexBuffer->getTexCoord0Strider(tex_coords0, mGeomIndex, mGeomCount); if (texgen != LLTextureEntry::TEX_GEN_PLANAR) { @@ -1655,12 +1610,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, { LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM); S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF; - LLVector4a::memcpyNonAliased16((F32*) tex_coords.get(), (F32*) vf.mTexCoords, tc_size); + LLVector4a::memcpyNonAliased16((F32*) tex_coords0.get(), (F32*) vf.mTexCoords, tc_size); } else { LLFastTimer t(FTM_FACE_TEX_QUICK_XFORM); - F32* dst = (F32*) tex_coords.get(); + F32* dst = (F32*) tex_coords0.get(); LLVector4a* src = (LLVector4a*) vf.mTexCoords; LLVector4a trans; @@ -1706,7 +1661,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, tmp = tmp * *mTextureMatrix; tc.mV[0] = tmp.mV[0]; tc.mV[1] = tmp.mV[1]; - *tex_coords++ = tc; + *tex_coords0++ = tc; } } } @@ -1729,7 +1684,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, tc.mV[0] = tmp.mV[0]; tc.mV[1] = tmp.mV[1]; - *tex_coords++ = tc; + *tex_coords0++ = tc; } } else @@ -1745,7 +1700,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, xform(tc, cos_ang, sin_ang, os, ot, ms, mt); - *tex_coords++ = tc; + *tex_coords0++ = tc; } } } @@ -1758,9 +1713,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, else { //either bump mapped or in atlas, just do the whole expensive loop LLFastTimer t(FTM_FACE_TEX_DEFAULT); - mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex, mGeomCount, map_range); std::vector bump_tc; + + LLStrider dst; + + mVertexBuffer->getTexCoord0Strider(dst, mGeomIndex, mGeomCount, map_range); + for (S32 i = 0; i < num_vertices; i++) { @@ -1776,20 +1735,10 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, vec.mul(scalea); - switch (texgen) + if (texgen == LLTextureEntry::TEX_GEN_PLANAR) { - case LLTextureEntry::TEX_GEN_PLANAR: - planarProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_SPHERICAL: - sphericalProjection(tc, norm, center, vec); - break; - case LLTextureEntry::TEX_GEN_CYLINDRICAL: - cylindricalProjection(tc, norm, center, vec); - break; - default: - break; - } + planarProjection(tc, norm, center, vec); + } } if (tex_mode && mTextureMatrix) @@ -1804,8 +1753,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, xform(tc, cos_ang, sin_ang, os, ot, ms, mt); } - - *tex_coords++ = tc; + *dst++ = tc; if (do_bump) { bump_tc.push_back(tc); @@ -1819,7 +1767,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, if (do_bump) { - mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex, mGeomCount, map_range); + mVertexBuffer->getTexCoord1Strider(tex_coords1, mGeomIndex, mGeomCount, map_range); for (S32 i = 0; i < num_vertices; i++) { @@ -1843,10 +1791,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, } binormal.normalize3fast(); + LLVector2 tc = bump_tc[i]; tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() ); - *tex_coords2++ = tc; + *tex_coords1++ = tc; } if (map_range) diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 9a00bc1e6..d6e58fdc1 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -196,7 +196,7 @@ public: }; }; -LL_ALIGN_PREFIX(16) +LL_ALIGN_PREFIX(64) class LLSpatialGroup : public LLOctreeListener { friend class LLSpatialPartition; diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index eea72a9f7..465df0465 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -1043,6 +1043,7 @@ void LLVOSurfacePatch::updateSpatialExtents(LLVector4a& newMin, LLVector4a &newM { LLVector3 posAgent = getPositionAgent(); LLVector3 scale = getScale(); + //make z-axis scale at least 1 to avoid shadow artifacts on totally flat land scale.mV[VZ] = llmax(scale.mV[VZ], 1.f); newMin.load3( (posAgent-scale*0.5f).mV); // Changing to 2.f makes the culling a -little- better, but still wrong newMax.load3( (posAgent+scale*0.5f).mV); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2d42aff94..a76949240 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9724,11 +9724,13 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) LLVector4a left; left.load3(camera.getLeftAxis().mV); left.mul(left); + llassert(left.dot3(left).getF32() > F_APPROXIMATELY_ZERO); left.normalize3fast(); LLVector4a up; up.load3(camera.getUpAxis().mV); up.mul(up); + llassert(up.dot3(up).getF32() > F_APPROXIMATELY_ZERO); up.normalize3fast(); tdim.mV[0] = fabsf(half_height.dot3(left).getF32());