diff options
author | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-01 18:23:35 -0300 |
---|---|---|
committer | Thales1330 <thaleslima.ufu@gmail.com> | 2016-09-01 18:23:35 -0300 |
commit | b817a3f0e398c7e938ed1a37ebdbfc5a03eb7471 (patch) | |
tree | 2d3b71b7ec3bafe8978eeb958baeb635354df029 /Project/Bus.cpp | |
parent | 8f475833e585692544cb0f481b0dce0c3439a1a9 (diff) | |
download | PSP.git-b817a3f0e398c7e938ed1a37ebdbfc5a03eb7471.tar.gz PSP.git-b817a3f0e398c7e938ed1a37ebdbfc5a03eb7471.tar.xz PSP.git-b817a3f0e398c7e938ed1a37ebdbfc5a03eb7471.zip |
generator under implementation
Diffstat (limited to 'Project/Bus.cpp')
-rw-r--r-- | Project/Bus.cpp | 69 |
1 files changed, 1 insertions, 68 deletions
diff --git a/Project/Bus.cpp b/Project/Bus.cpp index 9f38da0..9d0775e 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -79,75 +79,8 @@ bool Bus::Intersects(wxRect2DDouble rect) const if(m_angle == 0.0 || m_angle == 180.0) return m_rect.Intersects(rect); return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0); - - /*wxPoint2DDouble m_rectCorners[4] = {m_rect.GetLeftTop(), m_rect.GetLeftBottom(), m_rect.GetRightBottom(), - m_rect.GetRightTop()}; - wxPoint2DDouble rectCorners[4] = {rect.GetLeftTop(), rect.GetLeftBottom(), rect.GetRightBottom(), - rect.GetRightTop()}; - - // Rotate the m_rect corners - for(int i = 0; i < 4; i++) { - m_rectCorners[i] = RotateAtPosition(m_rectCorners[i], m_angle); - } - - //[Ref] http://www.gamedev.net/page/resources/_/technical/game-programming/2d-rotated-rectangle-collision-r2604 - - // Find the rectangles axis to project - wxPoint2DDouble axis[4] = {m_rectCorners[3] - m_rectCorners[0], m_rectCorners[3] - m_rectCorners[2], - rectCorners[3] - rectCorners[0], rectCorners[3] - rectCorners[2]}; - - // Calculate the projected points to each axis - wxPoint2DDouble m_rectProjPts[4][4]; // [axis][corner] - wxPoint2DDouble rectProjPts[4][4]; // [axis][corner] - for(int i = 0; i < 4; i++) { - double den = axis[i].m_x * axis[i].m_x + axis[i].m_y * axis[i].m_y; - for(int j = 0; j < 4; j++) { - double m_rectProj = (m_rectCorners[j].m_x * axis[i].m_x + m_rectCorners[j].m_y * axis[i].m_y) / den; - double rectProj = (rectCorners[j].m_x * axis[i].m_x + rectCorners[j].m_y * axis[i].m_y) / den; - - m_rectProjPts[i][j] = wxPoint2DDouble(m_rectProj * axis[i].m_x, m_rectProj * axis[i].m_y); - rectProjPts[i][j] = wxPoint2DDouble(rectProj * axis[i].m_x, rectProj * axis[i].m_y); - } - } - - // Calculate the scalar value to identify the max and min values on projections - double m_rectScalar[4][4]; //[axis][corner] - double rectScalar[4][4]; //[axis][corner] - for(int i = 0; i < 4; i++) { - for(int j = 0; j < 4; j++) { - m_rectScalar[i][j] = m_rectProjPts[i][j].m_x * axis[i].m_x + m_rectProjPts[i][j].m_y * axis[i].m_y; - rectScalar[i][j] = rectProjPts[i][j].m_x * axis[i].m_x + rectProjPts[i][j].m_y * axis[i].m_y; - } - } - // Identify the max and min values - double m_rectMin[4]; - double m_rectMax[4]; - double rectMin[4]; - double rectMax[4]; - - for(int i = 0; i < 4; i++) { - m_rectMax[i] = m_rectScalar[i][0]; - rectMax[i] = rectScalar[i][0]; - m_rectMin[i] = m_rectScalar[i][0]; - rectMin[i] = rectScalar[i][0]; - - for(int j = 1; j < 4; j++) { - if(m_rectMax[i] < m_rectScalar[i][j]) m_rectMax[i] = m_rectScalar[i][j]; - if(rectMax[i] < rectScalar[i][j]) rectMax[i] = rectScalar[i][j]; - - if(m_rectMin[i] > m_rectScalar[i][j]) m_rectMin[i] = m_rectScalar[i][j]; - if(rectMin[i] > rectScalar[i][j]) rectMin[i] = rectScalar[i][j]; - } - } - - // Check if any segment don't overlap - for(int i = 0; i < 4; i++) { - if(!(rectMin[i] <= m_rectMax[i] && rectMax[i] >= m_rectMin[i])) return false; - } - - return true; - // return rect.Intersects(m_rect);*/ } + bool Bus::PickboxContains(wxPoint2DDouble position) { m_activePickboxID = ID_PB_NONE; |