Windlight/water parameter managers now derived from standard LLSingleton instead of using some silly redundant clone.

This commit is contained in:
Shyotl
2011-09-02 06:35:53 -05:00
parent 91cb401324
commit 443d4e9f56
31 changed files with 418 additions and 390 deletions

View File

@@ -49,7 +49,8 @@ void LLWLAnimator::update(LLWLParamSet& curParams)
curTime = getDayTime();
// don't do anything if empty
if(mTimeTrack.size() == 0) {
if(mTimeTrack.size() == 0)
{
return;
}
@@ -59,13 +60,15 @@ void LLWLAnimator::update(LLWLParamSet& curParams)
mSecondIt++;
// grab the two tween iterators
while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first) {
while(mSecondIt != mTimeTrack.end() && curTime > mSecondIt->first)
{
mFirstIt++;
mSecondIt++;
}
// scroll it around when you get to the end
if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime) {
if(mSecondIt == mTimeTrack.end() || mFirstIt->first > curTime)
{
mSecondIt = mTimeTrack.begin();
mFirstIt = mTimeTrack.end();
mFirstIt--;
@@ -73,56 +76,66 @@ void LLWLAnimator::update(LLWLParamSet& curParams)
F32 weight = 0;
if(mFirstIt->first < mSecondIt->first) {
if(mFirstIt->first < mSecondIt->first)
{
// get the delta time and the proper weight
weight = F32 (curTime - mFirstIt->first) /
(mSecondIt->first - mFirstIt->first);
// handle the ends
} else if(mFirstIt->first > mSecondIt->first) {
}
else if(mFirstIt->first > mSecondIt->first)
{
// right edge of time line
if(curTime >= mFirstIt->first) {
if(curTime >= mFirstIt->first)
{
weight = F32 (curTime - mFirstIt->first) /
((1 + mSecondIt->first) - mFirstIt->first);
// left edge of time line
} else {
}
else
{
weight = F32 ((1 + curTime) - mFirstIt->first) /
((1 + mSecondIt->first) - mFirstIt->first);
}
// handle same as whatever the last one is
} else {
}
else
{
weight = 1;
}
// do the interpolation and set the parameters
curParams.mix(LLWLParamManager::instance()->mParamList[mFirstIt->second],
LLWLParamManager::instance()->mParamList[mSecondIt->second], weight);
curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second],
LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight);
}
F64 LLWLAnimator::getDayTime()
{
if(!mIsRunning) {
if(!mIsRunning)
{
return mDayTime;
}
if(mUseLindenTime) {
if(mUseLindenTime)
{
F32 phase = gSky.getSunPhase() / F_PI;
// we're not solving the non-linear equation that determines sun phase
// we're just linearly interpolating between the major points
if (phase <= 5.0 / 4.0) {
mDayTime = (1.0 / 3.0) * phase + (1.0 / 3.0);
} else {
}
else
{
mDayTime = phase - (1.0 / 2.0);
}
if(mDayTime > 1) {
if(mDayTime > 1)
{
mDayTime--;
}
@@ -133,10 +146,12 @@ F64 LLWLAnimator::getDayTime()
mDayTime = (LLTimer::getElapsedSeconds() - mStartTime) / mDayRate;
// clamp it
if(mDayTime < 0) {
if(mDayTime < 0)
{
mDayTime = 0;
}
while(mDayTime > 1) {
while(mDayTime > 1)
{
mDayTime--;
}
@@ -150,9 +165,12 @@ void LLWLAnimator::setDayTime(F64 dayTime)
mDayTime = dayTime;
// clamp it
if(mDayTime < 0) {
if(mDayTime < 0)
{
mDayTime = 0;
} else if(mDayTime > 1) {
}
else if(mDayTime > 1)
{
mDayTime = 1;
}
}