|
59 | 59 | #include "llviewershadermgr.h" |
60 | 60 | #include "llviewertexture.h" |
61 | 61 | #include "llvoavatar.h" |
| 62 | +#include "llsculptidsize.h" |
62 | 63 |
|
63 | 64 | #define LL_MAX_INDICES_COUNT 1000000 |
64 | 65 |
|
@@ -851,90 +852,49 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, |
851 | 852 | //get bounding box |
852 | 853 | if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED)) |
853 | 854 | { |
854 | | - //VECTORIZE THIS |
855 | | - const LLMatrix4a& mat_vert = mat_vert_in; |
856 | | - //mat_vert.loadu(mat_vert_in); |
857 | | - |
858 | | - LLVector4a min,max; |
859 | | - |
860 | 855 | if (f >= volume.getNumVolumeFaces()) |
861 | 856 | { |
862 | 857 | LL_WARNS() << "Generating bounding box for invalid face index!" << LL_ENDL; |
863 | 858 | f = 0; |
864 | 859 | } |
865 | 860 |
|
866 | 861 | const LLVolumeFace &face = volume.getVolumeFace(f); |
867 | | - min = face.mExtents[0]; |
868 | | - max = face.mExtents[1]; |
869 | 862 |
|
870 | | - llassert(less_than_max_mag(min)); |
871 | | - llassert(less_than_max_mag(max)); |
872 | | - |
873 | | - //min, max are in volume space, convert to drawable render space |
874 | 863 |
|
875 | | - //get 8 corners of bounding box |
876 | | - LLVector4Logical mask[6]; |
877 | | - |
878 | | - for (U32 i = 0; i < 6; ++i) |
| 864 | + // MAINT-8264 - stray vertices, especially in low LODs, cause bounding box errors. |
| 865 | + if (face.mNumVertices < 3) |
879 | 866 | { |
880 | | - mask[i].clear(); |
| 867 | + LL_DEBUGS("RiggedBox") << "skipping face " << f << ", bad num vertices " |
| 868 | + << face.mNumVertices << " " << face.mNumIndices << " " << face.mWeights << LL_ENDL; |
| 869 | + return FALSE; |
881 | 870 | } |
882 | 871 |
|
883 | | - mask[0].setElement<2>(); //001 |
884 | | - mask[1].setElement<1>(); //010 |
885 | | - mask[2].setElement<1>(); //011 |
886 | | - mask[2].setElement<2>(); |
887 | | - mask[3].setElement<0>(); //100 |
888 | | - mask[4].setElement<0>(); //101 |
889 | | - mask[4].setElement<2>(); |
890 | | - mask[5].setElement<0>(); //110 |
891 | | - mask[5].setElement<1>(); |
892 | | - |
893 | | - LLVector4a v[8]; |
894 | | - |
895 | | - v[6] = min; |
896 | | - v[7] = max; |
897 | | - |
898 | | - for (U32 i = 0; i < 6; ++i) |
899 | | - { |
900 | | - v[i].setSelectWithMask(mask[i], min, max); |
901 | | - } |
902 | | - |
903 | | - LLVector4a tv[8]; |
904 | | - |
905 | | - //transform bounding box into drawable space |
906 | | - for (U32 i = 0; i < 8; ++i) |
907 | | - { |
908 | | - mat_vert.affineTransform(v[i], tv[i]); |
909 | | - } |
910 | | - |
911 | | - //find bounding box |
912 | | - LLVector4a& newMin = mExtents[0]; |
913 | | - LLVector4a& newMax = mExtents[1]; |
| 872 | + //VECTORIZE THIS |
| 873 | + LLMatrix4a mat_vert = mat_vert_in; |
| 874 | + LLVector4a new_extents[2]; |
914 | 875 |
|
915 | | - newMin = newMax = tv[0]; |
| 876 | + llassert(less_than_max_mag(face.mExtents[0])); |
| 877 | + llassert(less_than_max_mag(face.mExtents[1])); |
916 | 878 |
|
917 | | - for (U32 i = 1; i < 8; ++i) |
918 | | - { |
919 | | - newMin.setMin(newMin, tv[i]); |
920 | | - newMax.setMax(newMax, tv[i]); |
921 | | - } |
| 879 | + matMulBoundBox(mat_vert, face.mExtents, mExtents); |
922 | 880 |
|
923 | 881 | if (!mDrawablep->isActive()) |
924 | 882 | { // Shift position for region |
925 | 883 | LLVector4a offset; |
926 | 884 | offset.load3(mDrawablep->getRegion()->getOriginAgent().mV); |
927 | | - newMin.add(offset); |
928 | | - newMax.add(offset); |
| 885 | + mExtents[0].add(offset); |
| 886 | + mExtents[1].add(offset); |
| 887 | + LL_DEBUGS("RiggedBox") << "updating extents for face " << f |
| 888 | + << " not active, added offset " << offset << LL_ENDL; |
929 | 889 | } |
930 | 890 |
|
931 | 891 | LLVector4a t; |
932 | | - t.setAdd(newMin,newMax); |
| 892 | + t.setAdd(mExtents[0],mExtents[1]); |
933 | 893 | t.mul(0.5f); |
934 | 894 |
|
935 | 895 | mCenterLocal.set(t.getF32ptr()); |
936 | 896 |
|
937 | | - t.setSub(newMax,newMin); |
| 897 | + t.setSub(mExtents[1],mExtents[0]); |
938 | 898 | mBoundingSphereRadius = t.getLength3().getF32()*0.5f; |
939 | 899 |
|
940 | 900 | updateCenterAgent(); |
@@ -2521,12 +2481,25 @@ LLViewerTexture* LLFace::getTexture(U32 ch) const |
2521 | 2481 |
|
2522 | 2482 | void LLFace::setVertexBuffer(LLVertexBuffer* buffer) |
2523 | 2483 | { |
| 2484 | + if (buffer) |
| 2485 | + { |
| 2486 | + LLSculptIDSize::instance().inc(mDrawablep, buffer->getSize() + buffer->getIndicesSize()); |
| 2487 | + } |
| 2488 | + |
| 2489 | + if (mVertexBuffer) |
| 2490 | + { |
| 2491 | + LLSculptIDSize::instance().dec(mDrawablep); |
| 2492 | + } |
2524 | 2493 | mVertexBuffer = buffer; |
2525 | 2494 | llassert(verify()); |
2526 | 2495 | } |
2527 | 2496 |
|
2528 | 2497 | void LLFace::clearVertexBuffer() |
2529 | 2498 | { |
| 2499 | + if (mVertexBuffer) |
| 2500 | + { |
| 2501 | + LLSculptIDSize::instance().dec(mDrawablep); |
| 2502 | + } |
2530 | 2503 | mVertexBuffer = NULL; |
2531 | 2504 | } |
2532 | 2505 |
|
|
0 commit comments