aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llface.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llface.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/newview/llface.cpp')
-rw-r--r--linden/indra/newview/llface.cpp191
1 files changed, 111 insertions, 80 deletions
diff --git a/linden/indra/newview/llface.cpp b/linden/indra/newview/llface.cpp
index 5095f38..3dfe6a2 100644
--- a/linden/indra/newview/llface.cpp
+++ b/linden/indra/newview/llface.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -164,6 +165,7 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
164 mReferenceIndex = -1; 165 mReferenceIndex = -1;
165 166
166 mTextureMatrix = NULL; 167 mTextureMatrix = NULL;
168 mDrawInfo = NULL;
167 169
168 mFaceColor = LLColor4(1,0,0,1); 170 mFaceColor = LLColor4(1,0,0,1);
169 171
@@ -177,9 +179,6 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
177 179
178void LLFace::destroy() 180void LLFace::destroy()
179{ 181{
180 mDrawablep = NULL;
181 mVObjp = NULL;
182
183 if (mDrawPoolp) 182 if (mDrawPoolp)
184 { 183 {
185 mDrawPoolp->removeFace(this); 184 mDrawPoolp->removeFace(this);
@@ -190,7 +189,21 @@ void LLFace::destroy()
190 { 189 {
191 delete mTextureMatrix; 190 delete mTextureMatrix;
192 mTextureMatrix = NULL; 191 mTextureMatrix = NULL;
192
193 if (mDrawablep.notNull())
194 {
195 LLSpatialGroup* group = mDrawablep->getSpatialGroup();
196 if (group)
197 {
198 group->dirtyGeom();
199 }
200 }
193 } 201 }
202
203 setDrawInfo(NULL);
204
205 mDrawablep = NULL;
206 mVObjp = NULL;
194} 207}
195 208
196 209
@@ -288,7 +301,7 @@ U16 LLFace::getGeometryAvatar(
288 { 301 {
289 mVertexBuffer->getVertexStrider (vertices, mGeomIndex); 302 mVertexBuffer->getVertexStrider (vertices, mGeomIndex);
290 mVertexBuffer->getNormalStrider (normals, mGeomIndex); 303 mVertexBuffer->getNormalStrider (normals, mGeomIndex);
291 mVertexBuffer->getTexCoordStrider (tex_coords, mGeomIndex); 304 mVertexBuffer->getTexCoord0Strider (tex_coords, mGeomIndex);
292 mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex); 305 mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex);
293 mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex); 306 mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex);
294 } 307 }
@@ -308,9 +321,9 @@ U16 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &no
308 { 321 {
309 mVertexBuffer->getNormalStrider(normals, mGeomIndex); 322 mVertexBuffer->getNormalStrider(normals, mGeomIndex);
310 } 323 }
311 if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD)) 324 if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD0))
312 { 325 {
313 mVertexBuffer->getTexCoordStrider(tex_coords, mGeomIndex); 326 mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex);
314 } 327 }
315 328
316 mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); 329 mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
@@ -434,12 +447,13 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color)
434 setFaceColor(color); 447 setFaceColor(color);
435 renderSetColor(); 448 renderSetColor();
436 449
437 mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD); 450 mVertexBuffer->setBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
438#if !LL_RELEASE_FOR_DOWNLOAD 451#if !LL_RELEASE_FOR_DOWNLOAD
439 LLGLState::checkClientArrays("", LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD); 452 LLGLState::checkClientArrays("", LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
440#endif 453#endif
441 mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex); 454 mVertexBuffer->draw(LLRender::TRIANGLES, mIndicesCount, mIndicesIndex);
442 455
456 unsetFaceColor();
443 unsetFaceColor(); 457 unsetFaceColor();
444 gGL.popMatrix(); 458 gGL.popMatrix();
445 } 459 }
@@ -476,9 +490,27 @@ void LLFace::renderSelectedUV()
476 glMatrixMode(GL_MODELVIEW); 490 glMatrixMode(GL_MODELVIEW);
477 gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); 491 gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
478} 492}
479
480*/ 493*/
481 494
495void LLFace::setDrawInfo(LLDrawInfo* draw_info)
496{
497 if (draw_info)
498 {
499 if (draw_info->mFace)
500 {
501 draw_info->mFace->setDrawInfo(NULL);
502 }
503 draw_info->mFace = this;
504 }
505
506 if (mDrawInfo)
507 {
508 mDrawInfo->mFace = NULL;
509 }
510
511 mDrawInfo = draw_info;
512}
513
482void LLFace::printDebugInfo() const 514void LLFace::printDebugInfo() const
483{ 515{
484 LLFacePool *poolp = getPool(); 516 LLFacePool *poolp = getPool();
@@ -586,11 +618,11 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
586 //get bounding box 618 //get bounding box
587 if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION)) 619 if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION))
588 { 620 {
589 if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME)) 621 //if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
590 { //vertex buffer no longer valid 622 //{ //vertex buffer no longer valid
591 mVertexBuffer = NULL; 623 // mVertexBuffer = NULL;
592 mLastVertexBuffer = NULL; 624 // mLastVertexBuffer = NULL;
593 } 625 //}
594 626
595 LLVector3 min,max; 627 LLVector3 min,max;
596 628
@@ -738,6 +770,34 @@ LLVector2 LLFace::surfaceToTexture(LLVector2 surface_coord, LLVector3 position,
738 return tc; 770 return tc;
739} 771}
740 772
773void LLFace::updateRebuildFlags()
774{
775 if (!mDrawablep->isState(LLDrawable::REBUILD_VOLUME))
776 {
777 BOOL moved = TRUE;
778 if (mLastVertexBuffer == mVertexBuffer &&
779 !mVertexBuffer->isEmpty())
780 { //this face really doesn't need to be regenerated, try real hard not to do so
781 if (mLastGeomCount == mGeomCount &&
782 mLastGeomIndex == mGeomIndex &&
783 mLastIndicesCount == mIndicesCount &&
784 mLastIndicesIndex == mIndicesIndex)
785 { //data is in same location in vertex buffer
786 moved = FALSE;
787 }
788 }
789 mLastMoveTime = gFrameTimeSeconds;
790
791 if (moved)
792 {
793 mDrawablep->setState(LLDrawable::REBUILD_VOLUME);
794 }
795 }
796 else
797 {
798 mLastUpdateTime = gFrameTimeSeconds;
799 }
800}
741 801
742BOOL LLFace::getGeometryVolume(const LLVolume& volume, 802BOOL LLFace::getGeometryVolume(const LLVolume& volume,
743 const S32 &f, 803 const S32 &f,
@@ -763,16 +823,16 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
763 } 823 }
764 } 824 }
765 825
766 LLStrider<LLVector3> old_verts,vertices; 826 LLStrider<LLVector3> vertices;
767 LLStrider<LLVector2> old_texcoords,tex_coords; 827 LLStrider<LLVector2> tex_coords;
768 LLStrider<LLVector2> old_texcoords2,tex_coords2; 828 LLStrider<LLVector2> tex_coords2;
769 LLStrider<LLVector3> old_normals,normals; 829 LLStrider<LLVector3> normals;
770 LLStrider<LLColor4U> old_colors,colors; 830 LLStrider<LLColor4U> colors;
831 LLStrider<LLVector3> binormals;
771 LLStrider<U16> indicesp; 832 LLStrider<U16> indicesp;
772 833
773 BOOL full_rebuild = mDrawablep->isState(LLDrawable::REBUILD_VOLUME); 834 BOOL full_rebuild = mDrawablep->isState(LLDrawable::REBUILD_VOLUME);
774 BOOL moved = TRUE; 835
775
776 BOOL global_volume = mDrawablep->getVOVolume()->isVolumeGlobal(); 836 BOOL global_volume = mDrawablep->getVOVolume()->isVolumeGlobal();
777 LLVector3 scale; 837 LLVector3 scale;
778 if (global_volume) 838 if (global_volume)
@@ -783,35 +843,12 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
783 { 843 {
784 scale = mVObjp->getScale(); 844 scale = mVObjp->getScale();
785 } 845 }
786
787 if (!full_rebuild)
788 {
789 if (mLastVertexBuffer == mVertexBuffer &&
790 !mVertexBuffer->isEmpty())
791 { //this face really doesn't need to be regenerated, try real hard not to do so
792 if (mLastGeomCount == mGeomCount &&
793 mLastGeomIndex == mGeomIndex &&
794 mLastIndicesCount == mIndicesCount &&
795 mLastIndicesIndex == mIndicesIndex)
796 { //data is in same location in vertex buffer
797 moved = FALSE;
798 }
799
800 if (!moved && !mDrawablep->isState(LLDrawable::REBUILD_ALL))
801 { //nothing needs to be done
802 return FALSE;
803 }
804 }
805 mLastMoveTime = gFrameTimeSeconds;
806 }
807 else
808 {
809 mLastUpdateTime = gFrameTimeSeconds;
810 }
811 846
812 BOOL rebuild_pos = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_POSITION); 847 BOOL rebuild_pos = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_POSITION);
813 BOOL rebuild_color = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_COLOR); 848 BOOL rebuild_color = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_COLOR);
814 BOOL rebuild_tcoord = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_TCOORD); 849 BOOL rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
850 BOOL rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
851 BOOL rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
815 852
816 const LLTextureEntry *tep = mVObjp->getTE(f); 853 const LLTextureEntry *tep = mVObjp->getTE(f);
817 U8 bump_code = tep ? tep->getBumpmap() : 0; 854 U8 bump_code = tep ? tep->getBumpmap() : 0;
@@ -819,14 +856,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
819 if (rebuild_pos) 856 if (rebuild_pos)
820 { 857 {
821 mVertexBuffer->getVertexStrider(vertices, mGeomIndex); 858 mVertexBuffer->getVertexStrider(vertices, mGeomIndex);
859 }
860 if (rebuild_normal)
861 {
822 mVertexBuffer->getNormalStrider(normals, mGeomIndex); 862 mVertexBuffer->getNormalStrider(normals, mGeomIndex);
823 } 863 }
864 if (rebuild_binormal)
865 {
866 mVertexBuffer->getBinormalStrider(binormals, mGeomIndex);
867 }
824 if (rebuild_tcoord) 868 if (rebuild_tcoord)
825 { 869 {
826 mVertexBuffer->getTexCoordStrider(tex_coords, mGeomIndex); 870 mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex);
827 if (bump_code) 871 if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
828 { 872 {
829 mVertexBuffer->getTexCoord2Strider(tex_coords2, mGeomIndex); 873 mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex);
830 } 874 }
831 } 875 }
832 if (rebuild_color) 876 if (rebuild_color)
@@ -888,12 +932,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
888 { 932 {
889 clearState(TEXTURE_ANIM); 933 clearState(TEXTURE_ANIM);
890 } 934 }
891 //else if (getVirtualSize() <= 512.f)
892 //{
893 // //vobj->mTextureAnimp->animateTextures(os, ot, ms, mt, r);
894 // //cos_ang = cos(r);
895 // //sin_ang = sin(r);
896 //}
897 else 935 else
898 { 936 {
899 os = ot = 0.f; 937 os = ot = 0.f;
@@ -921,14 +959,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
921 0.75f 959 0.75f
922 }; 960 };
923 961
924 if (getPoolType() != LLDrawPool::POOL_ALPHA && LLPipeline::sRenderBump && tep->getShiny()) 962 if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || LLPipeline::sRenderBump && tep->getShiny()))
925 { 963 {
926 color.mV[3] = U8 (alpha[tep->getShiny()] * 255); 964 color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
927 } 965 }
928 } 966 }
929 967
930 // INDICES 968 // INDICES
931 if (full_rebuild || moved) 969 if (full_rebuild)
932 { 970 {
933 mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); 971 mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
934 for (U16 i = 0; i < num_indices; i++) 972 for (U16 i = 0; i < num_indices; i++)
@@ -1045,7 +1083,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
1045 1083
1046 *tex_coords++ = tc; 1084 *tex_coords++ = tc;
1047 1085
1048 if (bump_code) 1086 if (bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1))
1049 { 1087 {
1050 LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal; 1088 LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal;
1051 1089
@@ -1065,38 +1103,31 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
1065 *tex_coords2++ = tc; 1103 *tex_coords2++ = tc;
1066 } 1104 }
1067 } 1105 }
1068 else if (moved)
1069 {
1070 *tex_coords++ = *old_texcoords++;
1071 if (bump_code)
1072 {
1073 *tex_coords2++ = *old_texcoords2++;
1074 }
1075 }
1076 1106
1077 if (rebuild_pos) 1107 if (rebuild_pos)
1078 { 1108 {
1079 *vertices++ = vf.mVertices[i].mPosition * mat_vert; 1109 *vertices++ = vf.mVertices[i].mPosition * mat_vert;
1080 1110 }
1111
1112 if (rebuild_normal)
1113 {
1081 LLVector3 normal = vf.mVertices[i].mNormal * mat_normal; 1114 LLVector3 normal = vf.mVertices[i].mNormal * mat_normal;
1082 normal.normVec(); 1115 normal.normVec();
1083 1116
1084 *normals++ = normal; 1117 *normals++ = normal;
1085 } 1118 }
1086 else if (moved) 1119
1120 if (rebuild_binormal)
1087 { 1121 {
1088 *normals++ = *old_normals++; 1122 LLVector3 binormal = vf.mVertices[i].mBinormal * mat_normal;
1089 *vertices++ = *old_verts++; 1123 binormal.normVec();
1124 *binormals++ = binormal;
1090 } 1125 }
1091 1126
1092 if (rebuild_color) 1127 if (rebuild_color)
1093 { 1128 {
1094 *colors++ = color; 1129 *colors++ = color;
1095 } 1130 }
1096 else if (moved)
1097 {
1098 *colors++ = *old_colors++;
1099 }
1100 } 1131 }
1101 1132
1102 if (rebuild_tcoord) 1133 if (rebuild_tcoord)