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

Method _renderCone

Engine/source/T3D/sfx/sfxEmitter.cpp:959–1037  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957//-----------------------------------------------------------------------------
958
959void SFXEmitter::_renderCone( F32 radialIncrements, F32 sweepIncrements,
960 F32 pointDistance,
961 F32 startAngle, F32 stopAngle,
962 F32 startVolume, F32 stopVolume,
963 const ColorI& color )
964{
965 if( startAngle == stopAngle )
966 return;
967
968 const F32 startAngleRadians = mDegToRad( startAngle );
969 const F32 stopAngleRadians = mDegToRad( stopAngle );
970 const F32 radialIncrementsRadians = mDegToRad( radialIncrements );
971
972 // Unit quaternions representing the start and end angle so we
973 // can interpolate between the two without flipping.
974
975 QuatF rotateZStart( EulerF( 0.f, 0.f, startAngleRadians / 2.f ) );
976 QuatF rotateZEnd( EulerF( 0.f, 0.f, stopAngleRadians / 2.f ) );
977
978 // Do an angular sweep on one side of our XY disc. Since we do a full 360 radial sweep
979 // around Y for each angle, we only need to sweep over one side.
980
981 const F32 increment = 1.f / ( ( ( startAngle / 2.f ) - ( stopAngle / 2.f ) ) / sweepIncrements );
982 for( F32 t = 0.f; t < 1.0f; t += increment )
983 {
984 // Quaternion to rotate point into place on XY disc.
985 QuatF rotateZ;
986 rotateZ.interpolate( rotateZStart, rotateZEnd, t );
987
988 // Quaternion to rotate one position around Y axis. Used for radial sweep.
989 QuatF rotateYOne( EulerF( 0.f, radialIncrementsRadians, 0.f ) );
990
991 // Do a radial sweep each step along the distance axis. For each step, volume is
992 // the same for any point on the sweep circle.
993
994 for( F32 y = pointDistance; y <= mDescription.mMaxDistance; y += pointDistance )
995 {
996 ColorI c = color;
997
998 // Compute volume at current point. First off, find the interpolated volume
999 // in the cone. Only for the outer cone will this actually result in
1000 // interpolation. For the remaining angles, the cone volume is constant.
1001
1002 F32 volume = mLerp( startVolume, stopVolume, t );
1003 if( volume == 0.f )
1004 c.alpha = 0;
1005 else
1006 {
1007 // Apply distance attenuation.
1008
1009 F32 attenuatedVolume = SFXDistanceAttenuation(
1010 SFX->getDistanceModel(),
1011 mDescription.mMinDistance,
1012 mDescription.mMaxDistance,
1013 y,
1014 volume,
1015 SFX->getRolloffFactor() ); //RDTODO
1016

Callers

nothing calls this directly

Calls 9

mDegToRadFunction · 0.85
mLerpFunction · 0.85
SFXDistanceAttenuationFunction · 0.85
vertex3fFunction · 0.85
getDistanceModelMethod · 0.80
mulPMethod · 0.80
colorFunction · 0.50
interpolateMethod · 0.45
getRolloffFactorMethod · 0.45

Tested by

no test coverage detected