// 3D Floor effect public void AddEffect3DFloor(Linedef sourcelinedef) { Effect3DFloor e = new Effect3DFloor(this, sourcelinedef); extrafloors.Add(e); alleffects.Add(e); //mxd. Extrafloor neighbours should be updated when extrafloor is changed foreach (Sidedef sd in this.Sector.Sidedefs) { if (sd.Other != null && sd.Other.Sector != null) { AddUpdateSector(sd.Other.Sector, false); } } }
//mxd public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside) { Sector s = level.sector; Vector2D texscale; this.innerside = innerside; base.Setup(level, extrafloor); // Fetch ZDoom fields float rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationfloor", 0.0f)); Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0f), s.Fields.GetValue("ypanningfloor", 0.0f)); Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0f), s.Fields.GetValue("yscalefloor", 1.0f)); //Load floor texture if (s.LongFloorTexture != MapSet.EmptyLongName) { base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); if (base.Texture == null || base.Texture is UnknownImage) { base.Texture = General.Map.Data.UnknownTexture3D; setuponloadedtexture = s.LongFloorTexture; } else if (!base.Texture.IsImageLoaded) { setuponloadedtexture = s.LongFloorTexture; } } else { // Use missing texture base.Texture = General.Map.Data.MissingTexture3D; setuponloadedtexture = 0; } // Determine texture scale if (base.Texture.IsImageLoaded) { texscale = new Vector2D(1.0f / base.Texture.ScaledWidth, 1.0f / base.Texture.ScaledHeight); } else { texscale = new Vector2D(1.0f / 64.0f, 1.0f / 64.0f); } // Determine brightness int color = PixelColor.FromInt(level.color).WithAlpha((byte)General.Clamp(level.alpha, 0, 255)).ToInt(); //mxd. Top extrafloor level should calculate fogdensity //from the brightness of the level above it int targetbrightness; if (extrafloor != null && extrafloor.VavoomType && !level.disablelighting) { targetbrightness = 0; SectorData sd = mode.GetSectorData(this.Sector.Sector); for (int i = 0; i < sd.LightLevels.Count - 1; i++) { if (sd.LightLevels[i] == level) { targetbrightness = sd.LightLevels[i + 1].brightnessbelow; break; } } } else { targetbrightness = level.brightnessbelow; } //mxd. Determine fog density fogfactor = CalculateFogFactor(targetbrightness); // Make vertices ReadOnlyCollection <Vector2D> triverts = Sector.Sector.Triangles.Vertices; WorldVertex[] verts = new WorldVertex[triverts.Count]; for (int i = 0; i < triverts.Count; i++) { // Color shading verts[i].c = color; //mxd // Vertex coordinates verts[i].x = triverts[i].x; verts[i].y = triverts[i].y; verts[i].z = level.plane.GetZ(triverts[i]); // Texture coordinates Vector2D pos = triverts[i]; pos = pos.GetRotated(rotate); pos.y = -pos.y; pos = (pos + offset) * scale * texscale; verts[i].u = pos.x; verts[i].v = pos.y; } // The sector triangulation created clockwise triangles that // are right up for the floor. For the ceiling we must flip // the triangles upside down. if ((extrafloor != null) && !extrafloor.VavoomType && !innerside) { SwapTriangleVertices(verts); } // Determine render pass if (extrafloor != null) { if (extrafloor.Sloped3dFloor) //mxd { this.RenderPass = RenderPass.Mask; } else if (extrafloor.RenderAdditive) //mxd { this.RenderPass = RenderPass.Additive; } else if (level.alpha < 255) { this.RenderPass = RenderPass.Alpha; } else { this.RenderPass = RenderPass.Mask; } } else { this.RenderPass = RenderPass.Solid; } //mxd. Update sky render flag UpdateSkyRenderFlag(); // Apply vertices base.SetVertices(verts); return(verts.Length > 0); }
// This builds the geometry. Returns false when no geometry created. public override bool Setup(SectorLevel level, Effect3DFloor extrafloor) { return(Setup(level, extrafloor, innerside)); }
public bool Setup(Effect3DFloor extrafloor) { Sidedef sourceside = extrafloor.Linedef.Front; this.extrafloor = extrafloor; //mxd. Extrafloor may've become invalid during undo/redo... if (sourceside == null) { base.SetVertices(null); return(false); } Vector2D vl, vr; //mxd. lightfog flag support int lightvalue; bool lightabsolute; GetLightValue(out lightvalue, out lightabsolute); Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0f), sourceside.Fields.GetValue("scaley_mid", 1.0f)); Vector2D tscaleAbs = new Vector2D(Math.Abs(tscale.x), Math.Abs(tscale.y)); Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), Sidedef.Fields.GetValue("offsety_mid", 0.0f)); Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0f), sourceside.Fields.GetValue("offsety_mid", 0.0f)); // Left and right vertices for this sidedef if (Sidedef.IsFront) { vl = new Vector2D(Sidedef.Line.Start.Position.x, Sidedef.Line.Start.Position.y); vr = new Vector2D(Sidedef.Line.End.Position.x, Sidedef.Line.End.Position.y); } else { vl = new Vector2D(Sidedef.Line.End.Position.x, Sidedef.Line.End.Position.y); vr = new Vector2D(Sidedef.Line.Start.Position.x, Sidedef.Line.Start.Position.y); } // Load sector data SectorData sd = mode.GetSectorData(Sidedef.Sector); //mxd. which texture we must use? long texturelong = 0; if ((sourceside.Line.Args[2] & (int)Effect3DFloor.Flags.UseUpperTexture) != 0) { if (Sidedef.LongHighTexture != MapSet.EmptyLongName) { texturelong = Sidedef.LongHighTexture; } } else if ((sourceside.Line.Args[2] & (int)Effect3DFloor.Flags.UseLowerTexture) != 0) { if (Sidedef.LongLowTexture != MapSet.EmptyLongName) { texturelong = Sidedef.LongLowTexture; } } else if (sourceside.LongMiddleTexture != MapSet.EmptyLongName) { texturelong = sourceside.LongMiddleTexture; } // Texture given? if (texturelong != 0) { // Load texture base.Texture = General.Map.Data.GetTextureImage(texturelong); if (base.Texture == null || base.Texture is UnknownImage) { base.Texture = General.Map.Data.UnknownTexture3D; setuponloadedtexture = texturelong; } else if (!base.Texture.IsImageLoaded) { setuponloadedtexture = texturelong; } } else { // Use missing texture base.Texture = General.Map.Data.MissingTexture3D; setuponloadedtexture = 0; } // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); tsz = tsz / tscale; // Get texture offsets Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY); tof = tof + toffset1 + toffset2; tof = tof / tscaleAbs; if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) { tof = tof * base.Texture.Scale; } // For Vavoom type 3D floors the ceiling is lower than floor and they are reversed. // We choose here. float sourcetopheight = extrafloor.VavoomType ? sourceside.Sector.FloorHeight : sourceside.Sector.CeilHeight; float sourcebottomheight = extrafloor.VavoomType ? sourceside.Sector.CeilHeight : sourceside.Sector.FloorHeight; // Determine texture coordinates plane as they would be in normal circumstances. // We can then use this plane to find any texture coordinate we need. // The logic here is the same as in the original VisualMiddleSingle (except that // the values are stored in a TexturePlane) // NOTE: I use a small bias for the floor height, because if the difference in // height is 0 then the TexturePlane doesn't work! TexturePlane tp = new TexturePlane(); float floorbias = (sourcetopheight == sourcebottomheight) ? 1.0f : 0.0f; tp.trb.x = tp.tlt.x + (float)Math.Round(Sidedef.Line.Length); //mxd. (G)ZDoom snaps texture coordinates to integral linedef length tp.trb.y = tp.tlt.y + (sourcetopheight - sourcebottomheight) + floorbias; // Apply texture offset tp.tlt += tof; tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; tp.trb /= tsz; // Left top and right bottom of the geometry that tp.vlt = new Vector3D(vl.x, vl.y, sourcetopheight); tp.vrb = new Vector3D(vr.x, vr.y, sourcebottomheight + floorbias); // Make the right-top coordinates tp.trt = new Vector2D(tp.trb.x, tp.tlt.y); tp.vrt = new Vector3D(tp.vrb.x, tp.vrb.y, tp.vlt.z); //mxd. Get ceiling and floor heights. Use our and neighbour sector's data SectorData sdo = mode.GetSectorData(Sidedef.Other.Sector); float flo = sdo.Floor.plane.GetZ(vl); float fro = sdo.Floor.plane.GetZ(vr); float clo = sdo.Ceiling.plane.GetZ(vl); float cro = sdo.Ceiling.plane.GetZ(vr); float fle = sd.Floor.plane.GetZ(vl); float fre = sd.Floor.plane.GetZ(vr); float cle = sd.Ceiling.plane.GetZ(vl); float cre = sd.Ceiling.plane.GetZ(vr); float fl = flo > fle ? flo : fle; float fr = fro > fre ? fro : fre; float cl = clo < cle ? clo : cle; float cr = cro < cre ? cro : cre; // Anything to see? if (((cl - fl) > 0.01f) || ((cr - fr) > 0.01f)) { // Keep top and bottom planes for intersection testing top = extrafloor.Floor.plane; bottom = extrafloor.Ceiling.plane; // Create initial polygon, which is just a quad between floor and ceiling WallPolygon poly = new WallPolygon(); poly.Add(new Vector3D(vl.x, vl.y, fl)); poly.Add(new Vector3D(vl.x, vl.y, cl)); poly.Add(new Vector3D(vr.x, vr.y, cr)); poly.Add(new Vector3D(vr.x, vr.y, fr)); // Determine initial color int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; //mxd. This calculates light with doom-style wall shading PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); fogfactor = CalculateFogFactor(lightlevel); poly.color = wallcolor.WithAlpha(255).ToInt(); // Cut off the part above the 3D floor and below the 3D ceiling CropPoly(ref poly, extrafloor.Floor.plane, false); CropPoly(ref poly, extrafloor.Ceiling.plane, false); // Cut out pieces that overlap 3D floors in this sector List <WallPolygon> polygons = new List <WallPolygon> { poly }; bool translucent = (extrafloor.RenderAdditive || extrafloor.Alpha < 255); foreach (Effect3DFloor ef in sd.ExtraFloors) { //mxd. Our poly should be clipped when our ond other extrafloors are both solid or both translucent, // or when only our extrafloor is translucent. // Our poly should not be clipped when our extrafloor is translucent and the other one isn't and both have renderinside setting. bool othertranslucent = (ef.RenderAdditive || ef.Alpha < 255); if (translucent && !othertranslucent && !ef.ClipSidedefs) { continue; } if (ef.ClipSidedefs == extrafloor.ClipSidedefs || ef.ClipSidedefs) { //TODO: find out why ef can be not updated at this point //TODO: [this crashed on me once when performing auto-align on myriad of textures on BoA C1M0] if (ef.Floor == null || ef.Ceiling == null) { ef.Update(); } int num = polygons.Count; for (int pi = 0; pi < num; pi++) { // Split by floor plane of 3D floor WallPolygon p = polygons[pi]; WallPolygon np = SplitPoly(ref p, ef.Ceiling.plane, true); if (np.Count > 0) { // Split part below floor by the ceiling plane of 3D floor // and keep only the part below the ceiling (front) SplitPoly(ref np, ef.Floor.plane, true); if (p.Count == 0) { polygons[pi] = np; } else { polygons[pi] = p; polygons.Add(np); } } else { polygons[pi] = p; } } } } // Process the polygon and create vertices if (polygons.Count > 0) { List <WorldVertex> verts = CreatePolygonVertices(polygons, tp, sd, lightvalue, lightabsolute); if (verts.Count > 2) { if (extrafloor.Sloped3dFloor) { this.RenderPass = RenderPass.Mask; //mxd } else if (extrafloor.RenderAdditive) { this.RenderPass = RenderPass.Additive; //mxd } else if ((extrafloor.Alpha < 255) || Texture.IsTranslucent) { this.RenderPass = RenderPass.Alpha; // [ZZ] translucent texture should trigger Alpha pass } else { this.RenderPass = RenderPass.Mask; } if (extrafloor.Alpha < 255) { // Apply alpha to vertices byte alpha = (byte)General.Clamp(extrafloor.Alpha, 0, 255); if (alpha < 255) { for (int i = 0; i < verts.Count; i++) { WorldVertex v = verts[i]; v.c = PixelColor.FromInt(v.c).WithAlpha(alpha).ToInt(); verts[i] = v; } } } base.SetVertices(verts); return(true); } } } base.SetVertices(null); //mxd return(false); }
public virtual bool Setup(SectorLevel level, Effect3DFloor extrafloor) { this.level = level; this.extrafloor = extrafloor; return(false); }
//mxd public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside) { Sector s = level.sector; Vector2D texscale; this.innerside = innerside; //mxd base.Setup(level, extrafloor); // Fetch ZDoom fields float rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationceiling", 0.0f)); Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0f), s.Fields.GetValue("ypanningceiling", 0.0f)); Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0f), s.Fields.GetValue("yscaleceiling", 1.0f)); //Load ceiling texture if (s.LongCeilTexture != MapSet.EmptyLongName) { base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture); if (base.Texture == null || base.Texture is UnknownImage) { base.Texture = General.Map.Data.UnknownTexture3D; setuponloadedtexture = s.LongCeilTexture; } else if (!base.Texture.IsImageLoaded) { setuponloadedtexture = s.LongCeilTexture; } } else { // Use missing texture base.Texture = General.Map.Data.MissingTexture3D; setuponloadedtexture = 0; } // Determine texture scale if (base.Texture.IsImageLoaded) { texscale = new Vector2D(1.0f / base.Texture.ScaledWidth, 1.0f / base.Texture.ScaledHeight); } else { texscale = new Vector2D(1.0f / 64.0f, 1.0f / 64.0f); } // Determine brightness byte alpha = (byte)General.Clamp(level.alpha, 0, 255); int color = PixelColor.FromInt(level.color).WithAlpha(alpha).ToInt(); int targetbrightness; if (extrafloor != null && !extrafloor.VavoomType && !level.disablelighting) { //mxd. Top extrafloor level should calculate fogdensity from the brightness of the level above it if (!innerside) { targetbrightness = 0; SectorData sd = mode.GetSectorData(this.Sector.Sector); for (int i = 0; i < sd.LightLevels.Count - 1; i++) { if (sd.LightLevels[i] == level) { targetbrightness = sd.LightLevels[i + 1].brightnessbelow; break; } } } //mxd. Inner extrafloor ceilings must be colored using control sector's color and brightness else { targetbrightness = level.brightnessbelow; SectorData sd = mode.GetSectorData(this.Sector.Sector); for (int i = 0; i < sd.LightLevels.Count; i++) { if (sd.LightLevels[i] == level) { if (i > 0) { color = PixelColor.FromInt(sd.LightLevels[i - 1].color).WithAlpha(alpha).ToInt(); } break; } } } } else { targetbrightness = level.brightnessbelow; } //mxd. Determine fog density fogfactor = CalculateFogFactor(targetbrightness); // Make vertices ReadOnlyCollection <Vector2D> triverts = Sector.Sector.Triangles.Vertices; WorldVertex[] verts = new WorldVertex[triverts.Count]; for (int i = 0; i < triverts.Count; i++) { // Color shading verts[i].c = color; //mxd // Vertex coordinates verts[i].x = triverts[i].x; verts[i].y = triverts[i].y; verts[i].z = level.plane.GetZ(triverts[i]); // Texture coordinates Vector2D pos = triverts[i]; pos = pos.GetRotated(rotate); pos.y = -pos.y; pos = (pos + offset) * scale * texscale; verts[i].u = pos.x; verts[i].v = pos.y; } // The sector triangulation created clockwise triangles that // are right up for the floor. For the ceiling we must flip // the triangles upside down. if (extrafloor == null || extrafloor.VavoomType || innerside) { SwapTriangleVertices(verts); } // Determine render pass if (extrafloor != null) { if (extrafloor.Sloped3dFloor) //mxd { this.RenderPass = RenderPass.Mask; } else if (extrafloor.RenderAdditive) //mxd { this.RenderPass = RenderPass.Additive; } else if (level.alpha < 255) { this.RenderPass = RenderPass.Alpha; } else { this.RenderPass = RenderPass.Mask; } } else { this.RenderPass = RenderPass.Solid; } //mxd. Update sky render flag bool isrenderedassky = renderassky; renderassky = (level.sector.CeilTexture == General.Map.Config.SkyFlatName); if (isrenderedassky != renderassky && Sector.Sides != null) { // Upper sidedef geometry may need updating... foreach (Sidedef side in level.sector.Sidedefs) { VisualSidedefParts parts = Sector.GetSidedefParts(side); // Upper side can exist in either our, or the neightbouring sector, right? if (parts.upper != null && parts.upper.Triangles > 0) { parts.upper.UpdateSkyRenderFlag(); } else if (side.Other != null && side.Other.Sector != null && side.Other.Sector.CeilTexture == General.Map.Config.SkyFlatName) { // Update upper side of the neightbouring sector BaseVisualSector other = (BaseVisualSector)mode.GetVisualSector(side.Other.Sector); if (other != null && other.Sides != null) { parts = other.GetSidedefParts(side.Other); if (parts.upper != null && parts.upper.Triangles > 0) { parts.upper.UpdateSkyRenderFlag(); } } } } } // Apply vertices base.SetVertices(verts); return(verts.Length > 0); }
// This (re)builds the visual sector, calculating all geometry from scratch public void Rebuild() { // Forget old geometry base.ClearGeometry(); // Get sector data SectorData data = GetSectorData(); if (!data.Updated) { data.Update(); } // Create floor floor = (floor ?? new VisualFloor(mode, this)); if (floor.Setup(data.Floor, null)) { AddGeometry(floor); } // Create ceiling ceiling = (ceiling ?? new VisualCeiling(mode, this)); if (ceiling.Setup(data.Ceiling, null)) { AddGeometry(ceiling); } // Create 3D floors for (int i = 0; i < data.ExtraFloors.Count; i++) { Effect3DFloor ef = data.ExtraFloors[i]; bool floorRequired = ef.VavoomType; //mxd bool ceilingRequired = ef.VavoomType; //mxd if (ef.VavoomType || !ef.IgnoreBottomHeight) { //mxd. check if 3d floor is between real floor and ceiling if (!ef.VavoomType) { if (ef.Ceiling.plane.GetInverted().Normal != floor.Level.plane.Normal || ef.Ceiling.plane.Normal != ceiling.Level.plane.Normal) { //mxd. check if at least one vertex of 3d floor is between floor and ceiling floorRequired = Check3dFloorPlane(floor.Vertices, ceiling.Vertices, ef.Ceiling.plane); } //if floor, ceiling and 3d floor are not sloped, compare offsets else if (-floor.Level.plane.Offset < ef.Ceiling.plane.Offset && ceiling.Level.plane.Offset > ef.Ceiling.plane.Offset) { floorRequired = true; } } //mxd. Create a floor if (floorRequired && ef.Ceiling.sector.IsDisposed == false) { VisualFloor vf = (i < extrafloors.Count) ? extrafloors[i] : new VisualFloor(mode, this); if (vf.Setup(ef.Ceiling, ef)) { base.AddGeometry(vf); //mxd. add backside as well if (!ef.VavoomType && ef.RenderInside) { VisualFloor vfb = (i < extrabackfloors.Count) ? extrabackfloors[i] : new VisualFloor(mode, this); if (vfb.Setup(ef.Ceiling, ef, true)) { base.AddGeometry(vfb); } if (i >= extrabackfloors.Count) { extrabackfloors.Add(vfb); } } } if (i >= extrafloors.Count) { extrafloors.Add(vf); } } } //mxd. check if 3d ceiling is between real floor and ceiling if (!ef.VavoomType) { if (ef.Floor.plane.GetInverted().Normal != ceiling.Level.plane.Normal || ef.Floor.plane.Normal != floor.Level.plane.Normal) { //mxd. check if at least one vertex of 3d ceiling is between floor and ceiling ceilingRequired = Check3dFloorPlane(floor.Vertices, ceiling.Vertices, ef.Floor.plane); } //if floor, ceiling and 3d ceiling are not sloped, compare offsets else if (ceiling.Level.plane.Offset > -ef.Floor.plane.Offset && floor.Level.plane.Offset > ef.Floor.plane.Offset) { ceilingRequired = true; } } //mxd. Create a ceiling if (ceilingRequired && ef.Floor.sector.IsDisposed == false) { VisualCeiling vc = (i < extraceilings.Count) ? extraceilings[i] : new VisualCeiling(mode, this); if (vc.Setup(ef.Floor, ef)) { base.AddGeometry(vc); //mxd. add backside as well if (!ef.VavoomType && (ef.RenderInside || ef.IgnoreBottomHeight)) { VisualCeiling vcb = (i < extrabackceilings.Count) ? extrabackceilings[i] : new VisualCeiling(mode, this); if (vcb.Setup(ef.Floor, ef, true)) { base.AddGeometry(vcb); } if (i >= extrabackceilings.Count) { extrabackceilings.Add(vcb); } } } if (i >= extraceilings.Count) { extraceilings.Add(vc); } } } // Go for all sidedefs Dictionary <Sidedef, VisualSidedefParts> oldsides = sides ?? new Dictionary <Sidedef, VisualSidedefParts>(1); sides = new Dictionary <Sidedef, VisualSidedefParts>(base.Sector.Sidedefs.Count); foreach (Sidedef sd in base.Sector.Sidedefs) { // VisualSidedef already exists? VisualSidedefParts parts = oldsides.ContainsKey(sd) ? oldsides[sd] : new VisualSidedefParts(); // Doublesided or singlesided? if (sd.Other != null && sd.Line.IsFlagSet(General.Map.Config.DoubleSidedFlag)) { // Create upper part VisualUpper vu = parts.upper ?? new VisualUpper(mode, this, sd); if (vu.Setup()) { base.AddGeometry(vu); } // Create lower part VisualLower vl = parts.lower ?? new VisualLower(mode, this, sd); if (vl.Setup()) { base.AddGeometry(vl); } // Create middle part VisualMiddleDouble vm = parts.middledouble ?? new VisualMiddleDouble(mode, this, sd); if (vm.Setup()) { base.AddGeometry(vm); } //mxd. Create fog boundary VisualFogBoundary vb = parts.fogboundary ?? new VisualFogBoundary(mode, this, sd); if (vb.Setup()) { vm.FogFactor = 0; // Avoid double-fogging the middle part base.AddGeometry(vb); } // Create 3D wall parts SectorData osd = mode.GetSectorData(sd.Other.Sector); if (!osd.Updated) { osd.Update(); } List <VisualMiddle3D> middles = parts.middle3d ?? new List <VisualMiddle3D>(osd.ExtraFloors.Count); for (int i = 0; i < osd.ExtraFloors.Count; i++) { Effect3DFloor ef = osd.ExtraFloors[i]; if (!ef.VavoomType && ef.IgnoreBottomHeight) { continue; //mxd } VisualMiddle3D vm3 = (i < middles.Count) ? middles[i] : new VisualMiddle3D(mode, this, sd); if (vm3.Setup(ef)) { base.AddGeometry(vm3); } if (i >= middles.Count) { middles.Add(vm3); } } //mxd. Create backsides List <VisualMiddleBack> middlebacks = new List <VisualMiddleBack>(); for (int i = 0; i < data.ExtraFloors.Count; i++) { Effect3DFloor ef = data.ExtraFloors[i]; if (!ef.VavoomType && ef.RenderInside && !ef.IgnoreBottomHeight) { VisualMiddleBack vms = new VisualMiddleBack(mode, this, sd); if (vms.Setup(ef)) { base.AddGeometry(vms); } middlebacks.Add(vms); } } // Store sides.Add(sd, new VisualSidedefParts(vu, vl, vm, vb, middles, middlebacks)); } else { // Create middle part VisualMiddleSingle vm = parts.middlesingle ?? new VisualMiddleSingle(mode, this, sd); if (vm.Setup()) { base.AddGeometry(vm); } // Store sides.Add(sd, new VisualSidedefParts(vm)); } } // Done changed = false; }