Fix const loop invariant issues (#2921)

* Fix const loop invariant issues by defining explicit operator= for structs

* Fix J2DMatBlock weak func order
This commit is contained in:
LagoLunatic
2025-12-06 17:19:09 -05:00
committed by GitHub
parent 136f6b3f40
commit 7ac2c38caf
8 changed files with 72 additions and 36 deletions
@@ -1543,6 +1543,15 @@ struct J3DAlphaCompInfo {
/* 0x5 */ u8 field_0x5;
/* 0x6 */ u8 field_0x6;
/* 0x7 */ u8 field_0x7;
J3DAlphaCompInfo& operator=(const J3DAlphaCompInfo& other) {
mComp0 = other.mComp0;
mRef0 = other.mRef0;
mOp = other.mOp;
mComp1 = other.mComp1;
mRef1 = other.mRef1;
return *this;
}
};
extern const u16 j3dDefaultAlphaCmpID;
+10 -1
View File
@@ -4,6 +4,7 @@
#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/J3DAssert.h"
#include "JSystem/JUtility/JUTTexture.h"
#include "global.h"
#include <stdint.h>
/**
@@ -79,6 +80,14 @@ struct J3DTexCoordInfo {
/* 0x1 */ u8 mTexGenSrc;
/* 0x2 */ u8 mTexGenMtx;
/* 0x3 */ u8 pad;
J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) {
mTexGenType = other.mTexGenType;
mTexGenSrc = other.mTexGenSrc;
mTexGenMtx = other.mTexGenMtx;
pad = other.pad;
return *this;
}
};
extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8];
@@ -108,7 +117,7 @@ struct J3DTexCoord : public J3DTexCoordInfo {
void setTexMtxReg(u16 reg) { mTexMtxReg = reg; }
J3DTexCoord& operator=(const J3DTexCoord& other) {
// Fake match (__memcpy or = doesn't match)
*(uintptr_t*)this = *(uintptr_t*)&other;
*(u32*)this = *(u32*)&other;
return *this;
}