private void ApplyIntakeDrag(float currentRamDrag, Vector3 vesselVelNorm, float dynPres)
        {
            for (int i = _intakeTransforms.Count - 1; i >= 0; i--)
            {
                ModuleResourceIntake intake = _intakeModules[i];
                if (!intake.intakeEnabled)
                {
                    continue;
                }

                Transform transform = _intakeTransforms[i];
                if (transform == null)
                {
                    _intakeModules.RemoveAt(i);
                    _intakeTransforms.RemoveAt(i);
                    _aeroModulesWithIntakes.RemoveAt(i);
                    //++i;
                    continue;
                }

                float cosAoA = Vector3.Dot(_intakeTransforms[i].forward, vesselVelNorm);
                if (cosAoA < 0)
                {
                    cosAoA = 0;
                }

                if (cosAoA <= 0)
                {
                    continue;
                }

                FARAeroPartModule aeroModule = _aeroModulesWithIntakes[i];


                Vector3 force = -aeroModule.partLocalVelNorm * cosAoA * currentRamDrag * (float)intake.area * 100f;
                //if(float.IsNaN(force.sqrMagnitude))
                //    force = Vector3.zero;
                aeroModule.AddLocalForce(force, Vector3.zero);
            }
        }
Пример #2
0
        private void ApplyIntakeDrag(float currentRamDrag, Vector3 vesselVelNorm, float dynPres)
        {
            for (int i = 0; i < _intakeTransforms.Count; i++)
            {
                ModuleResourceIntake intake = _intakeModules[i];
                if (!intake.intakeEnabled)
                {
                    continue;
                }

                Transform transform = _intakeTransforms[i];
                if (transform == null)
                {
                    _intakeModules.RemoveAt(i);
                    _intakeTransforms.RemoveAt(i);
                    _aeroModulesWithIntakes.RemoveAt(i);
                    --i;
                    continue;
                }

                float cosAoA = Vector3.Dot(_intakeTransforms[i].forward, vesselVelNorm);
                if (cosAoA < 0)
                {
                    cosAoA = 0;
                }

                if (cosAoA <= intake.aoaThreshold)
                {
                    continue;
                }

                FARAeroPartModule aeroModule = _aeroModulesWithIntakes[i];

                aeroModule.AddLocalForce(-aeroModule.partLocalVelNorm * dynPres * cosAoA * currentRamDrag * intake.area * 100, Vector3.zero);
            }
        }