Program: 175828
Project: 175828
Buggy source:
protected void createDormerWindow(MiniRoof roof,QuadF l,MeshBuilder window,MeshBuilder glass,float sillDepth,float sillHeight,float corniceHeight,double panelWidth,double panelHeight){
  Vector3d along=new Vector3d(l.corners[3]);
  along.sub(l.corners[0]);
  along.normalize();
  Vector3d up=new Vector3d(0,1,0);
  Vector3d out=new Vector3d();
  out.cross(along,up);
  out.scale(1 / out.length());
  Line3d lout;
{
    Point3d away=new Point3d(l.corners[0]);
    away.add(out);
    lout=new Line3d(new Point3d(l.corners[0]),away);
  }
  Vector3d loc=new Vector3d(l.found[0]);
  if (lout.findPPram(l.found[0]) < lout.findPPram(l.found[1])) {
    loc=new Vector3d(up);
    loc.scale(-l.original.height);
    loc.add(l.found[1]);
  }
{
    Vector3d avoidRoof=new Vector3d(out);
    avoidRoof.scale(0.09);
    loc.add(avoidRoof);
  }
  Point3d deepest=Arrays.stream(l.found).map(p -> new Pair<Point3d,Double>(p,lout.findPPram(p))).max((a,b) -> b.second().compareTo(a.second())).get().first();
  double depth=lout.closestPointOn(deepest,false).distance(lout.closestPointOn(new Point3d(loc),false));
  Matrix4d to3d;
  double outset=0.1;
{
    Matrix4d to2dXY=new Matrix4d();
    to2dXY.setRow(2,up.x,up.y,up.z,0);
    to2dXY.setRow(1,-out.x,-out.y,-out.z,0);
    to2dXY.setRow(0,along.x,along.y,along.z,0);
    Vector3d p=new Vector3d(out);
    p.scale(outset / p.length());
    p.add(loc);
    to2dXY.m33=1;
    to2dXY.transform(p);
    to2dXY.m03=-p.x;
    to2dXY.m13=-p.y;
    to2dXY.m23=-p.z;
    to3d=new Matrix4d(to2dXY);
    to3d.invert();
  }
  FRect w=new FRect(l.original,false);
{
    w.app.coveringRoof=new Loop<Point2d>();
    Point2d p=new Point2d(loc.x,loc.z), d=new Point2d(deepest.x,deepest.z);
    p.scaleAdd(outset,new Vector2d(out.x,out.z),p);
    w.app.coveringRoof.append(new Point2d(p));
    w.app.coveringRoof.append(new Point2d(d));
    d.scaleAdd(w.width,new Vector2d(along.x,along.z),d);
    w.app.coveringRoof.append(new Point2d(d));
    p.scaleAdd(w.width,new Vector2d(along.x,along.z),p);
    w.app.coveringRoof.append(new Point2d(p));
  }
  w.x=0;
  w.y=0;
  if (tweed != null)   if (w.app.texture == null)   WindowGen.createWindow(window,glass,new Window(Jme3z.to(loc),Jme3z.to(along),Jme3z.to(up),l.original.width,l.original.height,depth,panelWidth,panelHeight));
 else   if (w.app.panes == null) {
    createInnie(w,ZERO_ONE_UVS,to3d,window,0.2f,0,MeshBuilder.NO_FRONT_OR_BACK);
    mbs.getTexture("String_Node_Str" + w.app.texture + "String_Node_Str"+ w.hashCode(),w.app.texture,w).add(w,ZERO_ONE_UVS,to3d,-0.2);
  }
 else {
    createInnie(w,null,to3d,mbs.GRAY,-depth + outset - 0.5,-depth + outset - 0.5,new boolean[]{true,true,false,true,false,false});
    if (w.app.coveringRoof != null) {
      double height=loc.y + w.height;
      LoopL<Point3d> rp=w.app.coveringRoof.singleton().new Map<Point3d>(){
        @Override public Point3d map(        Loopable<Point2d> input){
          return Pointz.to3(input.get(),height);
        }
      }
.run();
      LoopL<Point2d> uvs=w.app.coveringRoof.singleton().new Map<Point2d>(){
        @Override public Point2d map(        Loopable<Point2d> input){
          if (roof.app.textureRect == null)           return input.get();
 else           return roof.app.textureRect.normalize(input.get());
        }
      }
.run();
      MeshBuilder roofTexture=roof.app.texture == null ? window : mbs.getTexture("String_Node_Str" + roof.app.texture,roof.app.texture,roof);
      roofTexture.add(rp,roof.app.texture == null ? null : uvs,true);
    }
 else {
      createInnie(w,null,to3d,window,-depth + outset - 0.5,-depth + outset - 0.5,new boolean[]{false,false,true,false,false,false});
    }
    createWindowFromPanes(w.app.panes,w,w,to3d,mbs.getTexture("String_Node_Str" + w.app.texture + "String_Node_Str"+ w.hashCode(),w.app.texture,w),0.1,0);
  }
}

Fixed version (ground truth):
protected void createDormerWindow(MiniRoof roof,QuadF l,MeshBuilder window,MeshBuilder glass,float sillDepth,float sillHeight,float corniceHeight,double panelWidth,double panelHeight){
  Vector3d along=new Vector3d(l.corners[3]);
  along.sub(l.corners[0]);
  along.normalize();
  Vector3d up=new Vector3d(0,1,0);
  Vector3d out=new Vector3d();
  out.cross(along,up);
  out.scale(1 / out.length());
  Line3d lout;
{
    Point3d away=new Point3d(l.corners[0]);
    away.add(out);
    lout=new Line3d(new Point3d(l.corners[0]),away);
  }
  Vector3d loc=new Vector3d(l.found[0]);
  if (lout.findPPram(l.found[0]) < lout.findPPram(l.found[1])) {
    loc=new Vector3d(up);
    loc.scale(-l.original.height);
    loc.add(l.found[1]);
  }
{
    Vector3d avoidRoof=new Vector3d(out);
    avoidRoof.scale(0.09);
    loc.add(avoidRoof);
  }
  Point3d deepest=Arrays.stream(l.found).map(p -> new Pair<Point3d,Double>(p,lout.findPPram(p))).max((a,b) -> b.second().compareTo(a.second())).get().first();
  double depth=lout.closestPointOn(deepest,false).distance(lout.closestPointOn(new Point3d(loc),false));
  Matrix4d to3d;
  double outset=0.1;
{
    Matrix4d to2dXY=new Matrix4d();
    to2dXY.setRow(2,up.x,up.y,up.z,0);
    to2dXY.setRow(1,-out.x,-out.y,-out.z,0);
    to2dXY.setRow(0,along.x,along.y,along.z,0);
    Vector3d p=new Vector3d(out);
    p.scale(outset / p.length());
    p.add(loc);
    to2dXY.m33=1;
    to2dXY.transform(p);
    to2dXY.m03=-p.x;
    to2dXY.m13=-p.y;
    to2dXY.m23=-p.z;
    to3d=new Matrix4d(to2dXY);
    to3d.invert();
  }
  FRect w=new FRect(l.original,false);
{
    w.app.coveringRoof=new Loop<Point2d>();
    Point2d p=new Point2d(loc.x,loc.z), d=new Point2d();
    d.scaleAdd(-depth,new Vector2d(out.x,out.z),p);
    p.scaleAdd(outset,new Vector2d(out.x,out.z),p);
    w.app.coveringRoof.append(new Point2d(p));
    w.app.coveringRoof.append(new Point2d(d));
    d.scaleAdd(w.width,new Vector2d(along.x,along.z),d);
    w.app.coveringRoof.append(new Point2d(d));
    p.scaleAdd(w.width,new Vector2d(along.x,along.z),p);
    w.app.coveringRoof.append(new Point2d(p));
  }
  w.x=0;
  w.y=0;
  if (tweed != null)   if (w.app.texture == null)   WindowGen.createWindow(window,glass,new Window(Jme3z.to(loc),Jme3z.to(along),Jme3z.to(up),l.original.width,l.original.height,depth,panelWidth,panelHeight));
 else   if (w.app.panes == null) {
    createInnie(w,null,to3d,window,0.2f,0,MeshBuilder.NO_FRONT_OR_BACK);
    mbs.getTexture("String_Node_Str" + w.app.texture + "String_Node_Str"+ w.hashCode(),w.app.texture,w).add(w,ZERO_ONE_UVS,to3d,-0.2);
  }
 else {
    createInnie(w,null,to3d,mbs.GRAY,-depth + outset - 0.5,-depth + outset - 0.5,new boolean[]{true,true,false,true,false,false});
    if (w.app.coveringRoof != null) {
      double height=loc.y + w.height;
      LoopL<Point3d> rp=w.app.coveringRoof.singleton().new Map<Point3d>(){
        @Override public Point3d map(        Loopable<Point2d> input){
          return Pointz.to3(input.get(),height);
        }
      }
.run();
      LoopL<Point2d> uvs=w.app.coveringRoof.singleton().new Map<Point2d>(){
        @Override public Point2d map(        Loopable<Point2d> input){
          if (roof.app.textureRect == null)           return input.get();
 else           return roof.app.textureRect.normalize(input.get());
        }
      }
.run();
      MeshBuilder roofTexture=roof.app.texture == null ? window : mbs.getTexture("String_Node_Str" + roof.app.texture,roof.app.texture,roof);
      roofTexture.add(rp,roof.app.texture == null ? null : uvs,true);
    }
 else {
      createInnie(w,null,to3d,window,-depth + outset - 0.5,-depth + outset - 0.5,new boolean[]{false,false,true,false,false,false});
    }
    createWindowFromPanes(w.app.panes,w,w,to3d,mbs.getTexture("String_Node_Str" + w.app.texture + "String_Node_Str"+ w.hashCode(),w.app.texture,w),0.1,0);
  }
}