diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llwearable.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llwearable.cpp | 125 |
1 files changed, 49 insertions, 76 deletions
diff --git a/linden/indra/newview/llwearable.cpp b/linden/indra/newview/llwearable.cpp index 0cadd5c..9365eeb 100644 --- a/linden/indra/newview/llwearable.cpp +++ b/linden/indra/newview/llwearable.cpp | |||
@@ -132,8 +132,6 @@ LLWearable::LLWearable(const LLAssetID& asset_id) : | |||
132 | 132 | ||
133 | LLWearable::~LLWearable() | 133 | LLWearable::~LLWearable() |
134 | { | 134 | { |
135 | mVisualParamMap.deleteAllData(); | ||
136 | mTEMap.deleteAllData(); | ||
137 | } | 135 | } |
138 | 136 | ||
139 | 137 | ||
@@ -227,35 +225,37 @@ BOOL LLWearable::exportFile( FILE* file ) | |||
227 | } | 225 | } |
228 | 226 | ||
229 | // parameters | 227 | // parameters |
230 | S32 num_parameters = mVisualParamMap.getLength(); | 228 | S32 num_parameters = mVisualParamMap.size(); |
231 | if( fprintf( file, "parameters %d\n", num_parameters ) < 0 ) | 229 | if( fprintf( file, "parameters %d\n", num_parameters ) < 0 ) |
232 | { | 230 | { |
233 | return FALSE; | 231 | return FALSE; |
234 | } | 232 | } |
235 | 233 | ||
236 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | 234 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ |
237 | for( F32* param_weightp = mVisualParamMap.getFirstData(); param_weightp; param_weightp = mVisualParamMap.getNextData() ) | 235 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
236 | iter != mVisualParamMap.end(); ++iter) | ||
238 | { | 237 | { |
239 | S32 param_id = mVisualParamMap.getCurrentKeyWithoutIncrement(); | 238 | S32 param_id = iter->first; |
240 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( *param_weightp, s ) ) < 0 ) | 239 | F32 param_weight = iter->second; |
240 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ) < 0 ) | ||
241 | { | 241 | { |
242 | return FALSE; | 242 | return FALSE; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | // texture entries | 246 | // texture entries |
247 | S32 num_textures = mTEMap.getLength(); | 247 | S32 num_textures = mTEMap.size(); |
248 | if( fprintf( file, "textures %d\n", num_textures ) < 0 ) | 248 | if( fprintf( file, "textures %d\n", num_textures ) < 0 ) |
249 | { | 249 | { |
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | for( LLUUID* image_id = mTEMap.getFirstData(); image_id; image_id = mTEMap.getNextData() ) | 253 | for (te_map_t::iterator iter = mTEMap.begin(); |
254 | iter != mTEMap.end(); ++iter) | ||
254 | { | 255 | { |
255 | S32 te = mTEMap.getCurrentKeyWithoutIncrement(); | 256 | S32 te = iter->first; |
256 | char image_id_string[UUID_STR_LENGTH]; /* Flawfinder: ignore */ | 257 | LLUUID& image_id = iter->second; |
257 | image_id->toString( image_id_string ); | 258 | if( fprintf( file, "%d %s\n", te, image_id.asString().c_str()) < 0 ) |
258 | if( fprintf( file, "%d %s\n", te, image_id_string) < 0 ) | ||
259 | { | 259 | { |
260 | return FALSE; | 260 | return FALSE; |
261 | } | 261 | } |
@@ -418,7 +418,7 @@ BOOL LLWearable::importFile( FILE* file ) | |||
418 | llwarns << "Bad Wearable asset: bad parameter, #" << i << llendl; | 418 | llwarns << "Bad Wearable asset: bad parameter, #" << i << llendl; |
419 | return FALSE; | 419 | return FALSE; |
420 | } | 420 | } |
421 | mVisualParamMap.addData( param_id, new F32(param_weight) ); | 421 | mVisualParamMap[param_id] = param_weight; |
422 | } | 422 | } |
423 | 423 | ||
424 | // textures header | 424 | // textures header |
@@ -450,7 +450,7 @@ BOOL LLWearable::importFile( FILE* file ) | |||
450 | return FALSE; | 450 | return FALSE; |
451 | } | 451 | } |
452 | 452 | ||
453 | mTEMap.addData( te, new LLUUID( text_buffer ) ); | 453 | mTEMap[te] = LLUUID(text_buffer ); |
454 | } | 454 | } |
455 | 455 | ||
456 | return TRUE; | 456 | return TRUE; |
@@ -488,13 +488,13 @@ BOOL LLWearable::isOldVersion() | |||
488 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 488 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
489 | { | 489 | { |
490 | param_count++; | 490 | param_count++; |
491 | if( !mVisualParamMap.checkKey( param->getID() ) ) | 491 | if( !is_in_map(mVisualParamMap, param->getID() ) ) |
492 | { | 492 | { |
493 | return TRUE; | 493 | return TRUE; |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | if( param_count != mVisualParamMap.getLength() ) | 497 | if( param_count != mVisualParamMap.size() ) |
498 | { | 498 | { |
499 | return TRUE; | 499 | return TRUE; |
500 | } | 500 | } |
@@ -506,13 +506,13 @@ BOOL LLWearable::isOldVersion() | |||
506 | if( LLVOAvatar::getTEWearableType( te ) == mType ) | 506 | if( LLVOAvatar::getTEWearableType( te ) == mType ) |
507 | { | 507 | { |
508 | te_count++; | 508 | te_count++; |
509 | if( !mTEMap.checkKey( te ) ) | 509 | if( !is_in_map(mTEMap, te ) ) |
510 | { | 510 | { |
511 | return TRUE; | 511 | return TRUE; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | if( te_count != mTEMap.getLength() ) | 515 | if( te_count != mTEMap.size() ) |
516 | { | 516 | { |
517 | return TRUE; | 517 | return TRUE; |
518 | } | 518 | } |
@@ -543,16 +543,8 @@ BOOL LLWearable::isDirty() | |||
543 | { | 543 | { |
544 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 544 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
545 | { | 545 | { |
546 | F32* weightp = mVisualParamMap.getIfThere( param->getID() ); | 546 | F32 weight = get_if_there(mVisualParamMap, param->getID(), param->getDefaultWeight()); |
547 | F32 weight; | 547 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); |
548 | if( weightp ) | ||
549 | { | ||
550 | weight = llclamp( *weightp, param->getMinWeight(), param->getMaxWeight() ); | ||
551 | } | ||
552 | else | ||
553 | { | ||
554 | weight = param->getDefaultWeight(); | ||
555 | } | ||
556 | 548 | ||
557 | U8 a = F32_to_U8( param->getWeight(), param->getMinWeight(), param->getMaxWeight() ); | 549 | U8 a = F32_to_U8( param->getWeight(), param->getMinWeight(), param->getMaxWeight() ); |
558 | U8 b = F32_to_U8( weight, param->getMinWeight(), param->getMaxWeight() ); | 550 | U8 b = F32_to_U8( weight, param->getMinWeight(), param->getMaxWeight() ); |
@@ -573,8 +565,7 @@ BOOL LLWearable::isDirty() | |||
573 | llassert( 0 ); | 565 | llassert( 0 ); |
574 | continue; | 566 | continue; |
575 | } | 567 | } |
576 | LLUUID* mapped_image_id = mTEMap.getIfThere( te ); | 568 | const LLUUID& image_id = get_if_there(mTEMap, te, LLVOAvatar::getDefaultTEImageID( te ) ); |
577 | const LLUUID& image_id = mapped_image_id ? *mapped_image_id : LLVOAvatar::getDefaultTEImageID( te ); | ||
578 | if( avatar_image->getID() != image_id ) | 569 | if( avatar_image->getID() != image_id ) |
579 | { | 570 | { |
580 | return TRUE; | 571 | return TRUE; |
@@ -603,24 +594,24 @@ void LLWearable::setParamsToDefaults() | |||
603 | return; | 594 | return; |
604 | } | 595 | } |
605 | 596 | ||
606 | mVisualParamMap.deleteAllData(); | 597 | mVisualParamMap.clear(); |
607 | for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) | 598 | for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) |
608 | { | 599 | { |
609 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 600 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType ) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
610 | { | 601 | { |
611 | mVisualParamMap.addData( param->getID(), new F32( param->getDefaultWeight() ) ); | 602 | mVisualParamMap[param->getID()] = param->getDefaultWeight(); |
612 | } | 603 | } |
613 | } | 604 | } |
614 | } | 605 | } |
615 | 606 | ||
616 | void LLWearable::setTexturesToDefaults() | 607 | void LLWearable::setTexturesToDefaults() |
617 | { | 608 | { |
618 | mTEMap.deleteAllData(); | 609 | mTEMap.clear(); |
619 | for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ ) | 610 | for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ ) |
620 | { | 611 | { |
621 | if( LLVOAvatar::getTEWearableType( te ) == mType ) | 612 | if( LLVOAvatar::getTEWearableType( te ) == mType ) |
622 | { | 613 | { |
623 | mTEMap.addData( te, new LLUUID( LLVOAvatar::getDefaultTEImageID( te ) ) ); | 614 | mTEMap[te] = LLVOAvatar::getDefaultTEImageID( te ); |
624 | } | 615 | } |
625 | } | 616 | } |
626 | } | 617 | } |
@@ -643,30 +634,15 @@ void LLWearable::writeToAvatar( BOOL set_by_user ) | |||
643 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 634 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
644 | { | 635 | { |
645 | S32 param_id = param->getID(); | 636 | S32 param_id = param->getID(); |
646 | F32* weight = mVisualParamMap.getIfThere( param_id ); | 637 | F32 weight = get_if_there(mVisualParamMap, param_id, param->getDefaultWeight()); |
647 | if( weight ) | 638 | // only animate with user-originated changes |
639 | if (set_by_user) | ||
648 | { | 640 | { |
649 | // only animate with user-originated changes | 641 | param->setAnimationTarget(weight, set_by_user); |
650 | if (set_by_user) | ||
651 | { | ||
652 | param->setAnimationTarget(*weight, set_by_user); | ||
653 | } | ||
654 | else | ||
655 | { | ||
656 | avatar->setVisualParamWeight( param_id, *weight, set_by_user ); | ||
657 | } | ||
658 | } | 642 | } |
659 | else | 643 | else |
660 | { | 644 | { |
661 | // only animate with user-originated changes | 645 | avatar->setVisualParamWeight( param_id, weight, set_by_user ); |
662 | if (set_by_user) | ||
663 | { | ||
664 | param->setAnimationTarget(param->getDefaultWeight(), set_by_user); | ||
665 | } | ||
666 | else | ||
667 | { | ||
668 | avatar->setVisualParamWeight( param_id, param->getDefaultWeight(), set_by_user ); | ||
669 | } | ||
670 | } | 646 | } |
671 | } | 647 | } |
672 | } | 648 | } |
@@ -682,8 +658,7 @@ void LLWearable::writeToAvatar( BOOL set_by_user ) | |||
682 | { | 658 | { |
683 | if( LLVOAvatar::getTEWearableType( te ) == mType ) | 659 | if( LLVOAvatar::getTEWearableType( te ) == mType ) |
684 | { | 660 | { |
685 | LLUUID* mapped_image_id = mTEMap.getIfThere( te ); | 661 | const LLUUID& image_id = get_if_there(mTEMap, te, LLVOAvatar::getDefaultTEImageID( te ) ); |
686 | const LLUUID& image_id = mapped_image_id ? *mapped_image_id : LLVOAvatar::getDefaultTEImageID( te ); | ||
687 | LLViewerImage* image = gImageList.getImage( image_id ); | 662 | LLViewerImage* image = gImageList.getImage( image_id ); |
688 | avatar->setLocTexTE( te, image, set_by_user ); | 663 | avatar->setLocTexTE( te, image, set_by_user ); |
689 | } | 664 | } |
@@ -792,16 +767,16 @@ void LLWearable::readFromAvatar() | |||
792 | 767 | ||
793 | mDefinitionVersion = LLWearable::sCurrentDefinitionVersion; | 768 | mDefinitionVersion = LLWearable::sCurrentDefinitionVersion; |
794 | 769 | ||
795 | mVisualParamMap.deleteAllData(); | 770 | mVisualParamMap.clear(); |
796 | for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) | 771 | for( LLVisualParam* param = avatar->getFirstVisualParam(); param; param = avatar->getNextVisualParam() ) |
797 | { | 772 | { |
798 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 773 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
799 | { | 774 | { |
800 | mVisualParamMap.addData( param->getID(), new F32( param->getWeight() ) ); | 775 | mVisualParamMap[param->getID()] = param->getWeight(); |
801 | } | 776 | } |
802 | } | 777 | } |
803 | 778 | ||
804 | mTEMap.deleteAllData(); | 779 | mTEMap.clear(); |
805 | for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ ) | 780 | for( S32 te = 0; te < LLVOAvatar::TEX_NUM_ENTRIES; te++ ) |
806 | { | 781 | { |
807 | if( LLVOAvatar::getTEWearableType( te ) == mType ) | 782 | if( LLVOAvatar::getTEWearableType( te ) == mType ) |
@@ -809,7 +784,7 @@ void LLWearable::readFromAvatar() | |||
809 | LLViewerImage* image = avatar->getTEImage( te ); | 784 | LLViewerImage* image = avatar->getTEImage( te ); |
810 | if( image ) | 785 | if( image ) |
811 | { | 786 | { |
812 | mTEMap.addData( te, new LLUUID( image->getID() ) ); | 787 | mTEMap[te] = image->getID(); |
813 | } | 788 | } |
814 | } | 789 | } |
815 | } | 790 | } |
@@ -847,9 +822,8 @@ void LLWearable::copyDataFrom( LLWearable* src ) | |||
847 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 822 | if( (param->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
848 | { | 823 | { |
849 | S32 id = param->getID(); | 824 | S32 id = param->getID(); |
850 | F32* weightp = src->mVisualParamMap.getIfThere( id ); | 825 | F32 weight = get_if_there(src->mVisualParamMap, id, param->getDefaultWeight() ); |
851 | F32 weight = weightp ? *weightp : param->getDefaultWeight(); | 826 | mVisualParamMap[id] = weight; |
852 | mVisualParamMap.addData( id, new F32( weight ) ); | ||
853 | } | 827 | } |
854 | } | 828 | } |
855 | 829 | ||
@@ -858,9 +832,8 @@ void LLWearable::copyDataFrom( LLWearable* src ) | |||
858 | { | 832 | { |
859 | if( LLVOAvatar::getTEWearableType( te ) == mType ) | 833 | if( LLVOAvatar::getTEWearableType( te ) == mType ) |
860 | { | 834 | { |
861 | LLUUID* mapped_image_id = src->mTEMap.getIfThere( te ); | 835 | const LLUUID& image_id = get_if_there(src->mTEMap, te, LLVOAvatar::getDefaultTEImageID( te ) ); |
862 | const LLUUID& image_id = mapped_image_id ? *mapped_image_id : LLVOAvatar::getDefaultTEImageID( te ); | 836 | mTEMap[te] = image_id; |
863 | mTEMap.addData( te, new LLUUID( image_id ) ); | ||
864 | } | 837 | } |
865 | } | 838 | } |
866 | } | 839 | } |
@@ -985,21 +958,21 @@ void LLWearable::dump() | |||
985 | //mSaleInfo | 958 | //mSaleInfo |
986 | 959 | ||
987 | llinfos << " Params:" << llendl; | 960 | llinfos << " Params:" << llendl; |
988 | for( F32* param_weightp = mVisualParamMap.getFirstData(); | 961 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
989 | param_weightp; | 962 | iter != mVisualParamMap.end(); ++iter) |
990 | param_weightp = mVisualParamMap.getNextData() ) | ||
991 | { | 963 | { |
992 | S32 param_id = mVisualParamMap.getCurrentKeyWithoutIncrement(); | 964 | S32 param_id = iter->first; |
993 | llinfos << " " << param_id << " " << *param_weightp << llendl; | 965 | F32 param_weight = iter->second; |
966 | llinfos << " " << param_id << " " << param_weight << llendl; | ||
994 | } | 967 | } |
995 | 968 | ||
996 | llinfos << " Textures:" << llendl; | 969 | llinfos << " Textures:" << llendl; |
997 | for( LLUUID* image_id = mTEMap.getFirstData(); | 970 | for (te_map_t::iterator iter = mTEMap.begin(); |
998 | image_id; | 971 | iter != mTEMap.end(); ++iter) |
999 | image_id = mTEMap.getNextData() ) | ||
1000 | { | 972 | { |
1001 | S32 te = mTEMap.getCurrentKeyWithoutIncrement(); | 973 | S32 te = iter->first; |
1002 | llinfos << " " << te << " " << *image_id << llendl; | 974 | LLUUID& image_id = iter->second; |
975 | llinfos << " " << te << " " << image_id << llendl; | ||
1003 | } | 976 | } |
1004 | } | 977 | } |
1005 | 978 | ||