diff options
Diffstat (limited to 'linden/indra/newview/llviewerobject.cpp')
-rw-r--r-- | linden/indra/newview/llviewerobject.cpp | 339 |
1 files changed, 259 insertions, 80 deletions
diff --git a/linden/indra/newview/llviewerobject.cpp b/linden/indra/newview/llviewerobject.cpp index a989c9d..c560ced 100644 --- a/linden/indra/newview/llviewerobject.cpp +++ b/linden/indra/newview/llviewerobject.cpp | |||
@@ -96,6 +96,7 @@ | |||
96 | #include "pipeline.h" | 96 | #include "pipeline.h" |
97 | #include "llviewernetwork.h" | 97 | #include "llviewernetwork.h" |
98 | #include "llvowlsky.h" | 98 | #include "llvowlsky.h" |
99 | #include "llmanip.h" | ||
99 | 100 | ||
100 | //#define DEBUG_UPDATE_TYPE | 101 | //#define DEBUG_UPDATE_TYPE |
101 | 102 | ||
@@ -402,13 +403,10 @@ void LLViewerObject::dump() const | |||
402 | mNameValuePairs[key]->printNameValue(buffer); | 403 | mNameValuePairs[key]->printNameValue(buffer); |
403 | llinfos << buffer << llendl; | 404 | llinfos << buffer << llendl; |
404 | } | 405 | } |
405 | 406 | for (child_list_t::iterator iter = mChildList.begin(); | |
406 | S32 i; | 407 | iter != mChildList.end(); iter++) |
407 | |||
408 | LLViewerObject *child; | ||
409 | for (i = 0; i < mChildList.size(); i++) | ||
410 | { | 408 | { |
411 | child = mChildList[i]; | 409 | LLViewerObject* child = *iter; |
412 | llinfos << " child " << child->getID() << llendl; | 410 | llinfos << " child " << child->getID() << llendl; |
413 | } | 411 | } |
414 | */ | 412 | */ |
@@ -467,7 +465,7 @@ void LLViewerObject::setNameValueList(const std::string& name_value_list) | |||
467 | if (end > start) | 465 | if (end > start) |
468 | { | 466 | { |
469 | std::string tok = name_value_list.substr(start, end - start); | 467 | std::string tok = name_value_list.substr(start, end - start); |
470 | addNVPair(tok.c_str()); | 468 | addNVPair(tok); |
471 | } | 469 | } |
472 | start = end+1; | 470 | start = end+1; |
473 | } | 471 | } |
@@ -555,20 +553,16 @@ void LLViewerObject::removeChild(LLViewerObject *childp) | |||
555 | } | 553 | } |
556 | } | 554 | } |
557 | 555 | ||
558 | LLViewerObject::child_list_t& LLViewerObject::getChildren() | ||
559 | { | ||
560 | return mChildList; | ||
561 | } | ||
562 | |||
563 | void LLViewerObject::addThisAndAllChildren(LLDynamicArray<LLViewerObject*>& objects) | 556 | void LLViewerObject::addThisAndAllChildren(LLDynamicArray<LLViewerObject*>& objects) |
564 | { | 557 | { |
565 | objects.put(this); | 558 | objects.put(this); |
566 | S32 count = mChildList.size(); | 559 | for (child_list_t::iterator iter = mChildList.begin(); |
567 | for(S32 i = 0; i < count; i++) | 560 | iter != mChildList.end(); iter++) |
568 | { | 561 | { |
569 | if (!mChildList[i]->isAvatar()) | 562 | LLViewerObject* child = *iter; |
563 | if (!child->isAvatar()) | ||
570 | { | 564 | { |
571 | (mChildList[i])->addThisAndAllChildren(objects); | 565 | child->addThisAndAllChildren(objects); |
572 | } | 566 | } |
573 | } | 567 | } |
574 | } | 568 | } |
@@ -581,24 +575,25 @@ void LLViewerObject::addThisAndNonJointChildren(LLDynamicArray<LLViewerObject*>& | |||
581 | { | 575 | { |
582 | return; | 576 | return; |
583 | } | 577 | } |
584 | S32 count = mChildList.size(); | 578 | for (child_list_t::iterator iter = mChildList.begin(); |
585 | for(S32 i = 0; i < count; i++) | 579 | iter != mChildList.end(); iter++) |
586 | { | 580 | { |
587 | if ( (!mChildList[i]->isAvatar()) | 581 | LLViewerObject* child = *iter; |
588 | && (!mChildList[i]->isJointChild())) | 582 | if ( (!child->isAvatar()) && (!child->isJointChild())) |
589 | { | 583 | { |
590 | (mChildList[i])->addThisAndNonJointChildren(objects); | 584 | child->addThisAndNonJointChildren(objects); |
591 | } | 585 | } |
592 | } | 586 | } |
593 | } | 587 | } |
594 | 588 | ||
595 | BOOL LLViewerObject::isChild(LLViewerObject *childp) const | 589 | BOOL LLViewerObject::isChild(LLViewerObject *childp) const |
596 | { | 590 | { |
597 | S32 count = mChildList.size(); | 591 | for (child_list_t::const_iterator iter = mChildList.begin(); |
598 | for(S32 i = 0; i < count; i++) | 592 | iter != mChildList.end(); iter++) |
599 | { | 593 | { |
600 | const LLViewerObject *testChildp = &(*mChildList[i]); | 594 | LLViewerObject* testchild = *iter; |
601 | if (testChildp == childp) return TRUE; | 595 | if (testchild == childp) |
596 | return TRUE; | ||
602 | } | 597 | } |
603 | return FALSE; | 598 | return FALSE; |
604 | } | 599 | } |
@@ -607,11 +602,11 @@ BOOL LLViewerObject::isChild(LLViewerObject *childp) const | |||
607 | // returns TRUE if at least one avatar is sitting on this object | 602 | // returns TRUE if at least one avatar is sitting on this object |
608 | BOOL LLViewerObject::isSeat() const | 603 | BOOL LLViewerObject::isSeat() const |
609 | { | 604 | { |
610 | S32 count = mChildList.size(); | 605 | for (child_list_t::const_iterator iter = mChildList.begin(); |
611 | for(S32 i = 0; i < count; i++) | 606 | iter != mChildList.end(); iter++) |
612 | { | 607 | { |
613 | const LLViewerObject *childp = &(*mChildList[i]); | 608 | LLViewerObject* child = *iter; |
614 | if (childp->isAvatar()) | 609 | if (child->isAvatar()) |
615 | { | 610 | { |
616 | return TRUE; | 611 | return TRUE; |
617 | } | 612 | } |
@@ -955,12 +950,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
955 | S32 nv_size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_NameValue); | 950 | S32 nv_size = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_NameValue); |
956 | if (nv_size > 0) | 951 | if (nv_size > 0) |
957 | { | 952 | { |
958 | char* name_value_list = new char[nv_size]; | 953 | std::string name_value_list; |
959 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_NameValue, nv_size, name_value_list, block_num); | 954 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_NameValue, name_value_list, block_num); |
960 | |||
961 | setNameValueList(name_value_list); | 955 | setNameValueList(name_value_list); |
962 | |||
963 | delete [] name_value_list; | ||
964 | } | 956 | } |
965 | 957 | ||
966 | // Clear out any existing generic data | 958 | // Clear out any existing generic data |
@@ -996,8 +988,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
996 | mText->setOnHUDAttachment(isHUDAttachment()); | 988 | mText->setOnHUDAttachment(isHUDAttachment()); |
997 | } | 989 | } |
998 | 990 | ||
999 | char temp_string[256]; /* Flawfinder: ignore */ // not MAX_STRING, must hold 255 chars + \0 | 991 | std::string temp_string; |
1000 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, 256, temp_string, block_num ); | 992 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_Text, temp_string, block_num ); |
1001 | 993 | ||
1002 | LLColor4U coloru; | 994 | LLColor4U coloru; |
1003 | mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); | 995 | mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_TextColor, coloru.mV, 4, block_num); |
@@ -1019,13 +1011,13 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
1019 | mText = NULL; | 1011 | mText = NULL; |
1020 | } | 1012 | } |
1021 | 1013 | ||
1022 | char media_url[MAX_STRING+1]; /* Flawfinder: ignore */ | 1014 | std::string media_url; |
1023 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_MediaURL, MAX_STRING+1, media_url, block_num); | 1015 | mesgsys->getStringFast(_PREHASH_ObjectData, _PREHASH_MediaURL, media_url, block_num); |
1024 | //if (media_url[0]) | 1016 | //if (!media_url.empty()) |
1025 | //{ | 1017 | //{ |
1026 | // llinfos << "WEBONPRIM media_url " << media_url << llendl; | 1018 | // llinfos << "WEBONPRIM media_url " << media_url << llendl; |
1027 | //} | 1019 | //} |
1028 | if (!mMedia && media_url[0] != '\0') | 1020 | if (!mMedia && !media_url.empty()) |
1029 | { | 1021 | { |
1030 | retval |= MEDIA_URL_ADDED; | 1022 | retval |= MEDIA_URL_ADDED; |
1031 | mMedia = new LLViewerObjectMedia; | 1023 | mMedia = new LLViewerObjectMedia; |
@@ -1035,7 +1027,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
1035 | } | 1027 | } |
1036 | else if (mMedia) | 1028 | else if (mMedia) |
1037 | { | 1029 | { |
1038 | if (media_url[0] == '\0') | 1030 | if (media_url.empty()) |
1039 | { | 1031 | { |
1040 | retval |= MEDIA_URL_REMOVED; | 1032 | retval |= MEDIA_URL_REMOVED; |
1041 | delete mMedia; | 1033 | delete mMedia; |
@@ -1514,7 +1506,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
1514 | std::string name_value_list; | 1506 | std::string name_value_list; |
1515 | dp->unpackString(name_value_list, "NV"); | 1507 | dp->unpackString(name_value_list, "NV"); |
1516 | 1508 | ||
1517 | setNameValueList(name_value_list.c_str()); | 1509 | setNameValueList(name_value_list); |
1518 | } | 1510 | } |
1519 | 1511 | ||
1520 | mTotalCRC = crc; | 1512 | mTotalCRC = crc; |
@@ -1847,7 +1839,19 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
1847 | ||(this_update_precision > mBestUpdatePrecision)))) | 1839 | ||(this_update_precision > mBestUpdatePrecision)))) |
1848 | { | 1840 | { |
1849 | mBestUpdatePrecision = this_update_precision; | 1841 | mBestUpdatePrecision = this_update_precision; |
1850 | setPositionParent(new_pos_parent); | 1842 | |
1843 | LLVector3 diff = new_pos_parent - test_pos_parent ; | ||
1844 | F32 mag_sqr = diff.magVecSquared() ; | ||
1845 | if(llfinite(mag_sqr)) | ||
1846 | { | ||
1847 | setPositionParent(new_pos_parent); | ||
1848 | } | ||
1849 | else | ||
1850 | { | ||
1851 | llwarns << "Can not move the object/avatar to an infinite location!" << llendl ; | ||
1852 | |||
1853 | retval |= INVALID_UPDATE ; | ||
1854 | } | ||
1851 | 1855 | ||
1852 | if (mParent && ((LLViewerObject*)mParent)->isAvatar()) | 1856 | if (mParent && ((LLViewerObject*)mParent)->isAvatar()) |
1853 | { | 1857 | { |
@@ -1918,11 +1922,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, | |||
1918 | // Additionally, if any child is selected, need to update the dialogs and selection | 1922 | // Additionally, if any child is selected, need to update the dialogs and selection |
1919 | // center. | 1923 | // center. |
1920 | BOOL needs_refresh = mUserSelected; | 1924 | BOOL needs_refresh = mUserSelected; |
1921 | LLViewerObject *childp; | 1925 | for (child_list_t::iterator iter = mChildList.begin(); |
1922 | for (U32 i = 0; i < mChildList.size(); i++) | 1926 | iter != mChildList.end(); iter++) |
1923 | { | 1927 | { |
1924 | childp = mChildList[i]; | 1928 | LLViewerObject* child = *iter; |
1925 | needs_refresh = needs_refresh || childp->mUserSelected; | 1929 | needs_refresh = needs_refresh || child->mUserSelected; |
1926 | } | 1930 | } |
1927 | 1931 | ||
1928 | if (needs_refresh) | 1932 | if (needs_refresh) |
@@ -2148,7 +2152,7 @@ void LLViewerObject::deleteInventoryItem(const LLUUID& item_id) | |||
2148 | } | 2152 | } |
2149 | 2153 | ||
2150 | void LLViewerObject::doUpdateInventory( | 2154 | void LLViewerObject::doUpdateInventory( |
2151 | LLViewerInventoryItem* item, | 2155 | LLPointer<LLViewerInventoryItem>& item, |
2152 | U8 key, | 2156 | U8 key, |
2153 | bool is_new) | 2157 | bool is_new) |
2154 | { | 2158 | { |
@@ -2220,7 +2224,8 @@ void LLViewerObject::doUpdateInventory( | |||
2220 | --mInventorySerialNum; | 2224 | --mInventorySerialNum; |
2221 | } | 2225 | } |
2222 | } | 2226 | } |
2223 | LLViewerInventoryItem* new_item = new LLViewerInventoryItem(item); | 2227 | LLViewerInventoryItem* oldItem = item; |
2228 | LLViewerInventoryItem* new_item = new LLViewerInventoryItem(oldItem); | ||
2224 | new_item->setPermissions(perm); | 2229 | new_item->setPermissions(perm); |
2225 | mInventory->push_front(new_item); | 2230 | mInventory->push_front(new_item); |
2226 | doInventoryCallback(); | 2231 | doInventoryCallback(); |
@@ -2386,7 +2391,7 @@ void LLViewerObject::fetchInventoryFromServer() | |||
2386 | struct LLFilenameAndTask | 2391 | struct LLFilenameAndTask |
2387 | { | 2392 | { |
2388 | LLUUID mTaskID; | 2393 | LLUUID mTaskID; |
2389 | char mFilename[MAX_STRING]; /* Flawfinder: ignore */ // Just the filename, not the path | 2394 | std::string mFilename; |
2390 | #ifdef _DEBUG | 2395 | #ifdef _DEBUG |
2391 | static S32 sCount; | 2396 | static S32 sCount; |
2392 | LLFilenameAndTask() | 2397 | LLFilenameAndTask() |
@@ -2427,8 +2432,8 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data) | |||
2427 | msg->getS16Fast(_PREHASH_InventoryData, _PREHASH_Serial, object->mInventorySerialNum); | 2432 | msg->getS16Fast(_PREHASH_InventoryData, _PREHASH_Serial, object->mInventorySerialNum); |
2428 | LLFilenameAndTask* ft = new LLFilenameAndTask; | 2433 | LLFilenameAndTask* ft = new LLFilenameAndTask; |
2429 | ft->mTaskID = task_id; | 2434 | ft->mTaskID = task_id; |
2430 | msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, MAX_STRING, ft->mFilename); | 2435 | msg->getStringFast(_PREHASH_InventoryData, _PREHASH_Filename, ft->mFilename); |
2431 | if(!ft->mFilename[0]) | 2436 | if(ft->mFilename.empty()) |
2432 | { | 2437 | { |
2433 | lldebugs << "Task has no inventory" << llendl; | 2438 | lldebugs << "Task has no inventory" << llendl; |
2434 | // mock up some inventory to make a drop target. | 2439 | // mock up some inventory to make a drop target. |
@@ -2443,13 +2448,13 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data) | |||
2443 | LLPointer<LLInventoryObject> obj; | 2448 | LLPointer<LLInventoryObject> obj; |
2444 | obj = new LLInventoryObject(object->mID, LLUUID::null, | 2449 | obj = new LLInventoryObject(object->mID, LLUUID::null, |
2445 | LLAssetType::AT_CATEGORY, | 2450 | LLAssetType::AT_CATEGORY, |
2446 | "Contents"); | 2451 | std::string("Contents")); |
2447 | object->mInventory->push_front(obj); | 2452 | object->mInventory->push_front(obj); |
2448 | object->doInventoryCallback(); | 2453 | object->doInventoryCallback(); |
2449 | delete ft; | 2454 | delete ft; |
2450 | return; | 2455 | return; |
2451 | } | 2456 | } |
2452 | gXferManager->requestFile(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ft->mFilename).c_str(), | 2457 | gXferManager->requestFile(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ft->mFilename), |
2453 | ft->mFilename, LL_PATH_CACHE, | 2458 | ft->mFilename, LL_PATH_CACHE, |
2454 | object->mRegionp->getHost(), | 2459 | object->mRegionp->getHost(), |
2455 | TRUE, | 2460 | TRUE, |
@@ -2477,12 +2482,12 @@ void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code, LLExtS | |||
2477 | delete ft; | 2482 | delete ft; |
2478 | } | 2483 | } |
2479 | 2484 | ||
2480 | void LLViewerObject::loadTaskInvFile(const char* filename) | 2485 | void LLViewerObject::loadTaskInvFile(const std::string& filename) |
2481 | { | 2486 | { |
2482 | LLMemType mt(LLMemType::MTYPE_OBJECT); | 2487 | LLMemType mt(LLMemType::MTYPE_OBJECT); |
2483 | 2488 | ||
2484 | std::string filename_and_local_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, filename); | 2489 | std::string filename_and_local_path = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, filename); |
2485 | llifstream ifs(filename_and_local_path.c_str()); | 2490 | llifstream ifs(filename_and_local_path); |
2486 | if(ifs.good()) | 2491 | if(ifs.good()) |
2487 | { | 2492 | { |
2488 | char buffer[MAX_STRING]; /* Flawfinder: ignore */ | 2493 | char buffer[MAX_STRING]; /* Flawfinder: ignore */ |
@@ -2519,7 +2524,7 @@ void LLViewerObject::loadTaskInvFile(const char* filename) | |||
2519 | } | 2524 | } |
2520 | } | 2525 | } |
2521 | ifs.close(); | 2526 | ifs.close(); |
2522 | LLFile::remove(filename_and_local_path.c_str()); | 2527 | LLFile::remove(filename_and_local_path); |
2523 | } | 2528 | } |
2524 | else | 2529 | else |
2525 | { | 2530 | { |
@@ -2611,6 +2616,21 @@ void LLViewerObject::updateInventory( | |||
2611 | doUpdateInventory(task_item, key, is_new); | 2616 | doUpdateInventory(task_item, key, is_new); |
2612 | } | 2617 | } |
2613 | 2618 | ||
2619 | void LLViewerObject::updateInventoryLocal(LLInventoryItem* item, U8 key) | ||
2620 | { | ||
2621 | LLPointer<LLViewerInventoryItem> task_item = | ||
2622 | new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(), | ||
2623 | item->getAssetUUID(), item->getType(), | ||
2624 | item->getInventoryType(), | ||
2625 | item->getName(), item->getDescription(), | ||
2626 | item->getSaleInfo(), item->getFlags(), | ||
2627 | item->getCreationDate()); | ||
2628 | |||
2629 | // do the internal logic | ||
2630 | const bool is_new = false; | ||
2631 | doUpdateInventory(task_item, key, is_new); | ||
2632 | } | ||
2633 | |||
2614 | LLInventoryObject* LLViewerObject::getInventoryObject(const LLUUID& item_id) | 2634 | LLInventoryObject* LLViewerObject::getInventoryObject(const LLUUID& item_id) |
2615 | { | 2635 | { |
2616 | LLInventoryObject* rv = NULL; | 2636 | LLInventoryObject* rv = NULL; |
@@ -2879,13 +2899,20 @@ void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */) | |||
2879 | getTEImage(i)->setBoostLevel(LLViewerImage::BOOST_SELECTED); | 2899 | getTEImage(i)->setBoostLevel(LLViewerImage::BOOST_SELECTED); |
2880 | } | 2900 | } |
2881 | 2901 | ||
2902 | if (isSculpted()) | ||
2903 | { | ||
2904 | LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); | ||
2905 | LLUUID sculpt_id = sculpt_params->getSculptTexture(); | ||
2906 | gImageList.getImage(sculpt_id)->setBoostLevel(LLViewerImage::BOOST_SELECTED); | ||
2907 | } | ||
2908 | |||
2882 | if (boost_children) | 2909 | if (boost_children) |
2883 | { | 2910 | { |
2884 | S32 num_children = mChildList.size(); | 2911 | for (child_list_t::iterator iter = mChildList.begin(); |
2885 | for (i = 0; i < num_children; i++) | 2912 | iter != mChildList.end(); iter++) |
2886 | { | 2913 | { |
2887 | LLViewerObject *childp = mChildList[i]; | 2914 | LLViewerObject* child = *iter; |
2888 | childp->boostTexturePriority(); | 2915 | child->boostTexturePriority(); |
2889 | } | 2916 | } |
2890 | } | 2917 | } |
2891 | } | 2918 | } |
@@ -2970,7 +2997,7 @@ void LLViewerObject::addNVPair(const std::string& data) | |||
2970 | mNameValuePairs[nv->mName] = nv; | 2997 | mNameValuePairs[nv->mName] = nv; |
2971 | } | 2998 | } |
2972 | 2999 | ||
2973 | BOOL LLViewerObject::removeNVPair(const char *name) | 3000 | BOOL LLViewerObject::removeNVPair(const std::string& name) |
2974 | { | 3001 | { |
2975 | char* canonical_name = gNVNameTable.addString(name); | 3002 | char* canonical_name = gNVNameTable.addString(name); |
2976 | 3003 | ||
@@ -2989,7 +3016,7 @@ BOOL LLViewerObject::removeNVPair(const char *name) | |||
2989 | gMessageSystem->addUUIDFast(_PREHASH_ID, mID); | 3016 | gMessageSystem->addUUIDFast(_PREHASH_ID, mID); |
2990 | 3017 | ||
2991 | gMessageSystem->nextBlockFast(_PREHASH_NameValueData); | 3018 | gMessageSystem->nextBlockFast(_PREHASH_NameValueData); |
2992 | gMessageSystem->addStringFast(_PREHASH_NVPair, buffer.c_str()); | 3019 | gMessageSystem->addStringFast(_PREHASH_NVPair, buffer); |
2993 | 3020 | ||
2994 | gMessageSystem->sendReliable( mRegionp->getHost() ); | 3021 | gMessageSystem->sendReliable( mRegionp->getHost() ); |
2995 | */ | 3022 | */ |
@@ -3007,7 +3034,7 @@ BOOL LLViewerObject::removeNVPair(const char *name) | |||
3007 | } | 3034 | } |
3008 | 3035 | ||
3009 | 3036 | ||
3010 | LLNameValue *LLViewerObject::getNVPair(const char *name) const | 3037 | LLNameValue *LLViewerObject::getNVPair(const std::string& name) const |
3011 | { | 3038 | { |
3012 | char *canonical_name; | 3039 | char *canonical_name; |
3013 | 3040 | ||
@@ -3042,7 +3069,7 @@ void LLViewerObject::updatePositionCaches() const | |||
3042 | 3069 | ||
3043 | const LLVector3d LLViewerObject::getPositionGlobal() const | 3070 | const LLVector3d LLViewerObject::getPositionGlobal() const |
3044 | { | 3071 | { |
3045 | LLVector3d position_global = mRegionp->getPosGlobalFromRegion(getPositionRegion());; | 3072 | LLVector3d position_global = mRegionp->getPosGlobalFromRegion(getPositionRegion()); |
3046 | 3073 | ||
3047 | if (isAttachment()) | 3074 | if (isAttachment()) |
3048 | { | 3075 | { |
@@ -3368,6 +3395,19 @@ LLViewerObject* LLViewerObject::getRootEdit() const | |||
3368 | return (LLViewerObject*)root; | 3395 | return (LLViewerObject*)root; |
3369 | } | 3396 | } |
3370 | 3397 | ||
3398 | |||
3399 | BOOL LLViewerObject::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, | ||
3400 | S32 face, | ||
3401 | S32* face_hit, | ||
3402 | LLVector3* intersection, | ||
3403 | LLVector2* tex_coord, | ||
3404 | LLVector3* normal, | ||
3405 | LLVector3* bi_normal) | ||
3406 | { | ||
3407 | return false; | ||
3408 | } | ||
3409 | |||
3410 | |||
3371 | U8 LLViewerObject::getMediaType() const | 3411 | U8 LLViewerObject::getMediaType() const |
3372 | { | 3412 | { |
3373 | if (mMedia) | 3413 | if (mMedia) |
@@ -3394,7 +3434,7 @@ void LLViewerObject::setMediaType(U8 media_type) | |||
3394 | } | 3434 | } |
3395 | } | 3435 | } |
3396 | 3436 | ||
3397 | const LLString& LLViewerObject::getMediaURL() const | 3437 | std::string LLViewerObject::getMediaURL() const |
3398 | { | 3438 | { |
3399 | if (mMedia) | 3439 | if (mMedia) |
3400 | { | 3440 | { |
@@ -3402,11 +3442,11 @@ const LLString& LLViewerObject::getMediaURL() const | |||
3402 | } | 3442 | } |
3403 | else | 3443 | else |
3404 | { | 3444 | { |
3405 | return LLString::null; | 3445 | return std::string(); |
3406 | } | 3446 | } |
3407 | } | 3447 | } |
3408 | 3448 | ||
3409 | void LLViewerObject::setMediaURL(const LLString& media_url) | 3449 | void LLViewerObject::setMediaURL(const std::string& media_url) |
3410 | { | 3450 | { |
3411 | LLMemType mt(LLMemType::MTYPE_OBJECT); | 3451 | LLMemType mt(LLMemType::MTYPE_OBJECT); |
3412 | 3452 | ||
@@ -3970,9 +4010,11 @@ S32 LLViewerObject::countInventoryContents(LLAssetType::EType type) | |||
3970 | void LLViewerObject::setCanSelect(BOOL canSelect) | 4010 | void LLViewerObject::setCanSelect(BOOL canSelect) |
3971 | { | 4011 | { |
3972 | mbCanSelect = canSelect; | 4012 | mbCanSelect = canSelect; |
3973 | for (U32 i = 0; i < mChildList.size(); i++) | 4013 | for (child_list_t::iterator iter = mChildList.begin(); |
4014 | iter != mChildList.end(); iter++) | ||
3974 | { | 4015 | { |
3975 | mChildList[i]->mbCanSelect = canSelect; | 4016 | LLViewerObject* child = *iter; |
4017 | child->mbCanSelect = canSelect; | ||
3976 | } | 4018 | } |
3977 | } | 4019 | } |
3978 | 4020 | ||
@@ -4525,9 +4567,11 @@ void LLViewerObject::setDrawableState(U32 state, BOOL recursive) | |||
4525 | } | 4567 | } |
4526 | if (recursive) | 4568 | if (recursive) |
4527 | { | 4569 | { |
4528 | for (U32 i = 0; i < mChildList.size(); i++) | 4570 | for (child_list_t::iterator iter = mChildList.begin(); |
4571 | iter != mChildList.end(); iter++) | ||
4529 | { | 4572 | { |
4530 | mChildList[i]->setDrawableState(state, recursive); | 4573 | LLViewerObject* child = *iter; |
4574 | child->setDrawableState(state, recursive); | ||
4531 | } | 4575 | } |
4532 | } | 4576 | } |
4533 | } | 4577 | } |
@@ -4540,9 +4584,11 @@ void LLViewerObject::clearDrawableState(U32 state, BOOL recursive) | |||
4540 | } | 4584 | } |
4541 | if (recursive) | 4585 | if (recursive) |
4542 | { | 4586 | { |
4543 | for (U32 i = 0; i < mChildList.size(); i++) | 4587 | for (child_list_t::iterator iter = mChildList.begin(); |
4588 | iter != mChildList.end(); iter++) | ||
4544 | { | 4589 | { |
4545 | mChildList[i]->clearDrawableState(state, recursive); | 4590 | LLViewerObject* child = *iter; |
4591 | child->clearDrawableState(state, recursive); | ||
4546 | } | 4592 | } |
4547 | } | 4593 | } |
4548 | } | 4594 | } |
@@ -4777,7 +4823,7 @@ void LLViewerObject::setRegion(LLViewerRegion *regionp) | |||
4777 | mLatestRecvPacketID = 0; | 4823 | mLatestRecvPacketID = 0; |
4778 | mRegionp = regionp; | 4824 | mRegionp = regionp; |
4779 | 4825 | ||
4780 | for (child_list_t::iterator i = getChildren().begin(); i != getChildren().end(); ++i) | 4826 | for (child_list_t::iterator i = mChildList.begin(); i != mChildList.end(); ++i) |
4781 | { | 4827 | { |
4782 | LLViewerObject* child = *i; | 4828 | LLViewerObject* child = *i; |
4783 | child->setRegion(regionp); | 4829 | child->setRegion(regionp); |
@@ -4839,11 +4885,6 @@ BOOL LLViewerObject::setFlags(U32 flags, BOOL state) | |||
4839 | return setit; | 4885 | return setit; |
4840 | } | 4886 | } |
4841 | 4887 | ||
4842 | BOOL LLViewerObject::lineSegmentIntersect(const LLVector3& start, LLVector3& end) const | ||
4843 | { | ||
4844 | return FALSE; | ||
4845 | } | ||
4846 | |||
4847 | void LLViewerObject::applyAngularVelocity(F32 dt) | 4888 | void LLViewerObject::applyAngularVelocity(F32 dt) |
4848 | { | 4889 | { |
4849 | //do target omega here | 4890 | //do target omega here |
@@ -4916,3 +4957,141 @@ void LLStaticViewerObject::updateDrawable(BOOL force_damped) | |||
4916 | } | 4957 | } |
4917 | clearChanged(SHIFTED); | 4958 | clearChanged(SHIFTED); |
4918 | } | 4959 | } |
4960 | |||
4961 | void LLViewerObject::saveUnselectedChildrenPosition(std::vector<LLVector3>& positions) | ||
4962 | { | ||
4963 | if(mChildList.empty() || !positions.empty()) | ||
4964 | { | ||
4965 | return ; | ||
4966 | } | ||
4967 | |||
4968 | for (LLViewerObject::child_list_t::const_iterator iter = mChildList.begin(); | ||
4969 | iter != mChildList.end(); iter++) | ||
4970 | { | ||
4971 | LLViewerObject* childp = *iter; | ||
4972 | if (!childp->isSelected() && childp->mDrawable.notNull()) | ||
4973 | { | ||
4974 | positions.push_back(childp->getPositionEdit()); | ||
4975 | } | ||
4976 | } | ||
4977 | |||
4978 | return ; | ||
4979 | } | ||
4980 | |||
4981 | void LLViewerObject::saveUnselectedChildrenRotation(std::vector<LLQuaternion>& rotations) | ||
4982 | { | ||
4983 | if(mChildList.empty()) | ||
4984 | { | ||
4985 | return ; | ||
4986 | } | ||
4987 | |||
4988 | for (LLViewerObject::child_list_t::const_iterator iter = mChildList.begin(); | ||
4989 | iter != mChildList.end(); iter++) | ||
4990 | { | ||
4991 | LLViewerObject* childp = *iter; | ||
4992 | if (!childp->isSelected() && childp->mDrawable.notNull()) | ||
4993 | { | ||
4994 | rotations.push_back(childp->getRotationEdit()); | ||
4995 | } | ||
4996 | } | ||
4997 | |||
4998 | return ; | ||
4999 | } | ||
5000 | |||
5001 | //counter-rotation | ||
5002 | void LLViewerObject::resetChildrenRotationAndPosition(const std::vector<LLQuaternion>& rotations, | ||
5003 | const std::vector<LLVector3>& positions) | ||
5004 | { | ||
5005 | if(mChildList.empty()) | ||
5006 | { | ||
5007 | return ; | ||
5008 | } | ||
5009 | |||
5010 | S32 index = 0 ; | ||
5011 | LLQuaternion inv_rotation = ~getRotationEdit() ; | ||
5012 | LLVector3 offset = getPositionEdit() ; | ||
5013 | for (LLViewerObject::child_list_t::const_iterator iter = mChildList.begin(); | ||
5014 | iter != mChildList.end(); iter++) | ||
5015 | { | ||
5016 | LLViewerObject* childp = *iter; | ||
5017 | if (!childp->isSelected() && childp->mDrawable.notNull()) | ||
5018 | { | ||
5019 | if (childp->getPCode() != LL_PCODE_LEGACY_AVATAR) | ||
5020 | { | ||
5021 | childp->setRotation(rotations[index] * inv_rotation); | ||
5022 | childp->setPosition((positions[index] - offset) * inv_rotation); | ||
5023 | LLManip::rebuild(childp); | ||
5024 | } | ||
5025 | else //avatar | ||
5026 | { | ||
5027 | LLVector3 reset_pos = (positions[index] - offset) * inv_rotation ; | ||
5028 | LLQuaternion reset_rot = rotations[index] * inv_rotation ; | ||
5029 | |||
5030 | ((LLVOAvatar*)childp)->mDrawable->mXform.setPosition(reset_pos); | ||
5031 | ((LLVOAvatar*)childp)->mDrawable->mXform.setRotation(reset_rot) ; | ||
5032 | |||
5033 | ((LLVOAvatar*)childp)->mDrawable->getVObj()->setPosition(reset_pos, TRUE); | ||
5034 | ((LLVOAvatar*)childp)->mDrawable->getVObj()->setRotation(reset_rot, TRUE) ; | ||
5035 | |||
5036 | LLManip::rebuild(childp); | ||
5037 | } | ||
5038 | index++; | ||
5039 | } | ||
5040 | } | ||
5041 | |||
5042 | return ; | ||
5043 | } | ||
5044 | |||
5045 | //counter-translation | ||
5046 | void LLViewerObject::resetChildrenPosition(const LLVector3& offset, BOOL simplified) | ||
5047 | { | ||
5048 | if(mChildList.empty()) | ||
5049 | { | ||
5050 | return ; | ||
5051 | } | ||
5052 | |||
5053 | LLVector3 child_offset; | ||
5054 | if(simplified) //translation only, rotation matrix does not change | ||
5055 | { | ||
5056 | child_offset = offset * ~getRotation(); | ||
5057 | } | ||
5058 | else //rotation matrix might change too. | ||
5059 | { | ||
5060 | if (isAttachment() && mDrawable.notNull()) | ||
5061 | { | ||
5062 | LLXform* attachment_point_xform = mDrawable->getXform()->getParent(); | ||
5063 | LLQuaternion parent_rotation = getRotation() * attachment_point_xform->getWorldRotation(); | ||
5064 | child_offset = offset * ~parent_rotation; | ||
5065 | } | ||
5066 | else | ||
5067 | { | ||
5068 | child_offset = offset * ~getRenderRotation(); | ||
5069 | } | ||
5070 | } | ||
5071 | |||
5072 | for (LLViewerObject::child_list_t::const_iterator iter = mChildList.begin(); | ||
5073 | iter != mChildList.end(); iter++) | ||
5074 | { | ||
5075 | LLViewerObject* childp = *iter; | ||
5076 | if (!childp->isSelected() && childp->mDrawable.notNull()) | ||
5077 | { | ||
5078 | if (childp->getPCode() != LL_PCODE_LEGACY_AVATAR) | ||
5079 | { | ||
5080 | childp->setPosition(childp->getPosition() + child_offset); | ||
5081 | LLManip::rebuild(childp); | ||
5082 | } | ||
5083 | else //avatar | ||
5084 | { | ||
5085 | LLVector3 reset_pos = ((LLVOAvatar*)childp)->mDrawable->mXform.getPosition() + child_offset ; | ||
5086 | |||
5087 | ((LLVOAvatar*)childp)->mDrawable->mXform.setPosition(reset_pos); | ||
5088 | ((LLVOAvatar*)childp)->mDrawable->getVObj()->setPosition(reset_pos); | ||
5089 | |||
5090 | LLManip::rebuild(childp); | ||
5091 | } | ||
5092 | } | ||
5093 | } | ||
5094 | |||
5095 | return ; | ||
5096 | } | ||
5097 | |||