MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / PointWithinTriangle

Function PointWithinTriangle

src/SB/Core/gc/iCollide.cpp:35–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35S32 PointWithinTriangle(xVec3* _pt, xVec3** _tri, xVec3* _normal)
36{
37 RwV3d* pt = (RwV3d*)_pt;
38 RwV3d** tri = (RwV3d**)_tri;
39 RwV3d* normal = (RwV3d*)_normal;
40 Dimension dimension;
41 F32 absX = iabs(normal->x);
42 F32 absY = iabs(normal->y);
43 F32 absZ = iabs(normal->z);
44 S32 inside = FALSE;
45 S32 i;
46 S32 j;
47
48 if (absZ > absY)
49 {
50 if (absZ > absX)
51 {
52 dimension = ZDIM;
53 }
54 else
55 {
56 dimension = XDIM;
57 }
58 }
59 else
60 {
61 if (absY > absX)
62 {
63 dimension = YDIM;
64 }
65 else
66 {
67 dimension = XDIM;
68 }
69 }
70
71 switch (dimension)
72 {
73 case XDIM:
74 for (i = 0, j = 2; i < 3; j = i, i++)
75 {
76 if (((tri[i]->y <= pt->y && pt->y < tri[j]->y) ||
77 (tri[j]->y <= pt->y && pt->y < tri[i]->y)) &&
78 (pt->z < tri[i]->z + ((pt->y - tri[i]->y) * (tri[j]->z - tri[i]->z)) /
79 (tri[j]->y - tri[i]->y)))
80 {
81 inside = !inside;
82 }
83 }
84 break;
85 case YDIM:
86 for (i = 0, j = 2; i < 3; j = i, i++)
87 {
88 if (((tri[i]->z <= pt->z && pt->z < tri[j]->z) ||
89 (tri[j]->z <= pt->z && pt->z < tri[i]->z)) &&
90 (pt->x < tri[i]->x + ((pt->z - tri[i]->z) * (tri[j]->x - tri[i]->x)) /
91 (tri[j]->z - tri[i]->z)))
92 {

Callers 1

properSphereIsectTriFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected