瀏覽代碼

Merge pull request #6743 from mateka/issue-6296

Issue #6296: When searching for control, checking if matrix is inversible
Rémi Verschelde 9 年之前
父節點
當前提交
b9e010fb7f
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 1 1
      core/math/math_2d.cpp
  2. 3 0
      scene/main/viewport.cpp

+ 1 - 1
core/math/math_2d.cpp

@@ -424,7 +424,7 @@ Matrix32 Matrix32::inverse() const {
 
 void Matrix32::affine_invert() {
 
-	float det = elements[0][0]*elements[1][1] - elements[1][0]*elements[0][1];
+	float det = basis_determinant();
 	ERR_FAIL_COND(det==0);
 	float idet = 1.0 / det;
 

+ 3 - 0
scene/main/viewport.cpp

@@ -1715,6 +1715,9 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
 	}
 
 	Matrix32 matrix = p_xform * p_node->get_transform();
+	// matrix.basis_determinant() == 0.0f implies that node does not exist on scene
+	if(matrix.basis_determinant() == 0.0f)
+		return NULL;
 
 	if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {