diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2023-10-13 09:57:24 -0700 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2023-10-13 09:57:24 -0700 |
commit | 49a5b79c2b1ba5f4b909d1bfab89bb7ad9c1e888 (patch) | |
tree | 8b523f42c6c778967fa01a54db186fab1df1c520 /indra/newview/llvosurfacepatch.cpp | |
parent | 474923e3cb29df35e8807006ad16861eb1dc24d0 (diff) |
DRTVWR-592: (WIP) Debugging, rethinking
Diffstat (limited to 'indra/newview/llvosurfacepatch.cpp')
-rw-r--r-- | indra/newview/llvosurfacepatch.cpp | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index bfa622b6c1..edb07ffd9b 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -776,29 +776,33 @@ void LLVOSurfacePatch::updateEastGeometry(LLFace *facep, index_offset += num_vertices; } -struct MikktData +struct MikktTerrainData { - MikktData(S32 vert_offet, - S32 vert_size, - LLStrider<LLVector3> &verticesp, - LLStrider<LLVector3> &normalsp, - LLStrider<LLVector4a> &tangentsp, - LLStrider<LLVector2> &texCoords0p) : - vert_offset(vert_offset), - vert_size(vert_size), - verticesp(verticesp), - normalsp(normalsp), - texCoords0p(texCoords0p) + MikktTerrainData(U32 vert_offset, + U32 vert_size, + LLStrider<LLVector3> &verticesp, + LLStrider<LLVector3> &normalsp, + LLStrider<LLVector4a> &tangentsp, + LLStrider<LLVector2> &texCoords0p) : + mVertOffset(vert_offset), + mVertSize(vert_size), + mVerticesp(verticesp), + mNormalsp(normalsp), + mTangentsp(tangentsp), + mTexCoords0p(texCoords0p) { } - S32 vert_offset; - U32 vert_size; - LLStrider<LLVector3> verticesp; - LLStrider<LLVector3> normalsp; - LLStrider<LLVector4a> tangentsp; - LLStrider<LLVector2> texCoords0p; + U32 mVertOffset; + U32 mVertSize; + LLStrider<LLVector3> mVerticesp; + LLStrider<LLVector3> mNormalsp; + LLStrider<LLVector4a> mTangentsp; + LLStrider<LLVector2> mTexCoords0p; }; +// TODO: mikktspace? lol no, use this instead +// void CalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, +// const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) void LLVOSurfacePatch::genTerrainTangents(LLFace *facep, LLStrider<LLVector3> &verticesp, @@ -810,51 +814,46 @@ void LLVOSurfacePatch::genTerrainTangents(LLFace *facep, ms.m_getNumFaces = [](const SMikkTSpaceContext *pContext) { - MikktData *data = (MikktData *) pContext->m_pUserData; - return S32(data->vert_size / 3); + MikktTerrainData *data = (MikktTerrainData *) pContext->m_pUserData; + return S32(data->mVertSize / 3); }; ms.m_getNumVerticesOfFace = [](const SMikkTSpaceContext *pContext, const int iFace) { return 3; }; ms.m_getPosition = [](const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) { - MikktData *data = (MikktData *) pContext->m_pUserData; - fvPosOut[0] = data->verticesp[data->vert_offset + iVert].mV[0]; - fvPosOut[1] = data->verticesp[data->vert_offset + iVert].mV[1]; - fvPosOut[2] = data->verticesp[data->vert_offset + iVert].mV[2]; + MikktTerrainData *data = (MikktTerrainData *) pContext->m_pUserData; + fvPosOut[0] = data->mVerticesp[data->mVertOffset + iVert].mV[0]; + fvPosOut[1] = data->mVerticesp[data->mVertOffset + iVert].mV[1]; + fvPosOut[2] = data->mVerticesp[data->mVertOffset + iVert].mV[2]; }; ms.m_getNormal = [](const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) { - MikktData *data = (MikktData *) pContext->m_pUserData; - fvNormOut[0] = data->normalsp[data->vert_offset + iVert].mV[0]; - fvNormOut[1] = data->normalsp[data->vert_offset + iVert].mV[1]; - fvNormOut[2] = data->normalsp[data->vert_offset + iVert].mV[2]; + MikktTerrainData *data = (MikktTerrainData *) pContext->m_pUserData; + fvNormOut[0] = data->mNormalsp[data->mVertOffset + iVert].mV[0]; + fvNormOut[1] = data->mNormalsp[data->mVertOffset + iVert].mV[1]; + fvNormOut[2] = data->mNormalsp[data->mVertOffset + iVert].mV[2]; }; ms.m_getTexCoord = [](const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) { - MikktData *data = (MikktData *) pContext->m_pUserData; - fvTexcOut[0] = data->texCoords0p[data->vert_offset + iVert].mV[0]; - fvTexcOut[1] = data->texCoords0p[data->vert_offset + iVert].mV[1]; + MikktTerrainData *data = (MikktTerrainData *) pContext->m_pUserData; + fvTexcOut[0] = data->mTexCoords0p[data->mVertOffset + iVert].mV[0]; + fvTexcOut[1] = data->mTexCoords0p[data->mVertOffset + iVert].mV[1]; }; ms.m_setTSpaceBasic = [](const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert) { - MikktData *data = (MikktData *) pContext->m_pUserData; - data->tangentsp[data->vert_offset + iVert] = LLVector4a(fvTangent[0], fvTangent[1], fvTangent[2], fSign); + MikktTerrainData *data = (MikktTerrainData *) pContext->m_pUserData; + data->mTangentsp[data->mVertOffset + iVert] = LLVector4a(fvTangent[0], fvTangent[1], fvTangent[2], fSign); }; ms.m_setTSpace = nullptr; - MikktData data(facep->getGeomIndex(), - facep->getGeomCount(), - verticesp, - normalsp, - tangentsp, - texCoords0p); - SMikkTSpaceContext ctx = { &ms, &data }; + MikktTerrainData data((U32) (facep->getGeomIndex()), (U32) (facep->getGeomCount()), verticesp, normalsp, tangentsp, texCoords0p); + SMikkTSpaceContext ctx = {&ms, &data}; genTangSpaceDefault(&ctx); } @@ -1102,11 +1101,9 @@ void LLTerrainPartition::getGeometry(LLSpatialGroup* group) LLStrider<LLVector2> texcoords2; LLStrider<U16> indices; - const bool has_tangents = buffer->hasDataType(LLVertexBuffer::TYPE_TANGENT); - llassert_always(buffer->getVertexStrider(vertices)); llassert_always(buffer->getNormalStrider(normals)); - llassert_always(has_tangents ? buffer->getTangentStrider(tangents) : true); + llassert_always(buffer->getTangentStrider(tangents)); llassert_always(buffer->getTexCoord0Strider(texcoords)); llassert_always(buffer->getTexCoord1Strider(texcoords2)); llassert_always(buffer->getIndexStrider(indices)); |