| 239 | } |
| 240 | |
| 241 | void ForestWindMgr::updateWind( const Point3F &camPos, |
| 242 | const TreePlacementInfo &info, |
| 243 | F32 timeDelta ) |
| 244 | { |
| 245 | PROFILE_SCOPE(ForestWindMgr_updateWind); |
| 246 | |
| 247 | // See if we have the blended source available. |
| 248 | ForestWindAccumulator *blendDest = NULL; |
| 249 | { |
| 250 | IdToWindMap::Iterator iter = mPrevSources->find( info.itemKey ); |
| 251 | if ( iter != mPrevSources->end() ) |
| 252 | { |
| 253 | blendDest = iter->value; |
| 254 | mPrevSources->erase( iter ); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // Get some stuff we'll need for finding the emitters. |
| 259 | F32 treeHeight = info.scale * info.dataBlock->getObjBox().len_z(); |
| 260 | Point3F top = info.pos; |
| 261 | top.z += treeHeight; |
| 262 | if ( blendDest ) |
| 263 | top += ( 1.0f / info.scale ) * blendDest->getDirection(); |
| 264 | |
| 265 | // Go thru the emitters to accumulate the total wind force. |
| 266 | VectorF windForce( 0, 0, 0 ); |
| 267 | |
| 268 | F32 time = Sim::getCurrentTime() / 1000.0f; |
| 269 | |
| 270 | ForestWindEmitterList::iterator iter = mEmitters.begin(); |
| 271 | for ( ; iter != mEmitters.end(); iter++ ) |
| 272 | { |
| 273 | ForestWindEmitter *emitter = (*iter); |
| 274 | |
| 275 | // If disabled or no wind object... skip it. |
| 276 | if ( !emitter->isEnabled() || !emitter->getWind() ) |
| 277 | continue; |
| 278 | |
| 279 | ForestWind *wind = emitter->getWind(); |
| 280 | |
| 281 | F32 strength = wind->getStrength(); |
| 282 | |
| 283 | if ( emitter->isRadialEmitter() ) |
| 284 | { |
| 285 | Point3F closest = MathUtils::mClosestPointOnSegment( info.pos, top, emitter->getPosition() ); |
| 286 | Point3F dir = closest - emitter->getPosition(); |
| 287 | F32 lenSquared = dir.lenSquared(); |
| 288 | if ( lenSquared > emitter->getWindRadiusSquared() ) |
| 289 | continue; |
| 290 | |
| 291 | dir *= 1.0f / mSqrt( lenSquared ); |
| 292 | |
| 293 | F32 att = lenSquared / emitter->getWindRadiusSquared(); |
| 294 | strength *= 1.0f - att; |
| 295 | windForce += dir * strength; |
| 296 | } |
| 297 | else |
| 298 | { |
nothing calls this directly
no test coverage detected