summaryrefslogtreecommitdiff
path: root/src/JSystem/J3DGraphBase/J3DStruct.cpp
blob: b273cafffe1e3cfe66e28bfabac4241768b7ddd8 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//
// J3DStruct
//

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/JMath/JMath.h"

bool J3DTextureSRTInfo::operator==(J3DTextureSRTInfo& other) const {
    if (mScaleX == other.mScaleX &&
        mScaleY == other.mScaleY &&
        mRotation == other.mRotation &&
        mTranslationX == other.mTranslationX &&
        mTranslationY == other.mTranslationY
    ) {
        return true;
    }
    return false;
}

bool J3DLightInfo::operator==(J3DLightInfo& other) const {
    if (mLightPosition.x == other.mLightPosition.x &&
        mLightPosition.y == other.mLightPosition.y &&
        mLightPosition.z == other.mLightPosition.z &&
        mLightDirection.x == other.mLightDirection.x &&
        mLightDirection.y == other.mLightDirection.y &&
        mLightDirection.z == other.mLightDirection.z &&
        mColor.r == other.mColor.r &&
        mColor.g == other.mColor.g &&
        mColor.b == other.mColor.b &&
        mColor.a == other.mColor.a &&
        mCosAtten.x == other.mCosAtten.x &&
        mCosAtten.y == other.mCosAtten.y &&
        mCosAtten.z == other.mCosAtten.z &&
        mDistAtten.x == other.mDistAtten.x &&
        mDistAtten.y == other.mDistAtten.y &&
        mDistAtten.z == other.mDistAtten.z
    ) {
        return true;
    }
    return false;
}

J3DLightInfo& J3DLightInfo::operator=(J3DLightInfo const& param_0) {
    JMath::gekko_ps_copy6(&mLightPosition, &param_0.mLightPosition);
    mColor = param_0.mColor;
    JMath::gekko_ps_copy6(&mCosAtten, &param_0.mCosAtten);
    return *this;
}

bool J3DTexMtxInfo::operator==(J3DTexMtxInfo& other) const {
    if (mProjection != other.mProjection ||
        mInfo != other.mInfo ||
        !(mSRT == other.mSRT)
    ) {
        return false;
    }
    if (mEffectMtx[0][0] != other.mEffectMtx[0][0] ||
        mEffectMtx[0][1] != other.mEffectMtx[0][1] ||
        mEffectMtx[0][2] != other.mEffectMtx[0][2] ||
        mEffectMtx[0][3] != other.mEffectMtx[0][3] ||
        mEffectMtx[1][0] != other.mEffectMtx[1][0] ||
        mEffectMtx[1][1] != other.mEffectMtx[1][1] ||
        mEffectMtx[1][2] != other.mEffectMtx[1][2] ||
        mEffectMtx[1][3] != other.mEffectMtx[1][3] ||
        mEffectMtx[2][0] != other.mEffectMtx[2][0] ||
        mEffectMtx[2][1] != other.mEffectMtx[2][1] ||
        mEffectMtx[2][2] != other.mEffectMtx[2][2] ||
        mEffectMtx[2][3] != other.mEffectMtx[2][3] ||
        mEffectMtx[3][0] != other.mEffectMtx[3][0] ||
        mEffectMtx[3][1] != other.mEffectMtx[3][1] ||
        mEffectMtx[3][2] != other.mEffectMtx[3][2] ||
        mEffectMtx[3][3] != other.mEffectMtx[3][3]
    ) {
        return false;
    }
    if (
        mCenter.x != other.mCenter.x ||
        mCenter.y != other.mCenter.y ||
        mCenter.z != other.mCenter.z
    ) {
        return false;
    }
    return true;
}

J3DTexMtxInfo& J3DTexMtxInfo::operator=(J3DTexMtxInfo const& param_0) {
    mProjection = param_0.mProjection;
    mInfo = param_0.mInfo;
    JMath::gekko_ps_copy3(&mCenter, &param_0.mCenter);
    mSRT = param_0.mSRT;
    JMath::gekko_ps_copy16(&mEffectMtx, &param_0.mEffectMtx);
    return *this;
}

// Helper functions to set float literal order
static f32 dummyLiteralOrder() {
    return 1.0f;
}

void J3DTexMtxInfo::setEffectMtx(Mtx param_0) {
#ifdef __MWERKS__
    JMath::gekko_ps_copy12(&mEffectMtx, param_0);
    register f32 zero = 0.0f;
    register f32* mtx = (f32*)mEffectMtx;
    asm {
        psq_st zero, 0x30(mtx), 0, 0
    };
    mEffectMtx[3][2] = 0.0f;
    mEffectMtx[3][3] = 1.0f;
#endif
}

J3DIndTexMtxInfo& J3DIndTexMtxInfo::operator=(J3DIndTexMtxInfo const& param_0) {
    JMath::gekko_ps_copy6(field_0x0, param_0.field_0x0);
    field_0x18 = param_0.field_0x18;
    return *this;
}

bool J3DFogInfo::operator==(J3DFogInfo& other) const {
    if (mType == other.mType &&
        mAdjEnable == other.mAdjEnable &&
        mCenter == other.mCenter &&
        mStartZ == other.mStartZ &&
        mEndZ == other.mEndZ &&
        mNearZ == other.mNearZ &&
        mFarZ == other.mFarZ &&
        mColor.r == other.mColor.r &&
        mColor.g == other.mColor.g &&
        mColor.b == other.mColor.b &&
        mColor.a == other.mColor.a
    ) {
        for (int i = 0; i < 10; i++) {
            if (mFogAdjTable.r[i] != other.mFogAdjTable.r[i]) {
                return false;
            }
        }
        return true;
    }
    return false;
}

J3DFogInfo& J3DFogInfo::operator=(const J3DFogInfo& param_0) {
    mType = param_0.mType;
    mAdjEnable = param_0.mAdjEnable;
    mCenter = param_0.mCenter;
    mStartZ = param_0.mStartZ;
    mEndZ = param_0.mEndZ;
    mNearZ = param_0.mNearZ;
    mFarZ = param_0.mFarZ;
    mColor.r = param_0.mColor.r;
    mColor.g = param_0.mColor.g;
    mColor.b = param_0.mColor.b;
    mColor.a = param_0.mColor.a;
    for (int i = 0; i < 10; i++) {
        mFogAdjTable.r[i] = param_0.mFogAdjTable.r[i];
    }
    return *this;
}

bool J3DNBTScaleInfo::operator==(const J3DNBTScaleInfo& other) const {
    if (mbHasScale == other.mbHasScale &&
        mScale.x == other.mScale.x &&
        mScale.y == other.mScale.y &&
        mScale.z == other.mScale.z
    ) {
        return true;
    }
    return false;
}

J3DNBTScaleInfo& J3DNBTScaleInfo::operator=(const J3DNBTScaleInfo& other) {
    mbHasScale = other.mbHasScale;
    mScale.x = other.mScale.x;
    mScale.y = other.mScale.y;
    mScale.z = other.mScale.z;
    return *this;
}