diff options
author | Armin Weatherwax | 2010-02-22 17:57:35 +0100 |
---|---|---|
committer | Jacek Antonelli | 2010-03-05 14:18:48 -0600 |
commit | d0936606412ccaf05a2e17894d2bc9a3c18506ab (patch) | |
tree | fb15bb14014eb9f6cc0512f4f3fbf408de8459e3 /linden/indra/newview/llwearable.cpp | |
parent | Fixed some notifications that were ported from 1.2 incorrectly. (diff) | |
download | meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.zip meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.gz meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.bz2 meta-impy-d0936606412ccaf05a2e17894d2bc9a3c18506ab.tar.xz |
Ported breast physics from Emerald.
Diffstat (limited to 'linden/indra/newview/llwearable.cpp')
-rw-r--r-- | linden/indra/newview/llwearable.cpp | 122 |
1 files changed, 103 insertions, 19 deletions
diff --git a/linden/indra/newview/llwearable.cpp b/linden/indra/newview/llwearable.cpp index bf5fd4a..087c74c 100644 --- a/linden/indra/newview/llwearable.cpp +++ b/linden/indra/newview/llwearable.cpp | |||
@@ -152,38 +152,34 @@ EWearableType LLWearable::typeNameToType( const std::string& type_name ) | |||
152 | } | 152 | } |
153 | return WT_INVALID; | 153 | return WT_INVALID; |
154 | } | 154 | } |
155 | 155 | std::string terse_F32_to_string( F32 f ) | |
156 | const char* terse_F32_to_string( F32 f, char s[MAX_STRING] ) /* Flawfinder: ignore */ | ||
157 | { | 156 | { |
158 | char* r = s; | 157 | std::string r = llformat( "%.2f", f ); |
159 | S32 len = snprintf( s, MAX_STRING, "%.2f", f ); /* Flawfinder: ignore */ | ||
160 | |||
161 | // "1.20" -> "1.2" | 158 | // "1.20" -> "1.2" |
162 | // "24.00" -> "24." | 159 | // "24.00" -> "24." |
163 | while( '0' == r[len - 1] ) | 160 | S32 len = r.length(); |
161 | while( len > 0 && '0' == r[len - 1] ) | ||
164 | { | 162 | { |
165 | len--; | 163 | r.erase(len-1, 1); |
166 | r[len] = '\0'; | 164 | len--; |
167 | } | 165 | } |
168 | 166 | ||
169 | if( '.' == r[len - 1] ) | 167 | if( '.' == r[len - 1] ) |
170 | { | 168 | { |
171 | // "24." -> "24" | 169 | // "24." -> "24" |
172 | len--; | 170 | r.erase(len-1, 1); |
173 | r[len] = '\0'; | ||
174 | } | 171 | } |
175 | else | 172 | else |
176 | if( ('-' == r[0]) && ('0' == r[1]) ) | 173 | if( ('-' == r[0]) && ('0' == r[1]) ) |
177 | { | 174 | { |
178 | // "-0.59" -> "-.59" | 175 | // "-0.59" -> "-.59" |
179 | r++; | 176 | r.erase(1, 1); |
180 | r[0] = '-'; | ||
181 | } | 177 | } |
182 | else | 178 | else |
183 | if( '0' == r[0] ) | 179 | if( '0' == r[0] ) |
184 | { | 180 | { |
185 | // "0.59" -> ".59" | 181 | // "0.59" -> ".59" |
186 | r++; | 182 | r.erase(0, 1); |
187 | } | 183 | } |
188 | 184 | ||
189 | return r; | 185 | return r; |
@@ -200,13 +196,12 @@ BOOL LLWearable::FileExportParams( FILE* file ) | |||
200 | S32 num_parameters = mVisualParamMap.size(); | 196 | S32 num_parameters = mVisualParamMap.size(); |
201 | fprintf( file, "parameters %d\n", num_parameters ); | 197 | fprintf( file, "parameters %d\n", num_parameters ); |
202 | 198 | ||
203 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
204 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | 199 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
205 | iter != mVisualParamMap.end(); ++iter) | 200 | iter != mVisualParamMap.end(); ++iter) |
206 | { | 201 | { |
207 | S32 param_id = iter->first; | 202 | S32 param_id = iter->first; |
208 | F32 param_weight = iter->second; | 203 | F32 param_weight = iter->second; |
209 | fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ); | 204 | fprintf( file, "%d %s\n", param_id, terse_F32_to_string(param_weight).c_str() ); |
210 | } | 205 | } |
211 | 206 | ||
212 | return TRUE; | 207 | return TRUE; |
@@ -280,13 +275,12 @@ BOOL LLWearable::exportFile( LLFILE* file ) | |||
280 | return FALSE; | 275 | return FALSE; |
281 | } | 276 | } |
282 | 277 | ||
283 | char s[ MAX_STRING ]; /* Flawfinder: ignore */ | ||
284 | for (param_map_t::iterator iter = mVisualParamMap.begin(); | 278 | for (param_map_t::iterator iter = mVisualParamMap.begin(); |
285 | iter != mVisualParamMap.end(); ++iter) | 279 | iter != mVisualParamMap.end(); ++iter) |
286 | { | 280 | { |
287 | S32 param_id = iter->first; | 281 | S32 param_id = iter->first; |
288 | F32 param_weight = iter->second; | 282 | F32 param_weight = iter->second; |
289 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight, s ) ) < 0 ) | 283 | if( fprintf( file, "%d %s\n", param_id, terse_F32_to_string( param_weight ).c_str() ) < 0 ) |
290 | { | 284 | { |
291 | return FALSE; | 285 | return FALSE; |
292 | } | 286 | } |
@@ -597,9 +591,52 @@ BOOL LLWearable::isDirty() | |||
597 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); | 591 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); |
598 | 592 | ||
599 | U8 a = F32_to_U8( param->getWeight(), param->getMinWeight(), param->getMaxWeight() ); | 593 | U8 a = F32_to_U8( param->getWeight(), param->getMinWeight(), param->getMaxWeight() ); |
600 | U8 b = F32_to_U8( weight, param->getMinWeight(), param->getMaxWeight() ); | 594 | |
595 | if(avatar->getAppearanceFlag() == true) | ||
596 | { | ||
597 | //boob | ||
598 | if(param->getID() == 507) | ||
599 | { | ||
600 | weight = get_if_there(mVisualParamMap, param->getID(), avatar->getActualBoobGrav()); | ||
601 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); | ||
602 | } | ||
603 | //butt | ||
604 | if(param->getID() == 795) | ||
605 | { | ||
606 | weight = get_if_there(mVisualParamMap, param->getID(), avatar->getActualButtGrav()); | ||
607 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); | ||
608 | } | ||
609 | //fat | ||
610 | if(param->getID() == 157) | ||
611 | { | ||
612 | weight = get_if_there(mVisualParamMap, param->getID(), avatar->getActualFatGrav()); | ||
613 | weight = llclamp( weight, param->getMinWeight(), param->getMaxWeight() ); | ||
614 | } | ||
615 | } | ||
616 | else | ||
617 | { | ||
618 | //boob | ||
619 | if(param->getID() == 507) | ||
620 | { | ||
621 | a = F32_to_U8( avatar->getActualBoobGrav(), param->getMinWeight(), param->getMaxWeight() ); | ||
622 | } | ||
623 | //butt | ||
624 | if(param->getID() == 795) | ||
625 | { | ||
626 | a = F32_to_U8( avatar->getActualButtGrav(), param->getMinWeight(), param->getMaxWeight() ); | ||
627 | } | ||
628 | //fat | ||
629 | if(param->getID() == 157) | ||
630 | { | ||
631 | a = F32_to_U8( avatar->getActualFatGrav(), param->getMinWeight(), param->getMaxWeight() ); | ||
632 | } | ||
633 | } | ||
634 | |||
635 | |||
636 | U8 b = F32_to_U8( weight, param->getMinWeight(), param->getMaxWeight() ); | ||
601 | if( a != b ) | 637 | if( a != b ) |
602 | { | 638 | { |
639 | llwarns << "param ID " << param->getID() << " was changed." << llendl; | ||
603 | return TRUE; | 640 | return TRUE; |
604 | } | 641 | } |
605 | } | 642 | } |
@@ -685,6 +722,16 @@ void LLWearable::writeToAvatar( BOOL set_by_user ) | |||
685 | { | 722 | { |
686 | S32 param_id = param->getID(); | 723 | S32 param_id = param->getID(); |
687 | F32 weight = get_if_there(mVisualParamMap, param_id, param->getDefaultWeight()); | 724 | F32 weight = get_if_there(mVisualParamMap, param_id, param->getDefaultWeight()); |
725 | |||
726 | //ZOMG: When switching shapes from inventory | ||
727 | if(param_id == 507) | ||
728 | avatar->setActualBoobGrav(weight); | ||
729 | if(param_id == 795) | ||
730 | avatar->setActualButtGrav(weight); | ||
731 | if(param_id == 157) | ||
732 | avatar->setActualFatGrav(weight); | ||
733 | |||
734 | |||
688 | // only animate with user-originated changes | 735 | // only animate with user-originated changes |
689 | if (set_by_user) | 736 | if (set_by_user) |
690 | { | 737 | { |
@@ -745,7 +792,7 @@ void LLWearable::writeToAvatar( BOOL set_by_user ) | |||
745 | 792 | ||
746 | // if( set_by_user ) | 793 | // if( set_by_user ) |
747 | // { | 794 | // { |
748 | // gAgent.sendAgentSetAppearance(); | 795 | gAgent.sendAgentSetAppearance(); |
749 | // } | 796 | // } |
750 | } | 797 | } |
751 | 798 | ||
@@ -822,6 +869,22 @@ void LLWearable::readFromAvatar() | |||
822 | { | 869 | { |
823 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) | 870 | if( (((LLViewerVisualParam*)param)->getWearableType() == mType) && (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE ) ) |
824 | { | 871 | { |
872 | |||
873 | //pretty sure is right | ||
874 | if(param->getID() == 507) | ||
875 | avatar->setActualBoobGrav(param->getWeight()); | ||
876 | if(param->getID() == 151) | ||
877 | avatar->setActualButtGrav(param->getWeight()); | ||
878 | if(param->getID() == 157) | ||
879 | avatar->setActualFatGrav(param->getWeight()); | ||
880 | |||
881 | //if(param->getID() == 507) | ||
882 | //{ | ||
883 | // llwarns << "current = " << avatar->getActualBoobGrav() << llendl; | ||
884 | // llwarns << "param weight = " << param->getWeight() << llendl; | ||
885 | //} | ||
886 | |||
887 | |||
825 | mVisualParamMap[param->getID()] = param->getWeight(); | 888 | mVisualParamMap[param->getID()] = param->getWeight(); |
826 | } | 889 | } |
827 | } | 890 | } |
@@ -873,6 +936,27 @@ void LLWearable::copyDataFrom( LLWearable* src ) | |||
873 | { | 936 | { |
874 | S32 id = param->getID(); | 937 | S32 id = param->getID(); |
875 | F32 weight = get_if_there(src->mVisualParamMap, id, param->getDefaultWeight() ); | 938 | F32 weight = get_if_there(src->mVisualParamMap, id, param->getDefaultWeight() ); |
939 | //llwarns << "------------------------------" << llendl; | ||
940 | //llwarns << "copydatafrom" << llendl; | ||
941 | //llwarns << "------------------------------" << llendl; | ||
942 | |||
943 | //if(id == 507) | ||
944 | //{ | ||
945 | // llwarns << "weight = " << weight << llendl; | ||
946 | // llwarns << "actual = " << avatar->getActualBoobGrav() << llendl; | ||
947 | // llwarns << "mVisualParamMap[id] = " << mVisualParamMap[id] << llendl; | ||
948 | //} | ||
949 | |||
950 | //pretty sure right | ||
951 | if(id == 507) | ||
952 | avatar->setActualBoobGrav(weight); | ||
953 | if(id == 795) | ||
954 | avatar->setActualButtGrav(weight); | ||
955 | if(id == 157) | ||
956 | avatar->setActualFatGrav(weight); | ||
957 | |||
958 | |||
959 | |||
876 | mVisualParamMap[id] = weight; | 960 | mVisualParamMap[id] = weight; |
877 | } | 961 | } |
878 | } | 962 | } |