Skip to content

Commit d18ed69

Browse files
committed
fix: linter
1 parent d12a071 commit d18ed69

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

collision_test.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func TestBroadPhaseTwoStaticBodies(t *testing.T) {
121121
}
122122

123123
// Static-static collisions should be skipped
124-
if len(pairs) != 0 {
124+
if len(contactPairs) != 0 {
125125
t.Errorf("BroadPhase with two static bodies returned %d pairs, want 0 (should skip static-static)", len(pairs))
126126
}
127127
}
@@ -563,9 +563,7 @@ func BenchmarkLargeBroadPhase2(b *testing.B) {
563563
}
564564

565565
// BenchmarkLargeGJK2-16 1010 1174808 ns/op 133546 B/op 2362 allocs/op
566-
// BenchmarkLargeGJK2-16 100 10239257 ns/op 1073609 B/op 24118 allocs/op
567-
// BenchmarkLargeGJK2-16 100 19060863 ns/op 1000860 B/op 10399 allocs/op
568-
// BenchmarkLargeGJK2-16 126 9732729 ns/op 1172060 B/op 10395 allocs/op
566+
// BenchmarkLargeGJK2-16 32847 40166 ns/op 16228 B/op 53 allocs/op
569567
func BenchmarkLargeGJK2(b *testing.B) {
570568
const cubesCount = 1000
571569
const rowSize = 100.0
@@ -587,12 +585,14 @@ func BenchmarkLargeGJK2(b *testing.B) {
587585
f, _ := os.Create("trace.out")
588586
fcpu, _ := os.Create(`cpu.prof`)
589587
fheap, _ := os.Create(`heap.prof`)
590-
defer f.Close()
591-
defer fcpu.Close()
592-
defer fheap.Close()
593-
pprof.StartCPUProfile(fcpu)
594-
pprof.WriteHeapProfile(fheap)
595-
trace.Start(f)
588+
defer func() {
589+
_ = f.Close()
590+
_ = fcpu.Close()
591+
_ = fheap.Close()
592+
}()
593+
_ = pprof.StartCPUProfile(fcpu)
594+
_ = pprof.WriteHeapProfile(fheap)
595+
_ = trace.Start(f)
596596

597597
b.ReportAllocs()
598598
b.ResetTimer()
@@ -602,11 +602,8 @@ func BenchmarkLargeGJK2(b *testing.B) {
602602
b.StartTimer()
603603

604604
collisionPair := GJK(pair)
605-
606-
for cp := range collisionPair {
607-
s := cp.simplex.Count
608-
s++
609-
}
605+
cp := <-collisionPair
606+
cp.BodyA.IsSleeping = false
610607
}
611608

612609
b.StopTimer()
@@ -643,12 +640,14 @@ func BenchmarkLargeEPA2(b *testing.B) {
643640
f, _ := os.Create("trace.out")
644641
fcpu, _ := os.Create(`cpu.prof`)
645642
fheap, _ := os.Create(`heap.prof`)
646-
defer f.Close()
647-
defer fcpu.Close()
648-
defer fheap.Close()
649-
pprof.StartCPUProfile(fcpu)
650-
pprof.WriteHeapProfile(fheap)
651-
trace.Start(f)
643+
defer func() {
644+
_ = f.Close()
645+
_ = fcpu.Close()
646+
_ = fheap.Close()
647+
}()
648+
_ = pprof.StartCPUProfile(fcpu)
649+
_ = pprof.WriteHeapProfile(fheap)
650+
_ = trace.Start(f)
652651

653652
b.ReportAllocs()
654653
b.ResetTimer()
@@ -756,12 +755,14 @@ func BenchmarkLargeWorldStep(b *testing.B) {
756755
f, _ := os.Create("trace.out")
757756
fcpu, _ := os.Create(`cpu.prof`)
758757
fheap, _ := os.Create(`heap.prof`)
759-
defer f.Close()
760-
defer fcpu.Close()
761-
defer fheap.Close()
762-
pprof.StartCPUProfile(fcpu)
763-
pprof.WriteHeapProfile(fheap)
764-
trace.Start(f)
758+
defer func() {
759+
_ = f.Close()
760+
_ = fcpu.Close()
761+
_ = fheap.Close()
762+
}()
763+
_ = pprof.StartCPUProfile(fcpu)
764+
_ = pprof.WriteHeapProfile(fheap)
765+
_ = trace.Start(f)
765766

766767
b.ReportAllocs()
767768
b.ResetTimer()

epa/face_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package epa
22

33
import (
4+
"fmt"
45
"math"
56
"testing"
67

@@ -618,7 +619,11 @@ func BenchmarkBuildInitialFaces(b *testing.B) {
618619
b.ResetTimer()
619620
for i := 0; i < b.N; i++ {
620621
builder.Reset()
621-
builder.BuildInitialFaces(simplex)
622+
err := builder.BuildInitialFaces(simplex)
623+
624+
if err != nil {
625+
fmt.Printf("error building initial faces: %v", err)
626+
}
622627
}
623628
}
624629

@@ -646,7 +651,10 @@ func BenchmarkFindBoundaryEdges(b *testing.B) {
646651

647652
b.ResetTimer()
648653
for i := 0; i < b.N; i++ {
649-
builder.findBoundaryEdges()
654+
err := builder.findBoundaryEdges()
655+
if err != nil {
656+
fmt.Printf("error finding boundary edges: %v", err)
657+
}
650658
}
651659
}
652660

@@ -666,6 +674,9 @@ func BenchmarkAddPointAndRebuildFaces(b *testing.B) {
666674
Face{Points: [3]mgl64.Vec3{{0, 0, 0}, {0, 0, 1}, {1, 0, 0}}, Normal: mgl64.Vec3{0, 1, 0}, Distance: 0.1})
667675
b.StartTimer()
668676

669-
builder.AddPointAndRebuildFaces(support, closestIndex)
677+
err := builder.AddPointAndRebuildFaces(support, closestIndex)
678+
if err != nil {
679+
fmt.Printf("error adding faces: %v", err)
680+
}
670681
}
671682
}

epa/polytope.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ type PolytopeBuilder struct {
2525

2626
// Visible face tracking
2727
visibleIndices []int
28-
29-
// Temporary workspace for face construction
30-
tempFace Face
3128
}
3229

3330
// EdgeEntry represents an edge with occurrence counting for boundary detection.

0 commit comments

Comments
 (0)