MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / OBBHitTest

Method OBBHitTest

LuaSTGPlus/CollisionDetect.cpp:6–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace LuaSTGPlus;
5
6bool LuaSTGPlus::OBBHitTest(fcyVec2 P1, fcyVec2 Size1, float Angle1,
7 fcyVec2 P2, fcyVec2 Size2, float Angle2)
8{
9 // ��������ε�4������
10 fcyVec2 tFinalPos[2][4] =
11 {
12 {
13 fcyVec2(-Size1.x, -Size1.y),
14 fcyVec2(Size1.x, -Size1.y),
15 fcyVec2(Size1.x, Size1.y),
16 fcyVec2(-Size1.x, Size1.y)
17 },
18 {
19 fcyVec2(-Size2.x, -Size2.y),
20 fcyVec2(Size2.x, -Size2.y),
21 fcyVec2(Size2.x, Size2.y),
22 fcyVec2(-Size2.x, Size2.y)
23 }
24 };
25
26 float tSin, tCos;
27 {
28 /*
29 tSin = sin(Angle1);
30 tCos = cos(Angle1);
31 */
32 SinCos(Angle1, tSin, tCos);
33
34 for (int i = 0; i<4; i++)
35 {
36 tFinalPos[0][i].RotationSC(tSin, tCos);
37 tFinalPos[0][i] += P1;
38 }
39 }
40 {
41 /*
42 tSin = sin(Angle2);
43 tCos = cos(Angle2);
44 */
45 SinCos(Angle2, tSin, tCos);
46
47 for (int i = 0; i<4; i++)
48 {
49 tFinalPos[1][i].RotationSC(tSin, tCos);
50 tFinalPos[1][i] += P2;
51 }
52 }
53
54 // �����������������
55 for (int i = 0; i<2; i++)
56 {
57 fcyVec2 tAxis[2] =
58 {
59 tFinalPos[i][1] - tFinalPos[i][0],
60 tFinalPos[i][2] - tFinalPos[i][1]
61 };
62
63 // �������

Callers

nothing calls this directly

Calls 2

SinCosFunction · 0.85
OverlapTestFunction · 0.85

Tested by

no test coverage detected