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.cpp97
1 files changed, 89 insertions, 8 deletions
diff --git a/linden/indra/llprimitive/llprimitive.cpp b/linden/indra/llprimitive/llprimitive.cpp
index 9ab44f7..1dfc570 100644
--- a/linden/indra/llprimitive/llprimitive.cpp
+++ b/linden/indra/llprimitive/llprimitive.cpp
@@ -107,6 +107,9 @@ const BOOL FLEXIBLE_OBJECT_DEFAULT_USING_COLLISION_SPHERE = FALSE;
107const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE = FALSE; 107const BOOL FLEXIBLE_OBJECT_DEFAULT_RENDERING_COLLISION_SPHERE = FALSE;
108 108
109 109
110const char *SCULPT_DEFAULT_TEXTURE = "be293869-d0d9-0a69-5989-ad27f1946fd4"; // old inverted texture: "7595d345-a24c-e7ef-f0bd-78793792133e";
111
112
110//=============================================================== 113//===============================================================
111LLPrimitive::LLPrimitive() 114LLPrimitive::LLPrimitive()
112{ 115{
@@ -511,6 +514,18 @@ S32 LLPrimitive::setTEMediaFlags(const U8 te, const U8 media_flags)
511 return mTextureList[te].setMediaFlags( media_flags ); 514 return mTextureList[te].setMediaFlags( media_flags );
512} 515}
513 516
517S32 LLPrimitive::setTEGlow(const U8 te, const F32 glow)
518{
519 // if we're asking for a non-existent face, return null
520 if (te >= mNumTEs)
521 {
522 llwarns << "setting non-existent te " << te << llendl
523 return 0;
524 }
525
526 return mTextureList[te].setGlow( glow );
527}
528
514 529
515LLPCode LLPrimitive::legacyToPCode(const U8 legacy) 530LLPCode LLPrimitive::legacyToPCode(const U8 legacy)
516{ 531{
@@ -1292,7 +1307,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1292 S16 image_rot[MAX_TES]; 1307 S16 image_rot[MAX_TES];
1293 U8 bump[MAX_TES]; 1308 U8 bump[MAX_TES];
1294 U8 media_flags[MAX_TES]; 1309 U8 media_flags[MAX_TES];
1295 1310 U8 glow[MAX_TES];
1311
1296 const U32 MAX_TE_BUFFER = 4096; 1312 const U32 MAX_TE_BUFFER = 4096;
1297 U8 packed_buffer[MAX_TE_BUFFER]; 1313 U8 packed_buffer[MAX_TE_BUFFER];
1298 U8 *cur_ptr = packed_buffer; 1314 U8 *cur_ptr = packed_buffer;
@@ -1328,7 +1344,7 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1328 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); 1344 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF));
1329 bump[face_index] = te->getBumpShinyFullbright(); 1345 bump[face_index] = te->getBumpShinyFullbright();
1330 media_flags[face_index] = te->getMediaTexGen(); 1346 media_flags[face_index] = te->getMediaTexGen();
1331// llinfos << "BUMP pack [" << (S32)face_index << "]=" << (S32) bump[face_index] << llendl; 1347 glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
1332 } 1348 }
1333 1349
1334 cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); 1350 cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID);
@@ -1348,6 +1364,8 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const
1348 cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8); 1364 cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8);
1349 *cur_ptr++ = 0; 1365 *cur_ptr++ = 0;
1350 cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); 1366 cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8);
1367 *cur_ptr++ = 0;
1368 cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8);
1351 } 1369 }
1352 mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer)); 1370 mesgsys->addBinaryDataFast(_PREHASH_TextureEntry, packed_buffer, (S32)(cur_ptr - packed_buffer));
1353 1371
@@ -1368,7 +1386,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1368 S16 image_rot[MAX_TES]; 1386 S16 image_rot[MAX_TES];
1369 U8 bump[MAX_TES]; 1387 U8 bump[MAX_TES];
1370 U8 media_flags[MAX_TES]; 1388 U8 media_flags[MAX_TES];
1371 1389 U8 glow[MAX_TES];
1390
1372 const U32 MAX_TE_BUFFER = 4096; 1391 const U32 MAX_TE_BUFFER = 4096;
1373 U8 packed_buffer[MAX_TE_BUFFER]; 1392 U8 packed_buffer[MAX_TE_BUFFER];
1374 U8 *cur_ptr = packed_buffer; 1393 U8 *cur_ptr = packed_buffer;
@@ -1404,8 +1423,7 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1404 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF)); 1423 image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * (F32)0x7FFF));
1405 bump[face_index] = te->getBumpShinyFullbright(); 1424 bump[face_index] = te->getBumpShinyFullbright();
1406 media_flags[face_index] = te->getMediaTexGen(); 1425 media_flags[face_index] = te->getMediaTexGen();
1407 1426 glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF));
1408// llinfos << "BUMP pack (Datapacker) [" << (S32)face_index << "]=" << (S32) bump[face_index] << llendl;
1409 } 1427 }
1410 1428
1411 cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID); 1429 cur_ptr += packTEField(cur_ptr, (U8 *)image_ids, sizeof(LLUUID),last_face_index, MVT_LLUUID);
@@ -1425,6 +1443,8 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const
1425 cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8); 1443 cur_ptr += packTEField(cur_ptr, (U8 *)bump, 1 ,last_face_index, MVT_U8);
1426 *cur_ptr++ = 0; 1444 *cur_ptr++ = 0;
1427 cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8); 1445 cur_ptr += packTEField(cur_ptr, (U8 *)media_flags, 1 ,last_face_index, MVT_U8);
1446 *cur_ptr++ = 0;
1447 cur_ptr += packTEField(cur_ptr, (U8 *)glow, 1 ,last_face_index, MVT_U8);
1428 } 1448 }
1429 1449
1430 dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry"); 1450 dp.packBinaryData(packed_buffer, (S32)(cur_ptr - packed_buffer), "TextureEntry");
@@ -1453,7 +1473,8 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1453 S16 image_rot[MAX_TES]; 1473 S16 image_rot[MAX_TES];
1454 U8 bump[MAX_TES]; 1474 U8 bump[MAX_TES];
1455 U8 media_flags[MAX_TES]; 1475 U8 media_flags[MAX_TES];
1456 1476 U8 glow[MAX_TES];
1477
1457 const U32 MAX_TE_BUFFER = 4096; 1478 const U32 MAX_TE_BUFFER = 4096;
1458 U8 packed_buffer[MAX_TE_BUFFER]; 1479 U8 packed_buffer[MAX_TE_BUFFER];
1459 U8 *cur_ptr = packed_buffer; 1480 U8 *cur_ptr = packed_buffer;
@@ -1503,7 +1524,9 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1503 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); 1524 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8);
1504 cur_ptr++; 1525 cur_ptr++;
1505 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); 1526 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8);
1506 1527 cur_ptr++;
1528 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8);
1529
1507 LLColor4 color; 1530 LLColor4 color;
1508 LLColor4U coloru; 1531 LLColor4U coloru;
1509 for (U32 i = 0; i < face_count; i++) 1532 for (U32 i = 0; i < face_count; i++)
@@ -1514,6 +1537,7 @@ S32 LLPrimitive::unpackTEMessage(LLMessageSystem *mesgsys, char *block_name, con
1514 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); 1537 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI);
1515 retval |= setTEBumpShinyFullbright(i, bump[i]); 1538 retval |= setTEBumpShinyFullbright(i, bump[i]);
1516 retval |= setTEMediaTexGen(i, media_flags[i]); 1539 retval |= setTEMediaTexGen(i, media_flags[i]);
1540 retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF);
1517 coloru = LLColor4U(colors + 4*i); 1541 coloru = LLColor4U(colors + 4*i);
1518 1542
1519 // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) 1543 // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f)
@@ -1548,6 +1572,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1548 S16 image_rot[MAX_TES]; 1572 S16 image_rot[MAX_TES];
1549 U8 bump[MAX_TES]; 1573 U8 bump[MAX_TES];
1550 U8 media_flags[MAX_TES]; 1574 U8 media_flags[MAX_TES];
1575 U8 glow[MAX_TES];
1551 1576
1552 const U32 MAX_TE_BUFFER = 4096; 1577 const U32 MAX_TE_BUFFER = 4096;
1553 U8 packed_buffer[MAX_TE_BUFFER]; 1578 U8 packed_buffer[MAX_TE_BUFFER];
@@ -1588,10 +1613,11 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1588 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8); 1613 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)bump, 1, face_count, MVT_U8);
1589 cur_ptr++; 1614 cur_ptr++;
1590 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8); 1615 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)media_flags, 1, face_count, MVT_U8);
1616 cur_ptr++;
1617 cur_ptr += unpackTEField(cur_ptr, packed_buffer+size, (U8 *)glow, 1, face_count, MVT_U8);
1591 1618
1592 for (i = 0; i < face_count; i++) 1619 for (i = 0; i < face_count; i++)
1593 { 1620 {
1594// llinfos << "BUMP unpack (Datapacker) [" << i << "]=" << S32(bump[i]) <<llendl;
1595 memcpy(image_ids[i].mData,&image_data[i*16],16); /* Flawfinder: ignore */ 1621 memcpy(image_ids[i].mData,&image_data[i*16],16); /* Flawfinder: ignore */
1596 } 1622 }
1597 1623
@@ -1605,6 +1631,7 @@ S32 LLPrimitive::unpackTEMessage(LLDataPacker &dp)
1605 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI); 1631 retval |= setTERotation(i, ((F32)image_rot[i]/ (F32)0x7FFF) * F_TWO_PI);
1606 retval |= setTEBumpShinyFullbright(i, bump[i]); 1632 retval |= setTEBumpShinyFullbright(i, bump[i]);
1607 retval |= setTEMediaTexGen(i, media_flags[i]); 1633 retval |= setTEMediaTexGen(i, media_flags[i]);
1634 retval |= setTEGlow(i, (F32)glow[i] / (F32)0xFF);
1608 coloru = LLColor4U(colors + 4*i); 1635 coloru = LLColor4U(colors + 4*i);
1609 1636
1610 // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f) 1637 // Note: This is an optimization to send common colors (1.f, 1.f, 1.f, 1.f)
@@ -1641,6 +1668,8 @@ BOOL LLNetworkData::isValid(U16 param_type, U32 size)
1641 return (size == 16); 1668 return (size == 16);
1642 case PARAMS_LIGHT: 1669 case PARAMS_LIGHT:
1643 return (size == 16); 1670 return (size == 16);
1671 case PARAMS_SCULPT:
1672 return (size == 17);
1644 } 1673 }
1645 1674
1646 return FALSE; 1675 return FALSE;
@@ -1796,3 +1825,55 @@ void LLFlexibleObjectData::copy(const LLNetworkData& data)
1796 //mUsingCollisionSphere = flex_data->mUsingCollisionSphere; 1825 //mUsingCollisionSphere = flex_data->mUsingCollisionSphere;
1797 //mRenderingCollisionSphere = flex_data->mRenderingCollisionSphere; 1826 //mRenderingCollisionSphere = flex_data->mRenderingCollisionSphere;
1798} 1827}
1828
1829
1830//============================================================================
1831
1832LLSculptParams::LLSculptParams()
1833{
1834 mType = PARAMS_SCULPT;
1835 mSculptTexture.set(SCULPT_DEFAULT_TEXTURE);
1836 mSculptType = LL_SCULPT_TYPE_SPHERE;
1837}
1838
1839BOOL LLSculptParams::pack(LLDataPacker &dp) const
1840{
1841 dp.packUUID(mSculptTexture, "texture");
1842 dp.packU8(mSculptType, "type");
1843
1844 return TRUE;
1845}
1846
1847BOOL LLSculptParams::unpack(LLDataPacker &dp)
1848{
1849 dp.unpackUUID(mSculptTexture, "texture");
1850 dp.unpackU8(mSculptType, "type");
1851
1852 return TRUE;
1853}
1854
1855bool LLSculptParams::operator==(const LLNetworkData& data) const
1856{
1857 if (data.mType != PARAMS_SCULPT)
1858 {
1859 return false;
1860 }
1861
1862 const LLSculptParams *param = (const LLSculptParams*)&data;
1863 if ( (param->mSculptTexture != mSculptTexture) ||
1864 (param->mSculptType != mSculptType) )
1865
1866 {
1867 return false;
1868 }
1869
1870 return true;
1871}
1872
1873void LLSculptParams::copy(const LLNetworkData& data)
1874{
1875 const LLSculptParams *param = (LLSculptParams*)&data;
1876 mSculptTexture = param->mSculptTexture;
1877 mSculptType = param->mSculptType;
1878}
1879