From 81158d1e793505033990c478e7077bc14f29eddb Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 21 Feb 2011 02:02:24 -0600 Subject: [PATCH 1/2] V2 llaudio merge --- indra/llaudio/llaudiodecodemgr.cpp | 46 +++++++++++++++---- indra/llaudio/llaudioengine.cpp | 18 ++++++-- indra/llaudio/llaudioengine.h | 11 ++++- indra/llaudio/llaudioengine_fmod.cpp | 9 ++-- indra/llaudio/llstreamingaudio_fmod.cpp | 4 +- indra/llaudio/llvorbisencode.cpp | 7 +++ indra/llaudio/llvorbisencode.h | 1 + indra/llaudio/llwindgen.h | 3 +- .../skins/default/xui/en-us/notifications.xml | 8 ++++ 9 files changed, 87 insertions(+), 20 deletions(-) diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index b80ce5306..908eca5a6 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -222,31 +222,61 @@ BOOL LLVorbisDecodeState::initDecode() S32 sample_count = ov_pcm_total(&mVF, -1); size_t size_guess = (size_t)sample_count; vorbis_info* vi = ov_info(&mVF, -1); - size_guess *= vi->channels; + size_guess *= (vi? vi->channels : 1); size_guess *= 2; size_guess += 2048; bool abort_decode = false; + + if (vi) + { + if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) + { + abort_decode = true; + llwarns << "Bad channel count: " << vi->channels << llendl; + } + } + else // !vi + { + abort_decode = true; + llwarns << "No default bitstream found" << llendl; + } // - // This magic value is equivilent to 150MiB of data. - // Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer + // This magic value is equivilent to 150MiB of data. + // Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer if(size_guess >= 157286400) { llwarns << "Bad sound caught by zmagic" << llendl; abort_decode = true; } - - else /* */if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) + else + { + // + //Much more restrictive than zmagic. Perhaps make toggleable. + if( (size_t)sample_count > LLVORBIS_CLIP_REJECT_SAMPLES || + (size_t)sample_count <= 0) { abort_decode = true; - llwarns << "Bad channel count: " << vi->channels << llendl; + llwarns << "Illegal sample count: " << sample_count << llendl; } - + if( size_guess > LLVORBIS_CLIP_REJECT_SIZE || + size_guess < 0) + { + abort_decode = true; + llwarns << "Illegal sample size: " << size_guess << llendl; + } + // + } + // if( abort_decode ) { llwarns << "Canceling initDecode. Bad asset: " << mUUID << llendl; - llwarns << "Bad asset encoded by: " << ov_comment(&mVF,-1)->vendor << llendl; + vorbis_comment* comment = ov_comment(&mVF,-1); + if (comment && comment->vendor) + { + llwarns << "Bad asset encoded by: " << comment->vendor << llendl; + } delete mInFilep; mInFilep = NULL; return FALSE; diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 36ab23d7a..b61d934dd 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -104,7 +104,11 @@ void LLAudioEngine::setDefaults() } mMasterGain = 1.f; - mInternalGain = 0.f; + // Setting mInternalGain to an out of range value fixes the issue reported in STORM-830. + // There is an edge case in setMasterGain during startup which prevents setInternalGain from + // being called if the master volume setting and mInternalGain both equal 0, so using -1 forces + // the if statement in setMasterGain to execute when the viewer starts up. + mInternalGain = -1.f; mNextWindUpdate = 0.f; mStreamingAudioImpl = NULL; @@ -204,12 +208,12 @@ void LLAudioEngine::updateInternetStream() } // virtual -int LLAudioEngine::isInternetStreamPlaying() +LLAudioEngine::LLAudioPlayState LLAudioEngine::isInternetStreamPlaying() { if (mStreamingAudioImpl) - return mStreamingAudioImpl->isPlaying(); + return (LLAudioEngine::LLAudioPlayState) mStreamingAudioImpl->isPlaying(); - return 0; // Stopped + return LLAudioEngine::AUDIO_STOPPED; // Stopped } @@ -594,7 +598,7 @@ LLAudioBuffer * LLAudioEngine::getFreeBuffer() if (buffer_id >= 0) { - llinfos << "Taking over unused buffer " << buffer_id << llendl; + lldebugs << "Taking over unused buffer " << buffer_id << llendl; //llinfos << "Flushing unused buffer!" << llendl; mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; delete mBuffers[buffer_id]; @@ -1627,6 +1631,10 @@ bool LLAudioSource::hasPendingPreloads() const LLAudioData *adp = iter->second; // note: a bad UUID will forever be !hasDecodedData() // but also !hasValidData(), hence the check for hasValidData() + if (!adp) + { + continue; + } if (!adp->hasDecodedData() && adp->hasValidData()) { // This source is still waiting for a preload diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index fa323607b..4d5d919e1 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -91,6 +91,15 @@ public: AUDIO_TYPE_COUNT = 4 // last }; + enum LLAudioPlayState + { + // isInternetStreamPlaying() returns an *int*, with + // 0 = stopped, 1 = playing, 2 = paused. + AUDIO_STOPPED = 0, + AUDIO_PLAYING = 1, + AUDIO_PAUSED = 2 + }; + LLAudioEngine(); virtual ~LLAudioEngine(); @@ -161,7 +170,7 @@ public: void stopInternetStream(); void pauseInternetStream(int pause); void updateInternetStream(); // expected to be called often - int isInternetStreamPlaying(); + LLAudioPlayState isInternetStreamPlaying(); // use a value from 0.0 to 1.0, inclusive void setInternetStreamGain(F32 vol); std::string getInternetStreamURL(); diff --git a/indra/llaudio/llaudioengine_fmod.cpp b/indra/llaudio/llaudioengine_fmod.cpp index 3c6573e74..8d3f70f89 100644 --- a/indra/llaudio/llaudioengine_fmod.cpp +++ b/indra/llaudio/llaudioengine_fmod.cpp @@ -131,6 +131,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) bool audio_ok = false; if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL; @@ -147,8 +148,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL; @@ -164,8 +166,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; @@ -181,7 +184,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) { LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL; diff --git a/indra/llaudio/llstreamingaudio_fmod.cpp b/indra/llaudio/llstreamingaudio_fmod.cpp index a71a87203..fe9468856 100644 --- a/indra/llaudio/llstreamingaudio_fmod.cpp +++ b/indra/llaudio/llstreamingaudio_fmod.cpp @@ -174,7 +174,7 @@ void LLStreamingAudio_FMOD::update() break; case -3: // failed to open, file not found, perhaps - llwarns << "InternetSteam - failed to open" << llendl; + llwarns << "InternetStream - failed to open" << llendl; stop(); return; case -4: @@ -271,7 +271,7 @@ void LLStreamingAudio_FMOD::setGain(F32 vol) if (mFMODInternetStreamChannel != -1) { - vol = llclamp(vol, 0.f, 1.f); + vol = llclamp(vol * vol, 0.f, 1.f); int vol_int = llround(vol * 255.f); FSOUND_SetVolumeAbsolute(mFMODInternetStreamChannel, vol_int); } diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp index a24394da1..443b57698 100644 --- a/indra/llaudio/llvorbisencode.cpp +++ b/indra/llaudio/llvorbisencode.cpp @@ -126,6 +126,13 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro + ((U32) wav_header[5] << 8) + wav_header[4]; + if (chunk_length > physical_file_size - file_pos - 4) + { + infile.close(); + error_msg = "SoundFileInvalidChunkSize"; + return(LLVORBISENC_CHUNK_SIZE_ERR); + } + // llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl; if (!(strncmp((char *)&(wav_header[0]),"fmt ",4))) diff --git a/indra/llaudio/llvorbisencode.h b/indra/llaudio/llvorbisencode.h index 2825a301e..0828073d7 100644 --- a/indra/llaudio/llvorbisencode.h +++ b/indra/llaudio/llvorbisencode.h @@ -44,6 +44,7 @@ const S32 LLVORBISENC_MULTICHANNEL_ERR = 7; // can't do stereo const S32 LLVORBISENC_UNSUPPORTED_SAMPLE_RATE = 8; // unsupported sample rate const S32 LLVORBISENC_UNSUPPORTED_WORD_SIZE = 9; // unsupported word size const S32 LLVORBISENC_CLIP_TOO_LONG = 10; // source file is too long +const S32 LLVORBISENC_CHUNK_SIZE_ERR = 11; // chunk size is wrong const F32 LLVORBIS_CLIP_MAX_TIME = 10.0f; const U8 LLVORBIS_CLIP_MAX_CHANNELS = 2; diff --git a/indra/llaudio/llwindgen.h b/indra/llaudio/llwindgen.h index 1908b2545..0e6d0aa2c 100644 --- a/indra/llaudio/llwindgen.h +++ b/indra/llaudio/llwindgen.h @@ -52,7 +52,8 @@ public: mY1(0.0f), mCurrentGain(0.f), mCurrentFreq(100.f), - mCurrentPanGainR(0.5f) + mCurrentPanGainR(0.5f), + mLastSample(0.f) { mSamplePeriod = (F32)mSubSamples / (F32)mInputSamplingRate; mB2 = expf(-F_TWO_PI * mFilterBandWidth * mSamplePeriod); diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index 85daad8a5..ba4d59c41 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -1454,6 +1454,14 @@ Could not find 'data' chunk in WAV header: [FILE] + +Wrong chunk size in WAV file: +[FILE] + + Date: Mon, 21 Feb 2011 21:23:37 -0600 Subject: [PATCH 2/2] V2 llcharacter merge --- indra/llcharacter/llanimationstates.cpp | 73 +++-- indra/llcharacter/llanimationstates.h | 284 ++++++++++---------- indra/llcharacter/llbvhloader.cpp | 172 ++++++++---- indra/llcharacter/llbvhloader.h | 57 +++- indra/llcharacter/llcharacter.cpp | 40 +-- indra/llcharacter/llcharacter.h | 40 ++- indra/llcharacter/lljoint.cpp | 1 + indra/llcharacter/lljoint.h | 2 +- indra/llcharacter/llkeyframemotion.cpp | 73 +++-- indra/llcharacter/llkeyframemotionparam.cpp | 171 ++++++------ indra/llcharacter/llkeyframewalkmotion.cpp | 23 +- indra/llcharacter/llmotioncontroller.cpp | 32 ++- indra/llcharacter/llmotioncontroller.h | 11 +- indra/llcharacter/llstatemachine.cpp | 2 + indra/llcharacter/llvisualparam.cpp | 57 +++- indra/llcharacter/llvisualparam.h | 47 ++-- indra/newview/llassetconverter.cpp | 19 +- indra/newview/llfloateranimpreview.cpp | 69 ++++- indra/newview/llviewerjointattachment.h | 2 +- indra/newview/llviewerjointmesh.h | 2 +- 20 files changed, 744 insertions(+), 433 deletions(-) diff --git a/indra/llcharacter/llanimationstates.cpp b/indra/llcharacter/llanimationstates.cpp index b6d405759..43f3e60b0 100644 --- a/indra/llcharacter/llanimationstates.cpp +++ b/indra/llcharacter/llanimationstates.cpp @@ -90,11 +90,13 @@ LLUUID const ANIM_AGENT_EXPRESS_TONGUE_OUT ("835965c6-7f2f-bda2-5deb-2478737f91b LLUUID const ANIM_AGENT_EXPRESS_TOOTHSMILE ("b92ec1a5-e7ce-a76b-2b05-bcdb9311417e"); LLUUID const ANIM_AGENT_EXPRESS_WINK ("da020525-4d94-59d6-23d7-81fdebf33148"); LLUUID const ANIM_AGENT_EXPRESS_WORRY ("9c05e5c7-6f07-6ca4-ed5a-b230390c3950"); -LLUUID const ANIM_AGENT_FALLDOWN ("666307d9-a860-572d-6fd4-c3ab8865c094"); -LLUUID const ANIM_AGENT_FEMALE_WALK ("f5fc7433-043d-e819-8298-f519a119b688"); -LLUUID const ANIM_AGENT_FINGER_WAG ("c1bc7f36-3ba0-d844-f93c-93be945d644f"); -LLUUID const ANIM_AGENT_FIST_PUMP ("7db00ccd-f380-f3ee-439d-61968ec69c8a"); -LLUUID const ANIM_AGENT_FLY ("aec4610c-757f-bc4e-c092-c6e9caf18daf"); +LLUUID const ANIM_AGENT_FALLDOWN ("666307d9-a860-572d-6fd4-c3ab8865c094"); +LLUUID const ANIM_AGENT_FEMALE_RUN_NEW ("85995026-eade-5d78-d364-94a64512cb66"); +LLUUID const ANIM_AGENT_FEMALE_WALK ("f5fc7433-043d-e819-8298-f519a119b688"); +LLUUID const ANIM_AGENT_FEMALE_WALK_NEW ("d60c41d2-7c24-7074-d3fa-6101cea22a51"); +LLUUID const ANIM_AGENT_FINGER_WAG ("c1bc7f36-3ba0-d844-f93c-93be945d644f"); +LLUUID const ANIM_AGENT_FIST_PUMP ("7db00ccd-f380-f3ee-439d-61968ec69c8a"); +LLUUID const ANIM_AGENT_FLY ("aec4610c-757f-bc4e-c092-c6e9caf18daf"); LLUUID const ANIM_AGENT_FLYSLOW ("2b5a38b2-5e00-3a97-a495-4c826bc443e6"); LLUUID const ANIM_AGENT_HELLO ("9b29cd61-c45b-5689-ded2-91756b8d76a9"); LLUUID const ANIM_AGENT_HOLD_BAZOOKA_R ("ef62d355-c815-4816-2474-b1acc21094a6"); @@ -122,21 +124,22 @@ LLUUID const ANIM_AGENT_PEACE ("b312b10e-65ab-a0a4-8b3c-1326ea8e3ed9"); LLUUID const ANIM_AGENT_POINT_ME ("17c024cc-eef2-f6a0-3527-9869876d7752"); LLUUID const ANIM_AGENT_POINT_YOU ("ec952cca-61ef-aa3b-2789-4d1344f016de"); LLUUID const ANIM_AGENT_PRE_JUMP ("7a4e87fe-de39-6fcb-6223-024b00893244"); -LLUUID const ANIM_AGENT_PUNCH_LEFT ("f3300ad9-3462-1d07-2044-0fef80062da0"); -LLUUID const ANIM_AGENT_PUNCH_RIGHT ("c8e42d32-7310-6906-c903-cab5d4a34656"); -LLUUID const ANIM_AGENT_REPULSED ("36f81a92-f076-5893-dc4b-7c3795e487cf"); -LLUUID const ANIM_AGENT_ROUNDHOUSE_KICK ("49aea43b-5ac3-8a44-b595-96100af0beda"); -LLUUID const ANIM_AGENT_RPS_COUNTDOWN ("35db4f7e-28c2-6679-cea9-3ee108f7fc7f"); -LLUUID const ANIM_AGENT_RPS_PAPER ("0836b67f-7f7b-f37b-c00a-460dc1521f5a"); -LLUUID const ANIM_AGENT_RPS_ROCK ("42dd95d5-0bc6-6392-f650-777304946c0f"); -LLUUID const ANIM_AGENT_RPS_SCISSORS ("16803a9f-5140-e042-4d7b-d28ba247c325"); -LLUUID const ANIM_AGENT_RUN ("05ddbff8-aaa9-92a1-2b74-8fe77a29b445"); -LLUUID const ANIM_AGENT_SAD ("0eb702e2-cc5a-9a88-56a5-661a55c0676a"); -LLUUID const ANIM_AGENT_SALUTE ("cd7668a6-7011-d7e2-ead8-fc69eff1a104"); -LLUUID const ANIM_AGENT_SHOOT_BOW_L ("e04d450d-fdb5-0432-fd68-818aaf5935f8"); -LLUUID const ANIM_AGENT_SHOUT ("6bd01860-4ebd-127a-bb3d-d1427e8e0c42"); -LLUUID const ANIM_AGENT_SHRUG ("70ea714f-3a97-d742-1b01-590a8fcd1db5"); -LLUUID const ANIM_AGENT_SIT ("1a5fe8ac-a804-8a5d-7cbd-56bd83184568"); +LLUUID const ANIM_AGENT_PUNCH_LEFT ("f3300ad9-3462-1d07-2044-0fef80062da0"); +LLUUID const ANIM_AGENT_PUNCH_RIGHT ("c8e42d32-7310-6906-c903-cab5d4a34656"); +LLUUID const ANIM_AGENT_REPULSED ("36f81a92-f076-5893-dc4b-7c3795e487cf"); +LLUUID const ANIM_AGENT_ROUNDHOUSE_KICK ("49aea43b-5ac3-8a44-b595-96100af0beda"); +LLUUID const ANIM_AGENT_RPS_COUNTDOWN ("35db4f7e-28c2-6679-cea9-3ee108f7fc7f"); +LLUUID const ANIM_AGENT_RPS_PAPER ("0836b67f-7f7b-f37b-c00a-460dc1521f5a"); +LLUUID const ANIM_AGENT_RPS_ROCK ("42dd95d5-0bc6-6392-f650-777304946c0f"); +LLUUID const ANIM_AGENT_RPS_SCISSORS ("16803a9f-5140-e042-4d7b-d28ba247c325"); +LLUUID const ANIM_AGENT_RUN ("05ddbff8-aaa9-92a1-2b74-8fe77a29b445"); +LLUUID const ANIM_AGENT_RUN_NEW ("1ab1b236-cd08-21e6-0cbc-0d923fc6eca2"); +LLUUID const ANIM_AGENT_SAD ("0eb702e2-cc5a-9a88-56a5-661a55c0676a"); +LLUUID const ANIM_AGENT_SALUTE ("cd7668a6-7011-d7e2-ead8-fc69eff1a104"); +LLUUID const ANIM_AGENT_SHOOT_BOW_L ("e04d450d-fdb5-0432-fd68-818aaf5935f8"); +LLUUID const ANIM_AGENT_SHOUT ("6bd01860-4ebd-127a-bb3d-d1427e8e0c42"); +LLUUID const ANIM_AGENT_SHRUG ("70ea714f-3a97-d742-1b01-590a8fcd1db5"); +LLUUID const ANIM_AGENT_SIT ("1a5fe8ac-a804-8a5d-7cbd-56bd83184568"); LLUUID const ANIM_AGENT_SIT_FEMALE ("b1709c8d-ecd3-54a1-4f28-d55ac0840782"); LLUUID const ANIM_AGENT_SIT_GENERIC ("245f3c54-f1c0-bf2e-811f-46d8eeb386e7"); LLUUID const ANIM_AGENT_SIT_GROUND ("1c7600d6-661f-b87b-efe2-d7421eb93c86"); @@ -164,10 +167,11 @@ LLUUID const ANIM_AGENT_THROW_R ("aa134404-7dac-7aca-2cba-435f9db875ca"); LLUUID const ANIM_AGENT_TRYON_SHIRT ("83ff59fe-2346-f236-9009-4e3608af64c1"); LLUUID const ANIM_AGENT_TURNLEFT ("56e0ba0d-4a9f-7f27-6117-32f2ebbf6135"); LLUUID const ANIM_AGENT_TURNRIGHT ("2d6daa51-3192-6794-8e2e-a15f8338ec30"); -LLUUID const ANIM_AGENT_TYPE ("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9"); -LLUUID const ANIM_AGENT_WALK ("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0"); -LLUUID const ANIM_AGENT_WHISPER ("7693f268-06c7-ea71-fa21-2b30d6533f8f"); -LLUUID const ANIM_AGENT_WHISTLE ("b1ed7982-c68e-a982-7561-52a88a5298c0"); +LLUUID const ANIM_AGENT_TYPE ("c541c47f-e0c0-058b-ad1a-d6ae3a4584d9"); +LLUUID const ANIM_AGENT_WALK ("6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0"); +LLUUID const ANIM_AGENT_WALK_NEW ("33339176-7ddc-9397-94a4-bf3403cbc8f5"); +LLUUID const ANIM_AGENT_WHISPER ("7693f268-06c7-ea71-fa21-2b30d6533f8f"); +LLUUID const ANIM_AGENT_WHISTLE ("b1ed7982-c68e-a982-7561-52a88a5298c0"); LLUUID const ANIM_AGENT_WINK ("869ecdad-a44b-671e-3266-56aef2e3ac2e"); LLUUID const ANIM_AGENT_WINK_HOLLYWOOD ("c0c4030f-c02b-49de-24ba-2331f43fe41c"); LLUUID const ANIM_AGENT_WORRY ("9f496bd2-589a-709f-16cc-69bf7df1d36c"); @@ -252,7 +256,9 @@ LLAnimationLibrary::LLAnimationLibrary() : mAnimMap[ANIM_AGENT_EXPRESS_WINK]= mAnimStringTable.addString("express_wink_emote"); mAnimMap[ANIM_AGENT_EXPRESS_WORRY]= mAnimStringTable.addString("express_worry_emote"); mAnimMap[ANIM_AGENT_FALLDOWN]= mAnimStringTable.addString("falldown"); + mAnimMap[ANIM_AGENT_FEMALE_RUN_NEW]= mAnimStringTable.addString("female_run_new"); mAnimMap[ANIM_AGENT_FEMALE_WALK]= mAnimStringTable.addString("female_walk"); + mAnimMap[ANIM_AGENT_FEMALE_WALK_NEW]= mAnimStringTable.addString("female_walk_new"); mAnimMap[ANIM_AGENT_FINGER_WAG]= mAnimStringTable.addString("angry_fingerwag"); mAnimMap[ANIM_AGENT_FIST_PUMP]= mAnimStringTable.addString("fist_pump"); mAnimMap[ANIM_AGENT_FLY]= mAnimStringTable.addString("fly"); @@ -292,6 +298,7 @@ LLAnimationLibrary::LLAnimationLibrary() : mAnimMap[ANIM_AGENT_RPS_ROCK]= mAnimStringTable.addString("rps_rock"); mAnimMap[ANIM_AGENT_RPS_SCISSORS]= mAnimStringTable.addString("rps_scissors"); mAnimMap[ANIM_AGENT_RUN]= mAnimStringTable.addString("run"); + mAnimMap[ANIM_AGENT_RUN_NEW]= mAnimStringTable.addString("run_new"); mAnimMap[ANIM_AGENT_SAD]= mAnimStringTable.addString("express_sad"); mAnimMap[ANIM_AGENT_SALUTE]= mAnimStringTable.addString("salute"); mAnimMap[ANIM_AGENT_SHOOT_BOW_L]= mAnimStringTable.addString("shoot_l_bow"); @@ -327,6 +334,7 @@ LLAnimationLibrary::LLAnimationLibrary() : mAnimMap[ANIM_AGENT_TURNRIGHT]= mAnimStringTable.addString("turnright"); mAnimMap[ANIM_AGENT_TYPE]= mAnimStringTable.addString("type"); mAnimMap[ANIM_AGENT_WALK]= mAnimStringTable.addString("walk"); + mAnimMap[ANIM_AGENT_WALK_NEW]= mAnimStringTable.addString("walk_new"); mAnimMap[ANIM_AGENT_WHISPER]= mAnimStringTable.addString("whisper"); mAnimMap[ANIM_AGENT_WHISTLE]= mAnimStringTable.addString("whistle"); mAnimMap[ANIM_AGENT_WINK]= mAnimStringTable.addString("express_wink"); @@ -396,6 +404,23 @@ LLUUID LLAnimationLibrary::stringToAnimState( const std::string& name, BOOL allo return id; } +//----------------------------------------------------------------------------- +// Associate an anim state with a name +//----------------------------------------------------------------------------- +void LLAnimationLibrary::animStateSetString( const LLUUID& state, const std::string& name) +{ + mAnimMap[state] = mAnimStringTable.addString(name); +} + +std::string LLAnimationLibrary::animationName( const LLUUID& id ) const +{ + const char *cptr = gAnimLibrary.animStateToString(id); + if (cptr) + return std::string(cptr); + else + return std::string("[") + id.asString() + std::string("]"); +} + // Animation states that the user can trigger as part of a gesture // See struct LLAnimStateEntry in header for label location information const LLAnimStateEntry gUserAnimStates[] = { diff --git a/indra/llcharacter/llanimationstates.h b/indra/llcharacter/llanimationstates.h index 2218b6d8a..77556013d 100644 --- a/indra/llcharacter/llanimationstates.h +++ b/indra/llcharacter/llanimationstates.h @@ -49,141 +49,145 @@ //----------------------------------------------------------------------------- const S32 MAX_CONCURRENT_ANIMS = 16; -extern LLUUID const ANIM_AGENT_AFRAID; -extern LLUUID const ANIM_AGENT_AIM_BAZOOKA_R; -extern LLUUID const ANIM_AGENT_AIM_BOW_L; -extern LLUUID const ANIM_AGENT_AIM_HANDGUN_R; -extern LLUUID const ANIM_AGENT_AIM_RIFLE_R; -extern LLUUID const ANIM_AGENT_ANGRY; -extern LLUUID const ANIM_AGENT_AWAY; -extern LLUUID const ANIM_AGENT_BACKFLIP; -extern LLUUID const ANIM_AGENT_BELLY_LAUGH; -extern LLUUID const ANIM_AGENT_BLOW_KISS; -extern LLUUID const ANIM_AGENT_BORED; -extern LLUUID const ANIM_AGENT_BOW; -extern LLUUID const ANIM_AGENT_BRUSH; -extern LLUUID const ANIM_AGENT_BUSY; -extern LLUUID const ANIM_AGENT_CLAP; -extern LLUUID const ANIM_AGENT_COURTBOW; -extern LLUUID const ANIM_AGENT_CROUCH; -extern LLUUID const ANIM_AGENT_CROUCHWALK; -extern LLUUID const ANIM_AGENT_CRY; -extern LLUUID const ANIM_AGENT_CUSTOMIZE; -extern LLUUID const ANIM_AGENT_CUSTOMIZE_DONE; -extern LLUUID const ANIM_AGENT_DANCE1; -extern LLUUID const ANIM_AGENT_DANCE2; -extern LLUUID const ANIM_AGENT_DANCE3; -extern LLUUID const ANIM_AGENT_DANCE4; -extern LLUUID const ANIM_AGENT_DANCE5; -extern LLUUID const ANIM_AGENT_DANCE6; -extern LLUUID const ANIM_AGENT_DANCE7; -extern LLUUID const ANIM_AGENT_DANCE8; -extern LLUUID const ANIM_AGENT_DEAD; -extern LLUUID const ANIM_AGENT_DRINK; -extern LLUUID const ANIM_AGENT_EMBARRASSED; -extern LLUUID const ANIM_AGENT_EXPRESS_AFRAID; -extern LLUUID const ANIM_AGENT_EXPRESS_ANGER; -extern LLUUID const ANIM_AGENT_EXPRESS_BORED; -extern LLUUID const ANIM_AGENT_EXPRESS_CRY; -extern LLUUID const ANIM_AGENT_EXPRESS_DISDAIN; -extern LLUUID const ANIM_AGENT_EXPRESS_EMBARRASSED; -extern LLUUID const ANIM_AGENT_EXPRESS_FROWN; -extern LLUUID const ANIM_AGENT_EXPRESS_KISS; -extern LLUUID const ANIM_AGENT_EXPRESS_LAUGH; -extern LLUUID const ANIM_AGENT_EXPRESS_OPEN_MOUTH; -extern LLUUID const ANIM_AGENT_EXPRESS_REPULSED; -extern LLUUID const ANIM_AGENT_EXPRESS_SAD; -extern LLUUID const ANIM_AGENT_EXPRESS_SHRUG; -extern LLUUID const ANIM_AGENT_EXPRESS_SMILE; -extern LLUUID const ANIM_AGENT_EXPRESS_SURPRISE; -extern LLUUID const ANIM_AGENT_EXPRESS_TONGUE_OUT; -extern LLUUID const ANIM_AGENT_EXPRESS_TOOTHSMILE; -extern LLUUID const ANIM_AGENT_EXPRESS_WINK; -extern LLUUID const ANIM_AGENT_EXPRESS_WORRY; -extern LLUUID const ANIM_AGENT_FALLDOWN; -extern LLUUID const ANIM_AGENT_FEMALE_WALK; -extern LLUUID const ANIM_AGENT_FINGER_WAG; -extern LLUUID const ANIM_AGENT_FIST_PUMP; -extern LLUUID const ANIM_AGENT_FLY; -extern LLUUID const ANIM_AGENT_FLYSLOW; -extern LLUUID const ANIM_AGENT_HELLO; -extern LLUUID const ANIM_AGENT_HOLD_BAZOOKA_R; -extern LLUUID const ANIM_AGENT_HOLD_BOW_L; -extern LLUUID const ANIM_AGENT_HOLD_HANDGUN_R; -extern LLUUID const ANIM_AGENT_HOLD_RIFLE_R; -extern LLUUID const ANIM_AGENT_HOLD_THROW_R; -extern LLUUID const ANIM_AGENT_HOVER; -extern LLUUID const ANIM_AGENT_HOVER_DOWN; -extern LLUUID const ANIM_AGENT_HOVER_UP; -extern LLUUID const ANIM_AGENT_IMPATIENT; -extern LLUUID const ANIM_AGENT_JUMP; -extern LLUUID const ANIM_AGENT_JUMP_FOR_JOY; -extern LLUUID const ANIM_AGENT_KISS_MY_BUTT; -extern LLUUID const ANIM_AGENT_LAND; -extern LLUUID const ANIM_AGENT_LAUGH_SHORT; -extern LLUUID const ANIM_AGENT_MEDIUM_LAND; -extern LLUUID const ANIM_AGENT_MOTORCYCLE_SIT; -extern LLUUID const ANIM_AGENT_MUSCLE_BEACH; -extern LLUUID const ANIM_AGENT_NO; -extern LLUUID const ANIM_AGENT_NO_UNHAPPY; -extern LLUUID const ANIM_AGENT_NYAH_NYAH; -extern LLUUID const ANIM_AGENT_ONETWO_PUNCH; -extern LLUUID const ANIM_AGENT_PEACE; -extern LLUUID const ANIM_AGENT_POINT_ME; -extern LLUUID const ANIM_AGENT_POINT_YOU; -extern LLUUID const ANIM_AGENT_PRE_JUMP; -extern LLUUID const ANIM_AGENT_PUNCH_LEFT; -extern LLUUID const ANIM_AGENT_PUNCH_RIGHT; -extern LLUUID const ANIM_AGENT_REPULSED; -extern LLUUID const ANIM_AGENT_ROUNDHOUSE_KICK; -extern LLUUID const ANIM_AGENT_RPS_COUNTDOWN; -extern LLUUID const ANIM_AGENT_RPS_PAPER; -extern LLUUID const ANIM_AGENT_RPS_ROCK; -extern LLUUID const ANIM_AGENT_RPS_SCISSORS; -extern LLUUID const ANIM_AGENT_RUN; -extern LLUUID const ANIM_AGENT_SAD; -extern LLUUID const ANIM_AGENT_SALUTE; -extern LLUUID const ANIM_AGENT_SHOOT_BOW_L; -extern LLUUID const ANIM_AGENT_SHOUT; -extern LLUUID const ANIM_AGENT_SHRUG; -extern LLUUID const ANIM_AGENT_SIT; -extern LLUUID const ANIM_AGENT_SIT_FEMALE; -extern LLUUID const ANIM_AGENT_SIT_GENERIC; -extern LLUUID const ANIM_AGENT_SIT_GROUND; -extern LLUUID const ANIM_AGENT_SIT_GROUND_CONSTRAINED; -extern LLUUID const ANIM_AGENT_SIT_TO_STAND; -extern LLUUID const ANIM_AGENT_SLEEP; -extern LLUUID const ANIM_AGENT_SMOKE_IDLE; -extern LLUUID const ANIM_AGENT_SMOKE_INHALE; -extern LLUUID const ANIM_AGENT_SMOKE_THROW_DOWN; -extern LLUUID const ANIM_AGENT_SNAPSHOT; -extern LLUUID const ANIM_AGENT_STAND; -extern LLUUID const ANIM_AGENT_STANDUP; -extern LLUUID const ANIM_AGENT_STAND_1; -extern LLUUID const ANIM_AGENT_STAND_2; -extern LLUUID const ANIM_AGENT_STAND_3; -extern LLUUID const ANIM_AGENT_STAND_4; -extern LLUUID const ANIM_AGENT_STRETCH; -extern LLUUID const ANIM_AGENT_STRIDE; -extern LLUUID const ANIM_AGENT_SURF; -extern LLUUID const ANIM_AGENT_SURPRISE; -extern LLUUID const ANIM_AGENT_SWORD_STRIKE; -extern LLUUID const ANIM_AGENT_TALK; -extern LLUUID const ANIM_AGENT_TANTRUM; -extern LLUUID const ANIM_AGENT_THROW_R; -extern LLUUID const ANIM_AGENT_TRYON_SHIRT; -extern LLUUID const ANIM_AGENT_TURNLEFT; -extern LLUUID const ANIM_AGENT_TURNRIGHT; -extern LLUUID const ANIM_AGENT_TYPE; -extern LLUUID const ANIM_AGENT_WALK; -extern LLUUID const ANIM_AGENT_WHISPER; -extern LLUUID const ANIM_AGENT_WHISTLE; -extern LLUUID const ANIM_AGENT_WINK; -extern LLUUID const ANIM_AGENT_WINK_HOLLYWOOD; -extern LLUUID const ANIM_AGENT_WORRY; -extern LLUUID const ANIM_AGENT_YES; -extern LLUUID const ANIM_AGENT_YES_HAPPY; -extern LLUUID const ANIM_AGENT_YOGA_FLOAT; +extern const LLUUID ANIM_AGENT_AFRAID; +extern const LLUUID ANIM_AGENT_AIM_BAZOOKA_R; +extern const LLUUID ANIM_AGENT_AIM_BOW_L; +extern const LLUUID ANIM_AGENT_AIM_HANDGUN_R; +extern const LLUUID ANIM_AGENT_AIM_RIFLE_R; +extern const LLUUID ANIM_AGENT_ANGRY; +extern const LLUUID ANIM_AGENT_AWAY; +extern const LLUUID ANIM_AGENT_BACKFLIP; +extern const LLUUID ANIM_AGENT_BELLY_LAUGH; +extern const LLUUID ANIM_AGENT_BLOW_KISS; +extern const LLUUID ANIM_AGENT_BORED; +extern const LLUUID ANIM_AGENT_BOW; +extern const LLUUID ANIM_AGENT_BRUSH; +extern const LLUUID ANIM_AGENT_BUSY; +extern const LLUUID ANIM_AGENT_CLAP; +extern const LLUUID ANIM_AGENT_COURTBOW; +extern const LLUUID ANIM_AGENT_CROUCH; +extern const LLUUID ANIM_AGENT_CROUCHWALK; +extern const LLUUID ANIM_AGENT_CRY; +extern const LLUUID ANIM_AGENT_CUSTOMIZE; +extern const LLUUID ANIM_AGENT_CUSTOMIZE_DONE; +extern const LLUUID ANIM_AGENT_DANCE1; +extern const LLUUID ANIM_AGENT_DANCE2; +extern const LLUUID ANIM_AGENT_DANCE3; +extern const LLUUID ANIM_AGENT_DANCE4; +extern const LLUUID ANIM_AGENT_DANCE5; +extern const LLUUID ANIM_AGENT_DANCE6; +extern const LLUUID ANIM_AGENT_DANCE7; +extern const LLUUID ANIM_AGENT_DANCE8; +extern const LLUUID ANIM_AGENT_DEAD; +extern const LLUUID ANIM_AGENT_DRINK; +extern const LLUUID ANIM_AGENT_EMBARRASSED; +extern const LLUUID ANIM_AGENT_EXPRESS_AFRAID; +extern const LLUUID ANIM_AGENT_EXPRESS_ANGER; +extern const LLUUID ANIM_AGENT_EXPRESS_BORED; +extern const LLUUID ANIM_AGENT_EXPRESS_CRY; +extern const LLUUID ANIM_AGENT_EXPRESS_DISDAIN; +extern const LLUUID ANIM_AGENT_EXPRESS_EMBARRASSED; +extern const LLUUID ANIM_AGENT_EXPRESS_FROWN; +extern const LLUUID ANIM_AGENT_EXPRESS_KISS; +extern const LLUUID ANIM_AGENT_EXPRESS_LAUGH; +extern const LLUUID ANIM_AGENT_EXPRESS_OPEN_MOUTH; +extern const LLUUID ANIM_AGENT_EXPRESS_REPULSED; +extern const LLUUID ANIM_AGENT_EXPRESS_SAD; +extern const LLUUID ANIM_AGENT_EXPRESS_SHRUG; +extern const LLUUID ANIM_AGENT_EXPRESS_SMILE; +extern const LLUUID ANIM_AGENT_EXPRESS_SURPRISE; +extern const LLUUID ANIM_AGENT_EXPRESS_TONGUE_OUT; +extern const LLUUID ANIM_AGENT_EXPRESS_TOOTHSMILE; +extern const LLUUID ANIM_AGENT_EXPRESS_WINK; +extern const LLUUID ANIM_AGENT_EXPRESS_WORRY; +extern const LLUUID ANIM_AGENT_FALLDOWN; +extern const LLUUID ANIM_AGENT_FEMALE_RUN_NEW; +extern const LLUUID ANIM_AGENT_FEMALE_WALK; +extern const LLUUID ANIM_AGENT_FEMALE_WALK_NEW; +extern const LLUUID ANIM_AGENT_FINGER_WAG; +extern const LLUUID ANIM_AGENT_FIST_PUMP; +extern const LLUUID ANIM_AGENT_FLY; +extern const LLUUID ANIM_AGENT_FLYSLOW; +extern const LLUUID ANIM_AGENT_HELLO; +extern const LLUUID ANIM_AGENT_HOLD_BAZOOKA_R; +extern const LLUUID ANIM_AGENT_HOLD_BOW_L; +extern const LLUUID ANIM_AGENT_HOLD_HANDGUN_R; +extern const LLUUID ANIM_AGENT_HOLD_RIFLE_R; +extern const LLUUID ANIM_AGENT_HOLD_THROW_R; +extern const LLUUID ANIM_AGENT_HOVER; +extern const LLUUID ANIM_AGENT_HOVER_DOWN; +extern const LLUUID ANIM_AGENT_HOVER_UP; +extern const LLUUID ANIM_AGENT_IMPATIENT; +extern const LLUUID ANIM_AGENT_JUMP; +extern const LLUUID ANIM_AGENT_JUMP_FOR_JOY; +extern const LLUUID ANIM_AGENT_KISS_MY_BUTT; +extern const LLUUID ANIM_AGENT_LAND; +extern const LLUUID ANIM_AGENT_LAUGH_SHORT; +extern const LLUUID ANIM_AGENT_MEDIUM_LAND; +extern const LLUUID ANIM_AGENT_MOTORCYCLE_SIT; +extern const LLUUID ANIM_AGENT_MUSCLE_BEACH; +extern const LLUUID ANIM_AGENT_NO; +extern const LLUUID ANIM_AGENT_NO_UNHAPPY; +extern const LLUUID ANIM_AGENT_NYAH_NYAH; +extern const LLUUID ANIM_AGENT_ONETWO_PUNCH; +extern const LLUUID ANIM_AGENT_PEACE; +extern const LLUUID ANIM_AGENT_POINT_ME; +extern const LLUUID ANIM_AGENT_POINT_YOU; +extern const LLUUID ANIM_AGENT_PRE_JUMP; +extern const LLUUID ANIM_AGENT_PUNCH_LEFT; +extern const LLUUID ANIM_AGENT_PUNCH_RIGHT; +extern const LLUUID ANIM_AGENT_REPULSED; +extern const LLUUID ANIM_AGENT_ROUNDHOUSE_KICK; +extern const LLUUID ANIM_AGENT_RPS_COUNTDOWN; +extern const LLUUID ANIM_AGENT_RPS_PAPER; +extern const LLUUID ANIM_AGENT_RPS_ROCK; +extern const LLUUID ANIM_AGENT_RPS_SCISSORS; +extern const LLUUID ANIM_AGENT_RUN; +extern const LLUUID ANIM_AGENT_RUN_NEW; +extern const LLUUID ANIM_AGENT_SAD; +extern const LLUUID ANIM_AGENT_SALUTE; +extern const LLUUID ANIM_AGENT_SHOOT_BOW_L; +extern const LLUUID ANIM_AGENT_SHOUT; +extern const LLUUID ANIM_AGENT_SHRUG; +extern const LLUUID ANIM_AGENT_SIT; +extern const LLUUID ANIM_AGENT_SIT_FEMALE; +extern const LLUUID ANIM_AGENT_SIT_GENERIC; +extern const LLUUID ANIM_AGENT_SIT_GROUND; +extern const LLUUID ANIM_AGENT_SIT_GROUND_CONSTRAINED; +extern const LLUUID ANIM_AGENT_SIT_TO_STAND; +extern const LLUUID ANIM_AGENT_SLEEP; +extern const LLUUID ANIM_AGENT_SMOKE_IDLE; +extern const LLUUID ANIM_AGENT_SMOKE_INHALE; +extern const LLUUID ANIM_AGENT_SMOKE_THROW_DOWN; +extern const LLUUID ANIM_AGENT_SNAPSHOT; +extern const LLUUID ANIM_AGENT_STAND; +extern const LLUUID ANIM_AGENT_STANDUP; +extern const LLUUID ANIM_AGENT_STAND_1; +extern const LLUUID ANIM_AGENT_STAND_2; +extern const LLUUID ANIM_AGENT_STAND_3; +extern const LLUUID ANIM_AGENT_STAND_4; +extern const LLUUID ANIM_AGENT_STRETCH; +extern const LLUUID ANIM_AGENT_STRIDE; +extern const LLUUID ANIM_AGENT_SURF; +extern const LLUUID ANIM_AGENT_SURPRISE; +extern const LLUUID ANIM_AGENT_SWORD_STRIKE; +extern const LLUUID ANIM_AGENT_TALK; +extern const LLUUID ANIM_AGENT_TANTRUM; +extern const LLUUID ANIM_AGENT_THROW_R; +extern const LLUUID ANIM_AGENT_TRYON_SHIRT; +extern const LLUUID ANIM_AGENT_TURNLEFT; +extern const LLUUID ANIM_AGENT_TURNRIGHT; +extern const LLUUID ANIM_AGENT_TYPE; +extern const LLUUID ANIM_AGENT_WALK; +extern const LLUUID ANIM_AGENT_WALK_NEW; +extern const LLUUID ANIM_AGENT_WHISPER; +extern const LLUUID ANIM_AGENT_WHISTLE; +extern const LLUUID ANIM_AGENT_WINK; +extern const LLUUID ANIM_AGENT_WINK_HOLLYWOOD; +extern const LLUUID ANIM_AGENT_WORRY; +extern const LLUUID ANIM_AGENT_YES; +extern const LLUUID ANIM_AGENT_YES_HAPPY; +extern const LLUUID ANIM_AGENT_YOGA_FLOAT; extern LLUUID AGENT_WALK_ANIMS[]; extern S32 NUM_AGENT_WALK_ANIMS; @@ -223,6 +227,16 @@ public: // Retun NULL if the name is invalid. //----------------------------------------------------------------------------- LLUUID stringToAnimState( const std::string& name, BOOL allow_ids = TRUE ); + + //----------------------------------------------------------------------------- + // Associate an anim state with a name + //----------------------------------------------------------------------------- + void animStateSetString( const LLUUID& state, const std::string& name); + + //----------------------------------------------------------------------------- + // Find the name for a given animation, or UUID string if none defined. + //----------------------------------------------------------------------------- + std::string animationName( const LLUUID& id ) const; }; struct LLAnimStateEntry diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp index 49b6d824e..7a516f838 100644 --- a/indra/llcharacter/llbvhloader.cpp +++ b/indra/llcharacter/llbvhloader.cpp @@ -56,7 +56,7 @@ const F32 ROTATION_MOTION_THRESHOLD = 0.001f; char gInFile[1024]; /* Flawfinder: ignore */ char gOutFile[1024]; /* Flawfinder: ignore */ - +/* //------------------------------------------------------------------------ // Status Codes //------------------------------------------------------------------------ @@ -91,6 +91,8 @@ const char *LLBVHLoader::ST_NO_XLT_EASEIN = "Can't get easeIn values."; const char *LLBVHLoader::ST_NO_XLT_EASEOUT = "Can't get easeOut values."; const char *LLBVHLoader::ST_NO_XLT_HAND = "Can't get hand morph value."; const char *LLBVHLoader::ST_NO_XLT_EMOTE = "Can't read emote name."; +const char *LLBVHLoader::ST_BAD_ROOT = "Illegal ROOT joint."; +*/ //------------------------------------------------------------------------ // find_next_whitespace() @@ -124,7 +126,9 @@ LLQuaternion::Order bvhStringToOrder( char *str ) //----------------------------------------------------------------------------- // LLBVHLoader() //----------------------------------------------------------------------------- -LLBVHLoader::LLBVHLoader(const char* buffer) + +/* + LLBVHLoader::LLBVHLoader(const char* buffer) { reset(); @@ -144,7 +148,7 @@ LLBVHLoader::LLBVHLoader(const char* buffer) } } - char error_text[128]; /* Flawfinder: ignore */ + char error_text[128]; // Flawfinder: ignore S32 error_line; mStatus = loadBVHFile(buffer, error_text, error_line); if (mStatus != LLBVHLoader::ST_OK) @@ -158,6 +162,49 @@ LLBVHLoader::LLBVHLoader(const char* buffer) mInitialized = TRUE; } +*/ +LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &errorLine) +{ + reset(); + errorLine = 0; + mStatus = loadTranslationTable("anim.ini"); + loadStatus = mStatus; + llinfos<<"Load Status 00 : "<< loadStatus << llendl; + if (mStatus == E_ST_NO_XLT_FILE) + { + //llwarns << "NOTE: No translation table found." << llendl; + loadStatus = mStatus; + return; + } + else + { + if (mStatus != E_ST_OK) + { + //llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl; + errorLine = getLineNumber(); + loadStatus = mStatus; + return; + } + } + + char error_text[128]; /* Flawfinder: ignore */ + S32 error_line; + mStatus = loadBVHFile(buffer, error_text, error_line); + + if (mStatus != E_ST_OK) + { + //llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl; + loadStatus = mStatus; + errorLine = getLineNumber(); + return; + } + + applyTranslations(); + optimize(); + + mInitialized = TRUE; +} + LLBVHLoader::~LLBVHLoader() { @@ -167,7 +214,7 @@ LLBVHLoader::~LLBVHLoader() //------------------------------------------------------------------------ // LLBVHLoader::loadTranslationTable() //------------------------------------------------------------------------ -LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) +ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName) { mLineNumber = 0; mTranslations.clear(); @@ -182,7 +229,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) infile.open(path, LL_APR_R, LLAPRFile::global); apr_file_t *fp = infile.getFileHandle(); if (!fp) - return ST_NO_XLT_FILE; + return E_ST_NO_XLT_FILE; llinfos << "NOTE: Loading translation table: " << fileName << llendl; @@ -194,9 +241,9 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) // load header //-------------------------------------------------------------------- if ( ! getLine(fp) ) - return ST_EOF; + return E_ST_EOF; if ( strncmp(mLine, "Translations 1.0", 16) ) - return ST_NO_XLT_HEADER; + return E_ST_NO_XLT_HEADER; //-------------------------------------------------------------------- // load data one line at a time @@ -222,7 +269,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char name[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " [%127[^]]", name) != 1 ) - return ST_NO_XLT_NAME; + return E_ST_NO_XLT_NAME; if (strcmp(name, "GLOBALS")==0) { @@ -245,7 +292,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char emote_str[1024]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %1023s", emote_str) != 1 ) /* Flawfinder: ignore */ - return ST_NO_XLT_EMOTE; + return E_ST_NO_XLT_EMOTE; mEmoteName.assign( emote_str ); // llinfos << "NOTE: Emote: " << mEmoteName.c_str() << llendl; @@ -260,7 +307,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { S32 priority; if ( sscanf(mLine, " %*s = %d", &priority) != 1 ) - return ST_NO_XLT_PRIORITY; + return E_ST_NO_XLT_PRIORITY; mPriority = priority; // llinfos << "NOTE: Priority: " << mPriority << llendl; @@ -288,7 +335,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } else { - return ST_NO_XLT_LOOP; + return E_ST_NO_XLT_LOOP; } mLoopInPoint = loop_in * mDuration; @@ -305,7 +352,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) F32 duration; char type[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %f %127s", &duration, type) != 2 ) /* Flawfinder: ignore */ - return ST_NO_XLT_EASEIN; + return E_ST_NO_XLT_EASEIN; mEaseIn = duration; continue; @@ -319,7 +366,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) F32 duration; char type[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %f %127s", &duration, type) != 2 ) /* Flawfinder: ignore */ - return ST_NO_XLT_EASEOUT; + return E_ST_NO_XLT_EASEOUT; mEaseOut = duration; continue; @@ -332,7 +379,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { S32 handMorph; if (sscanf(mLine, " %*s = %d", &handMorph) != 1) - return ST_NO_XLT_HAND; + return E_ST_NO_XLT_HAND; mHand = handMorph; continue; @@ -380,7 +427,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) &constraint.mTargetOffset.mV[VY], &constraint.mTargetOffset.mV[VZ]) != 13) { - return ST_NO_CONSTRAINT; + return E_ST_NO_CONSTRAINT; } } else @@ -440,7 +487,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) &constraint.mTargetOffset.mV[VY], &constraint.mTargetOffset.mV[VZ]) != 13) { - return ST_NO_CONSTRAINT; + return E_ST_NO_CONSTRAINT; } } else @@ -463,7 +510,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) // at this point there must be a valid trans pointer //---------------------------------------------------------------- if ( ! trans ) - return ST_NO_XLT_NAME; + return E_ST_NO_XLT_NAME; //---------------------------------------------------------------- // check for ignore flag @@ -472,7 +519,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char trueFalse[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", trueFalse) != 1 ) /* Flawfinder: ignore */ - return ST_NO_XLT_IGNORE; + return E_ST_NO_XLT_IGNORE; trans->mIgnore = (LLStringUtil::compareInsensitive(trueFalse, "true")==0); continue; @@ -497,12 +544,12 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } else { - return ST_NO_XLT_RELATIVE; + return E_ST_NO_XLT_RELATIVE; } } else { - return ST_NO_XLT_RELATIVE; + return E_ST_NO_XLT_RELATIVE; } continue; @@ -523,12 +570,12 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } else { - return ST_NO_XLT_RELATIVE; + return E_ST_NO_XLT_RELATIVE; } } else { - return ST_NO_XLT_RELATIVE; + return E_ST_NO_XLT_RELATIVE; } continue; @@ -541,7 +588,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char outName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", outName) != 1 ) /* Flawfinder: ignore */ - return ST_NO_XLT_OUTNAME; + return E_ST_NO_XLT_OUTNAME; trans->mOutName = outName; continue; @@ -557,7 +604,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) &fm.mMatrix[0][0], &fm.mMatrix[0][1], &fm.mMatrix[0][2], &fm.mMatrix[1][0], &fm.mMatrix[1][1], &fm.mMatrix[1][2], &fm.mMatrix[2][0], &fm.mMatrix[2][1], &fm.mMatrix[2][2] ) != 9 ) - return ST_NO_XLT_MATRIX; + return E_ST_NO_XLT_MATRIX; trans->mFrameMatrix = fm; continue; @@ -573,7 +620,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) &om.mMatrix[0][0], &om.mMatrix[0][1], &om.mMatrix[0][2], &om.mMatrix[1][0], &om.mMatrix[1][1], &om.mMatrix[1][2], &om.mMatrix[2][0], &om.mMatrix[2][1], &om.mMatrix[2][2] ) != 9 ) - return ST_NO_XLT_MATRIX; + return E_ST_NO_XLT_MATRIX; trans->mOffsetMatrix = om; continue; @@ -586,7 +633,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char mergeParentName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", mergeParentName) != 1 ) /* Flawfinder: ignore */ - return ST_NO_XLT_MERGEPARENT; + return E_ST_NO_XLT_MERGEPARENT; trans->mMergeParentName = mergeParentName; continue; @@ -599,7 +646,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { char mergeChildName[128]; /* Flawfinder: ignore */ if ( sscanf(mLine, " %*s = %127s", mergeChildName) != 1 ) /* Flawfinder: ignore */ - return ST_NO_XLT_MERGECHILD; + return E_ST_NO_XLT_MERGECHILD; trans->mMergeChildName = mergeChildName; continue; @@ -612,7 +659,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) { S32 priority; if ( sscanf(mLine, " %*s = %d", &priority) != 1 ) - return ST_NO_XLT_PRIORITY; + return E_ST_NO_XLT_PRIORITY; trans->mPriorityModifier = priority; continue; @@ -621,14 +668,14 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) } infile.close() ; - return ST_OK; + return E_ST_OK; } //------------------------------------------------------------------------ // LLBVHLoader::loadBVHFile() //------------------------------------------------------------------------ -LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_text, S32 &err_line) +ELoadStatus LLBVHLoader::loadBVHFile(const char *buffer, char* error_text, S32 &err_line) { std::string line; @@ -650,14 +697,14 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex // consume hierarchy //-------------------------------------------------------------------- if (iter == tokens.end()) - return ST_EOF; + return E_ST_EOF; line = (*(iter++)); err_line++; if ( !strstr(line.c_str(), "HIERARCHY") ) { // llinfos << line << llendl; - return ST_NO_HIER; + return E_ST_NO_HIER; } //-------------------------------------------------------------------- @@ -669,7 +716,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex // get next line //---------------------------------------------------------------- if (iter == tokens.end()) - return ST_EOF; + return E_ST_EOF; line = (*(iter++)); err_line++; @@ -719,7 +766,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex else { strncpy(error_text, line.c_str(), 127); /* Flawfinder: ignore */ - return ST_NO_JOINT; + return E_ST_NO_JOINT; } //---------------------------------------------------------------- @@ -729,9 +776,20 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( sscanf(line.c_str(), "%*s %79s", jointName) != 1 ) /* Flawfinder: ignore */ { strncpy(error_text, line.c_str(), 127); /* Flawfinder: ignore */ - return ST_NO_NAME; + return E_ST_NO_NAME; } + //--------------------------------------------------------------- + // we require the root joint be "hip" - DEV-26188 + //--------------------------------------------------------------- + const char* FORCED_ROOT_NAME = "hip"; + if ( (mJoints.size() == 0 ) && ( !strstr(jointName, FORCED_ROOT_NAME) ) ) + { + strncpy(error_text, line.c_str(), 127); /* Flawfinder: ignore */ + return E_ST_BAD_ROOT; + } + + //---------------------------------------------------------------- // add a set of keyframes for this joint //---------------------------------------------------------------- @@ -754,7 +812,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex //---------------------------------------------------------------- if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -765,7 +823,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "{") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_OFFSET; + return E_ST_NO_OFFSET; } else { @@ -777,7 +835,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex //---------------------------------------------------------------- if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -788,7 +846,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "OFFSET") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_OFFSET; + return E_ST_NO_OFFSET; } //---------------------------------------------------------------- @@ -796,7 +854,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex //---------------------------------------------------------------- if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -807,7 +865,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "CHANNELS") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_CHANNELS; + return E_ST_NO_CHANNELS; } //---------------------------------------------------------------- @@ -820,14 +878,14 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if (!p) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_ROTATION; + return E_ST_NO_ROTATION; } const char axis = *(p - 1); if ((axis != 'X') && (axis != 'Y') && (axis != 'Z')) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_AXIS; + return E_ST_NO_AXIS; } joint->mOrder[i] = axis; @@ -842,7 +900,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "MOTION") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_MOTION; + return E_ST_NO_MOTION; } //-------------------------------------------------------------------- @@ -850,7 +908,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex //-------------------------------------------------------------------- if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -858,13 +916,13 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "Frames:") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_FRAMES; + return E_ST_NO_FRAMES; } if ( sscanf(line.c_str(), "Frames: %d", &mNumFrames) != 1 ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_FRAMES; + return E_ST_NO_FRAMES; } //-------------------------------------------------------------------- @@ -872,7 +930,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex //-------------------------------------------------------------------- if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -880,13 +938,13 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( !strstr(line.c_str(), "Frame Time:") ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_FRAME_TIME; + return E_ST_NO_FRAME_TIME; } if ( sscanf(line.c_str(), "Frame Time: %f", &mFrameTime) != 1 ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_FRAME_TIME; + return E_ST_NO_FRAME_TIME; } mDuration = (F32)mNumFrames * mFrameTime; @@ -903,7 +961,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex // get next line if (iter == tokens.end()) { - return ST_EOF; + return E_ST_EOF; } line = (*(iter++)); err_line++; @@ -922,7 +980,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( sscanf(p, "%f %f %f", key.mPos, key.mPos+1, key.mPos+2) != 3 ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_POS; + return E_ST_NO_POS; } } @@ -931,19 +989,19 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if (!p) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_ROT; + return E_ST_NO_ROT; } p = find_next_whitespace(++p); if (!p) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_ROT; + return E_ST_NO_ROT; } p = find_next_whitespace(++p); if (!p) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_ROT; + return E_ST_NO_ROT; } // get 3 rot values for joint @@ -951,7 +1009,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex if ( sscanf(p, " %f %f %f", rot, rot+1, rot+2) != 3 ) { strncpy(error_text, line.c_str(), 127); /*Flawfinder: ignore*/ - return ST_NO_ROT; + return E_ST_NO_ROT; } p++; @@ -962,7 +1020,7 @@ LLBVHLoader::Status LLBVHLoader::loadBVHFile(const char *buffer, char* error_tex } } - return ST_OK; + return E_ST_OK; } diff --git a/indra/llcharacter/llbvhloader.h b/indra/llcharacter/llbvhloader.h index 6937b9d83..38617bd6d 100644 --- a/indra/llcharacter/llbvhloader.h +++ b/indra/llcharacter/llbvhloader.h @@ -166,6 +166,7 @@ public: Translation() { mIgnore = FALSE; + mIgnorePositions = FALSE; mRelativePositionKey = FALSE; mRelativeRotationKey = FALSE; mPriorityModifier = 0; @@ -184,6 +185,42 @@ public: S32 mPriorityModifier; }; +typedef enum e_load_status + { + E_ST_OK, + E_ST_EOF, + E_ST_NO_CONSTRAINT, + E_ST_NO_FILE, + E_ST_NO_HIER, + E_ST_NO_JOINT, + E_ST_NO_NAME, + E_ST_NO_OFFSET, + E_ST_NO_CHANNELS, + E_ST_NO_ROTATION, + E_ST_NO_AXIS, + E_ST_NO_MOTION, + E_ST_NO_FRAMES, + E_ST_NO_FRAME_TIME, + E_ST_NO_POS, + E_ST_NO_ROT, + E_ST_NO_XLT_FILE, + E_ST_NO_XLT_HEADER, + E_ST_NO_XLT_NAME, + E_ST_NO_XLT_IGNORE, + E_ST_NO_XLT_RELATIVE, + E_ST_NO_XLT_OUTNAME, + E_ST_NO_XLT_MATRIX, + E_ST_NO_XLT_MERGECHILD, + E_ST_NO_XLT_MERGEPARENT, + E_ST_NO_XLT_PRIORITY, + E_ST_NO_XLT_LOOP, + E_ST_NO_XLT_EASEIN, + E_ST_NO_XLT_EASEOUT, + E_ST_NO_XLT_HAND, + E_ST_NO_XLT_EMOTE, + E_ST_BAD_ROOT + } ELoadStatus; + //------------------------------------------------------------------------ // TranslationMap //------------------------------------------------------------------------ @@ -194,11 +231,13 @@ class LLBVHLoader friend class LLKeyframeMotion; public: // Constructor - LLBVHLoader(const char* buffer); +// LLBVHLoader(const char* buffer); + LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &errorLine); ~LLBVHLoader(); - + +/* // Status Codes - typedef const char *Status; + typedef const char *status_t; static const char *ST_OK; static const char *ST_EOF; static const char *ST_NO_CONSTRAINT; @@ -230,13 +269,14 @@ public: static const char *ST_NO_XLT_EASEOUT; static const char *ST_NO_XLT_HAND; static const char *ST_NO_XLT_EMOTE; - + static const char *ST_BAD_ROOT; +*/ // Loads the specified translation table. - Status loadTranslationTable(const char *fileName); + ELoadStatus loadTranslationTable(const char *fileName); // Load the specified BVH file. // Returns status code. - Status loadBVHFile(const char *buffer, char *error_text, S32 &error_line); + ELoadStatus loadBVHFile(const char *buffer, char *error_text, S32 &error_line); // Applies translations to BVH data loaded. void applyTranslations(); @@ -260,7 +300,7 @@ public: BOOL isInitialized() { return mInitialized; } - Status getStatus() { return mStatus; } + ELoadStatus getStatus() { return mStatus; } protected: // Consumes one line of input from file. @@ -287,7 +327,8 @@ protected: std::string mEmoteName; BOOL mInitialized; - Status mStatus; + ELoadStatus mStatus; + // computed values F32 mDuration; }; diff --git a/indra/llcharacter/llcharacter.cpp b/indra/llcharacter/llcharacter.cpp index 72cef8370..89a55658f 100644 --- a/indra/llcharacter/llcharacter.cpp +++ b/indra/llcharacter/llcharacter.cpp @@ -273,13 +273,13 @@ void LLCharacter::removeAnimationData(std::string name) //----------------------------------------------------------------------------- // setVisualParamWeight() //----------------------------------------------------------------------------- -BOOL LLCharacter::setVisualParamWeight(LLVisualParam* which_param, F32 weight, BOOL set_by_user) +BOOL LLCharacter::setVisualParamWeight(LLVisualParam* which_param, F32 weight, BOOL upload_bake) { S32 index = which_param->getID(); - VisualParamIndexMap_t::iterator index_iter = mVisualParamIndexMap.find(index); + visual_param_index_map_t::iterator index_iter = mVisualParamIndexMap.find(index); if (index_iter != mVisualParamIndexMap.end()) { - index_iter->second->setWeight(weight, set_by_user); + index_iter->second->setWeight(weight, upload_bake); return TRUE; } return FALSE; @@ -288,15 +288,15 @@ BOOL LLCharacter::setVisualParamWeight(LLVisualParam* which_param, F32 weight, B //----------------------------------------------------------------------------- // setVisualParamWeight() //----------------------------------------------------------------------------- -BOOL LLCharacter::setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user) +BOOL LLCharacter::setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake) { std::string tname(param_name); LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); - VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); + visual_param_name_map_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) { - name_iter->second->setWeight(weight, set_by_user); + name_iter->second->setWeight(weight, upload_bake); return TRUE; } llwarns << "LLCharacter::setVisualParamWeight() Invalid visual parameter: " << param_name << llendl; @@ -306,12 +306,12 @@ BOOL LLCharacter::setVisualParamWeight(const char* param_name, F32 weight, BOOL //----------------------------------------------------------------------------- // setVisualParamWeight() //----------------------------------------------------------------------------- -BOOL LLCharacter::setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user) +BOOL LLCharacter::setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake) { - VisualParamIndexMap_t::iterator index_iter = mVisualParamIndexMap.find(index); + visual_param_index_map_t::iterator index_iter = mVisualParamIndexMap.find(index); if (index_iter != mVisualParamIndexMap.end()) { - index_iter->second->setWeight(weight, set_by_user); + index_iter->second->setWeight(weight, upload_bake); return TRUE; } llwarns << "LLCharacter::setVisualParamWeight() Invalid visual parameter index: " << index << llendl; @@ -324,7 +324,7 @@ BOOL LLCharacter::setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user) F32 LLCharacter::getVisualParamWeight(LLVisualParam *which_param) { S32 index = which_param->getID(); - VisualParamIndexMap_t::iterator index_iter = mVisualParamIndexMap.find(index); + visual_param_index_map_t::iterator index_iter = mVisualParamIndexMap.find(index); if (index_iter != mVisualParamIndexMap.end()) { return index_iter->second->getWeight(); @@ -344,7 +344,7 @@ F32 LLCharacter::getVisualParamWeight(const char* param_name) std::string tname(param_name); LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); - VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); + visual_param_name_map_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) { return name_iter->second->getWeight(); @@ -358,7 +358,7 @@ F32 LLCharacter::getVisualParamWeight(const char* param_name) //----------------------------------------------------------------------------- F32 LLCharacter::getVisualParamWeight(S32 index) { - VisualParamIndexMap_t::iterator index_iter = mVisualParamIndexMap.find(index); + visual_param_index_map_t::iterator index_iter = mVisualParamIndexMap.find(index); if (index_iter != mVisualParamIndexMap.end()) { return index_iter->second->getWeight(); @@ -415,7 +415,7 @@ LLVisualParam* LLCharacter::getVisualParam(const char *param_name) std::string tname(param_name); LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.checkString(tname); - VisualParamNameMap_t::iterator name_iter = mVisualParamNameMap.find(tableptr); + visual_param_name_map_t::iterator name_iter = mVisualParamNameMap.find(tableptr); if (name_iter != mVisualParamNameMap.end()) { return name_iter->second; @@ -430,7 +430,7 @@ LLVisualParam* LLCharacter::getVisualParam(const char *param_name) void LLCharacter::addSharedVisualParam(LLVisualParam *param) { S32 index = param->getID(); - VisualParamIndexMap_t::iterator index_iter = mVisualParamIndexMap.find(index); + visual_param_index_map_t::iterator index_iter = mVisualParamIndexMap.find(index); LLVisualParam* current_param = 0; if (index_iter != mVisualParamIndexMap.end()) current_param = index_iter->second; @@ -457,13 +457,13 @@ void LLCharacter::addVisualParam(LLVisualParam *param) { S32 index = param->getID(); // Add Index map - std::pair idxres; - idxres = mVisualParamIndexMap.insert(VisualParamIndexMap_t::value_type(index, param)); + std::pair idxres; + idxres = mVisualParamIndexMap.insert(visual_param_index_map_t::value_type(index, param)); if (!idxres.second) { llwarns << "Visual parameter " << param->getName() << " already exists with same ID as " << param->getName() << llendl; - VisualParamIndexMap_t::iterator index_iter = idxres.first; + visual_param_index_map_t::iterator index_iter = idxres.first; index_iter->second = param; } @@ -473,12 +473,12 @@ void LLCharacter::addVisualParam(LLVisualParam *param) std::string tname(param->getName()); LLStringUtil::toLower(tname); char *tableptr = sVisualParamNames.addString(tname); - std::pair nameres; - nameres = mVisualParamNameMap.insert(VisualParamNameMap_t::value_type(tableptr, param)); + std::pair nameres; + nameres = mVisualParamNameMap.insert(visual_param_name_map_t::value_type(tableptr, param)); if (!nameres.second) { // Already exists, copy param - VisualParamNameMap_t::iterator name_iter = nameres.first; + visual_param_name_map_t::iterator name_iter = nameres.first; name_iter->second = param; } } diff --git a/indra/llcharacter/llcharacter.h b/indra/llcharacter/llcharacter.h index e6c5351f8..06c4e5ff4 100644 --- a/indra/llcharacter/llcharacter.h +++ b/indra/llcharacter/llcharacter.h @@ -169,7 +169,7 @@ public: void updateMotions(e_update_t update_type); LLAnimPauseRequest requestPause(); - BOOL areAnimationsPaused() { return mMotionController.isPaused(); } + BOOL areAnimationsPaused() const { return mMotionController.isPaused(); } void setAnimTimeFactor(F32 factor) { mMotionController.setTimeFactor(factor); } void setTimeStep(F32 time_step) { mMotionController.setTimeStep(time_step); } @@ -203,9 +203,9 @@ public: void addVisualParam(LLVisualParam *param); void addSharedVisualParam(LLVisualParam *param); - BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL set_by_user = FALSE ); - BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user = FALSE ); - BOOL setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user = FALSE ); + virtual BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL upload_bake = FALSE ); + virtual BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL upload_bake = FALSE ); + virtual BOOL setVisualParamWeight(S32 index, F32 weight, BOOL upload_bake = FALSE ); // get visual param weight by param or name F32 getVisualParamWeight(LLVisualParam *distortion); @@ -231,14 +231,29 @@ public: return (mCurIterator++)->second; } + S32 getVisualParamCountInGroup(const EVisualParamGroup group) const + { + S32 rtn = 0; + for (visual_param_index_map_t::const_iterator iter = mVisualParamIndexMap.begin(); + iter != mVisualParamIndexMap.end(); + /* */ ) + { + if ((iter++)->second->getGroup() == group) + { + ++rtn; + } + } + return rtn; + } + LLVisualParam* getVisualParam(S32 id) { - VisualParamIndexMap_t::iterator iter = mVisualParamIndexMap.find(id); + visual_param_index_map_t::iterator iter = mVisualParamIndexMap.find(id); return (iter == mVisualParamIndexMap.end()) ? 0 : iter->second; } S32 getVisualParamID(LLVisualParam *id) { - VisualParamIndexMap_t::iterator iter; + visual_param_index_map_t::iterator iter; for (iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++) { if (iter->second == id) @@ -250,7 +265,7 @@ public: LLVisualParam* getVisualParam(const char *name); - ESex getSex() { return mSex; } + ESex getSex() const { return mSex; } void setSex( ESex sex ) { mSex = sex; } // set appearance flag @@ -281,11 +296,12 @@ protected: private: // visual parameter stuff - typedef std::map VisualParamIndexMap_t; - VisualParamIndexMap_t mVisualParamIndexMap; - VisualParamIndexMap_t::iterator mCurIterator; - typedef std::map VisualParamNameMap_t; - VisualParamNameMap_t mVisualParamNameMap; + typedef std::map visual_param_index_map_t; + typedef std::map visual_param_name_map_t; + + visual_param_index_map_t::iterator mCurIterator; + visual_param_index_map_t mVisualParamIndexMap; + visual_param_name_map_t mVisualParamNameMap; static LLStringTable sVisualParamNames; }; diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp index 3313f372e..25fbc03fa 100644 --- a/indra/llcharacter/lljoint.cpp +++ b/indra/llcharacter/lljoint.cpp @@ -70,6 +70,7 @@ LLJoint::LLJoint(const std::string &name, LLJoint *parent) mXform.setScaleChildOffset(TRUE); mXform.setScale(LLVector3(1.0f, 1.0f, 1.0f)); mDirtyFlags = MATRIX_DIRTY | ROTATION_DIRTY | POSITION_DIRTY; + mUpdateXform = FALSE; mJointNum = 0; setName(name); diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index b5507e1e4..37ae44998 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -174,7 +174,7 @@ public: void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot); - virtual BOOL isAnimatable() { return TRUE; } + virtual BOOL isAnimatable() const { return TRUE; } S32 getJointNum() const { return mJointNum; } void setJointNum(S32 joint_num) { mJointNum = joint_num; } diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index bae409af9..29b51091e 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -669,15 +669,12 @@ BOOL LLKeyframeMotion::onActivate() // If the keyframe anim has an associated emote, trigger it. if( mJointMotionList->mEmoteName.length() > 0 ) { - // crashfix - //mCharacter->startMotion( gAnimLibrary.stringToAnimState(mJointMotionList->mEmoteName) ); - LLUUID emo = gAnimLibrary.stringToAnimState(mJointMotionList->mEmoteName); - - if(mCharacter->findMotion(emo) == NULL) + LLUUID emote_anim_id = gAnimLibrary.stringToAnimState(mJointMotionList->mEmoteName); + // don't start emote if already active to avoid recursion + if (!mCharacter->isMotionActive(emote_anim_id)) { - mCharacter->startMotion(emo); + mCharacter->startMotion( emote_anim_id ); } - // } mLastLoopedTime = 0.f; @@ -1230,7 +1227,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (!dp.unpackS32(temp_priority, "base_priority")) { - llwarns << "can't read priority" << llendl; + llwarns << "can't read animation base_priority" << llendl; return FALSE; } mJointMotionList->mBasePriority = (LLJoint::JointPriority) temp_priority; @@ -1240,6 +1237,11 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) mJointMotionList->mBasePriority = (LLJoint::JointPriority)((int)LLJoint::ADDITIVE_PRIORITY-1); mJointMotionList->mMaxPriority = mJointMotionList->mBasePriority; } + else if (mJointMotionList->mBasePriority < LLJoint::USE_MOTION_PRIORITY) + { + llwarns << "bad animation base_priority " << mJointMotionList->mBasePriority << llendl; + return FALSE; + } //------------------------------------------------------------------------- // get duration @@ -1250,7 +1252,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - if (mJointMotionList->mDuration > MAX_ANIM_DURATION ) + if (mJointMotionList->mDuration > MAX_ANIM_DURATION || + !llfinite(mJointMotionList->mDuration)) { llwarns << "invalid animation duration" << llendl; return FALSE; @@ -1270,17 +1273,19 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) llwarns << "Malformed animation mEmoteName==mID" << llendl; return FALSE; } - + //------------------------------------------------------------------------- // get loop //------------------------------------------------------------------------- - if (!dp.unpackF32(mJointMotionList->mLoopInPoint, "loop_in_point")) + if (!dp.unpackF32(mJointMotionList->mLoopInPoint, "loop_in_point") || + !llfinite(mJointMotionList->mLoopInPoint)) { llwarns << "can't read loop point" << llendl; return FALSE; } - if (!dp.unpackF32(mJointMotionList->mLoopOutPoint, "loop_out_point")) + if (!dp.unpackF32(mJointMotionList->mLoopOutPoint, "loop_out_point") || + !llfinite(mJointMotionList->mLoopOutPoint)) { llwarns << "can't read loop point" << llendl; return FALSE; @@ -1295,13 +1300,15 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //------------------------------------------------------------------------- // get easeIn and easeOut //------------------------------------------------------------------------- - if (!dp.unpackF32(mJointMotionList->mEaseInDuration, "ease_in_duration")) + if (!dp.unpackF32(mJointMotionList->mEaseInDuration, "ease_in_duration") || + !llfinite(mJointMotionList->mEaseInDuration)) { llwarns << "can't read easeIn" << llendl; return FALSE; } - if (!dp.unpackF32(mJointMotionList->mEaseOutDuration, "ease_out_duration")) + if (!dp.unpackF32(mJointMotionList->mEaseOutDuration, "ease_out_duration") || + !llfinite(mJointMotionList->mEaseOutDuration)) { llwarns << "can't read easeOut" << llendl; return FALSE; @@ -1415,10 +1422,16 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) llwarns << "can't read joint priority." << llendl; return FALSE; } + + if (joint_priority < LLJoint::USE_MOTION_PRIORITY) + { + llwarns << "joint priority unknown - too low." << llendl; + return FALSE; + } joint_motion->mPriority = (LLJoint::JointPriority)joint_priority; if (joint_priority != LLJoint::USE_MOTION_PRIORITY && - joint_priority > mJointMotionList->mMaxPriority) + joint_priority > mJointMotionList->mMaxPriority) { mJointMotionList->mMaxPriority = (LLJoint::JointPriority)joint_priority; } @@ -1428,7 +1441,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //--------------------------------------------------------------------- // scan rotation curve header //--------------------------------------------------------------------- - if (!dp.unpackS32(joint_motion->mRotationCurve.mNumKeys, "num_rot_keys")) + if (!dp.unpackS32(joint_motion->mRotationCurve.mNumKeys, "num_rot_keys") || joint_motion->mRotationCurve.mNumKeys < 0) { llwarns << "can't read number of rotation keys" << llendl; return FALSE; @@ -1452,7 +1465,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (old_version) { - if (!dp.unpackF32(time, "time")) + if (!dp.unpackF32(time, "time") || + !llfinite(time)) { llwarns << "can't read rotation key (" << k << ")" << llendl; return FALSE; @@ -1485,7 +1499,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (old_version) { - success = dp.unpackVector3(rot_angles, "rot_angles"); + success = dp.unpackVector3(rot_angles, "rot_angles") && rot_angles.isFinite(); LLQuaternion::Order ro = StringToOrder("ZYX"); rot_key.mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); @@ -1521,7 +1535,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) //--------------------------------------------------------------------- // scan position curve header //--------------------------------------------------------------------- - if (!dp.unpackS32(joint_motion->mPositionCurve.mNumKeys, "num_pos_keys")) + if (!dp.unpackS32(joint_motion->mPositionCurve.mNumKeys, "num_pos_keys") || joint_motion->mPositionCurve.mNumKeys < 0) { llwarns << "can't read number of position keys" << llendl; return FALSE; @@ -1545,7 +1559,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) if (old_version) { - if (!dp.unpackF32(pos_key.mTime, "time")) + if (!dp.unpackF32(pos_key.mTime, "time") || + !llfinite(pos_key.mTime)) { llwarns << "can't read position key (" << k << ")" << llendl; return FALSE; @@ -1614,9 +1629,9 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - if (num_constraints > MAX_CONSTRAINTS) + if (num_constraints > MAX_CONSTRAINTS || num_constraints < 0) { - llwarns << "Too many constraints... ignoring" << llendl; + llwarns << "Bad number of constraints... ignoring: " << num_constraints << llendl; } else { @@ -1661,7 +1676,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) constraintp->mConstraintType = (EConstraintType)byte; const S32 BIN_DATA_LENGTH = 16; - U8 bin_data[BIN_DATA_LENGTH]; + U8 bin_data[BIN_DATA_LENGTH+1]; if (!dp.unpackBinaryDataFixed(bin_data, BIN_DATA_LENGTH, "source_volume")) { llwarns << "can't read source volume name" << llendl; @@ -1669,7 +1684,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - bin_data[BIN_DATA_LENGTH-1] = 0; // Ensure null termination + bin_data[BIN_DATA_LENGTH] = 0; // Ensure null termination str = (char*)bin_data; constraintp->mSourceConstraintVolume = mCharacter->getCollisionVolumeID(str); @@ -1703,7 +1718,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) return FALSE; } - bin_data[BIN_DATA_LENGTH-1] = 0; // Ensure null termination + bin_data[BIN_DATA_LENGTH] = 0; // Ensure null termination str = (char*)bin_data; if (str == "GROUND") { @@ -1750,28 +1765,28 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) // constraintp->mTargetConstraintDir *= constraintp->mSourceConstraintOffset.magVec(); } - if (!dp.unpackF32(constraintp->mEaseInStartTime, "ease_in_start")) + if (!dp.unpackF32(constraintp->mEaseInStartTime, "ease_in_start") || !llfinite(constraintp->mEaseInStartTime)) { llwarns << "can't read constraint ease in start time" << llendl; delete constraintp; return FALSE; } - if (!dp.unpackF32(constraintp->mEaseInStopTime, "ease_in_stop")) + if (!dp.unpackF32(constraintp->mEaseInStopTime, "ease_in_stop") || !llfinite(constraintp->mEaseInStopTime)) { llwarns << "can't read constraint ease in stop time" << llendl; delete constraintp; return FALSE; } - if (!dp.unpackF32(constraintp->mEaseOutStartTime, "ease_out_start")) + if (!dp.unpackF32(constraintp->mEaseOutStartTime, "ease_out_start") || !llfinite(constraintp->mEaseOutStartTime)) { llwarns << "can't read constraint ease out start time" << llendl; delete constraintp; return FALSE; } - if (!dp.unpackF32(constraintp->mEaseOutStopTime, "ease_out_stop")) + if (!dp.unpackF32(constraintp->mEaseOutStopTime, "ease_out_stop") || !llfinite(constraintp->mEaseOutStopTime)) { llwarns << "can't read constraint ease out stop time" << llendl; delete constraintp; diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index 3692bf676..d309cb1d0 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -347,8 +347,11 @@ BOOL LLKeyframeMotionParam::loadMotions() // Load named file by concatenating the character prefix with the motion name. // Load data into a buffer to be parsed. //------------------------------------------------------------------------- - std::string path = gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix()) - + "_" + getName() + ".llp"; + //std::string path = gDirUtilp->getExpandedFilename(LL_PATH_MOTIONS,mCharacter->getAnimationPrefix()) + // + "_" + getName() + ".llp"; + //RN: deprecated unused reference to "motion" directory + std::string path; + //------------------------------------------------------------------------- // open the file @@ -364,97 +367,97 @@ BOOL LLKeyframeMotionParam::loadMotions() } // allocate a text buffer - char *text = new char[ fileSize+1 ]; - if ( !text ) + try { - llinfos << "ERROR: can't allocated keyframe text buffer." << llendl; - return FALSE; - } + std::vector text(fileSize+1); - //------------------------------------------------------------------------- - // load data from file into buffer - //------------------------------------------------------------------------- - bool error = false; - char *p = text; - while ( 1 ) - { - if (apr_file_eof(fp) == APR_EOF) + //------------------------------------------------------------------------- + // load data from file into buffer + //------------------------------------------------------------------------- + bool error = false; + char *p = &text[0]; + while ( 1 ) { - break; + if (apr_file_eof(fp) == APR_EOF) + { + break; + } + if (apr_file_gets(p, 1024, fp) != APR_SUCCESS) + { + error = true; + break; + } + while ( *(++p) ) + ; } - if (apr_file_gets(p, 1024, fp) != APR_SUCCESS) + + //------------------------------------------------------------------------- + // close the file + //------------------------------------------------------------------------- + infile.close(); + + //------------------------------------------------------------------------- + // check for error + //------------------------------------------------------------------------- + llassert( p <= (&text[0] + fileSize) ); + + if ( error ) { - error = true; - break; - } - while ( *(++p) ) - ; - } - - //------------------------------------------------------------------------- - // close the file - //------------------------------------------------------------------------- - infile.close(); - - //------------------------------------------------------------------------- - // check for error - //------------------------------------------------------------------------- - llassert( p <= (text+fileSize) ); - - if ( error ) - { - llinfos << "ERROR: error while reading from " << path << llendl; - delete [] text; - return FALSE; - } - - llinfos << "Loading parametric keyframe data for: " << getName() << llendl; - - //------------------------------------------------------------------------- - // parse the text and build keyframe data structures - //------------------------------------------------------------------------- - p = text; - S32 num; - char strA[80]; /* Flawfinder: ignore */ - char strB[80]; /* Flawfinder: ignore */ - F32 floatA = 0.0f; - - - //------------------------------------------------------------------------- - // get priority - //------------------------------------------------------------------------- - BOOL isFirstMotion = TRUE; - num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */ - - while(1) - { - if (num == 0 || num == EOF) break; - if ((num != 3)) - { - llinfos << "WARNING: can't read parametric motion" << llendl; - delete [] text; + llinfos << "ERROR: error while reading from " << path << llendl; return FALSE; } - addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(std::string(strA)), strB, floatA); - if (isFirstMotion) - { - isFirstMotion = FALSE; - setDefaultKeyframeMotion(strA); - } - - p = strstr(p, "\n"); - if (!p) - { - break; - } - - p++; - num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */ - } + llinfos << "Loading parametric keyframe data for: " << getName() << llendl; - delete [] text; - return TRUE; + //------------------------------------------------------------------------- + // parse the text and build keyframe data structures + //------------------------------------------------------------------------- + p = &text[0]; + S32 num; + char strA[80]; /* Flawfinder: ignore */ + char strB[80]; /* Flawfinder: ignore */ + F32 floatA = 0.0f; + + + //------------------------------------------------------------------------- + // get priority + //------------------------------------------------------------------------- + BOOL isFirstMotion = TRUE; + num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */ + + while(1) + { + if (num == 0 || num == EOF) break; + if ((num != 3)) + { + llinfos << "WARNING: can't read parametric motion" << llendl; + return FALSE; + } + + addKeyframeMotion(strA, gAnimLibrary.stringToAnimState(std::string(strA)), strB, floatA); + if (isFirstMotion) + { + isFirstMotion = FALSE; + setDefaultKeyframeMotion(strA); + } + + p = strstr(p, "\n"); + if (!p) + { + break; + } + + p++; + num = sscanf(p, "%79s %79s %f", strA, strB, &floatA); /* Flawfinder: ignore */ + } + + return TRUE; + } + catch(std::bad_alloc) + { + llinfos << "ERROR: Unable to allocate keyframe text buffer." << llendl; + return FALSE; + } } // End diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index 7e679e871..034b7720e 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -59,12 +59,14 @@ const F32 SPEED_FINAL_SCALING = 0.5f; // final scaling for walk animation // LLKeyframeWalkMotion() // Class Constructor //----------------------------------------------------------------------------- -LLKeyframeWalkMotion::LLKeyframeWalkMotion(const LLUUID &id) : LLKeyframeMotion(id) -{ - mRealTimeLast = 0.0f; - mAdjTimeLast = 0.0f; - mCharacter = NULL; -} +LLKeyframeWalkMotion::LLKeyframeWalkMotion(const LLUUID &id) +: LLKeyframeMotion(id), + mCharacter(NULL), + mCyclePhase(0.0f), + mRealTimeLast(0.0f), + mAdjTimeLast(0.0f), + mDownFoot(0) +{} //----------------------------------------------------------------------------- @@ -72,8 +74,7 @@ LLKeyframeWalkMotion::LLKeyframeWalkMotion(const LLUUID &id) : LLKeyframeMotion( // Class Destructor //----------------------------------------------------------------------------- LLKeyframeWalkMotion::~LLKeyframeWalkMotion() -{ -} +{} //----------------------------------------------------------------------------- @@ -413,14 +414,8 @@ BOOL LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) // roll is critically damped interpolation between current roll and angular velocity-derived target roll mRoll = lerp(mRoll, target_roll, LLCriticalDamp::getInterpolant(0.1f)); -// llinfos << mRoll << llendl; - LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); mPelvisState->setRotation(roll); -// F32 lerp_amt = LLCriticalDamp::getInterpolant(0.2f); -// -// LLVector3 pelvis_correction = mPelvisState->getPosition() - lerp(LLVector3::zero, mPelvisState->getJoint()->getPosition() + mPelvisState->getPosition(), lerp_amt); -// mPelvisState->setPosition(pelvis_correction); return TRUE; } diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index 006d2b5f6..ab2f87275 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -143,7 +143,8 @@ LLMotionController::LLMotionController() mPauseTime(0.f), mTimeStep(0.f), mTimeStepCount(0), - mLastInterp(0.f) + mLastInterp(0.f), + mIsSelf(FALSE) { } @@ -1019,9 +1020,9 @@ bool LLMotionController::isMotionLoading(LLMotion* motion) //----------------------------------------------------------------------------- // findMotion() //----------------------------------------------------------------------------- -LLMotion* LLMotionController::findMotion(const LLUUID& id) +LLMotion* LLMotionController::findMotion(const LLUUID& id) const { - motion_map_t::iterator iter = mAllMotions.find(id); + motion_map_t::const_iterator iter = mAllMotions.find(id); if(iter == mAllMotions.end()) { return NULL; @@ -1032,6 +1033,31 @@ LLMotion* LLMotionController::findMotion(const LLUUID& id) } } +//----------------------------------------------------------------------------- +// dumpMotions() +//----------------------------------------------------------------------------- +void LLMotionController::dumpMotions() +{ + llinfos << "=====================================" << llendl; + for (motion_map_t::iterator iter = mAllMotions.begin(); + iter != mAllMotions.end(); iter++) + { + LLUUID id = iter->first; + std::string state_string; + LLMotion *motion = iter->second; + if (mLoadingMotions.find(motion) != mLoadingMotions.end()) + state_string += std::string("l"); + if (mLoadedMotions.find(motion) != mLoadedMotions.end()) + state_string += std::string("L"); + if (std::find(mActiveMotions.begin(), mActiveMotions.end(), motion)!=mActiveMotions.end()) + state_string += std::string("A"); + if (mDeprecatedMotions.find(motion) != mDeprecatedMotions.end()) + state_string += std::string("D"); + llinfos << gAnimLibrary.animationName(id) << " " << state_string << llendl; + + } +} + //----------------------------------------------------------------------------- // deactivateAllMotions() //----------------------------------------------------------------------------- diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h index 9271483a2..f8bf5ac28 100644 --- a/indra/llcharacter/llmotioncontroller.h +++ b/indra/llcharacter/llmotioncontroller.h @@ -92,6 +92,7 @@ class LLMotionController public: typedef std::list motion_list_t; typedef std::set motion_set_t; + BOOL mIsSelf; public: // Constructor @@ -153,12 +154,12 @@ public: // pause and continue all motions void pauseAllMotions(); void unpauseAllMotions(); - BOOL isPaused() { return mPaused; } + BOOL isPaused() const { return mPaused; } void setTimeStep(F32 step); void setTimeFactor(F32 time_factor); - F32 getTimeFactor() { return mTimeFactor; } + F32 getTimeFactor() const { return mTimeFactor; } motion_list_t& getActiveMotions() { return mActiveMotions; } @@ -167,7 +168,11 @@ public: //protected: bool isMotionActive( LLMotion *motion ); bool isMotionLoading( LLMotion *motion ); - LLMotion *findMotion( const LLUUID& id ); + LLMotion *findMotion( const LLUUID& id ) const; + + void dumpMotions(); + + const LLFrameTimer& getFrameTimer() { return mTimer; } protected: // internal operations act on motion instances directly diff --git a/indra/llcharacter/llstatemachine.cpp b/indra/llcharacter/llstatemachine.cpp index 71e2eaaef..cc74d9ccf 100644 --- a/indra/llcharacter/llstatemachine.cpp +++ b/indra/llcharacter/llstatemachine.cpp @@ -54,6 +54,7 @@ bool operator!=(const LLUniqueID &a, const LLUniqueID &b) //----------------------------------------------------------------------------- LLStateDiagram::LLStateDiagram() { + mDefaultState = NULL; mUseDefaultState = FALSE; } @@ -305,6 +306,7 @@ LLStateMachine::LLStateMachine() // we haven't received a starting state yet mCurrentState = NULL; mLastState = NULL; + mLastTransition = NULL; mStateDiagram = NULL; } diff --git a/indra/llcharacter/llvisualparam.cpp b/indra/llcharacter/llvisualparam.cpp index 9579ff8af..122406e20 100644 --- a/indra/llcharacter/llvisualparam.cpp +++ b/indra/llcharacter/llvisualparam.cpp @@ -147,6 +147,21 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node) return TRUE; } +//virtual +void LLVisualParamInfo::toStream(std::ostream &out) +{ + out << mID << "\t"; + out << mName << "\t"; + out << mDisplayName << "\t"; + out << mMinName << "\t"; + out << mMaxName << "\t"; + out << mGroup << "\t"; + out << mMinWeight << "\t"; + out << mMaxWeight << "\t"; + out << mDefaultWeight << "\t"; + out << mSex << "\t"; +} + //----------------------------------------------------------------------------- // LLVisualParam() //----------------------------------------------------------------------------- @@ -158,7 +173,8 @@ LLVisualParam::LLVisualParam() mTargetWeight( 0.f ), mIsAnimating( FALSE ), mID( -1 ), - mInfo( 0 ) + mInfo( 0 ), + mIsDummy(FALSE) { } @@ -209,7 +225,7 @@ BOOL LLVisualParam::parseData(LLXmlTreeNode *node) //----------------------------------------------------------------------------- // setWeight() //----------------------------------------------------------------------------- -void LLVisualParam::setWeight(F32 weight, BOOL set_by_user) +void LLVisualParam::setWeight(F32 weight, BOOL upload_bake) { if (mIsAnimating) { @@ -227,15 +243,22 @@ void LLVisualParam::setWeight(F32 weight, BOOL set_by_user) if (mNext) { - mNext->setWeight(weight, set_by_user); + mNext->setWeight(weight, upload_bake); } } //----------------------------------------------------------------------------- // setAnimationTarget() //----------------------------------------------------------------------------- -void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user) +void LLVisualParam::setAnimationTarget(F32 target_value, BOOL upload_bake) { + // don't animate dummy parameters + if (mIsDummy) + { + setWeight(target_value, upload_bake); + return; + } + if (mInfo) { if (isTweakable()) @@ -251,7 +274,7 @@ void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user) if (mNext) { - mNext->setAnimationTarget(target_value, set_by_user); + mNext->setAnimationTarget(target_value, upload_bake); } } @@ -261,30 +284,44 @@ void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user) void LLVisualParam::setNextParam( LLVisualParam *next ) { llassert(!mNext); - + llassert(getWeight() == getDefaultWeight()); // need to establish mNext before we start changing values on this, else initial value won't get mirrored (we can fix that, but better to forbid this pattern) mNext = next; } //----------------------------------------------------------------------------- // animate() //----------------------------------------------------------------------------- -void LLVisualParam::animate( F32 delta, BOOL set_by_user ) +void LLVisualParam::animate( F32 delta, BOOL upload_bake ) { if (mIsAnimating) { F32 new_weight = ((mTargetWeight - mCurWeight) * delta) + mCurWeight; - setWeight(new_weight, set_by_user); + setWeight(new_weight, upload_bake); } } //----------------------------------------------------------------------------- // stopAnimating() //----------------------------------------------------------------------------- -void LLVisualParam::stopAnimating(BOOL set_by_user) +void LLVisualParam::stopAnimating(BOOL upload_bake) { if (mIsAnimating && isTweakable()) { mIsAnimating = FALSE; - setWeight(mTargetWeight, set_by_user); + setWeight(mTargetWeight, upload_bake); } } + +//virtual +BOOL LLVisualParam::linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params) +{ + // nothing to do for non-driver parameters + return TRUE; +} + +//virtual +void LLVisualParam::resetDrivenParams() +{ + // nothing to do for non-driver parameters + return; +} diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h index e8fa6d1c5..63b9d6893 100644 --- a/indra/llcharacter/llvisualparam.h +++ b/indra/llcharacter/llvisualparam.h @@ -36,6 +36,7 @@ #include "v3math.h" #include "llstring.h" #include "llxmltree.h" +#include class LLPolyMesh; class LLXmlTreeNode; @@ -69,6 +70,10 @@ public: virtual ~LLVisualParamInfo() {}; virtual BOOL parseXml(LLXmlTreeNode *node); + + S32 getID() const { return mID; } + + virtual void toStream(std::ostream &out); protected: S32 mID; // ID associated with VisualParam @@ -93,6 +98,7 @@ protected: class LLVisualParam { public: + typedef boost::function visual_param_mapper; LLVisualParam(); virtual ~LLVisualParam(); @@ -107,13 +113,16 @@ public: //virtual BOOL parseData( LLXmlTreeNode *node ) = 0; virtual void apply( ESex avatar_sex ) = 0; // Default functions - virtual void setWeight(F32 weight, BOOL set_by_user); - virtual void setAnimationTarget( F32 target_value, BOOL set_by_user ); - virtual void animate(F32 delta, BOOL set_by_user); - virtual void stopAnimating(BOOL set_by_user); + virtual void setWeight(F32 weight, BOOL upload_bake); + virtual void setAnimationTarget( F32 target_value, BOOL upload_bake ); + virtual void animate(F32 delta, BOOL upload_bake); + virtual void stopAnimating(BOOL upload_bake); + + virtual BOOL linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params); + virtual void resetDrivenParams(); // Interface methods - S32 getID() { return mID; } + S32 getID() const { return mID; } void setID(S32 id) { llassert(!mInfo); mID = id; } const std::string& getName() const { return mInfo->mName; } @@ -125,23 +134,25 @@ public: void setMaxDisplayName(const std::string& s) { mInfo->mMaxName = s; } void setMinDisplayName(const std::string& s) { mInfo->mMinName = s; } - EVisualParamGroup getGroup() const { return mInfo->mGroup; } - F32 getMinWeight() { return mInfo->mMinWeight; } - F32 getMaxWeight() { return mInfo->mMaxWeight; } - F32 getDefaultWeight() { return mInfo->mDefaultWeight; } - ESex getSex() { return mInfo->mSex; } + EVisualParamGroup getGroup() const { return mInfo->mGroup; } + F32 getMinWeight() const { return mInfo->mMinWeight; } + F32 getMaxWeight() const { return mInfo->mMaxWeight; } + F32 getDefaultWeight() const { return mInfo->mDefaultWeight; } + ESex getSex() const { return mInfo->mSex; } - F32 getWeight() { return mIsAnimating ? mTargetWeight : mCurWeight; } - F32 getCurrentWeight() { return mCurWeight; } - F32 getLastWeight() { return mLastWeight; } - BOOL isAnimating() { return mIsAnimating; } - BOOL isTweakable() { return (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) || (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT); } + F32 getWeight() const { return mIsAnimating ? mTargetWeight : mCurWeight; } + F32 getCurrentWeight() const { return mCurWeight; } + F32 getLastWeight() const { return mLastWeight; } + BOOL isAnimating() const { return mIsAnimating; } + BOOL isTweakable() const { return (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) || (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT); } LLVisualParam* getNextParam() { return mNext; } void setNextParam( LLVisualParam *next ); - virtual void setAnimating(BOOL is_animating) { mIsAnimating = is_animating; } - BOOL getAnimating() { return mIsAnimating; } + virtual void setAnimating(BOOL is_animating) { mIsAnimating = is_animating && !mIsDummy; } + BOOL getAnimating() const { return mIsAnimating; } + + void setIsDummy(BOOL is_dummy) { mIsDummy = is_dummy; } protected: F32 mCurWeight; // current weight @@ -149,6 +160,8 @@ protected: LLVisualParam* mNext; // next param in a shared chain F32 mTargetWeight; // interpolation target BOOL mIsAnimating; // this value has been given an interpolation target + BOOL mIsDummy; // this is used to prevent dummy visual params from animating + S32 mID; // id for storing weight/morphtarget compares compactly LLVisualParamInfo *mInfo; diff --git a/indra/newview/llassetconverter.cpp b/indra/newview/llassetconverter.cpp index b0a14dbc7..3fec62779 100644 --- a/indra/newview/llassetconverter.cpp +++ b/indra/newview/llassetconverter.cpp @@ -8,6 +8,7 @@ #include "llvorbisencode.h" #include "llbvhloader.h" // static +extern std::string STATUS[]; LLAssetType::EType LLAssetConverter::convert(std::string src_filename, std::string filename) { std::string exten = gDirUtilp->getExtension(src_filename); @@ -73,24 +74,24 @@ LLAssetType::EType LLAssetConverter::convert(std::string src_filename, std::stri //else if(exten == "tmp") FIXME else if (exten == "bvh") { + asset_type = LLAssetType::AT_ANIMATION; S32 file_size; LLAPRFile fp; fp.open(src_filename, LL_APR_RB, LLAPRFile::global, &file_size); if(!fp.getFileHandle()) return LLAssetType::AT_NONE; char* file_buffer = new char[file_size + 1]; - if(fp.read(file_buffer, file_size) == 0) //not sure if this is right, gotta check this one + ELoadStatus load_status = E_ST_OK; + S32 line_number = 0; + LLBVHLoader* loaderp = new LLBVHLoader(file_buffer, load_status, line_number); + + if(load_status == E_ST_NO_XLT_FILE) { - fp.close(); - delete[] file_buffer; - return LLAssetType::AT_NONE; + llwarns << "NOTE: No translation table found." << llendl; } - LLBVHLoader* loaderp = new LLBVHLoader(file_buffer); - if(!loaderp->isInitialized()) + else { - fp.close(); - delete[] file_buffer; - return LLAssetType::AT_NONE; + llwarns << "ERROR: [line: " << line_number << "] " << STATUS[load_status].c_str() << llendl; } S32 buffer_size = loaderp->getOutputSize(); U8* buffer = new U8[buffer_size]; diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp index c8c259413..c71a258d3 100644 --- a/indra/newview/llfloateranimpreview.cpp +++ b/indra/newview/llfloateranimpreview.cpp @@ -105,6 +105,43 @@ struct LLSaveInfo }; // +std::string STATUS[] = +{ + "E_ST_OK", + "E_ST_EOF", + "E_ST_NO_CONSTRAINT", + "E_ST_NO_FILE", + "E_ST_NO_HIER", + "E_ST_NO_JOINT", + "E_ST_NO_NAME", + "E_ST_NO_OFFSET", + "E_ST_NO_CHANNELS", + "E_ST_NO_ROTATION", + "E_ST_NO_AXIS", + "E_ST_NO_MOTION", + "E_ST_NO_FRAMES", + "E_ST_NO_FRAME_TIME", + "E_ST_NO_POS", + "E_ST_NO_ROT", + "E_ST_NO_XLT_FILE", + "E_ST_NO_XLT_HEADER", + "E_ST_NO_XLT_NAME", + "E_ST_NO_XLT_IGNORE", + "E_ST_NO_XLT_RELATIVE", + "E_ST_NO_XLT_OUTNAME", + "E_ST_NO_XLT_MATRIX", + "E_ST_NO_XLT_MERGECHILD", + "E_ST_NO_XLT_MERGEPARENT", + "E_ST_NO_XLT_PRIORITY", + "E_ST_NO_XLT_LOOP", + "E_ST_NO_XLT_EASEIN", + "E_ST_NO_XLT_EASEOUT", + "E_ST_NO_XLT_HAND", + "E_ST_NO_XLT_EMOTE", +"E_ST_BAD_ROOT" +}; + + //----------------------------------------------------------------------------- // LLFloaterAnimPreview() //----------------------------------------------------------------------------- @@ -303,14 +340,26 @@ BOOL LLFloaterAnimPreview::postBuild() { file_buffer[file_size] = '\0'; llinfos << "Loading BVH file " << mFilename << llendl; - loaderp = new LLBVHLoader(file_buffer); + ELoadStatus load_status = E_ST_OK; + S32 line_number = 0; + loaderp = new LLBVHLoader(file_buffer, load_status, line_number); + std::string status = getString(STATUS[load_status]); + + if(load_status == E_ST_NO_XLT_FILE) + { + llwarns << "NOTE: No translation table found." << llendl; + } + else + { + llwarns << "ERROR: [line: " << line_number << "] " << status << llendl; + } } infile.close() ; delete[] file_buffer; // moved everything bvh from below - if(loaderp && loaderp->isInitialized()) + if(loaderp && loaderp->isInitialized() && loaderp->getDuration() <= MAX_ANIM_DURATION) { mTransactionID.generate(); mMotionID = mTransactionID.makeAssetID(gAgent.getSecureSessionID()); @@ -345,9 +394,19 @@ BOOL LLFloaterAnimPreview::postBuild() success = false; if ( loaderp ) { - LLUIString out_str = getString("failed_file_read"); - out_str.setArg("[STATUS]", loaderp->getStatus()); // *TODO:Translate - childSetValue("bad_animation_text", out_str.getString()); + if (loaderp->getDuration() > MAX_ANIM_DURATION) + { + LLUIString out_str = getString("anim_too_long"); + out_str.setArg("[LENGTH]", llformat("%.1f", loaderp->getDuration())); + out_str.setArg("[MAX_LENGTH]", llformat("%.1f", MAX_ANIM_DURATION)); + getChild("bad_animation_text")->setValue(out_str.getString()); + } + else + { + LLUIString out_str = getString("failed_file_read"); + out_str.setArg("[STATUS]", getString(STATUS[loaderp->getStatus()])); + getChild("bad_animation_text")->setValue(out_str.getString()); + } } //setEnabled(FALSE); diff --git a/indra/newview/llviewerjointattachment.h b/indra/newview/llviewerjointattachment.h index f640e8ee0..7037db039 100644 --- a/indra/newview/llviewerjointattachment.h +++ b/indra/newview/llviewerjointattachment.h @@ -81,7 +81,7 @@ public: BOOL getIsHUDAttachment() const { return mIsHUDAttachment; } // [/RLVa:KB] - BOOL isAnimatable() { return FALSE; } + /*virtual*/ BOOL isAnimatable() const { return FALSE; } // S32 getGroup() { return mGroup; } // S32 getPieSlice() { return mPieSlice; } diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index b6156c8f5..ee019f659 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -148,7 +148,7 @@ public: void setIsTransparent(BOOL is_transparent) { mIsTransparent = is_transparent; } - /*virtual*/ BOOL isAnimatable() { return FALSE; } + /*virtual*/ BOOL isAnimatable() const { return FALSE; } static void updateVectorize(); // Update globals when settings variables change