Просмотр исходного кода

fixed gui panel intersection test

leonsal 8 лет назад
Родитель
Сommit
11b11536e2
2 измененных файлов с 9 добавлено и 12 удалено
  1. 7 12
      gui/panel.go
  2. 2 0
      renderer/renderer.go

+ 7 - 12
gui/panel.go

@@ -572,20 +572,15 @@ func (p *Panel) InsideBorders(x, y float32) bool {
 // Intersects returns if this panel intersects with the other panel
 func (p *Panel) Intersects(other *Panel) bool {
 
-	pospix := other.Pospix()
-	if p.ContainsPosition(pospix.X, pospix.Y) {
-		return true
-	}
-	if p.ContainsPosition(pospix.X+other.width-1, pospix.Y) {
-		return true
-	}
-	if p.ContainsPosition(pospix.X, pospix.Y+other.height-1) {
-		return true
+	// Checks if one panel is completely on the left side of the other
+	if p.pospix.X+p.width <= other.pospix.X || other.pospix.X+other.width <= p.pospix.X {
+		return false
 	}
-	if p.ContainsPosition(pospix.X+other.width-1, pospix.Y+other.height-1) {
-		return true
+	// Checks if one panel is completely above the other
+	if p.pospix.Y+p.height <= other.pospix.Y || other.pospix.Y+other.height <= p.pospix.Y {
+		return false
 	}
-	return false
+	return true
 }
 
 // SetEnabled sets the panel enabled state

+ 2 - 0
renderer/renderer.go

@@ -34,6 +34,8 @@ type Renderer struct {
 	panList     []gui.IPanel               // list of panels to render
 }
 
+// Stats describes how many object types were rendered
+// It is cleared at the start of each render
 type Stats struct {
 	Graphics int // Number of graphic objects rendered
 	Lights   int // Number of lights rendered