diff options
Diffstat (limited to 'linden/indra/newview/llface.cpp')
-rw-r--r-- | linden/indra/newview/llface.cpp | 587 |
1 files changed, 193 insertions, 394 deletions
diff --git a/linden/indra/newview/llface.cpp b/linden/indra/newview/llface.cpp index 058c506..2be82f7 100644 --- a/linden/indra/newview/llface.cpp +++ b/linden/indra/newview/llface.cpp | |||
@@ -40,9 +40,9 @@ | |||
40 | #include "m3math.h" | 40 | #include "m3math.h" |
41 | #include "v3color.h" | 41 | #include "v3color.h" |
42 | 42 | ||
43 | #include "lldrawpoolsimple.h" | ||
44 | #include "lldrawpoolbump.h" | 43 | #include "lldrawpoolbump.h" |
45 | #include "llgl.h" | 44 | #include "llgl.h" |
45 | #include "llglimmediate.h" | ||
46 | #include "lllightconstants.h" | 46 | #include "lllightconstants.h" |
47 | #include "llsky.h" | 47 | #include "llsky.h" |
48 | #include "llviewercamera.h" | 48 | #include "llviewercamera.h" |
@@ -50,6 +50,7 @@ | |||
50 | #include "llvosky.h" | 50 | #include "llvosky.h" |
51 | #include "llvovolume.h" | 51 | #include "llvovolume.h" |
52 | #include "pipeline.h" | 52 | #include "pipeline.h" |
53 | #include "llviewerregion.h" | ||
53 | 54 | ||
54 | #define LL_MAX_INDICES_COUNT 1000000 | 55 | #define LL_MAX_INDICES_COUNT 1000000 |
55 | 56 | ||
@@ -140,19 +141,20 @@ void cylindricalProjection(LLVector2 &tc, const LLVolumeFace::VertexData &vd, co | |||
140 | void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) | 141 | void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) |
141 | { | 142 | { |
142 | mLastUpdateTime = gFrameTimeSeconds; | 143 | mLastUpdateTime = gFrameTimeSeconds; |
144 | mLastMoveTime = 0.f; | ||
143 | mVSize = 0.f; | 145 | mVSize = 0.f; |
144 | mPixelArea = 1024.f; | 146 | mPixelArea = 16.f; |
145 | mState = GLOBAL; | 147 | mState = GLOBAL; |
146 | mDrawPoolp = NULL; | 148 | mDrawPoolp = NULL; |
147 | mPoolType = 0; | 149 | mPoolType = 0; |
148 | mGeomIndex = -1; | 150 | mCenterLocal = objp->getPosition(); |
149 | // mCenterLocal | 151 | mCenterAgent = drawablep->getPositionAgent(); |
150 | // mCenterAgent | ||
151 | mDistance = 0.f; | 152 | mDistance = 0.f; |
152 | 153 | ||
153 | mGeomCount = 0; | 154 | mGeomCount = 0; |
155 | mGeomIndex = 0; | ||
154 | mIndicesCount = 0; | 156 | mIndicesCount = 0; |
155 | mIndicesIndex = -1; | 157 | mIndicesIndex = 0; |
156 | mTexture = NULL; | 158 | mTexture = NULL; |
157 | mTEOffset = -1; | 159 | mTEOffset = -1; |
158 | 160 | ||
@@ -160,7 +162,8 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) | |||
160 | mVObjp = objp; | 162 | mVObjp = objp; |
161 | 163 | ||
162 | mReferenceIndex = -1; | 164 | mReferenceIndex = -1; |
163 | mAlphaFade = 0.f; | 165 | |
166 | mTextureMatrix = NULL; | ||
164 | 167 | ||
165 | mFaceColor = LLColor4(1,0,0,1); | 168 | mFaceColor = LLColor4(1,0,0,1); |
166 | 169 | ||
@@ -182,6 +185,12 @@ void LLFace::destroy() | |||
182 | mDrawPoolp->removeFace(this); | 185 | mDrawPoolp->removeFace(this); |
183 | mDrawPoolp = NULL; | 186 | mDrawPoolp = NULL; |
184 | } | 187 | } |
188 | |||
189 | if (mTextureMatrix) | ||
190 | { | ||
191 | delete mTextureMatrix; | ||
192 | mTextureMatrix = NULL; | ||
193 | } | ||
185 | } | 194 | } |
186 | 195 | ||
187 | 196 | ||
@@ -216,7 +225,7 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerImage *texturep) | |||
216 | gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_ALL, TRUE); | 225 | gPipeline.markRebuild(mDrawablep, LLDrawable::REBUILD_ALL, TRUE); |
217 | } | 226 | } |
218 | } | 227 | } |
219 | mGeomIndex = -1; | 228 | mGeomIndex = 0; |
220 | 229 | ||
221 | // Add to new pool | 230 | // Add to new pool |
222 | if (new_pool) | 231 | if (new_pool) |
@@ -260,10 +269,9 @@ void LLFace::setSize(const S32 num_vertices, const S32 num_indices) | |||
260 | 269 | ||
261 | //============================================================================ | 270 | //============================================================================ |
262 | 271 | ||
263 | S32 LLFace::getGeometryAvatar( | 272 | U16 LLFace::getGeometryAvatar( |
264 | LLStrider<LLVector3> &vertices, | 273 | LLStrider<LLVector3> &vertices, |
265 | LLStrider<LLVector3> &normals, | 274 | LLStrider<LLVector3> &normals, |
266 | LLStrider<LLVector3> &binormals, | ||
267 | LLStrider<LLVector2> &tex_coords, | 275 | LLStrider<LLVector2> &tex_coords, |
268 | LLStrider<F32> &vertex_weights, | 276 | LLStrider<F32> &vertex_weights, |
269 | LLStrider<LLVector4> &clothing_weights) | 277 | LLStrider<LLVector4> &clothing_weights) |
@@ -274,56 +282,19 @@ S32 LLFace::getGeometryAvatar( | |||
274 | { | 282 | { |
275 | mVertexBuffer->getVertexStrider (vertices, mGeomIndex); | 283 | mVertexBuffer->getVertexStrider (vertices, mGeomIndex); |
276 | mVertexBuffer->getNormalStrider (normals, mGeomIndex); | 284 | mVertexBuffer->getNormalStrider (normals, mGeomIndex); |
277 | mVertexBuffer->getBinormalStrider (binormals, mGeomIndex); | ||
278 | mVertexBuffer->getTexCoordStrider (tex_coords, mGeomIndex); | 285 | mVertexBuffer->getTexCoordStrider (tex_coords, mGeomIndex); |
279 | mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex); | 286 | mVertexBuffer->getWeightStrider(vertex_weights, mGeomIndex); |
280 | mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex); | 287 | mVertexBuffer->getClothWeightStrider(clothing_weights, mGeomIndex); |
281 | } | 288 | } |
282 | else | ||
283 | { | ||
284 | mGeomIndex = -1; | ||
285 | } | ||
286 | |||
287 | return mGeomIndex; | ||
288 | } | ||
289 | 289 | ||
290 | S32 LLFace::getGeometryTerrain( | ||
291 | LLStrider<LLVector3> &vertices, | ||
292 | LLStrider<LLVector3> &normals, | ||
293 | LLStrider<LLColor4U> &colors, | ||
294 | LLStrider<LLVector2> &texcoords0, | ||
295 | LLStrider<LLVector2> &texcoords1, | ||
296 | LLStrider<U32> &indicesp) | ||
297 | { | ||
298 | LLMemType mt1(LLMemType::MTYPE_DRAWABLE); | ||
299 | |||
300 | if (mVertexBuffer.notNull()) | ||
301 | { | ||
302 | mVertexBuffer->getVertexStrider(vertices, mGeomIndex); | ||
303 | mVertexBuffer->getNormalStrider(normals, mGeomIndex); | ||
304 | mVertexBuffer->getColorStrider(colors, mGeomIndex); | ||
305 | mVertexBuffer->getTexCoordStrider(texcoords0, mGeomIndex); | ||
306 | mVertexBuffer->getTexCoord2Strider(texcoords1, mGeomIndex); | ||
307 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); | ||
308 | } | ||
309 | else | ||
310 | { | ||
311 | mGeomIndex = -1; | ||
312 | } | ||
313 | |||
314 | return mGeomIndex; | 290 | return mGeomIndex; |
315 | } | 291 | } |
316 | 292 | ||
317 | S32 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &normals, | 293 | U16 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &normals, |
318 | LLStrider<LLVector2> &tex_coords, LLStrider<U32> &indicesp) | 294 | LLStrider<LLVector2> &tex_coords, LLStrider<U16> &indicesp) |
319 | { | 295 | { |
320 | LLMemType mt1(LLMemType::MTYPE_DRAWABLE); | 296 | LLMemType mt1(LLMemType::MTYPE_DRAWABLE); |
321 | 297 | ||
322 | if (mGeomCount <= 0) | ||
323 | { | ||
324 | return -1; | ||
325 | } | ||
326 | |||
327 | if (mVertexBuffer.notNull()) | 298 | if (mVertexBuffer.notNull()) |
328 | { | 299 | { |
329 | mVertexBuffer->getVertexStrider(vertices, mGeomIndex); | 300 | mVertexBuffer->getVertexStrider(vertices, mGeomIndex); |
@@ -338,26 +309,10 @@ S32 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &no | |||
338 | 309 | ||
339 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); | 310 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); |
340 | } | 311 | } |
341 | else | ||
342 | { | ||
343 | mGeomIndex = -1; | ||
344 | } | ||
345 | 312 | ||
346 | return mGeomIndex; | 313 | return mGeomIndex; |
347 | } | 314 | } |
348 | 315 | ||
349 | S32 LLFace::getGeometryColors(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &normals, | ||
350 | LLStrider<LLVector2> &tex_coords, LLStrider<LLColor4U> &colors, | ||
351 | LLStrider<U32> &indicesp) | ||
352 | { | ||
353 | S32 res = getGeometry(vertices, normals, tex_coords, indicesp); | ||
354 | if (res >= 0) | ||
355 | { | ||
356 | getColors(colors); | ||
357 | } | ||
358 | return res; | ||
359 | } | ||
360 | |||
361 | void LLFace::updateCenterAgent() | 316 | void LLFace::updateCenterAgent() |
362 | { | 317 | { |
363 | if (mDrawablep->isActive()) | 318 | if (mDrawablep->isActive()) |
@@ -372,7 +327,13 @@ void LLFace::updateCenterAgent() | |||
372 | 327 | ||
373 | void LLFace::renderForSelect(U32 data_mask) | 328 | void LLFace::renderForSelect(U32 data_mask) |
374 | { | 329 | { |
375 | if(mGeomIndex < 0 || mDrawablep.isNull() || mVertexBuffer.isNull()) | 330 | if(mDrawablep.isNull() || mVertexBuffer.isNull()) |
331 | { | ||
332 | return; | ||
333 | } | ||
334 | |||
335 | LLSpatialGroup* group = mDrawablep->getSpatialGroup(); | ||
336 | if (!group || group->isState(LLSpatialGroup::GEOM_DIRTY)) | ||
376 | { | 337 | { |
377 | return; | 338 | return; |
378 | } | 339 | } |
@@ -407,7 +368,7 @@ void LLFace::renderForSelect(U32 data_mask) | |||
407 | #if !LL_RELEASE_FOR_DOWNLOAD | 368 | #if !LL_RELEASE_FOR_DOWNLOAD |
408 | LLGLState::checkClientArrays(data_mask); | 369 | LLGLState::checkClientArrays(data_mask); |
409 | #endif | 370 | #endif |
410 | U32* indicesp = (U32*) mVertexBuffer->getIndicesPointer() + mIndicesIndex; | 371 | U16* indicesp = (U16*) mVertexBuffer->getIndicesPointer() + mIndicesIndex; |
411 | 372 | ||
412 | if (gPickFaces && mTEOffset != -1) | 373 | if (gPickFaces && mTEOffset != -1) |
413 | { | 374 | { |
@@ -421,13 +382,23 @@ void LLFace::renderForSelect(U32 data_mask) | |||
421 | { | 382 | { |
422 | if (isState(GLOBAL)) | 383 | if (isState(GLOBAL)) |
423 | { | 384 | { |
424 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_INT, indicesp); | 385 | if (mDrawablep->getVOVolume()) |
386 | { | ||
387 | glPushMatrix(); | ||
388 | glMultMatrixf((float*) mDrawablep->getRegion()->mRenderMatrix.mMatrix); | ||
389 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, indicesp); | ||
390 | glPopMatrix(); | ||
391 | } | ||
392 | else | ||
393 | { | ||
394 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, indicesp); | ||
395 | } | ||
425 | } | 396 | } |
426 | else | 397 | else |
427 | { | 398 | { |
428 | glPushMatrix(); | 399 | glPushMatrix(); |
429 | glMultMatrixf((float*)getRenderMatrix().mMatrix); | 400 | glMultMatrixf((float*)getRenderMatrix().mMatrix); |
430 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_INT, indicesp); | 401 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, indicesp); |
431 | glPopMatrix(); | 402 | glPopMatrix(); |
432 | } | 403 | } |
433 | } | 404 | } |
@@ -450,7 +421,7 @@ void LLFace::renderForSelect(U32 data_mask) | |||
450 | 421 | ||
451 | void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color, const S32 offset, const S32 count) | 422 | void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color, const S32 offset, const S32 count) |
452 | { | 423 | { |
453 | if(mGeomIndex < 0 || mDrawablep.isNull() || mVertexBuffer.isNull()) | 424 | if(mDrawablep.isNull() || mVertexBuffer.isNull()) |
454 | { | 425 | { |
455 | return; | 426 | return; |
456 | } | 427 | } |
@@ -461,11 +432,15 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color, const S32 | |||
461 | glColor4fv(color.mV); | 432 | glColor4fv(color.mV); |
462 | 433 | ||
463 | LLViewerImage::bindTexture(imagep); | 434 | LLViewerImage::bindTexture(imagep); |
464 | if (!isState(GLOBAL)) | 435 | |
436 | glPushMatrix(); | ||
437 | if (mDrawablep->isActive()) | ||
438 | { | ||
439 | glMultMatrixf((GLfloat*)mDrawablep->getRenderMatrix().mMatrix); | ||
440 | } | ||
441 | else | ||
465 | { | 442 | { |
466 | // Apply the proper transform for non-global objects. | 443 | glMultMatrixf((GLfloat*)mDrawablep->getRegion()->mRenderMatrix.mMatrix); |
467 | glPushMatrix(); | ||
468 | glMultMatrixf((float*)getRenderMatrix().mMatrix); | ||
469 | } | 444 | } |
470 | 445 | ||
471 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 446 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
@@ -476,24 +451,20 @@ void LLFace::renderSelected(LLImageGL *imagep, const LLColor4& color, const S32 | |||
476 | #if !LL_RELEASE_FOR_DOWNLOAD | 451 | #if !LL_RELEASE_FOR_DOWNLOAD |
477 | LLGLState::checkClientArrays(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD); | 452 | LLGLState::checkClientArrays(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD); |
478 | #endif | 453 | #endif |
479 | U32* indicesp = ((U32*) mVertexBuffer->getIndicesPointer()) + mIndicesIndex; | 454 | U16* indicesp = ((U16*) mVertexBuffer->getIndicesPointer()) + mIndicesIndex; |
480 | 455 | ||
481 | if (count) | 456 | if (count) |
482 | { | 457 | { |
483 | glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, indicesp + offset); | 458 | glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, indicesp + offset); |
484 | } | 459 | } |
485 | else | 460 | else |
486 | { | 461 | { |
487 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_INT, indicesp); | 462 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, indicesp); |
488 | } | 463 | } |
489 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 464 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
490 | glDisableClientState(GL_NORMAL_ARRAY); | 465 | glDisableClientState(GL_NORMAL_ARRAY); |
491 | 466 | ||
492 | if (!isState(GLOBAL)) | 467 | glPopMatrix(); |
493 | { | ||
494 | // Restore the tranform for non-global objects | ||
495 | glPopMatrix(); | ||
496 | } | ||
497 | } | 468 | } |
498 | } | 469 | } |
499 | 470 | ||
@@ -507,8 +478,7 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
507 | 478 | ||
508 | LLGLSObjectSelect object_select; | 479 | LLGLSObjectSelect object_select; |
509 | LLGLEnable blend(GL_BLEND); | 480 | LLGLEnable blend(GL_BLEND); |
510 | LLGLEnable texture(GL_TEXTURE_2D); | 481 | |
511 | |||
512 | if (!mDrawPoolp || !getIndicesCount() || getIndicesStart() < 0) | 482 | if (!mDrawPoolp || !getIndicesCount() || getIndicesStart() < 0) |
513 | { | 483 | { |
514 | return; | 484 | return; |
@@ -519,7 +489,7 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
519 | static F32 factor = -10.f; | 489 | static F32 factor = -10.f; |
520 | if (mGeomCount > 0) | 490 | if (mGeomCount > 0) |
521 | { | 491 | { |
522 | glColor4fv(LLColor4::white.mV); | 492 | gGL.color4fv(LLColor4::white.mV); |
523 | 493 | ||
524 | if (pass == 0) | 494 | if (pass == 0) |
525 | { | 495 | { |
@@ -527,7 +497,7 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
527 | } | 497 | } |
528 | else // pass == 1 | 498 | else // pass == 1 |
529 | { | 499 | { |
530 | glBlendFunc(GL_ONE, GL_ONE); | 500 | gGL.blendFunc(GL_ONE, GL_ONE); |
531 | LLViewerImage::bindTexture(green_imagep); | 501 | LLViewerImage::bindTexture(green_imagep); |
532 | glMatrixMode(GL_TEXTURE); | 502 | glMatrixMode(GL_TEXTURE); |
533 | glPushMatrix(); | 503 | glPushMatrix(); |
@@ -549,15 +519,15 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
549 | glPolygonOffset(factor, bias); | 519 | glPolygonOffset(factor, bias); |
550 | if (sSafeRenderSelect) | 520 | if (sSafeRenderSelect) |
551 | { | 521 | { |
552 | glBegin(GL_TRIANGLES); | 522 | gGL.begin(GL_TRIANGLES); |
553 | if (count) | 523 | if (count) |
554 | { | 524 | { |
555 | for (S32 i = offset; i < offset + count; i++) | 525 | for (S32 i = offset; i < offset + count; i++) |
556 | { | 526 | { |
557 | LLVector2 tc = mDrawPoolp->getTexCoord(mDrawPoolp->getIndex(getIndicesStart() + i), 0); | 527 | LLVector2 tc = mDrawPoolp->getTexCoord(mDrawPoolp->getIndex(getIndicesStart() + i), 0); |
558 | glTexCoord2fv(tc.mV); | 528 | gGL.texCoord2fv(tc.mV); |
559 | LLVector3 vertex = mDrawPoolp->getVertex(mDrawPoolp->getIndex(getIndicesStart() + i)); | 529 | LLVector3 vertex = mDrawPoolp->getVertex(mDrawPoolp->getIndex(getIndicesStart() + i)); |
560 | glVertex3fv(vertex.mV); | 530 | gGL.vertex3fv(vertex.mV); |
561 | } | 531 | } |
562 | } | 532 | } |
563 | else | 533 | else |
@@ -565,12 +535,12 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
565 | for (U32 i = 0; i < getIndicesCount(); i++) | 535 | for (U32 i = 0; i < getIndicesCount(); i++) |
566 | { | 536 | { |
567 | LLVector2 tc = mDrawPoolp->getTexCoord(mDrawPoolp->getIndex(getIndicesStart() + i), 0); | 537 | LLVector2 tc = mDrawPoolp->getTexCoord(mDrawPoolp->getIndex(getIndicesStart() + i), 0); |
568 | glTexCoord2fv(tc.mV); | 538 | gGL.texCoord2fv(tc.mV); |
569 | LLVector3 vertex = mDrawPoolp->getVertex(mDrawPoolp->getIndex(getIndicesStart() + i)); | 539 | LLVector3 vertex = mDrawPoolp->getVertex(mDrawPoolp->getIndex(getIndicesStart() + i)); |
570 | glVertex3fv(vertex.mV); | 540 | gGL.vertex3fv(vertex.mV); |
571 | } | 541 | } |
572 | } | 542 | } |
573 | glEnd(); | 543 | gGL.end(); |
574 | } | 544 | } |
575 | else | 545 | else |
576 | { | 546 | { |
@@ -581,7 +551,7 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
581 | { | 551 | { |
582 | if (mIndicesCount > 0) | 552 | if (mIndicesCount > 0) |
583 | { | 553 | { |
584 | glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, getRawIndices() + offset); | 554 | glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, getRawIndices() + offset); |
585 | } | 555 | } |
586 | else | 556 | else |
587 | { | 557 | { |
@@ -593,7 +563,7 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
593 | { | 563 | { |
594 | if (mIndicesCount > 0) | 564 | if (mIndicesCount > 0) |
595 | { | 565 | { |
596 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_INT, getRawIndices()); | 566 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, getRawIndices()); |
597 | } | 567 | } |
598 | else | 568 | else |
599 | { | 569 | { |
@@ -614,13 +584,13 @@ void LLFace::renderSelectedUV(const S32 offset, const S32 count) | |||
614 | glMatrixMode(GL_TEXTURE); | 584 | glMatrixMode(GL_TEXTURE); |
615 | glPopMatrix(); | 585 | glPopMatrix(); |
616 | glMatrixMode(GL_MODELVIEW); | 586 | glMatrixMode(GL_MODELVIEW); |
617 | glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); | 587 | gGL.blendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); |
618 | } | 588 | } |
619 | } | 589 | } |
620 | } | 590 | } |
621 | 591 | ||
622 | //restore blend func | 592 | //restore blend func |
623 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 593 | gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
624 | #endif | 594 | #endif |
625 | } | 595 | } |
626 | 596 | ||
@@ -804,34 +774,51 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, | |||
804 | } | 774 | } |
805 | } | 775 | } |
806 | 776 | ||
777 | if (!mDrawablep->isActive()) | ||
778 | { | ||
779 | LLVector3 offset = mDrawablep->getRegion()->getOriginAgent(); | ||
780 | newMin += offset; | ||
781 | newMax += offset; | ||
782 | } | ||
783 | |||
807 | mCenterLocal = (newMin+newMax)*0.5f; | 784 | mCenterLocal = (newMin+newMax)*0.5f; |
785 | |||
808 | updateCenterAgent(); | 786 | updateCenterAgent(); |
809 | } | 787 | } |
810 | 788 | ||
811 | return TRUE; | 789 | return TRUE; |
812 | } | 790 | } |
813 | 791 | ||
814 | |||
815 | BOOL LLFace::getGeometryVolume(const LLVolume& volume, | 792 | BOOL LLFace::getGeometryVolume(const LLVolume& volume, |
816 | S32 f, | 793 | const S32 &f, |
817 | LLStrider<LLVector3>& vertices, | ||
818 | LLStrider<LLVector3>& normals, | ||
819 | LLStrider<LLVector2>& tex_coords, | ||
820 | LLStrider<LLVector2>& tex_coords2, | ||
821 | LLStrider<LLColor4U>& colors, | ||
822 | LLStrider<U32>& indicesp, | ||
823 | const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, | 794 | const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, |
824 | U32& index_offset) | 795 | const U16 &index_offset) |
825 | { | 796 | { |
826 | const LLVolumeFace &vf = volume.getVolumeFace(f); | 797 | const LLVolumeFace &vf = volume.getVolumeFace(f); |
827 | S32 num_vertices = (S32)vf.mVertices.size(); | 798 | S32 num_vertices = (S32)vf.mVertices.size(); |
828 | S32 num_indices = (S32)vf.mIndices.size(); | 799 | S32 num_indices = (S32)vf.mIndices.size(); |
829 | 800 | ||
830 | LLStrider<LLVector3> old_verts; | 801 | if (mVertexBuffer.notNull()) |
831 | LLStrider<LLVector2> old_texcoords; | 802 | { |
832 | LLStrider<LLVector2> old_texcoords2; | 803 | if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices()) |
833 | LLStrider<LLVector3> old_normals; | 804 | { |
834 | LLStrider<LLColor4U> old_colors; | 805 | llwarns << "Index buffer overflow!" << llendl; |
806 | return FALSE; | ||
807 | } | ||
808 | |||
809 | if (num_vertices + mGeomIndex > mVertexBuffer->getNumVerts()) | ||
810 | { | ||
811 | llwarns << "Vertex buffer overflow!" << llendl; | ||
812 | return FALSE; | ||
813 | } | ||
814 | } | ||
815 | |||
816 | LLStrider<LLVector3> old_verts,vertices; | ||
817 | LLStrider<LLVector2> old_texcoords,tex_coords; | ||
818 | LLStrider<LLVector2> old_texcoords2,tex_coords2; | ||
819 | LLStrider<LLVector3> old_normals,normals; | ||
820 | LLStrider<LLColor4U> old_colors,colors; | ||
821 | LLStrider<U16> indicesp; | ||
835 | 822 | ||
836 | BOOL full_rebuild = mDrawablep->isState(LLDrawable::REBUILD_VOLUME); | 823 | BOOL full_rebuild = mDrawablep->isState(LLDrawable::REBUILD_VOLUME); |
837 | BOOL moved = TRUE; | 824 | BOOL moved = TRUE; |
@@ -859,91 +846,49 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
859 | { //data is in same location in vertex buffer | 846 | { //data is in same location in vertex buffer |
860 | moved = FALSE; | 847 | moved = FALSE; |
861 | } | 848 | } |
862 | 849 | ||
863 | if (!moved && !mDrawablep->isState(LLDrawable::REBUILD_ALL)) | 850 | if (!moved && !mDrawablep->isState(LLDrawable::REBUILD_ALL)) |
864 | { //nothing needs to be done | 851 | { //nothing needs to be done |
865 | vertices += mGeomCount; | ||
866 | normals += mGeomCount; | ||
867 | tex_coords += mGeomCount; | ||
868 | colors += mGeomCount; | ||
869 | tex_coords2 += mGeomCount; | ||
870 | index_offset += mGeomCount; | ||
871 | indicesp += mIndicesCount; | ||
872 | return FALSE; | 852 | return FALSE; |
873 | } | 853 | } |
874 | |||
875 | if (mLastGeomCount == mGeomCount) | ||
876 | { | ||
877 | if (mLastGeomIndex >= mGeomIndex && | ||
878 | mLastGeomIndex + mGeomCount+1 < mVertexBuffer->getNumVerts()) | ||
879 | { | ||
880 | //copy from further down the buffer | ||
881 | mVertexBuffer->getVertexStrider(old_verts, mLastGeomIndex); | ||
882 | mVertexBuffer->getTexCoordStrider(old_texcoords, mLastGeomIndex); | ||
883 | mVertexBuffer->getTexCoord2Strider(old_texcoords2, mLastGeomIndex); | ||
884 | mVertexBuffer->getNormalStrider(old_normals, mLastGeomIndex); | ||
885 | mVertexBuffer->getColorStrider(old_colors, mLastGeomIndex); | ||
886 | |||
887 | if (!mDrawablep->isState(LLDrawable::REBUILD_ALL)) | ||
888 | { | ||
889 | //quick copy | ||
890 | for (S32 i = 0; i < mGeomCount; i++) | ||
891 | { | ||
892 | *vertices++ = *old_verts++; | ||
893 | *tex_coords++ = *old_texcoords++; | ||
894 | *tex_coords2++ = *old_texcoords2++; | ||
895 | *colors++ = *old_colors++; | ||
896 | *normals++ = *old_normals++; | ||
897 | } | ||
898 | |||
899 | for (U32 i = 0; i < mIndicesCount; i++) | ||
900 | { | ||
901 | *indicesp++ = vf.mIndices[i] + index_offset; | ||
902 | } | ||
903 | |||
904 | index_offset += mGeomCount; | ||
905 | mLastGeomIndex = mGeomIndex; | ||
906 | mLastIndicesCount = mIndicesCount; | ||
907 | mLastIndicesIndex = mIndicesIndex; | ||
908 | |||
909 | return TRUE; | ||
910 | } | ||
911 | } | ||
912 | else | ||
913 | { | ||
914 | full_rebuild = TRUE; | ||
915 | } | ||
916 | } | ||
917 | else | ||
918 | { | ||
919 | full_rebuild = TRUE; | ||
920 | } | ||
921 | } | ||
922 | else | ||
923 | { | ||
924 | full_rebuild = TRUE; | ||
925 | } | 854 | } |
855 | mLastMoveTime = gFrameTimeSeconds; | ||
926 | } | 856 | } |
927 | else | 857 | else |
928 | { | 858 | { |
929 | mLastUpdateTime = gFrameTimeSeconds; | 859 | mLastUpdateTime = gFrameTimeSeconds; |
930 | } | 860 | } |
861 | |||
862 | BOOL rebuild_pos = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_POSITION); | ||
863 | BOOL rebuild_color = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_COLOR); | ||
864 | BOOL rebuild_tcoord = full_rebuild || moved || mDrawablep->isState(LLDrawable::REBUILD_TCOORD); | ||
931 | 865 | ||
866 | const LLTextureEntry *tep = mVObjp->getTE(f); | ||
867 | U8 bump_code = tep ? tep->getBumpmap() : 0; | ||
932 | 868 | ||
933 | BOOL rebuild_pos = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_POSITION); | 869 | if (rebuild_pos) |
934 | BOOL rebuild_color = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_COLOR); | 870 | { |
935 | BOOL rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD); | 871 | mVertexBuffer->getVertexStrider(vertices, mGeomIndex); |
872 | mVertexBuffer->getNormalStrider(normals, mGeomIndex); | ||
873 | } | ||
874 | if (rebuild_tcoord) | ||
875 | { | ||
876 | mVertexBuffer->getTexCoordStrider(tex_coords, mGeomIndex); | ||
877 | if (bump_code) | ||
878 | { | ||
879 | mVertexBuffer->getTexCoord2Strider(tex_coords2, mGeomIndex); | ||
880 | } | ||
881 | } | ||
882 | if (rebuild_color) | ||
883 | { | ||
884 | mVertexBuffer->getColorStrider(colors, mGeomIndex); | ||
885 | } | ||
936 | 886 | ||
937 | F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; | 887 | F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0; |
938 | 888 | ||
939 | BOOL is_static = mDrawablep->isStatic(); | 889 | BOOL is_static = mDrawablep->isStatic(); |
940 | BOOL is_global = is_static; | 890 | BOOL is_global = is_static; |
941 | 891 | ||
942 | if (index_offset == (U32) -1) | ||
943 | { | ||
944 | return TRUE; | ||
945 | } | ||
946 | |||
947 | LLVector3 center_sum(0.f, 0.f, 0.f); | 892 | LLVector3 center_sum(0.f, 0.f, 0.f); |
948 | 893 | ||
949 | if (is_global) | 894 | if (is_global) |
@@ -957,8 +902,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
957 | 902 | ||
958 | LLVector2 tmin, tmax; | 903 | LLVector2 tmin, tmax; |
959 | 904 | ||
960 | const LLTextureEntry *tep = mVObjp->getTE(f); | 905 | |
961 | U8 bump_code = tep ? tep->getBumpmap() : 0; | ||
962 | 906 | ||
963 | if (rebuild_tcoord) | 907 | if (rebuild_tcoord) |
964 | { | 908 | { |
@@ -983,14 +927,23 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
983 | } | 927 | } |
984 | } | 928 | } |
985 | 929 | ||
930 | U8 tex_mode = 0; | ||
931 | |||
986 | if (isState(TEXTURE_ANIM)) | 932 | if (isState(TEXTURE_ANIM)) |
987 | { | 933 | { |
988 | LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp; | 934 | LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp; |
989 | U8 mode = vobj->mTexAnimMode; | 935 | tex_mode = vobj->mTexAnimMode; |
990 | if (!mode) | 936 | |
937 | if (!tex_mode) | ||
991 | { | 938 | { |
992 | clearState(TEXTURE_ANIM); | 939 | clearState(TEXTURE_ANIM); |
993 | } | 940 | } |
941 | //else if (getVirtualSize() <= 512.f) | ||
942 | //{ | ||
943 | // //vobj->mTextureAnimp->animateTextures(os, ot, ms, mt, r); | ||
944 | // //cos_ang = cos(r); | ||
945 | // //sin_ang = sin(r); | ||
946 | //} | ||
994 | else | 947 | else |
995 | { | 948 | { |
996 | os = ot = 0.f; | 949 | os = ot = 0.f; |
@@ -999,6 +952,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
999 | sin_ang = 0.f; | 952 | sin_ang = 0.f; |
1000 | ms = mt = 1.f; | 953 | ms = mt = 1.f; |
1001 | } | 954 | } |
955 | |||
956 | if (getVirtualSize() >= MIN_TEX_ANIM_SIZE) | ||
957 | { //don't override texture transform during tc bake | ||
958 | tex_mode = 0; | ||
959 | } | ||
1002 | } | 960 | } |
1003 | 961 | ||
1004 | LLColor4U color = tep->getColor(); | 962 | LLColor4U color = tep->getColor(); |
@@ -1013,7 +971,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1013 | 0.75f | 971 | 0.75f |
1014 | }; | 972 | }; |
1015 | 973 | ||
1016 | if (gPipeline.getPoolTypeFromTE(tep, getTexture()) == LLDrawPool::POOL_BUMP) | 974 | if (getPoolType() != LLDrawPool::POOL_ALPHA && LLPipeline::sRenderBump && tep->getShiny()) |
1017 | { | 975 | { |
1018 | color.mV[3] = U8 (alpha[tep->getShiny()] * 255); | 976 | color.mV[3] = U8 (alpha[tep->getShiny()] * 255); |
1019 | } | 977 | } |
@@ -1022,23 +980,28 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1022 | // INDICES | 980 | // INDICES |
1023 | if (full_rebuild || moved) | 981 | if (full_rebuild || moved) |
1024 | { | 982 | { |
1025 | for (S32 i = 0; i < num_indices; i++) | 983 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); |
984 | for (U16 i = 0; i < num_indices; i++) | ||
1026 | { | 985 | { |
1027 | *indicesp++ = vf.mIndices[i] + index_offset; | 986 | *indicesp++ = vf.mIndices[i] + index_offset; |
1028 | } | 987 | } |
1029 | } | 988 | } |
1030 | else | 989 | |
1031 | { | ||
1032 | indicesp += num_indices; | ||
1033 | } | ||
1034 | 990 | ||
1035 | //bump setup | 991 | //bump setup |
1036 | LLVector3 binormal_dir( -sin_ang, cos_ang, 0 ); | 992 | LLVector3 binormal_dir( -sin_ang, cos_ang, 0 ); |
1037 | LLVector3 bump_s_primary_light_ray; | 993 | LLVector3 bump_s_primary_light_ray; |
1038 | LLVector3 bump_t_primary_light_ray; | 994 | LLVector3 bump_t_primary_light_ray; |
995 | |||
996 | LLQuaternion bump_quat; | ||
997 | if (mDrawablep->isActive()) | ||
998 | { | ||
999 | bump_quat = LLQuaternion(mDrawablep->getRenderMatrix()); | ||
1000 | } | ||
1039 | 1001 | ||
1040 | if (bump_code) | 1002 | if (bump_code) |
1041 | { | 1003 | { |
1004 | mVObjp->getVolume()->genBinormals(f); | ||
1042 | F32 offset_multiple; | 1005 | F32 offset_multiple; |
1043 | switch( bump_code ) | 1006 | switch( bump_code ) |
1044 | { | 1007 | { |
@@ -1073,14 +1036,22 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1073 | { | 1036 | { |
1074 | tep->getScale( &s_scale, &t_scale ); | 1037 | tep->getScale( &s_scale, &t_scale ); |
1075 | } | 1038 | } |
1076 | LLVector3 sun_ray = gSky.getSunDirection(); | 1039 | // Use the nudged south when coming from above sun angle, such |
1040 | // that emboss mapping always shows up on the upward faces of cubes when | ||
1041 | // it's noon (since a lot of builders build with the sun forced to noon). | ||
1042 | LLVector3 sun_ray = gSky.mVOSkyp->mBumpSunDir; | ||
1077 | LLVector3 moon_ray = gSky.getMoonDirection(); | 1043 | LLVector3 moon_ray = gSky.getMoonDirection(); |
1078 | LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray; | 1044 | LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray; |
1045 | |||
1079 | bump_s_primary_light_ray = offset_multiple * s_scale * primary_light_ray; | 1046 | bump_s_primary_light_ray = offset_multiple * s_scale * primary_light_ray; |
1080 | bump_t_primary_light_ray = offset_multiple * t_scale * primary_light_ray; | 1047 | bump_t_primary_light_ray = offset_multiple * t_scale * primary_light_ray; |
1081 | } | 1048 | } |
1082 | 1049 | ||
1083 | U8 texgen = getTextureEntry()->getTexGen(); | 1050 | U8 texgen = getTextureEntry()->getTexGen(); |
1051 | if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT) | ||
1052 | { //planar texgen needs binormals | ||
1053 | mVObjp->getVolume()->genBinormals(f); | ||
1054 | } | ||
1084 | 1055 | ||
1085 | for (S32 i = 0; i < num_vertices; i++) | 1056 | for (S32 i = 0; i < num_vertices; i++) |
1086 | { | 1057 | { |
@@ -1110,20 +1081,37 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1110 | } | 1081 | } |
1111 | } | 1082 | } |
1112 | 1083 | ||
1113 | xform(tc, cos_ang, sin_ang, os, ot, ms, mt); | 1084 | if (tex_mode && mTextureMatrix) |
1085 | { | ||
1086 | LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f); | ||
1087 | tmp = tmp * *mTextureMatrix; | ||
1088 | tc.mV[0] = tmp.mV[0]; | ||
1089 | tc.mV[1] = tmp.mV[1]; | ||
1090 | } | ||
1091 | else | ||
1092 | { | ||
1093 | xform(tc, cos_ang, sin_ang, os, ot, ms, mt); | ||
1094 | } | ||
1095 | |||
1114 | *tex_coords++ = tc; | 1096 | *tex_coords++ = tc; |
1115 | 1097 | ||
1116 | if (bump_code) | 1098 | if (bump_code) |
1117 | { | 1099 | { |
1118 | LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal; | 1100 | LLVector3 tangent = vf.mVertices[i].mBinormal % vf.mVertices[i].mNormal; |
1101 | |||
1119 | LLMatrix3 tangent_to_object; | 1102 | LLMatrix3 tangent_to_object; |
1120 | tangent_to_object.setRows(tangent, vf.mVertices[i].mBinormal, vf.mVertices[i].mNormal); | 1103 | tangent_to_object.setRows(tangent, vf.mVertices[i].mBinormal, vf.mVertices[i].mNormal); |
1121 | LLVector3 binormal = binormal_dir * tangent_to_object; | 1104 | LLVector3 binormal = binormal_dir * tangent_to_object; |
1122 | |||
1123 | binormal = binormal * mat_normal; | 1105 | binormal = binormal * mat_normal; |
1124 | binormal.normVec(); | 1106 | |
1107 | if (mDrawablep->isActive()) | ||
1108 | { | ||
1109 | binormal *= bump_quat; | ||
1110 | } | ||
1125 | 1111 | ||
1112 | binormal.normVec(); | ||
1126 | tc += LLVector2( bump_s_primary_light_ray * tangent, bump_t_primary_light_ray * binormal ); | 1113 | tc += LLVector2( bump_s_primary_light_ray * tangent, bump_t_primary_light_ray * binormal ); |
1114 | |||
1127 | *tex_coords2++ = tc; | 1115 | *tex_coords2++ = tc; |
1128 | } | 1116 | } |
1129 | } | 1117 | } |
@@ -1161,26 +1149,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1161 | } | 1149 | } |
1162 | } | 1150 | } |
1163 | 1151 | ||
1164 | if (!rebuild_pos && !moved) | ||
1165 | { | ||
1166 | vertices += num_vertices; | ||
1167 | } | ||
1168 | |||
1169 | if (!rebuild_tcoord && !moved) | ||
1170 | { | ||
1171 | tex_coords2 += num_vertices; | ||
1172 | tex_coords += num_vertices; | ||
1173 | } | ||
1174 | else if (!bump_code) | ||
1175 | { | ||
1176 | tex_coords2 += num_vertices; | ||
1177 | } | ||
1178 | |||
1179 | if (!rebuild_color && !moved) | ||
1180 | { | ||
1181 | colors += num_vertices; | ||
1182 | } | ||
1183 | |||
1184 | if (rebuild_tcoord) | 1152 | if (rebuild_tcoord) |
1185 | { | 1153 | { |
1186 | mTexExtents[0].setVec(0,0); | 1154 | mTexExtents[0].setVec(0,0); |
@@ -1189,8 +1157,6 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1189 | xform(mTexExtents[1], cos_ang, sin_ang, os, ot, ms, mt); | 1157 | xform(mTexExtents[1], cos_ang, sin_ang, os, ot, ms, mt); |
1190 | } | 1158 | } |
1191 | 1159 | ||
1192 | index_offset += num_vertices; | ||
1193 | |||
1194 | mLastVertexBuffer = mVertexBuffer; | 1160 | mLastVertexBuffer = mVertexBuffer; |
1195 | mLastGeomCount = mGeomCount; | 1161 | mLastGeomCount = mGeomCount; |
1196 | mLastGeomIndex = mGeomIndex; | 1162 | mLastGeomIndex = mGeomIndex; |
@@ -1200,136 +1166,11 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume, | |||
1200 | return TRUE; | 1166 | return TRUE; |
1201 | } | 1167 | } |
1202 | 1168 | ||
1203 | #if 0 | ||
1204 | BOOL LLFace::genLighting(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, | ||
1205 | const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL do_lighting) | ||
1206 | { | ||
1207 | if (drawablep->isLight()) | ||
1208 | { | ||
1209 | do_lighting = FALSE; | ||
1210 | } | ||
1211 | |||
1212 | if (!((mDrawPoolp->mDataMaskIL) & LLDrawPool::DATA_COLORS_MASK)) | ||
1213 | { | ||
1214 | return FALSE; | ||
1215 | } | ||
1216 | if (mGeomIndex < 0) | ||
1217 | { | ||
1218 | return FALSE; // no geometry | ||
1219 | } | ||
1220 | LLStrider<LLColor4U> colorsp; | ||
1221 | S32 idx = getColors(colorsp); | ||
1222 | if (idx < 0) | ||
1223 | { | ||
1224 | return FALSE; | ||
1225 | } | ||
1226 | |||
1227 | for (S32 vol_face = fstart; vol_face <= fend; vol_face++) | ||
1228 | { | ||
1229 | const LLVolumeFace &vf = volume->getVolumeFace(vol_face); | ||
1230 | S32 num_vertices = (S32)vf.mVertices.size(); | ||
1231 | |||
1232 | if (isState(FULLBRIGHT) || !do_lighting) | ||
1233 | { | ||
1234 | for (S32 i = 0; i < num_vertices; i++) | ||
1235 | { | ||
1236 | (*colorsp++).setToBlack(); | ||
1237 | } | ||
1238 | } | ||
1239 | else | ||
1240 | { | ||
1241 | for (S32 i = 0; i < num_vertices; i++) | ||
1242 | { | ||
1243 | LLVector3 vertex = vf.mVertices[i].mPosition * mat_vert; | ||
1244 | LLVector3 normal = vf.mVertices[i].mNormal * mat_normal; | ||
1245 | normal.normVec(); | ||
1246 | |||
1247 | LLColor4 color; | ||
1248 | for (LLDrawable::drawable_set_t::const_iterator iter = drawablep->mLightSet.begin(); | ||
1249 | iter != drawablep->mLightSet.end(); ++iter) | ||
1250 | { | ||
1251 | LLDrawable* light_drawable = *iter; | ||
1252 | LLVOVolume* light = light_drawable->getVOVolume(); | ||
1253 | if (!light) | ||
1254 | { | ||
1255 | continue; | ||
1256 | } | ||
1257 | LLColor4 light_color; | ||
1258 | light->calcLightAtPoint(vertex, normal, light_color); | ||
1259 | color += light_color; | ||
1260 | } | ||
1261 | |||
1262 | color.mV[3] = 1.0f; | ||
1263 | |||
1264 | (*colorsp++).setVecScaleClamp(color); | ||
1265 | } | ||
1266 | } | ||
1267 | } | ||
1268 | return TRUE; | ||
1269 | } | ||
1270 | |||
1271 | BOOL LLFace::genShadows(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, | ||
1272 | const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL use_shadow_factor) | ||
1273 | { | ||
1274 | if (drawablep->isLight()) | ||
1275 | { | ||
1276 | return FALSE; | ||
1277 | } | ||
1278 | |||
1279 | if (!((mDrawPoolp->mDataMaskIL) & LLDrawPool::DATA_COLORS_MASK)) | ||
1280 | { | ||
1281 | return FALSE; | ||
1282 | } | ||
1283 | if (mGeomIndex < 0) | ||
1284 | { | ||
1285 | return FALSE; // no geometry | ||
1286 | } | ||
1287 | LLStrider<LLColor4U> colorsp; | ||
1288 | S32 idx = getColors(colorsp); | ||
1289 | if (idx < 0) | ||
1290 | { | ||
1291 | return FALSE; | ||
1292 | } | ||
1293 | |||
1294 | for (S32 vol_face = fstart; vol_face <= fend; vol_face++) | ||
1295 | { | ||
1296 | const LLVolumeFace &vf = volume->getVolumeFace(vol_face); | ||
1297 | S32 num_vertices = (S32)vf.mVertices.size(); | ||
1298 | |||
1299 | if (isState(FULLBRIGHT)) | ||
1300 | { | ||
1301 | continue; | ||
1302 | } | ||
1303 | |||
1304 | for (S32 i = 0; i < num_vertices; i++) | ||
1305 | { | ||
1306 | LLVector3 vertex = vf.mVertices[i].mPosition * mat_vert; | ||
1307 | LLVector3 normal = vf.mVertices[i].mNormal * mat_normal; | ||
1308 | normal.normVec(); | ||
1309 | |||
1310 | U8 shadow; | ||
1311 | |||
1312 | if (use_shadow_factor) | ||
1313 | { | ||
1314 | shadow = (U8) (drawablep->getSunShadowFactor() * 255); | ||
1315 | } | ||
1316 | else | ||
1317 | { | ||
1318 | shadow = 255; | ||
1319 | } | ||
1320 | |||
1321 | (*colorsp++).mV[3] = shadow; | ||
1322 | } | ||
1323 | } | ||
1324 | return TRUE; | ||
1325 | } | ||
1326 | #endif | ||
1327 | |||
1328 | BOOL LLFace::verify(const U32* indices_array) const | 1169 | BOOL LLFace::verify(const U32* indices_array) const |
1329 | { | 1170 | { |
1330 | BOOL ok = TRUE; | 1171 | BOOL ok = TRUE; |
1331 | // First, check whether the face data fits within the pool's range. | 1172 | // First, check whether the face data fits within the pool's range. |
1332 | if ((mGeomIndex < 0) || (mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts()) | 1173 | if ((mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts()) |
1333 | { | 1174 | { |
1334 | ok = FALSE; | 1175 | ok = FALSE; |
1335 | llinfos << "Face not within pool range!" << llendl; | 1176 | llinfos << "Face not within pool range!" << llendl; |
@@ -1385,27 +1226,6 @@ void LLFace::setViewerObject(LLViewerObject* objp) | |||
1385 | mVObjp = objp; | 1226 | mVObjp = objp; |
1386 | } | 1227 | } |
1387 | 1228 | ||
1388 | void LLFace::enableLights() const | ||
1389 | { | ||
1390 | if (isState(FULLBRIGHT|HUD_RENDER)) | ||
1391 | { | ||
1392 | gPipeline.enableLightsFullbright(LLColor4::white); | ||
1393 | } | ||
1394 | else if (mDrawablep->isState(LLDrawable::LIGHTING_BUILT)) | ||
1395 | { | ||
1396 | gPipeline.enableLightsStatic(1.f); | ||
1397 | } | ||
1398 | else | ||
1399 | { | ||
1400 | gPipeline.enableLightsDynamic(1.f); | ||
1401 | } | ||
1402 | if (isState(LIGHT)) | ||
1403 | { | ||
1404 | const LLVOVolume* vovolume = (const LLVOVolume*)mDrawablep->getVObj(); | ||
1405 | gPipeline.setAmbient(vovolume->getLightColor()); | ||
1406 | } | ||
1407 | } | ||
1408 | |||
1409 | const LLColor4& LLFace::getRenderColor() const | 1229 | const LLColor4& LLFace::getRenderColor() const |
1410 | { | 1230 | { |
1411 | if (isState(USE_FACE_COLOR)) | 1231 | if (isState(USE_FACE_COLOR)) |
@@ -1425,18 +1245,11 @@ void LLFace::renderSetColor() const | |||
1425 | { | 1245 | { |
1426 | const LLColor4* color = &(getRenderColor()); | 1246 | const LLColor4* color = &(getRenderColor()); |
1427 | 1247 | ||
1428 | if ((mDrawPoolp->mVertexShaderLevel > 0) && (mDrawPoolp->getMaterialAttribIndex() != 0)) | 1248 | glColor4fv(color->mV); |
1429 | { | ||
1430 | glVertexAttrib4fvARB(mDrawPoolp->getMaterialAttribIndex(), color->mV); | ||
1431 | } | ||
1432 | else | ||
1433 | { | ||
1434 | glColor4fv(color->mV); | ||
1435 | } | ||
1436 | } | 1249 | } |
1437 | } | 1250 | } |
1438 | 1251 | ||
1439 | S32 LLFace::pushVertices(const U32* index_array) const | 1252 | S32 LLFace::pushVertices(const U16* index_array) const |
1440 | { | 1253 | { |
1441 | if (mIndicesCount) | 1254 | if (mIndicesCount) |
1442 | { | 1255 | { |
@@ -1444,14 +1257,15 @@ S32 LLFace::pushVertices(const U32* index_array) const | |||
1444 | mIndicesCount <= (U32) gGLManager.mGLMaxIndexRange) | 1257 | mIndicesCount <= (U32) gGLManager.mGLMaxIndexRange) |
1445 | { | 1258 | { |
1446 | glDrawRangeElements(GL_TRIANGLES, mGeomIndex, mGeomIndex + mGeomCount-1, mIndicesCount, | 1259 | glDrawRangeElements(GL_TRIANGLES, mGeomIndex, mGeomIndex + mGeomCount-1, mIndicesCount, |
1447 | GL_UNSIGNED_INT, index_array + mIndicesIndex); | 1260 | GL_UNSIGNED_SHORT, index_array + mIndicesIndex); |
1448 | } | 1261 | } |
1449 | else | 1262 | else |
1450 | { | 1263 | { |
1451 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_INT, index_array+mIndicesIndex); | 1264 | glDrawElements(GL_TRIANGLES, mIndicesCount, GL_UNSIGNED_SHORT, index_array+mIndicesIndex); |
1452 | } | 1265 | } |
1266 | gPipeline.addTrianglesDrawn(mIndicesCount/3); | ||
1453 | } | 1267 | } |
1454 | 1268 | ||
1455 | return mIndicesCount; | 1269 | return mIndicesCount; |
1456 | } | 1270 | } |
1457 | 1271 | ||
@@ -1460,7 +1274,7 @@ const LLMatrix4& LLFace::getRenderMatrix() const | |||
1460 | return mDrawablep->getRenderMatrix(); | 1274 | return mDrawablep->getRenderMatrix(); |
1461 | } | 1275 | } |
1462 | 1276 | ||
1463 | S32 LLFace::renderElements(const U32 *index_array) const | 1277 | S32 LLFace::renderElements(const U16 *index_array) const |
1464 | { | 1278 | { |
1465 | S32 ret = 0; | 1279 | S32 ret = 0; |
1466 | 1280 | ||
@@ -1481,7 +1295,7 @@ S32 LLFace::renderElements(const U32 *index_array) const | |||
1481 | 1295 | ||
1482 | S32 LLFace::renderIndexed() | 1296 | S32 LLFace::renderIndexed() |
1483 | { | 1297 | { |
1484 | if(mGeomIndex < 0 || mDrawablep.isNull() || mDrawPoolp == NULL) | 1298 | if(mDrawablep.isNull() || mDrawPoolp == NULL) |
1485 | { | 1299 | { |
1486 | return 0; | 1300 | return 0; |
1487 | } | 1301 | } |
@@ -1497,28 +1311,13 @@ S32 LLFace::renderIndexed(U32 mask) | |||
1497 | } | 1311 | } |
1498 | 1312 | ||
1499 | mVertexBuffer->setBuffer(mask); | 1313 | mVertexBuffer->setBuffer(mask); |
1500 | U32* index_array = (U32*) mVertexBuffer->getIndicesPointer(); | 1314 | U16* index_array = (U16*) mVertexBuffer->getIndicesPointer(); |
1501 | return renderElements(index_array); | 1315 | return renderElements(index_array); |
1502 | } | 1316 | } |
1503 | 1317 | ||
1504 | //============================================================================ | 1318 | //============================================================================ |
1505 | // From llface.inl | 1319 | // From llface.inl |
1506 | 1320 | ||
1507 | S32 LLFace::getVertices(LLStrider<LLVector3> &vertices) | ||
1508 | { | ||
1509 | if (!mGeomCount) | ||
1510 | { | ||
1511 | return -1; | ||
1512 | } | ||
1513 | |||
1514 | if (mGeomIndex >= 0) // flexible objects may not have geometry | ||
1515 | { | ||
1516 | mVertexBuffer->getVertexStrider(vertices, mGeomIndex); | ||
1517 | |||
1518 | } | ||
1519 | return mGeomIndex; | ||
1520 | } | ||
1521 | |||
1522 | S32 LLFace::getColors(LLStrider<LLColor4U> &colors) | 1321 | S32 LLFace::getColors(LLStrider<LLColor4U> &colors) |
1523 | { | 1322 | { |
1524 | if (!mGeomCount) | 1323 | if (!mGeomCount) |
@@ -1526,15 +1325,15 @@ S32 LLFace::getColors(LLStrider<LLColor4U> &colors) | |||
1526 | return -1; | 1325 | return -1; |
1527 | } | 1326 | } |
1528 | 1327 | ||
1529 | llassert(mGeomIndex >= 0); | 1328 | // llassert(mGeomIndex >= 0); |
1530 | mVertexBuffer->getColorStrider(colors, mGeomIndex); | 1329 | mVertexBuffer->getColorStrider(colors, mGeomIndex); |
1531 | return mGeomIndex; | 1330 | return mGeomIndex; |
1532 | } | 1331 | } |
1533 | 1332 | ||
1534 | S32 LLFace::getIndices(LLStrider<U32> &indicesp) | 1333 | S32 LLFace::getIndices(LLStrider<U16> &indicesp) |
1535 | { | 1334 | { |
1536 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); | 1335 | mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex); |
1537 | llassert(mGeomIndex >= 0 && indicesp[0] != indicesp[1]); | 1336 | llassert(indicesp[0] != indicesp[1]); |
1538 | return mIndicesIndex; | 1337 | return mIndicesIndex; |
1539 | } | 1338 | } |
1540 | 1339 | ||