예제 #1
0
 // This determines which sector the thing is in and links it
 public void DetermineSector()
 {
     //mxd
     sector = map.GetSectorByCoordinates(pos);
 }
예제 #2
0
        //mxd
        public static Geometry.Plane GetCeilingPlane(Sector s)
        {
            if (General.Map.UDMF)
            {
                // UDMF Sector slope?
                if (s.CeilSlope.GetLengthSq() > 0 && !double.IsNaN(s.CeilSlopeOffset / s.CeilSlope.z))
                {
                    return(new Geometry.Plane(s.CeilSlope, s.CeilSlopeOffset));
                }

                if (s.sidedefs.Count == 3)
                {
                    Geometry.Plane ceiling = new Geometry.Plane(new Vector3D(0, 0, -1), s.CeilHeight);
                    Vector3D[]     verts   = new Vector3D[3];
                    bool           sloped  = false;
                    int            index   = 0;

                    // Check vertices
                    foreach (Sidedef sd in s.Sidedefs)
                    {
                        Vertex v = sd.IsFront ? sd.Line.End : sd.Line.Start;

                        //create "normal" vertices
                        verts[index] = new Vector3D(v.Position);

                        // Check floor
                        if (!double.IsNaN(v.ZCeiling))
                        {
                            //vertex offset is absolute
                            verts[index].z = v.ZCeiling;
                            sloped         = true;
                        }
                        else
                        {
                            verts[index].z = ceiling.GetZ(v.Position);
                        }

                        index++;
                    }

                    // Have slope?
                    return(sloped ? new Geometry.Plane(verts[0], verts[2], verts[1], false) : ceiling);
                }
            }

            // Have line slope?
            foreach (Sidedef side in s.sidedefs)
            {
                // Carbon copy of EffectLineSlope class here...
                if (side.Line.Action == 181 && ((side.Line.Args[1] == 1 && side == side.Line.Front) || side.Line.Args[1] == 2) && side.Other != null)
                {
                    Linedef l = side.Line;

                    // Find the vertex furthest from the line
                    Vertex foundv    = null;
                    double founddist = -1.0f;
                    foreach (Sidedef sd in s.Sidedefs)
                    {
                        Vertex v = sd.IsFront ? sd.Line.Start : sd.Line.End;
                        double d = l.DistanceToSq(v.Position, false);
                        if (d > founddist)
                        {
                            foundv    = v;
                            founddist = d;
                        }
                    }

                    Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, side.Other.Sector.CeilHeight);
                    Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, side.Other.Sector.CeilHeight);
                    Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, s.CeilHeight);

                    return(l.SideOfLine(v3) > 0.0f ? new Geometry.Plane(v1, v2, v3, false) : new Geometry.Plane(v2, v1, v3, false));
                }
            }

            //TODO: other types of slopes...

            // Normal (flat) ceiling plane
            return(new Geometry.Plane(new Vector3D(0, 0, -1), s.CeilHeight));
        }
예제 #3
0
 // This determines which sector the thing is in and links it
 public void DetermineSector(VisualBlockMap blockmap)
 {
     sector = blockmap.GetSectorAt(pos);
 }