public void Clear() { m_glare = null; m_ignoreEntity1 = null; m_ignoreEntity2 = null; IsDone = false; }
public void Clear() { m_glare = null; m_ignoreEntity1 = null; m_ignoreEntity2 = null; IsDone = false; }
public void Start(MyLightGlare glare, Vector3 cameraPosition, MyEntity ignoreEntity1 = null, MyEntity ignoreEntity2 = null) { m_glare = glare; m_cameraPosition = cameraPosition; m_ignoreEntity1 = ignoreEntity1; m_ignoreEntity2 = ignoreEntity2; IsDone = false; }
public void Start(MyLightGlare glare, Vector3 cameraPosition, MyEntity ignoreEntity1 = null, MyEntity ignoreEntity2 = null) { m_glare = glare; m_cameraPosition = cameraPosition; m_ignoreEntity1 = ignoreEntity1; m_ignoreEntity2 = ignoreEntity2; IsDone = false; }
// IMPORTANT: This class isn't realy inicialized by constructor, but by Start() // So don't initialize members here, do it in Start() public MyLight() { m_glare = new MyLightGlare(this); }
public void DoWork() { var glare = m_glare; // we copy variable because other thread can null it if (glare == null) return; if (Vector3.DistanceSquared(glare.Position, m_cameraPosition) < MyMwcMathConstants.EPSILON) return; var directLine = new MyLine(glare.Position, m_cameraPosition); m_helperCollection.Clear(); using (MyEntities.EntityCloseLock.AcquireSharedUsing()) { var intersectionResult = MyEntities.GetIntersectionWithLine(ref directLine, m_ignoreEntity1, m_ignoreEntity2, false, false, false, false, true); //var intersectionResult = MyRender.GetAnyIntersectionWithLine(ref directLine, m_ignoreEntity1, m_ignoreEntity2, true); if (intersectionResult == null) { if (MySession.PlayerShip == null || MySession.PlayerShip.Weapons == null) { IsDone = true; m_helperCollection.Clear(); return; } MyIntersectionResultLineTriangleEx? cockpitIntersection = GetIntersectionInNearSpace(MySession.PlayerShip.GetShipCockpit(), ref directLine, true); Visible = !cockpitIntersection.HasValue; Debug.Assert(m_helperCollection.Count == 0); m_helperCollection.AddRange(MySession.PlayerShip.Weapons.GetMountedWeaponsWithHarvesterAndDrill()); foreach (var weapon in m_helperCollection) { MyIntersectionResultLineTriangleEx? intersection = GetIntersectionInNearSpace(weapon, ref directLine, true); if (intersection.HasValue) { Visible = false; IsDone = true; m_helperCollection.Clear(); return; } } } else { Visible = false; } IsDone = true; m_ignoreEntity1 = null; m_ignoreEntity2 = null; m_glare = null; } }
public void DoWork() { var glare = m_glare; // we copy variable because other thread can null it if (glare == null) { return; } if (Vector3.DistanceSquared(glare.Position, m_cameraPosition) < MyMwcMathConstants.EPSILON) { return; } var directLine = new MyLine(glare.Position, m_cameraPosition); m_helperCollection.Clear(); using (MyEntities.EntityCloseLock.AcquireSharedUsing()) { var intersectionResult = MyEntities.GetIntersectionWithLine(ref directLine, m_ignoreEntity1, m_ignoreEntity2, false, false, false, false, true); //var intersectionResult = MyRender.GetAnyIntersectionWithLine(ref directLine, m_ignoreEntity1, m_ignoreEntity2, true); if (intersectionResult == null) { if (MySession.PlayerShip == null || MySession.PlayerShip.Weapons == null) { IsDone = true; m_helperCollection.Clear(); return; } MyIntersectionResultLineTriangleEx?cockpitIntersection = GetIntersectionInNearSpace(MySession.PlayerShip.GetShipCockpit(), ref directLine, true); Visible = !cockpitIntersection.HasValue; Debug.Assert(m_helperCollection.Count == 0); m_helperCollection.AddRange(MySession.PlayerShip.Weapons.GetMountedWeaponsWithHarvesterAndDrill()); foreach (var weapon in m_helperCollection) { MyIntersectionResultLineTriangleEx?intersection = GetIntersectionInNearSpace(weapon, ref directLine, true); if (intersection.HasValue) { Visible = false; IsDone = true; m_helperCollection.Clear(); return; } } } else { Visible = false; } IsDone = true; m_ignoreEntity1 = null; m_ignoreEntity2 = null; m_glare = null; } }