MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / updateWind

Method updateWind

Engine/source/forest/forestWindMgr.cpp:241–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void 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 {

Callers

nothing calls this directly

Calls 15

mClosestPointOnSegmentFunction · 0.85
mSqrtFunction · 0.85
mSinFunction · 0.85
getWindMethod · 0.80
isRadialEmitterMethod · 0.80
getWindRadiusSquaredMethod · 0.80
presimulateMethod · 0.80
insertUniqueMethod · 0.80
getCurrentTimeFunction · 0.50
mDotFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected