void LLWLAnimator::update(LLWLParamSet& curParams) { F64 curTime; curTime = getDayTime(); // don't do anything if empty if(mTimeTrack.size() == 0) { return; } // start it off mFirstIt = mTimeTrack.begin(); mSecondIt = mTimeTrack.begin(); mSecondIt++; // grab the two tween iterators 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) { mSecondIt = mTimeTrack.begin(); mFirstIt = mTimeTrack.end(); mFirstIt--; } F32 weight = 0; 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) { // right edge of time line if(curTime >= mFirstIt->first) { weight = F32 (curTime - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); // left edge of time line } else { weight = F32 ((1 + curTime) - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); } // handle same as whatever the last one is } else { weight = 1; } // do the interpolation and set the parameters curParams.mix(LLWLParamManager::instance()->mParamList[mFirstIt->second], LLWLParamManager::instance()->mParamList[mSecondIt->second], weight); }
double Date::getSecond( void ) { double th, tm, ts ; getDayTime(static_cast<double>(jul.time), &th, &tm, &ts); return ts; }
double Date::getMinute( void ) { double th, tm, ts ; getDayTime(static_cast<double>(jul.time), &th, &tm, &ts); return tm; }
void Date::julian2ProlGreg( const Date::Julian &myJul, double *yr, double *mo, double *day, double *hr, double *mi, double *se ) { /* uint32_t J = static_cast<uint32_t>(myJul.jdn) ; uint32_t j = J + static_cast<uint32_t>(32044) ; uint32_t g = j / 146097; uint32_t dg = j % 146097; uint32_t c = (dg / 36524 + 1) * 3 / 4; uint32_t dc = dg - c * 36524; uint32_t b = dc / 1461; uint32_t db = dc % 1461; uint32_t a = (db / 365 + 1) * 3 / 4; uint32_t da = db - a * 365; uint32_t y = g * 400 + c * 100 + b * 4 + a; uint32_t m = (da * 5 + 308) / 153 - 2; uint32_t d = da - (m + 4) * 153 / 5 + 122; uint32_t Y = y - 4800 + (m + 2) / 12; uint32_t M = (m + 2) % 12 + 1; *yr = Y ; *mo = M ; *day = d + 1; */ uint32_t f = static_cast<uint32_t>(myJul.jdn) ; f = f + 1401 + ((( 4*f + 274277)/146097) * 3)/4 -38 ; uint32_t e = 4*f + 3 ; uint32_t g = ( e % 1461 ) / 4 ; uint32_t h = 5 * g + 2 ; uint32_t D = (h % 153) / 5 + 1 ; uint32_t M = (h/153 + 2) % 12 + 1 ; uint32_t Y = e/1461 - 4716 + (12 + 2 - M)/12 ; *yr = Y ; *mo = M ; *day = D ; // get the civil time getDayTime(static_cast<double>(myJul.time), hr, mi, se); return; }
void LLWLAnimator::update(LLWLParamSet& curParams) { //llassert(mUseLindenTime != mUseLocalTime); F64 curTime; curTime = getDayTime(); // don't do anything if empty if(mTimeTrack.size() == 0) { return; } // start it off mFirstIt = mTimeTrack.begin(); mSecondIt = mTimeTrack.begin(); mSecondIt++; // grab the two tween iterators 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) { mSecondIt = mTimeTrack.begin(); mFirstIt = mTimeTrack.end(); mFirstIt--; } F32 weight = 0; 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) { // right edge of time line if(curTime >= mFirstIt->first) { weight = F32 (curTime - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); // left edge of time line } else { weight = F32 ((1 + curTime) - mFirstIt->first) / ((1 + mSecondIt->first) - mFirstIt->first); } // handle same as whatever the last one is } else { weight = 1; } if(mIsInterpolating) { // *TODO_JACOB: this is kind of laggy. Not sure why. The part that lags is the curParams.mix call, and none of the other mixes. It works, though. clock_t current = clock(); if(current >= mInterpEndTime) { if (mIsInterpolatingSky) { deactivate(); // FIRE-3245: Some settings do not get fully mixed properly (possibly due to value extremes) // at the end of the interp cycle, force the end settings to get applied curParams.setAll(mInterpEndWL->getAll()); } // <FS:Ansariel> FIRE-11158: Set final merge for water WL on extreme values LLWaterParamManager::getInstance()->mCurParams.setAll(mInterpEndWater->getAll()); mIsInterpolating = false; mIsInterpolatingSky = false; return; } // <FS:Ansariel> Custom Windlight interpolate time static LLCachedControl<F32> interpolate_time(gSavedSettings, "FSWindlightInterpolateTime"); if (mIsInterpolatingSky) { // <FS:Ansariel> Custom Windlight interpolate time //weight = (current - mInterpStartTime) / (INTERP_TOTAL_SECONDS * CLOCKS_PER_SEC); weight = (current - mInterpStartTime) / ((F64)interpolate_time * CLOCKS_PER_SEC); curParams.mix(*mInterpBeginWL, *mInterpEndWL, weight); } else { // determine moving target for final interpolation value // *TODO: this will not work with lazy loading of sky presets. LLWLParamSet buf = LLWLParamSet(); buf.setAll(LLWLParamManager::getInstance()->mParamList[mFirstIt->second].getAll()); // just give it some values, otherwise it has no params to begin with (see comment in constructor) buf.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); // mix to determine moving target for interpolation finish (as below) // mix from previous value to moving target // <FS:Ansariel> Custom Windlight interpolate time //weight = (current - mInterpStartTime) / (INTERP_TOTAL_SECONDS * CLOCKS_PER_SEC); weight = (current - mInterpStartTime) / ((F64)interpolate_time * CLOCKS_PER_SEC); curParams.mix(*mInterpBeginWL, buf, weight); } // mix water LLWaterParamManager::getInstance()->mCurParams.mix(*mInterpBeginWater, *mInterpEndWater, weight); } else { // do the interpolation and set the parameters // *TODO: this will not work with lazy loading of sky presets. curParams.mix(LLWLParamManager::getInstance()->mParamList[mFirstIt->second], LLWLParamManager::getInstance()->mParamList[mSecondIt->second], weight); } }
void Date::julian2ModelDate( const Date::Julian &j, double *y, double *mo, double *d, double *h, double *mi, double *s ) { double resid; *mo = *d = 1.; *h = *mi = *s = 0.; if( currCalendarEnum == EQUAL_MONTHS ) { long double jd=j.jdn + j.time ; // this kind of julian day starts at 0000-01-01T00:00:00 *y = static_cast<double> ( static_cast<long long int> (jd / 360. ) ) ; resid = static_cast<double>( jd - *y*360. ); if( resid == 0. ) { *y += 1.; return; } *mo = static_cast<double>( static_cast<int>(resid / 30.) ) ; resid -= *mo*30 ; *d = static_cast<double>( static_cast<int>(resid) ) ; resid -= *d ; } else { // explicitly: months and/or leap year and/or leap_month // For calender: NO_LEAP, ALL_LEAP, UNDEF and not provided long double jd=j.jdn + j.time ; long double yrDays; if( currCalendarEnum == ALL_LEAP ) yrDays = 366. ; else if( lY_is ) yrDays = lY_yrDays + 0.25; else yrDays = 365. ; // this kind of julian day==0 starts at 0000-01-01T00:00:00 *y = static_cast<double> ( static_cast<long long int> (jd / yrDays ) ) ; resid = static_cast<double>( jd - *y*yrDays ); if( resid == 0. ) return; bool isCurrLY = false; if( lY_is ) if( (static_cast<int>(*y) - lY_start) % 4 == 0 ) isCurrLY = true; // we are looking for the current month double tmp=0. ; for(int imon=0 ; imon < 12 ; ++imon) { double currMon = regularMonthDays[imon]; if( isCurrLY && imon == lY_month ) currMon += 1.; tmp += currMon; if( tmp > resid ) { *mo = static_cast<double>(imon) ; resid -= (tmp - currMon); *d=static_cast<double>( static_cast<int>(resid) ) ; resid -= *d; break; } } } // day time getDayTime(resid, h, mi, s); // convert from numerical to date representation // y=1900, mo=11, d=30, h=24 <--> 1901-01-01 00:00:00 *y += 1. ; *mo += 1. ; *d += 1. ; return ; }