Esempio n. 1
0
        public void HandleSensorChanges()
        {
            foreach (var sensorToRemoveKVP in m_SensorsToRemove)
            {
                MySensor sensorToRemove = sensorToRemoveKVP.Value;

                ClearSensor(sensorToRemove);

                m_Sensors.Remove(sensorToRemove);
            }
            m_SensorsToRemove.Clear();

            foreach (var sensorToAddKVP in m_SensorsToAdd)
            {
                MySensor sensorToAdd = sensorToAddKVP.Value;

                // insert to sort into bp
                MySensorElement elem = sensorToAdd.GetElement();
                elem.UpdateAABB();
                MyPhysics.physicsSystem.GetRigidBodyModule().GetBroadphase().CreateVolume(elem);
                sensorToAdd.Inserted = true;

                m_Sensors.Add(sensorToAdd);
            }
            m_SensorsToAdd.Clear();
        }
Esempio n. 2
0
        private void ClearSensor(MySensor sensor)
        {
            MySensorElement elem = sensor.GetElement();

            elem.UpdateAABB();
            MyPhysics.physicsSystem.GetRigidBodyModule().GetBroadphase().DestroyVolume(elem);
            foreach (var siKvp in sensor.m_Interactions)
            {
                MyPhysics.physicsSystem.GetSensorInteractionModule().RemoveSensorInteraction(siKvp.Value);
            }
            sensor.m_Interactions.Clear();
            sensor.Active   = false;
            sensor.Inserted = false;

            if (sensor.IsMarkedForClose())
            {
                sensor.Close();
            }
        }