|
当たり判定いろいろ |
|
inline BOOL IsHitRect(CRect& rc1, CRest& rc2) { CRect rcResult; return rcResult.IntersectRect(&rc1, &rc2); } |
|
inline BOOL IsHitRect(RECT& rc1, RECT& rc2) { RECT rcResult; return ::IntersectRect(&rcResult, &rc1, &rc2); } |
|
inline BOOL IsHitPoint(CRect& rc, CPoint& pt) { return rc.PtInRect(pt); } |
|
inline BOOL IsHitPoint(RECT& rc, POINT& pt) { return ::PtInRect(&rc, pt); } |
|
#include <d3dx8math.h> inline BOOL IsHitCircle( D3DXVECTOR2 vec2Pos1, float fRad1, // 円1の中心位置と半径 D3DXVECTOR2 vec2Pos2, float fRad2 // 円2の中心位置と半径 ) { D3DXVECTOR2 vec2Dif = vec2Pos2 - vec2Pos1; float fLength = fRad1 + fRad2; return D3DXVec2LengthSq(&vec2Dif) < fLength * fLength; } |
|
inline BOOL IsHitBall( D3DXVECTOR3 vec3Pos1, float fRad1, // 球1の中心位置と半径 D3DXVECTOR3 vec3Pos2, float fRad2 // 球2の中心位置と半径 ) { D3DXVECTOR3 vec3Dif = vec3Pos2 - vec3Pos1; float fLength = fRad1 + fRad2; return D3DXVec3LengthSq(&vec3Dif) < fLength * fLength; } |
|
inline BOOL IsHitCircle( CPoint& pt1, float fRad1, // 円1の中心位置と半径 CPoint& pt2, float fRad2 // 円2の中心位置と半径 ) { CPoint pt = pt2 - pt1; float fLength = fRad1 + fRad2; return float(pt.x * pt.x + pt.y * pt.y) < fLength * fLength; } |
|
inline BOOL IsHitCircle( POINT& pt1, float fRad1, // 円1の中心位置と半径 POINT& pt2, float fRad2 // 円2の中心位置と半径 ) { float fDifX = float(pt2.x - pt1.x); float fDifY = float(pt2.y - pt1.y); float fLength = fRad1 + fRad2; return fDifX * fDifX + fDifY * fDifY < fLength * fLength; } |