Beispiel #1
0
		private Physics CreatePhysics(ErrorCallback errorCallback = null)
		{
			if (Physics.Instantiated)
				Assert.Fail("Physics is still created");

			if (errorCallback == null)
				errorCallback = _errorLog = new ErrorLog();

			if (_physics != null)
			{
				_physics.Dispose();
				_physics = null;
			}
			if (_foundation != null)
			{
				_foundation.Dispose();
				_foundation = null;
			}

			_foundation = new Foundation(errorCallback);

			_physics = new Physics(_foundation, checkRuntimeFiles: true);

			return _physics;
		}
Beispiel #2
0
        private Physics CreatePhysics(ErrorCallback errorCallback = null)
        {
            if (Physics.Instantiated)
            {
                Assert.Fail("Physics is still created");
            }

            if (errorCallback == null)
            {
                errorCallback = _errorLog = new ErrorLog();
            }

            if (_physics != null)
            {
                _physics.Dispose();
                _physics = null;
            }
            if (_foundation != null)
            {
                _foundation.Dispose();
                _foundation = null;
            }

            _foundation = new Foundation(errorCallback);

            _physics = new Physics(_foundation, checkRuntimeFiles: true);

            return(_physics);
        }
Beispiel #3
0
		public void CleanUp()
		{
			if (Physics.Instantiated)
			{
				_foundation.Dispose();
				_foundation = null;

				throw new Exception("After a test has run, the Physics singleton should have been disposed");
			}

			ObjectTable.Clear();

			if (_errorLog != null && _errorLog.HasErrors)
			{
				Trace.TraceError("There were errors, check the error log");
			}

			_errorLog = null;
		}
Beispiel #4
0
        public void CleanUp()
        {
            if (Physics.Instantiated)
            {
                _foundation?.Dispose();
                _foundation = null;

                throw new Exception("After a test has run, the Physics singleton should have been disposed");
            }

            ObjectTable.Clear();

            if (_errorLog != null && _errorLog.HasErrors)
            {
                Trace.TraceError("There were errors, check the error log");
            }

            _errorLog = null;
        }
Beispiel #5
0
        public override void Initialize(IMesher meshmerizer, Nini.Config.IConfigSource config, OpenMetaverse.UUID regionId)
        {
            _regionId = regionId;
            _mesher = meshmerizer;

            m_log.Info("[InWorldz.PhysxPhysics] Creating PhysX scene");

            if (config.Configs["InWorldz.PhysxPhysics"] != null)
            {
                Settings.Instance.UseVisualDebugger = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_visual_debugger", false);
                Settings.Instance.UseCCD = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_ccd", true);
                Settings.Instance.Gravity = config.Configs["InWorldz.PhysxPhysics"].GetFloat("gravity", -9.8f);
                Settings.Instance.ThrowOnSdkError = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("throw_on_sdk_error", false);
                Settings.Instance.InstrumentMeshing = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("instrument_meshing", false);
            }
            else
            {
                Settings.Instance.UseVisualDebugger = false;
                Settings.Instance.UseCCD = true;
                Settings.Instance.Gravity = -9.8f;
                Settings.Instance.ThrowOnSdkError = false;
                Settings.Instance.InstrumentMeshing = false;
            }

            Nini.Config.IConfig startupcfg = config.Configs["Startup"];
            if (startupcfg != null)
                _gridmode = startupcfg.GetBoolean("gridmode", false);

            if (_foundation == null)
            {
                _foundation = new PhysX.Foundation(s_ErrorCallback);
                _physics = new PhysX.Physics(_foundation);

                Material.BuiltinMaterialInit(_physics);
            }

            _sceneDesc = new PhysX.SceneDesc(null, Settings.Instance.UseCCD);
            _sceneDesc.Gravity = new PhysX.Math.Vector3(0f, 0f, Settings.Instance.Gravity);


            _simEventDelegator = new SimulationEventCallbackDelegator();
            _simEventDelegator.OnContactCallback += this.OnContact;
            _simEventDelegator.OnTriggerCallback += this.OnTrigger;
            _sceneDesc.SimulationEventCallback = _simEventDelegator;

            _scene = _physics.CreateScene(_sceneDesc);
            Preload();

            if (Settings.Instance.UseCCD)
            {
                _scene.SetFlag(PhysX.SceneFlag.SweptIntegration, true);
            }

            if (Settings.Instance.UseVisualDebugger && _physics.RemoteDebugger != null)
            {
                _physics.RemoteDebugger.Connect("localhost", null, null, PhysX.VisualDebugger.VisualDebuggerConnectionFlag.Debug, null);
            }

            _controllerManager = _scene.CreateControllerManager();

            CreateDefaults();

            _terrainMesher = new Meshing.TerrainMesher(_scene);
            _terrainMgr = new TerrainManager(_scene, _terrainMesher, regionId);
            _meshingStage = new Meshing.MeshingStage(_scene, meshmerizer, _terrainMesher);
            _meshingStage.OnShapeNeedsFreeing += new Meshing.MeshingStage.ShapeNeedsFreeingDelegate(_meshingStage_OnShapeNeedsFreeing);

            _kinematicManager = new KinematicManager();

            //fire up our work loop
            HeartbeatThread = Watchdog.StartThread(new ThreadStart(Heartbeat), "Physics Heartbeat",
                ThreadPriority.Normal, false);

            TimingThread = Watchdog.StartThread(new ThreadStart(DoTiming), string.Format("Physics Timing"),
                ThreadPriority.Highest, false);
        }
Beispiel #6
0
        public override void Initialize(IMesher meshmerizer, Nini.Config.IConfigSource config, OpenMetaverse.UUID regionId)
        {
            _regionId = regionId;
            _mesher   = meshmerizer;

            m_log.Info("[InWorldz.PhysxPhysics] Creating PhysX scene");

            if (config.Configs["InWorldz.PhysxPhysics"] != null)
            {
                Settings.Instance.UseVisualDebugger = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_visual_debugger", false);
                Settings.Instance.UseCCD            = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("use_ccd", true);
                Settings.Instance.Gravity           = config.Configs["InWorldz.PhysxPhysics"].GetFloat("gravity", -9.8f);
                Settings.Instance.ThrowOnSdkError   = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("throw_on_sdk_error", false);
                Settings.Instance.InstrumentMeshing = config.Configs["InWorldz.PhysxPhysics"].GetBoolean("instrument_meshing", false);
            }
            else
            {
                Settings.Instance.UseVisualDebugger = false;
                Settings.Instance.UseCCD            = true;
                Settings.Instance.Gravity           = -9.8f;
                Settings.Instance.ThrowOnSdkError   = false;
                Settings.Instance.InstrumentMeshing = false;
            }

            Nini.Config.IConfig startupcfg = config.Configs["Startup"];
            if (startupcfg != null)
            {
                _gridmode = startupcfg.GetBoolean("gridmode", false);
            }

            if (_foundation == null)
            {
                _foundation = new PhysX.Foundation(s_ErrorCallback);
                _physics    = new PhysX.Physics(_foundation);

                Material.BuiltinMaterialInit(_physics);
            }

            _sceneDesc         = new PhysX.SceneDesc(null, Settings.Instance.UseCCD);
            _sceneDesc.Gravity = new PhysX.Math.Vector3(0f, 0f, Settings.Instance.Gravity);


            _simEventDelegator = new SimulationEventCallbackDelegator();
            _simEventDelegator.OnContactCallback += this.OnContact;
            _simEventDelegator.OnTriggerCallback += this.OnTrigger;
            _sceneDesc.SimulationEventCallback    = _simEventDelegator;

            _scene = _physics.CreateScene(_sceneDesc);
            Preload();

            if (Settings.Instance.UseCCD)
            {
                _scene.SetFlag(PhysX.SceneFlag.SweptIntegration, true);
            }

            if (Settings.Instance.UseVisualDebugger && _physics.RemoteDebugger != null)
            {
                _physics.RemoteDebugger.Connect("localhost", null, null, PhysX.VisualDebugger.VisualDebuggerConnectionFlag.Debug, null);
            }

            _controllerManager = _scene.CreateControllerManager();

            CreateDefaults();

            _terrainMesher = new Meshing.TerrainMesher(_scene);
            _terrainMgr    = new TerrainManager(_scene, _terrainMesher, regionId);
            _meshingStage  = new Meshing.MeshingStage(_scene, meshmerizer, _terrainMesher);
            _meshingStage.OnShapeNeedsFreeing += new Meshing.MeshingStage.ShapeNeedsFreeingDelegate(_meshingStage_OnShapeNeedsFreeing);

            _kinematicManager = new KinematicManager();

            //fire up our work loop
            HeartbeatThread = Watchdog.StartThread(new ThreadStart(Heartbeat), "Physics Heartbeat",
                                                   ThreadPriority.Normal, false);

            TimingThread = Watchdog.StartThread(new ThreadStart(DoTiming), string.Format("Physics Timing"),
                                                ThreadPriority.Highest, false);
        }