From e9127832d7111571d81e074723c9d30f3d2f44ee Mon Sep 17 00:00:00 2001
From: Nomango <569629550@qq.com>
Date: Sun, 27 Jan 2019 13:08:56 +0800
Subject: [PATCH] add: Node::GetBoundingBox function
minor
minor
minor
---
project/vs2013/Easy2D.vcxproj | 3 +-
project/vs2013/Easy2D.vcxproj.filters | 9 +-
project/vs2015/Easy2D.vcxproj | 3 +-
project/vs2015/Easy2D.vcxproj.filters | 9 +-
project/vs2017/Easy2D.vcxproj | 3 +-
project/vs2017/Easy2D.vcxproj.filters | 9 +-
src/core/Node.cpp | 5 +
src/core/Node.h | 3 +
src/core/Sprite.cpp | 2 +-
src/core/helper.hpp | 2 +-
src/core/render.cpp | 4 +-
src/core/render.h | 5 +-
src/easy2d.h | 2 +-
src/math/Matrix.cpp | 152 ++++++++++++++++++++++++++
src/math/{Matrix.hpp => Matrix.h} | 152 ++++++--------------------
15 files changed, 228 insertions(+), 135 deletions(-)
create mode 100644 src/math/Matrix.cpp
rename src/math/{Matrix.hpp => Matrix.h} (63%)
diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj
index 3b5933ed..ebc74304 100644
--- a/project/vs2013/Easy2D.vcxproj
+++ b/project/vs2013/Easy2D.vcxproj
@@ -73,7 +73,7 @@
-
+
@@ -123,6 +123,7 @@
+
diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters
index 2a5164c8..c7d0b63c 100644
--- a/project/vs2013/Easy2D.vcxproj.filters
+++ b/project/vs2013/Easy2D.vcxproj.filters
@@ -62,9 +62,6 @@
core
-
- math
-
math
@@ -203,6 +200,9 @@
core
+
+ math
+
@@ -351,5 +351,8 @@
core
+
+ math
+
\ No newline at end of file
diff --git a/project/vs2015/Easy2D.vcxproj b/project/vs2015/Easy2D.vcxproj
index 707919bb..545da6a1 100644
--- a/project/vs2015/Easy2D.vcxproj
+++ b/project/vs2015/Easy2D.vcxproj
@@ -73,7 +73,7 @@
-
+
@@ -123,6 +123,7 @@
+
diff --git a/project/vs2015/Easy2D.vcxproj.filters b/project/vs2015/Easy2D.vcxproj.filters
index 2a5164c8..c7d0b63c 100644
--- a/project/vs2015/Easy2D.vcxproj.filters
+++ b/project/vs2015/Easy2D.vcxproj.filters
@@ -62,9 +62,6 @@
core
-
- math
-
math
@@ -203,6 +200,9 @@
core
+
+ math
+
@@ -351,5 +351,8 @@
core
+
+ math
+
\ No newline at end of file
diff --git a/project/vs2017/Easy2D.vcxproj b/project/vs2017/Easy2D.vcxproj
index 78bd6f34..0c41e53f 100644
--- a/project/vs2017/Easy2D.vcxproj
+++ b/project/vs2017/Easy2D.vcxproj
@@ -73,7 +73,7 @@
-
+
@@ -123,6 +123,7 @@
+
diff --git a/project/vs2017/Easy2D.vcxproj.filters b/project/vs2017/Easy2D.vcxproj.filters
index 2a5164c8..c7d0b63c 100644
--- a/project/vs2017/Easy2D.vcxproj.filters
+++ b/project/vs2017/Easy2D.vcxproj.filters
@@ -62,9 +62,6 @@
core
-
- math
-
math
@@ -203,6 +200,9 @@
core
+
+ math
+
@@ -351,5 +351,8 @@
core
+
+ math
+
\ No newline at end of file
diff --git a/src/core/Node.cpp b/src/core/Node.cpp
index d8f8273f..2a984ca7 100644
--- a/src/core/Node.cpp
+++ b/src/core/Node.cpp
@@ -500,6 +500,11 @@ namespace easy2d
return Rect(Point{}, size_);
}
+ Rect Node::GetBoundingBox() const
+ {
+ return GetTransformMatrix().Transform(GetBounds());
+ }
+
Array Node::GetChildren(String const& name) const
{
Array children;
diff --git a/src/core/Node.h b/src/core/Node.h
index 2f0668b9..547320e4 100644
--- a/src/core/Node.h
+++ b/src/core/Node.h
@@ -127,6 +127,9 @@ namespace easy2d
// 获取包围盒
Rect GetBounds() const;
+ // 获取外切包围盒
+ Rect GetBoundingBox() const;
+
// 获取二维变换矩阵
Matrix const& GetTransformMatrix() const;
diff --git a/src/core/Sprite.cpp b/src/core/Sprite.cpp
index 898b838f..529289be 100644
--- a/src/core/Sprite.cpp
+++ b/src/core/Sprite.cpp
@@ -99,7 +99,7 @@ namespace easy2d
{
if (image_)
{
- RenderSystem::Instance()->DrawImage(image_);
+ RenderSystem::Instance()->DrawImage(image_, GetBounds());
}
}
}
\ No newline at end of file
diff --git a/src/core/helper.hpp b/src/core/helper.hpp
index a8078b6e..6fc580aa 100644
--- a/src/core/helper.hpp
+++ b/src/core/helper.hpp
@@ -24,7 +24,7 @@
#include "closure.hpp"
#include "../math/vector.hpp"
#include "../math/Rect.hpp"
-#include "../math/Matrix.hpp"
+#include "../math/Matrix.h"
#include
#include