added flags and buildbsp to main
This commit is contained in:
37
main.go
37
main.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bspviz/internal/bsp"
|
||||
"bspviz/internal/geom"
|
||||
"bspviz/internal/mapfmt"
|
||||
"bspviz/internal/wad"
|
||||
@@ -21,6 +22,15 @@ func main() {
|
||||
extract := flag.String("extract", "", "Kommagetrennte Lump-Namen aus der Map extrahieren (z.B. VERTEXES,LINEDEFS)")
|
||||
outdir := flag.String("out", ".", "Zielordner für -extract")
|
||||
geomtest := flag.Bool("geomtest", false, "Geometrie-Check: Segmente/AABB/Probe-Split ausgeben")
|
||||
buildbsp := flag.Bool("buildbsp", false, "BSP bauen und Metriken ausgeben")
|
||||
alpha := flag.Float64("alpha", 10, "Kosten: Gewicht für Splits")
|
||||
beta := flag.Float64("beta", 1, "Kosten: Gewicht für Balance")
|
||||
eps := flag.Float64("eps", geom.EPS, "Epsilon für Geometrie")
|
||||
leaf := flag.Int("leafmax", 12, "max. Segmente pro Leaf")
|
||||
depth := flag.Int("maxdepth", 32, "max. Rekursionstiefe")
|
||||
cands := flag.Int("cands", 16, "Anzahl Kandidaten (Subsample)")
|
||||
seed := flag.Int64("seed", 0, "RNG-Seed (0 = default)")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *wadPath == "" {
|
||||
@@ -156,4 +166,31 @@ func main() {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if *buildbsp {
|
||||
raw, err := w.LoadMapLumps(*mapMarker, "VERTEXES", "LINEDEFS")
|
||||
if err != nil {
|
||||
log.Fatalf("load map lumps: %v", err)
|
||||
}
|
||||
m, err := mapfmt.LoadMap(raw)
|
||||
if err != nil {
|
||||
log.Fatalf("parse map: %v", err)
|
||||
}
|
||||
|
||||
segs := mapfmt.LinedefsToSegs(m.Vertices, m.Linedefs)
|
||||
p := bsp.Params{
|
||||
Alpha: *alpha, Beta: *beta, Eps: *eps,
|
||||
MaxDepth: *depth, LeafMax: *leaf, Cands: *cands, Seed: *seed,
|
||||
}
|
||||
root := bsp.Build(segs, p)
|
||||
st := bsp.Measure(root)
|
||||
|
||||
fmt.Printf("BSP built.\n")
|
||||
fmt.Printf(" nodes=%d leaves=%d maxDepth=%d totalLeafSegs=%d\n",
|
||||
st.Nodes, st.Leaves, st.MaxDepth, st.TotalSegs)
|
||||
fmt.Printf(" params: alpha=%.2f beta=%.2f eps=%.1e leafMax=%d maxDepth=%d cands=%d seed=%d\n",
|
||||
p.Alpha, p.Beta, p.Eps, p.LeafMax, p.MaxDepth, p.Cands, p.Seed)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user