public void prepare() { if (sectorBatches == null) { sectorBatches = new List <SectorBatch>(); // Build batches foreach (seg_t seg in segs) { r_segs.XNARenderWallToBatches(seg, sectorBatches); } foreach (SectorBatch batch in sectorBatches) { if (!batch.isAnimated()) { int tempSource = r_data.texturetranslation[batch.textureId]; batch.texture = Game1.instance.wallTexturesById[tempSource]; } if (batch.vb == null) { batch.createVB(); } } } if (floorBatch == null) { floorBatch = new SectorBatch(); r_plane.XNARenderFloorToBatch(this, floorBatch); if (floorBatch.vb == null) { floorBatch.createVB(); } } if (ceilingBatch == null) { ceilingBatch = new SectorBatch(); r_plane.XNARenderCeilToBatch(this, ceilingBatch); if (ceilingBatch.vb == null) { ceilingBatch.createVB(); } } }
public void invalidate(bool doNeighbors) { needUpdateAmbientMap = true; if (floorBatch != null) { floorBatch.vb.Dispose(); floorBatch = null; } if (ceilingBatch != null) { ceilingBatch.vb.Dispose(); ceilingBatch = null; } if (sectorBatches != null) { foreach (SectorBatch batch in sectorBatches) { if (batch.vb != null) { batch.vb.Dispose(); } } sectorBatches = null; } // Invalidate also neiborgh sectors if (doNeighbors) { if (segs != null) { foreach (seg_t seg in segs) { if (seg.backsector != null) { seg.backsector.invalidate(false); } } } // Check for lights that touch that sector, and invalidate their shadow for (DoomDef.thinker_t think = p_tick.thinkercap.next; think != p_tick.thinkercap; think = think.next) { if (think == null) { break; } if (think.function == null) { continue; } DoomDef.mobj_t mo = think.function.obj as DoomDef.mobj_t; if (mo == null) { continue; } if (mo.shadowInfo == null) { continue; } if (mo.sectorsInRadius.Contains(this)) { mo.shadowInfo.needUpdate = true; } } } justInvalidated = true; }