Ejemplo n.º 1
0
        private void RecalculateVoxel()
        {
            //this has been updated recently in the past; queue an update and return
            if (_updateRateLimiter < FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate)
            {
                VoxelizationUpdateQueued = true;
                return;
            }

            _updateRateLimiter       = 0;
            VoxelizationUpdateQueued = false;
            List <Part> partList = EditorLogic.SortedShipList;

            _currentGeometryModules.Clear();

            foreach (Part p in partList)
            {
                if (!p.Modules.Contains <GeometryPartModule>())
                {
                    continue;
                }
                GeometryPartModule g = p.Modules.GetModule <GeometryPartModule>();
                if (g == null)
                {
                    continue;
                }
                if (g.Ready)
                {
                    _currentGeometryModules.Add(g);
                }
                else
                {
                    _updateRateLimiter       = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                    VoxelizationUpdateQueued = true;
                    return;
                }
            }

            TriggerIGeometryUpdaters();


            if (_currentGeometryModules.Count <= 0)
            {
                return;
            }
            voxelWatch.Start();
            if (_vehicleAero.TryVoxelUpdate(EditorLogic.RootPart.partTransform.worldToLocalMatrix,
                                            EditorLogic.RootPart.partTransform.localToWorldMatrix,
                                            FARSettingsScenarioModule.VoxelSettings.numVoxelsControllableVessel,
                                            partList,
                                            _currentGeometryModules))
            {
                return;
            }
            voxelWatch.Stop();
            voxelWatch.Reset();
            _updateRateLimiter       = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
            VoxelizationUpdateQueued = true;
        }
Ejemplo n.º 2
0
        void RecalculateVoxel()
        {
            if (_updateRateLimiter < FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate)        //this has been updated recently in the past; queue an update and return
            {
                _updateQueued = true;
                return;
            }
            else                                //last update was far enough in the past to run; reset rate limit counter and clear the queued flag
            {
                _updateRateLimiter = 0;
                _updateQueued      = false;
            }
            List <Part> partList = EditorLogic.SortedShipList;

            _currentGeometryModules.Clear();

            for (int i = 0; i < partList.Count; i++)
            {
                Part p = partList[i];
                if (p.Modules.Contains <GeometryPartModule>())
                {
                    GeometryPartModule g = p.Modules.GetModule <GeometryPartModule>();
                    if (g != null)
                    {
                        if (g.Ready)
                        {
                            _currentGeometryModules.Add(g);
                        }
                        else
                        {
                            _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                            _updateQueued      = true;
                            //FARLogger.Info("We're not ready!");
                            return;
                        }
                    }
                }
            }
            TriggerIGeometryUpdaters();


            if (_currentGeometryModules.Count > 0)
            {
                voxelWatch.Start();
                if (!_vehicleAero.TryVoxelUpdate(EditorLogic.RootPart.partTransform.worldToLocalMatrix, EditorLogic.RootPart.partTransform.localToWorldMatrix, FARSettingsScenarioModule.VoxelSettings.numVoxelsControllableVessel, partList, _currentGeometryModules, true))
                {
                    voxelWatch.Stop();
                    voxelWatch.Reset();
                    _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                    _updateQueued      = true;
                }
            }
        }
Ejemplo n.º 3
0
        public void VesselUpdate(bool recalcGeoModules)
        {
            if (vessel == null)
            {
                vessel = gameObject.GetComponent <Vessel>();
                if (vessel == null || vessel.vesselTransform == null)
                {
                    return;
                }
            }

            if (_vehicleAero == null)
            {
                _vehicleAero         = new VehicleAerodynamics();
                _vesselIntakeRamDrag = new VesselIntakeRamDrag();
            }

            if (_updateRateLimiter < FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate)         //this has been updated recently in the past; queue an update and return
            {
                _updateQueued = true;
                return;
            }
            else                                 //last update was far enough in the past to run; reset rate limit counter and clear the queued flag
            {
                _updateRateLimiter = 0;
                _updateQueued      = false;
            }
            if (vessel.rootPart.Modules.Contains <LaunchClamp>())// || _vessel.rootPart.Modules.Contains("KerbalEVA"))
            {
                DisableModule();
                return;
            }
            if (recalcGeoModules)
            {
                _currentGeoModules.Clear();
                geoModulesReady = 0;
                for (int i = 0; i < vessel.Parts.Count; i++)
                {
                    Part p = vessel.Parts[i];
                    GeometryPartModule g = p.Modules.GetModule <GeometryPartModule>();
                    if ((object)g != null)
                    {
                        _currentGeoModules.Add(g);
                        if (g.Ready)
                        {
                            geoModulesReady++;
                        }
                    }
                }
            }
            if (_currentGeoModules.Count > geoModulesReady)
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
                return;
            }

            if (_currentGeoModules.Count == 0)
            {
                DisableModule();
                Debug.Log("Disabling FARVesselAero on " + vessel.name + " due to no FARGeometryModules on board");
            }

            TriggerIGeometryUpdaters();
            if (FARThreading.VoxelizationThreadpool.RunInMainThread)
            {
                for (int i = _currentGeoModules.Count - 1; i >= 0; --i)
                {
                    if (!_currentGeoModules[i].Ready)
                    {
                        _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                        _updateQueued      = true;
                        return;
                    }
                }
            }

            _voxelCount = VoxelCountFromType();
            if (!_vehicleAero.TryVoxelUpdate(vessel.vesselTransform.worldToLocalMatrix, vessel.vesselTransform.localToWorldMatrix, _voxelCount, vessel.Parts, _currentGeoModules, !setup))
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
            }
            if (!_updateQueued)
            {
                setup = true;
            }

            Debug.Log("Updating vessel voxel for " + vessel.vesselName);
        }
Ejemplo n.º 4
0
        public void VesselUpdate(bool recalcGeoModules)
        {
            if (vessel == null)
            {
                vessel = gameObject.GetComponent <Vessel>();
                if (vessel == null || vessel.vesselTransform == null)
                {
                    return;
                }
            }

            if (_vehicleAero == null)
            {
                _vehicleAero         = new VehicleAerodynamics();
                _vesselIntakeRamDrag = new VesselIntakeRamDrag();
            }

            //this has been updated recently in the past; queue an update and return
            if (_updateRateLimiter < FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate)
            {
                _updateQueued = true;
                return;
            }

            _updateRateLimiter = 0;
            _updateQueued      = false;
            if (vessel.rootPart.Modules.Contains <LaunchClamp>())
            {
                DisableModule();
                return;
            }

            if (recalcGeoModules)
            {
                _currentGeoModules.Clear();
                geoModulesReady = 0;
                foreach (Part p in vessel.Parts)
                {
                    GeometryPartModule g = p.Modules.GetModule <GeometryPartModule>();
                    if (g is null)
                    {
                        continue;
                    }
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }
            }

            if (_currentGeoModules.Count > geoModulesReady)
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
                return;
            }

            if (_currentGeoModules.Count == 0)
            {
                DisableModule();
                FARLogger.Info("Disabling FARVesselAero on " + vessel.name + " due to no FARGeometryModules on board");
            }

            TriggerIGeometryUpdaters();
            if (VoxelizationThreadpool.RunInMainThread)
            {
                for (int i = _currentGeoModules.Count - 1; i >= 0; --i)
                {
                    if (_currentGeoModules[i].Ready)
                    {
                        continue;
                    }
                    _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                    _updateQueued      = true;
                    return;
                }
            }

            _voxelCount = VoxelCountFromType();
            if (!_vehicleAero.TryVoxelUpdate(vessel.vesselTransform.worldToLocalMatrix,
                                             vessel.vesselTransform.localToWorldMatrix,
                                             _voxelCount,
                                             vessel.Parts,
                                             _currentGeoModules,
                                             !setup,
                                             vessel))
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
            }

            if (!_updateQueued)
            {
                setup = true;
            }

            FARLogger.Info("Updating vessel voxel for " + vessel.vesselName);
        }
Ejemplo n.º 5
0
        public void VesselUpdate(bool recalcGeoModules)
        {
            if (_vessel == null)
            {
                _vessel = gameObject.GetComponent <Vessel>();
            }
            if (_vehicleAero == null)
            {
                _vehicleAero         = new VehicleAerodynamics();
                _vesselIntakeRamDrag = new VesselIntakeRamDrag();
            }

            if (_updateRateLimiter < FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate)         //this has been updated recently in the past; queue an update and return
            {
                _updateQueued = true;
                return;
            }
            else                                 //last update was far enough in the past to run; reset rate limit counter and clear the queued flag
            {
                _updateRateLimiter = 0;
                _updateQueued      = false;
            }

            if (_vessel.rootPart.Modules.Contains("LaunchClamp") || _vessel.rootPart.Modules.Contains("KerbalEVA"))
            {
                DisableModule();
                return;
            }

            if (recalcGeoModules)
            {
                _currentGeoModules = new List <GeometryPartModule>();
                geoModulesReady    = 0;
                for (int i = 0; i < _vessel.Parts.Count; i++)
                {
                    Part p = _vessel.parts[i];
                    GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                    if ((object)g != null)
                    {
                        _currentGeoModules.Add(g);
                        if (g.Ready)
                        {
                            geoModulesReady++;
                        }
                    }
                }
            }

            if (_currentGeoModules.Count > geoModulesReady)
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
                return;
            }

            if (_currentGeoModules.Count == 0)
            {
                DisableModule();
            }

            TriggerIGeometryUpdaters();

            _voxelCount = VoxelCountFromType();
            if (!_vehicleAero.TryVoxelUpdate(_vessel.vesselTransform.worldToLocalMatrix, _vessel.vesselTransform.localToWorldMatrix, _voxelCount, _vessel.Parts, _currentGeoModules, !setup))
            {
                _updateRateLimiter = FARSettingsScenarioModule.VoxelSettings.minPhysTicksPerUpdate - 2;
                _updateQueued      = true;
            }

            setup = true;

            Debug.Log("Updating vessel voxel for " + _vessel.vesselName);
        }