aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/llprimitive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llprimitive/llprimitive.cpp')
-rw-r--r--linden/indra/llprimitive/llprimitive.cpp71
1 files changed, 34 insertions, 37 deletions
diff --git a/linden/indra/llprimitive/llprimitive.cpp b/linden/indra/llprimitive/llprimitive.cpp
index 859a34f..e2cf7e3 100644
--- a/linden/indra/llprimitive/llprimitive.cpp
+++ b/linden/indra/llprimitive/llprimitive.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -733,7 +734,7 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
733 snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */ 734 snprintf(pcode_string, sizeof(pcode_string), "text bubble"); /* Flawfinder: ignore */
734 break; 735 break;
735 case LL_PCODE_LEGACY_TREE: 736 case LL_PCODE_LEGACY_TREE:
736 snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */ 737 snprintf(pcode_string, sizeof(pcode_string), "tree"); /* Flawfinder: ignore */
737 break; 738 break;
738 case LL_PCODE_TREE_NEW: 739 case LL_PCODE_TREE_NEW:
739 snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */ 740 snprintf(pcode_string, sizeof(pcode_string), "tree_new"); /* Flawfinder: ignore */
@@ -764,23 +765,23 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
764 } 765 }
765 else if (base_code == LL_PCODE_PYRAMID) 766 else if (base_code == LL_PCODE_PYRAMID)
766 { 767 {
767 snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */ 768 snprintf(shape, sizeof(shape), "pyramid"); /* Flawfinder: ignore */
768 } 769 }
769 else if (base_code == LL_PCODE_SPHERE) 770 else if (base_code == LL_PCODE_SPHERE)
770 { 771 {
771 snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */ 772 snprintf(shape, sizeof(shape), "sphere"); /* Flawfinder: ignore */
772 } 773 }
773 else if (base_code == LL_PCODE_TETRAHEDRON) 774 else if (base_code == LL_PCODE_TETRAHEDRON)
774 { 775 {
775 snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */ 776 snprintf(shape, sizeof(shape), "tetrahedron"); /* Flawfinder: ignore */
776 } 777 }
777 else if (base_code == LL_PCODE_VOLUME) 778 else if (base_code == LL_PCODE_VOLUME)
778 { 779 {
779 snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */ 780 snprintf(shape, sizeof(shape), "volume"); /* Flawfinder: ignore */
780 } 781 }
781 else if (base_code == LL_PCODE_APP) 782 else if (base_code == LL_PCODE_APP)
782 { 783 {
783 snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */ 784 snprintf(shape, sizeof(shape), "app"); /* Flawfinder: ignore */
784 } 785 }
785 else 786 else
786 { 787 {
@@ -790,15 +791,15 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
790 U8 mask_code = pcode & (~LL_PCODE_BASE_MASK); 791 U8 mask_code = pcode & (~LL_PCODE_BASE_MASK);
791 if (base_code == LL_PCODE_APP) 792 if (base_code == LL_PCODE_APP)
792 { 793 {
793 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ 794 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
794 } 795 }
795 else if (mask_code & LL_PCODE_HEMI_MASK) 796 else if (mask_code & LL_PCODE_HEMI_MASK)
796 { 797 {
797 snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */ 798 snprintf(mask, sizeof(mask), "hemi"); /* Flawfinder: ignore */
798 } 799 }
799 else if (mask != 0) 800 else if (mask != 0)
800 { 801 {
801 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */ 802 snprintf(mask, sizeof(mask), "%x", mask_code); /* Flawfinder: ignore */
802 } 803 }
803 else 804 else
804 { 805 {
@@ -807,11 +808,11 @@ const char * LLPrimitive::pCodeToString(const LLPCode pcode)
807 808
808 if (mask[0]) 809 if (mask[0])
809 { 810 {
810 snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */ 811 snprintf(pcode_string, sizeof(pcode_string), "%s-%s", shape, mask); /* Flawfinder: ignore */
811 } 812 }
812 else 813 else
813 { 814 {
814 snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */ 815 snprintf(pcode_string, sizeof(pcode_string), "%s", shape); /* Flawfinder: ignore */
815 } 816 }
816 } 817 }
817 return pcode_string; 818 return pcode_string;
@@ -1279,8 +1280,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1279 1280
1280 U8 image_ids[MAX_TES*16]; 1281 U8 image_ids[MAX_TES*16];
1281 U8 colors[MAX_TES*4]; 1282 U8 colors[MAX_TES*4];
1282 S16 scale_s[MAX_TES]; 1283 F32 scale_s[MAX_TES];
1283 S16 scale_t[MAX_TES]; 1284 F32 scale_t[MAX_TES];
1284 S16 offset_s[MAX_TES]; 1285 S16 offset_s[MAX_TES];
1285 S16 offset_t[MAX_TES]; 1286 S16 offset_t[MAX_TES];
1286 S16 image_rot[MAX_TES]; 1287 S16 image_rot[MAX_TES];
@@ -1315,8 +1316,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1315 colors[4*face_index + 3] = 255 - coloru.mV[3]; 1316 colors[4*face_index + 3] = 255 - coloru.mV[3];
1316 1317
1317 const LLTextureEntry* te = getTE(face_index); 1318 const LLTextureEntry* te = getTE(face_index);
1318 scale_s[face_index] = (S16) llround(((llclamp(te->mScaleS,-LL_MAX_SCALE_S, LL_MAX_SCALE_S)-1.0f)/(LL_MAX_SCALE_S+1.f) * (F32)0x7FFF)); 1319 scale_s[face_index] = (F32) te->mScaleS;
1319 scale_t[face_index] = (S16) llround(((llclamp(te->mScaleT,-LL_MAX_SCALE_T, LL_MAX_SCALE_T)-1.0f)/(LL_MAX_SCALE_T+1.f) * (F32)0x7FFF)); 1320 scale_t[face_index] = (F32) te->mScaleT;
1320 offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; 1321 offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
1321 offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; 1322 offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
1322 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); 1323 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF));
@@ -1329,9 +1330,9 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1329 *cur_ptr++ = 0; 1330 *cur_ptr++ = 0;
1330 cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8); 1331 cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8);
1331 *cur_ptr++ = 0; 1332 *cur_ptr++ = 0;
1332 cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 2 ,last_face_index, MVT_S16Array); 1333 cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 4 ,last_face_index, MVT_F32);
1333 *cur_ptr++ = 0; 1334 *cur_ptr++ = 0;
1334 cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 2 ,last_face_index, MVT_S16Array); 1335 cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 4 ,last_face_index, MVT_F32);
1335 *cur_ptr++ = 0; 1336 *cur_ptr++ = 0;
1336 cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array); 1337 cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array);
1337 *cur_ptr++ = 0; 1338 *cur_ptr++ = 0;
@@ -1355,8 +1356,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1355 1356
1356 U8 image_ids[MAX_TES*16]; 1357 U8 image_ids[MAX_TES*16];
1357 U8 colors[MAX_TES*4]; 1358 U8 colors[MAX_TES*4];
1358 S16 scale_s[MAX_TES]; 1359 F32 scale_s[MAX_TES];
1359 S16 scale_t[MAX_TES]; 1360 F32 scale_t[MAX_TES];
1360 S16 offset_s[MAX_TES]; 1361 S16 offset_s[MAX_TES];
1361 S16 offset_t[MAX_TES]; 1362 S16 offset_t[MAX_TES];
1362 S16 image_rot[MAX_TES]; 1363 S16 image_rot[MAX_TES];
@@ -1391,8 +1392,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1391 colors[4*face_index + 3] = 255 - coloru.mV[3]; 1392 colors[4*face_index + 3] = 255 - coloru.mV[3];
1392 1393
1393 const LLTextureEntry* te = getTE(face_index); 1394 const LLTextureEntry* te = getTE(face_index);
1394 scale_s[face_index] = (S16) llround(((llclamp(te->mScaleS,-LL_MAX_SCALE_S, LL_MAX_SCALE_S)-1.0f)/(LL_MAX_SCALE_S+1.f) * (F32)0x7FFF)); 1395 scale_s[face_index] = (F32) te->mScaleS;
1395 scale_t[face_index] = (S16) llround(((llclamp(te->mScaleT,-LL_MAX_SCALE_T, LL_MAX_SCALE_T)-1.0f)/(LL_MAX_SCALE_T+1.f) * (F32)0x7FFF)); 1396 scale_t[face_index] = (F32) te->mScaleT;
1396 offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; 1397 offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ;
1397 offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; 1398 offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ;
1398 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); 1399 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF));
@@ -1406,9 +1407,9 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1406 *cur_ptr++ = 0; 1407 *cur_ptr++ = 0;
1407 cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8); 1408 cur_ptr += packTEField(cur_ptr, (U8 *)colors, 4 ,last_face_index, MVT_U8);
1408 *cur_ptr++ = 0; 1409 *cur_ptr++ = 0;
1409 cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 2 ,last_face_index, MVT_S16Array); 1410 cur_ptr += packTEField(cur_ptr, (U8 *)scale_s, 4 ,last_face_index, MVT_F32);
1410 *cur_ptr++ = 0; 1411 *cur_ptr++ = 0;
1411 cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 2 ,last_face_index, MVT_S16Array); 1412 cur_ptr += packTEField(cur_ptr, (U8 *)scale_t, 4 ,last_face_index, MVT_F32);
1412 *cur_ptr++ = 0; 1413 *cur_ptr++ = 0;
1413 cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array); 1414 cur_ptr += packTEField(cur_ptr, (U8 *)offset_s, 2 ,last_face_index, MVT_S16Array);
1414 *cur_ptr++ = 0; 1415 *cur_ptr++ = 0;
@@ -1440,8 +1441,8 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1440 1441
1441 U8 image_data[MAX_TES*16]; 1442 U8 image_data[MAX_TES*16];
1442 U8 colors[MAX_TES*4]; 1443 U8 colors[MAX_TES*4];
1443 S16 scale_s[MAX_TES]; 1444 F32 scale_s[MAX_TES];
1444 S16 scale_t[MAX_TES]; 1445 F32 scale_t[MAX_TES];
1445 S16 offset_s[MAX_TES]; 1446 S16 offset_s[MAX_TES];
1446 S16 offset_t[MAX_TES]; 1447 S16 offset_t[MAX_TES];
1447 S16 image_rot[MAX_TES]; 1448 S16 image_rot[MAX_TES];
@@ -1484,9 +1485,9 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1484 cur_ptr++; 1485 cur_ptr++;
1485 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); 1486 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8);
1486 cur_ptr++; 1487 cur_ptr++;
1487 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 2, face_count, MVT_S16Array); 1488 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 4, face_count, MVT_F32);
1488 cur_ptr++; 1489 cur_ptr++;
1489 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 2, face_count, MVT_S16Array); 1490 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 4, face_count, MVT_F32);
1490 cur_ptr++; 1491 cur_ptr++;
1491 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); 1492 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array);
1492 cur_ptr++; 1493 cur_ptr++;
@@ -1503,9 +1504,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1503 for (U32 i = 0; i < face_count; i++) 1504 for (U32 i = 0; i < face_count; i++)
1504 { 1505 {
1505 retval |= setTETexture(i, ((LLUUID*)image_data)[i]); 1506 retval |= setTETexture(i, ((LLUUID*)image_data)[i]);
1506 retval |= setTEScale(i, 1507 retval |= setTEScale(i, scale_s[i], scale_t[i]);
1507 floor((1.0f + ((((F32)scale_s[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_S+1.f))) * 100.f + 0.5f) / 100.f,
1508 floor((1.0f + ((((F32)scale_t[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_T+1.f))) * 100.f + 0.5f) / 100.f);
1509 retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); 1508 retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF);
1510 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); 1509 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI);
1511 retval |= setTEBumpShinyFullbright(i, bump[i]); 1510 retval |= setTEBumpShinyFullbright(i, bump[i]);
@@ -1537,8 +1536,8 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1537 1536
1538 U8 image_data[MAX_TES*16]; 1537 U8 image_data[MAX_TES*16];
1539 U8 colors[MAX_TES*4]; 1538 U8 colors[MAX_TES*4];
1540 S16 scale_s[MAX_TES]; 1539 F32 scale_s[MAX_TES];
1541 S16 scale_t[MAX_TES]; 1540 F32 scale_t[MAX_TES];
1542 S16 offset_s[MAX_TES]; 1541 S16 offset_s[MAX_TES];
1543 S16 offset_t[MAX_TES]; 1542 S16 offset_t[MAX_TES];
1544 S16 image_rot[MAX_TES]; 1543 S16 image_rot[MAX_TES];
@@ -1571,9 +1570,9 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1571 cur_ptr++; 1570 cur_ptr++;
1572 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8); 1571 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)colors, 4, face_count, MVT_U8);
1573 cur_ptr++; 1572 cur_ptr++;
1574 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 2, face_count, MVT_S16Array); 1573 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_s, 4, face_count, MVT_F32);
1575 cur_ptr++; 1574 cur_ptr++;
1576 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 2, face_count, MVT_S16Array); 1575 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)scale_t, 4, face_count, MVT_F32);
1577 cur_ptr++; 1576 cur_ptr++;
1578 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array); 1577 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)offset_s, 2, face_count, MVT_S16Array);
1579 cur_ptr++; 1578 cur_ptr++;
@@ -1596,9 +1595,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1596 for (i = 0; i < face_count; i++) 1595 for (i = 0; i < face_count; i++)
1597 { 1596 {
1598 retval |= setTETexture(i, image_ids[i]); 1597 retval |= setTETexture(i, image_ids[i]);
1599 retval |= setTEScale(i, 1598 retval |= setTEScale(i, scale_s[i], scale_t[i]);
1600 floor((1.0f + ((((F32)scale_s[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_S+1.f))) * 100.f + 0.5f) / 100.f,
1601 floor((1.0f + ((((F32)scale_t[i] / (F32)0x7FFF)) * (LL_MAX_SCALE_T+1.f))) * 100.f + 0.5f) / 100.f);
1602 retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF); 1599 retval |= setTEOffset(i, (F32)offset_s[i] / (F32)0x7FFF, (F32) offset_t[i] / (F32) 0x7FFF);
1603 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); 1600 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI);
1604 retval |= setTEBumpShinyFullbright(i, bump[i]); 1601 retval |= setTEBumpShinyFullbright(i, bump[i]);