A bit of harmless cleanup, null checking, nan checking. Removed sphericalProjection and cylindricalProjection from llface (broken/dead).
This commit is contained in:
@@ -77,9 +77,11 @@ LLPolyMorphData::LLPolyMorphData(const LLPolyMorphData &rhs) :
|
||||
{
|
||||
const S32 numVertices = mNumIndices;
|
||||
|
||||
mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
U32 size = sizeof(LLVector4a)*numVertices;
|
||||
|
||||
mCoords = static_cast<LLVector4a*>( ll_aligned_malloc_16(size) );
|
||||
mNormals = static_cast<LLVector4a*>( ll_aligned_malloc_16(size) );
|
||||
mBinormals = static_cast<LLVector4a*>( 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<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
mBinormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(numVertices * sizeof(LLVector4a)));
|
||||
|
||||
U32 size = sizeof(LLVector4a)*numVertices;
|
||||
|
||||
mCoords = static_cast<LLVector4a*>(ll_aligned_malloc_16(size));
|
||||
mNormals = static_cast<LLVector4a*>(ll_aligned_malloc_16(size));
|
||||
mBinormals = static_cast<LLVector4a*>(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;
|
||||
|
||||
@@ -636,7 +636,10 @@ public:
|
||||
parent = node->getOctParent();
|
||||
}
|
||||
|
||||
node->insert(data);
|
||||
if(node != this)
|
||||
{
|
||||
node->insert(data);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<LLVector2> bump_tc;
|
||||
|
||||
LLStrider<LLVector2> 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)
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
LL_ALIGN_PREFIX(16)
|
||||
LL_ALIGN_PREFIX(64)
|
||||
class LLSpatialGroup : public LLOctreeListener<LLDrawable>
|
||||
{
|
||||
friend class LLSpatialPartition;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user