summaryrefslogtreecommitdiff
path: root/libs/SSystem/SComponent/c_m3d_g_pla.cpp
blob: 0d5c35bd608dddd3f237bf1390388c22cb07f7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
 * c_m3d_g_pla.cpp
 *
 */

#include "SSystem/SComponent/c_m3d_g_pla.h"
#include "SSystem/SComponent/c_m3d.h"

/* 8026F3DC-8026F408 269D1C 002C+00 0/0 3/3 0/0 .text            __ct__8cM3dGPlaFPC4cXyzf */
cM3dGPla::cM3dGPla(const cXyz* normal, f32 d) : mNormal(*normal), mD(d) {}

/* 8026F408-8026F4C4 269D48 00BC+00 0/0 3/3 0/0 .text crossInfLin__8cM3dGPlaCFRC4cXyzRC4cXyzR4cXyz
 */
bool cM3dGPla::crossInfLin(const cXyz& start, const cXyz& end, cXyz& out) const {
    f32 tmp1 = (mD + VECDotProduct(&mNormal, &start));
    f32 tmp2 = tmp1 - (mD + VECDotProduct(&mNormal, &end));
    if (fabsf(tmp2) < G_CM3D_F_ABS_MIN) {
        out = end;
        return false;
    } else {
        cM3d_InDivPos2(&start, &end, (tmp1 / tmp2), &out);
        return true;
    }
}

/* 8026F4C4-8026F52C 269E04 0068+00 0/0 1/1 0/0 .text            SetupNP0__8cM3dGPlaFRC3VecRC3Vec */
void cM3dGPla::SetupNP0(const Vec& normal, const Vec& point) {
    mNormal = normal;
    VECNormalize(&mNormal, &mNormal);
    mD = -VECDotProduct(&mNormal, &point);
}

/* 8026F52C-8026F57C 269E6C 0050+00 0/0 2/2 0/0 .text            SetupNP__8cM3dGPlaFRC3VecRC3Vec */
void cM3dGPla::SetupNP(const Vec& normal, const Vec& point) {
    mNormal = normal;
    mD = -VECDotProduct(&mNormal, &point);
}

/* 8026F57C-8026F5D4 269EBC 0058+00 0/0 2/2 0/0 .text            getCrossY__8cM3dGPlaCFRC4cXyzPf */
bool cM3dGPla::getCrossY(const cXyz& point, f32* out) const {
    if (fabsf(mNormal.y) < G_CM3D_F_ABS_MIN) {
        return false;
    } else {
        *out = (-mNormal.x * point.x - mNormal.z * point.z - mD) / mNormal.y;
        return true;
    }
}

/* 8026F5D4-8026F624 269F14 0050+00 0/0 1/1 0/0 .text            getCrossYLessD__8cM3dGPlaCFRC3VecPf
 */
bool cM3dGPla::getCrossYLessD(const Vec& point, f32* out) const {
    if (fabsf(mNormal.y) < G_CM3D_F_ABS_MIN) {
        return false;
    } else {
        *out = (-mNormal.x * point.x - mNormal.z * point.z) / mNormal.y;
        return true;
    }
}

/* 8026F624-8026F648 269F64 0024+00 0/0 1/1 0/0 .text            Set__8cM3dGPlaFPC8cM3dGPla */
void cM3dGPla::Set(const cM3dGPla* other) {
    *this = *other;
}