@@ -42,7 +42,6 @@ public static AerodynamicsFX AeroFX
4242 public float MachAngle = 90 ;
4343 public float MachPass = 1 ;
4444 public float Mach = 0 ;
45- public Vector3 MachTipCameraNormal = new Vector3 ( ) ;
4645
4746 public bool SonicBoomed = true ;
4847
@@ -224,27 +223,24 @@ private void FixedUpdate()
224223 {
225224 VesselMass -= excludedPart . mass ;
226225 }
226+ }
227+
228+ private void LateUpdate ( )
229+ {
230+ if ( ! HighLogic . LoadedSceneIsFlight || ! initialized || gamePaused || noPhysics || ignoreVessel )
231+ return ;
232+
233+ if ( vesselDataDirty )
234+ {
235+ CacheVesselData ( ) ;
236+ }
227237
228238 if ( Settings . EnableAudioEffects && Settings . MufflerQuality > AudioMufflerQuality . Normal )
229239 {
230240 bool isActiveAndInternal = vessel == FlightGlobals . ActiveVessel && InternalCamera . Instance . isActive ;
231- var velocityDirection = vessel . velocityD . normalized * vessel . vesselSize . magnitude ;
232- var positionTip = transform . position + velocityDirection ;
233- var positionRear = transform . position - velocityDirection ;
234- var vesselTip = transform . position ;
235- var vesselRear = transform . position ;
236- RaycastHit tipHit ;
237-
238- if ( Physics . BoxCast ( positionTip , vessel . vesselSize , - vessel . velocityD . normalized , out tipHit ) )
239- {
240- vesselTip = tipHit . point ;
241- }
242-
243241 var cameraPosition = CameraManager . GetCurrentCamera ( ) . transform . position ;
244242
245- MachTipCameraNormal = ( cameraPosition - vesselTip ) . normalized ;
246243 Distance = Vector3 . Distance ( cameraPosition , transform . position ) ;
247- Angle = ( 1 + Vector3 . Dot ( MachTipCameraNormal , vessel . velocityD . normalized ) ) * 90 ;
248244
249245 if ( isActiveAndInternal )
250246 {
@@ -253,6 +249,25 @@ private void FixedUpdate()
253249 return ;
254250 }
255251
252+ if ( vessel . staticPressurekPa > 0 )
253+ {
254+ var vesselTip = transform . position ;
255+ var velocityDirection = vessel . velocityD . normalized * vessel . vesselSize . magnitude ;
256+ var positionTip = transform . position + velocityDirection ;
257+ Vector3 MachTipCameraNormal = ( cameraPosition - vesselTip ) . normalized ;
258+ RaycastHit tipHit ;
259+
260+ if ( Physics . BoxCast ( positionTip , vessel . vesselSize , - vessel . velocityD . normalized , out tipHit ) )
261+ {
262+ vesselTip = tipHit . point ;
263+ }
264+ Angle = ( 1 + Vector3 . Dot ( MachTipCameraNormal , vessel . velocityD . normalized ) ) * 90 ;
265+ }
266+ else
267+ {
268+ Angle = 0 ;
269+ }
270+
256271 if ( Settings . MachEffectsAmount > 0 )
257272 {
258273 Mach = ( float ) vessel . mach * Mathf . Clamp01 ( ( float ) ( vessel . staticPressurekPa * 1000 ) / 404.1f ) ;
@@ -266,17 +281,6 @@ private void FixedUpdate()
266281 MachPass = 1 ;
267282 }
268283 }
269- }
270-
271- private void LateUpdate ( )
272- {
273- if ( ! HighLogic . LoadedSceneIsFlight || ! initialized || gamePaused || noPhysics || ignoreVessel )
274- return ;
275-
276- if ( vesselDataDirty )
277- {
278- CacheVesselData ( ) ;
279- }
280284
281285 foreach ( var soundLayerGroup in ShipEffectsConfig . SoundLayerGroups )
282286 {
0 commit comments