Skip to content

Commit ca9481d

Browse files
authored
d_cloth_packet matching (#928)
* Match dCloth_packet_c::setMtx * Match dCloth_packet_c::setGlobalWind * Match dCloth_packet_c::dCloth_packet_c constructor implementation * Match dCloth_packet_c::getFactor and get_cloth_anim_sub_factor implementation * Match dCloth_packet_c::cloth_move implementation * Match dCloth_packet_c::setNrm implementation * Match dCloth_packet_c::init and default_factor_checkCB implementation * Match dCloth_packet_c::draw implementation * Match dCloth_packet_c::cloth_draw implementation * Match dCloth_packet_c::plot implementation * Match dCloth_packet_c::TexObjLoad implementation * Match dCloth_packet_c::TexObjInit implementation * Match dCloth_packet_c::TevSetting implementation * Match dCloth_packet_c::dCloth_packet_create implementation * Match dCloth_packet_c::TevSetting implementation * Match dCloth_packetXlu_c::TevSetting implementation and make dCloth_packet_c members protected * Match dCloth_packetXlu_c::cloth_draw implementation * Match dClothVobj03_c::cloth_copy implementation and update member definitions * Match dClothVobj04_c, dClothVobj05_c, and dClothVobj07_0_c::cloth_copy implementations and update member definitions * Match dClothVobj03_c::init implementation, update cloth_counter definitions, and add new member variables * Match `dClothVobj04_c::init`, `dClothVobj05_c::init`, and `dClothVobj07_0_c::init` implementations, and add new member variables. * Match `dClothVobj03_c::dClothVobj03_create` and constructor implementations, update member definitions, and add new logic checks. * Match `dClothVobj03_c::cloth_move` implementation * Match `dClothVobj04_c`, `dClothVobj05_c`, and `dClothVobj07_0_c::cloth_move` implementations * Match `dClothVobj03_c`, `dClothVobj04_c`, `dClothVobj05_c`, and `dClothVobj07_0_c::TexObjInit` implementations, update member definitions, and initialize `mTlutObj`. * Match `TexObjLoad` implementations for `dClothVobj03_c`, `dClothVobj04_c`, `dClothVobj05_c`, and `dClothVobj07_0_c`. * Fix `dClothVobj04_c::cloth_move` * Match `dClothVobj04_create`, `dClothVobj05_create`, and `dClothVobj07_0_create` implementations, update parameter definitions, and add new constructor logic. * Update parameter names in `dClothVobj05_VtxFactorCB` and `dClothVobj07_0_VtxFactorCB` for consistency. * Adjust parameter values in `dClothVobj05_create` and `dClothVobj07_0_create` for consistency with expected behavior. * Match `dClothVobj05_VtxFactorCB` and `dClothVobj07_0_VtxFactorCB` implementations and update return logic. * Fix constructors * Refactor repetitive parameter assignments in `dCloth_packet_c` with `setParam` and `setWindPower` for cleaner and more maintainable code. * Add `setFactorCheckCB` call in `dCloth_packet_c` initialization * Refactor `dCloth_packet_c` and related classes to eliminate redundant success checks with `chkCreateBuff` helper method. * Refactor `dCloth_packet_c` and related classes to use getter methods for cleaner access and rename methods for improved clarity. * Simplify constructors for `dClothVobj03_c`, `dClothVobj04_c`, `dClothVobj05_c`, and `dClothVobj07_0_c` by removing redundant parameters. * Replace `field_0x109` with `mIsIndoors` for improved clarity and consistency across `dCloth_packet_c` and related classes. * Replace `VECDotProduct` with `inprod` method in `dCloth_packet_c` for improved readability and modern syntax usage. * Make `top_pointer` and `cloth_counter` members private in multiple `dClothVobjXX_c` classes for encapsulation. * Match cloth creation functions * Add `l_alpha_matDL` assets and update `GXCallDisplayList` usage in `dCloth_packetXlu_c` * Match dCloth_packet_c::init * Match dCloth_packet_c::setNrm * Refactor dCloth_packet_c to use mDoMtx_stack_c methods * Match `get_cloth_anim_sub_factor` implementation in `dCloth_packet_c`. * Refactor `getFactor` in `dCloth_packet_c` to use a bitmask for neighbor checks, enhancing code clarity and efficiency. * Match dCloth_packet_c::cloth_move * Match dCloth_packet_c::setGlobalWind * Match dCloth_packet_c::plot implementation * Remove unused virtual function declarations * Update `d/d_cloth_packet.cpp` to Matching in configure.py * Refactor field_0x108 and mIsIndoors to boolean types, rename, and add explanatory comments. * Update `d/d_cloth_packet.cpp` to `MatchingFor("GZLE01")` in configure.py * Add new material and alpha material configurations for `d_cloth_packet` across GZLP01, GZLJ01, and D44J01 * Update `d/d_cloth_packet.cpp` to `Matching` in configure.py * Update `d/d_cloth_packet.cpp` to `MatchingFor("GZLE01", "GZLP01")` in configure.py * Add conditional GXSetNumIndStages and resetVcdVatCache for non-JPN versions in `dCloth_packet_c::draw` * Update `d/d_cloth_packet.cpp` to `MatchingFor("GZLJ01", "GZLE01", "GZLP01")` in configure.py * Matched dCloth_packet_c::dCloth_packet_c for `VERSION_DEMO` in `d/d_cloth_packet.cpp` * Matched dCloth_packet_c::cloth_move for `VERSION_DEMO` in `d/d_cloth_packet.cpp` * Matched dCloth_packet_c::draw for `VERSION_DEMO` in `d/d_cloth_packet.cpp` * Matched dCloth_packet_c::TexObjInit for `VERSION_DEMO` in `d/d_cloth_packet.cpp` * Matched dClothVobjXX_c::TexObjInit for `VERSION_DEMO` in `d/d_cloth_packet.cpp` * Update `d/d_cloth_packet.cpp` to `Matching` in configure.py * Replaced direct member access with getter methods in `d/d_cloth_packet.cpp` * Added `f` suffix to floating-point literals in `d/d_cloth_packet.cpp` for consistency.
1 parent 579931b commit ca9481d

File tree

7 files changed

+1022
-108
lines changed

7 files changed

+1022
-108
lines changed

config/D44J01/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,3 +3246,10 @@ extract:
32463246
binary: assets/l_DL__drawSpot__FP10view_class.bin
32473247
header: assets/l_DL__drawSpot__FP10view_class.h
32483248
rename: l_DL
3249+
3250+
- symbol: l_matDL!.data:0x8036ADA0
3251+
binary: assets/l_matDL__d_cloth_packet.bin
3252+
header: assets/l_matDL__d_cloth_packet.h
3253+
- symbol: l_alpha_matDL!.data:0x8036ADE0
3254+
binary: assets/l_alpha_matDL__d_cloth_packet.bin
3255+
header: assets/l_alpha_matDL__d_cloth_packet.h

config/GZLE01/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,3 +2795,10 @@ extract:
27952795
- symbol: l_toonMat1DL
27962796
binary: assets/l_toonMat1DL.bin
27972797
header: assets/l_toonMat1DL.h
2798+
2799+
- symbol: l_matDL!.data:0x80376e20
2800+
binary: assets/l_matDL__d_cloth_packet.bin
2801+
header: assets/l_matDL__d_cloth_packet.h
2802+
- symbol: l_alpha_matDL!.data:0x80376e60
2803+
binary: assets/l_alpha_matDL__d_cloth_packet.bin
2804+
header: assets/l_alpha_matDL__d_cloth_packet.h

config/GZLJ01/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,3 +2379,10 @@ extract:
23792379
- symbol: l_toonMat1DL
23802380
binary: assets/l_toonMat1DL.bin
23812381
header: assets/l_toonMat1DL.h
2382+
2383+
- symbol: l_matDL!.data:0x8036A2C0
2384+
binary: assets/l_matDL__d_cloth_packet.bin
2385+
header: assets/l_matDL__d_cloth_packet.h
2386+
- symbol: l_alpha_matDL!.data:0x8036A300
2387+
binary: assets/l_alpha_matDL__d_cloth_packet.bin
2388+
header: assets/l_alpha_matDL__d_cloth_packet.h

config/GZLP01/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,3 +2391,10 @@ extract:
23912391
- symbol: l_toonMat1DL
23922392
binary: assets/l_toonMat1DL.bin
23932393
header: assets/l_toonMat1DL.h
2394+
2395+
- symbol: l_matDL!.data:0x8037DB00
2396+
binary: assets/l_matDL__d_cloth_packet.bin
2397+
header: assets/l_matDL__d_cloth_packet.h
2398+
- symbol: l_alpha_matDL!.data:0x8037DB40
2399+
binary: assets/l_alpha_matDL__d_cloth_packet.bin
2400+
header: assets/l_alpha_matDL__d_cloth_packet.h

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def EquivalentFor(*versions):
498498
Object(Matching, "d/d_shop.cpp"),
499499
Object(Matching, "d/d_jnt_hit.cpp"),
500500
Object(Matching, "d/d_chain.cpp"),
501-
Object(NonMatching, "d/d_cloth_packet.cpp"),
501+
Object(Matching, "d/d_cloth_packet.cpp"),
502502
Object(NonMatching, "d/d_a_obj.cpp"),
503503
Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_a_obj_tribox_static.cpp"),
504504
Object(Matching, "d/d_a_ship_static.cpp"),

include/d/d_cloth_packet.h

Lines changed: 125 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ class dCloth_packet_c : public J3DPacket {
1313
typedef dCloth_packet_c* (*CreateFunc)(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
1414
typedef int (*FactorCheck)(dCloth_packet_c*, int, int);
1515

16-
dCloth_packet_c(ResTIMG*, int, int, float, float, dKy_tevstr_c*, cXyz**);
16+
dCloth_packet_c(ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr);
1717
~dCloth_packet_c();
1818
virtual void init();
1919
virtual void cloth_move();
2020
virtual void cloth_draw();
21-
virtual void TexObjInit(ResTIMG*);
21+
virtual void TexObjInit(ResTIMG* i_img);
2222
virtual void TexObjLoad();
2323
virtual void TevSetting();
2424

2525
void draw();
26-
void setGlobalWind(cXyz*);
27-
void getFactor(cXyz*, cXyz*, cXyz*, float, float, float, int, int);
26+
void setGlobalWind(cXyz* wind);
27+
cXyz getFactor(cXyz* pPos, cXyz* pNrm, cXyz* pSpeed, float distFly, float distHoist, float distBoth, int x, int y);
2828
void setNrm();
2929
void plot();
3030

@@ -48,7 +48,27 @@ class dCloth_packet_c : public J3DPacket {
4848
setWindPower(wind, windWave);
4949
}
5050

51-
private:
51+
void changeCurrentBuff() { mCurArr ^= 1; }
52+
53+
bool chkCreateBuff() {
54+
if (mpPosArr[0] != NULL && mpPosArr[1] != NULL && mpNrmArr[0] != NULL && mpNrmArr[1] != NULL && mpNrmArrBack[0] != NULL && mpNrmArrBack[1] != NULL &&
55+
mpSpeedArr != NULL)
56+
return true;
57+
return false;
58+
}
59+
60+
cXyz* getPosP() const { return mpPosArr[mCurArr]; }
61+
cXyz* getNrmP() const { return mpNrmArr[mCurArr]; }
62+
cXyz* getBackNrmP() const { return mpNrmArrBack[mCurArr]; }
63+
cXyz* getSpdP() const { return mpSpeedArr; }
64+
u32 getVerticalNum() const { return mHoistGridSize; }
65+
GXTexObj* getTexObjP() { return &mTexObj; }
66+
GXTexObj* getToonTexObjP() { return &mToonTex; }
67+
68+
friend int default_factor_checkCB(dCloth_packet_c* pPkt, int x, int y);
69+
friend dCloth_packet_c* dCloth_packet_create(ResTIMG*, ResTIMG*, int, int, float, float, dKy_tevstr_c*, cXyz**);
70+
71+
protected:
5272
/* 0x10 */ s32 mFlyGridSize;
5373
/* 0x14 */ s32 mHoistGridSize;
5474
/* 0x18 */ f32 mFlyLength;
@@ -80,76 +100,146 @@ class dCloth_packet_c : public J3DPacket {
80100
/* 0xF6 */ s16 mRotateY;
81101
/* 0xF8 */ u8 mCurArr;
82102
}; // Size: 0xFC
83-
dCloth_packet_c* dCloth_packet_create(ResTIMG*, ResTIMG*, int, int, float, float, dKy_tevstr_c*, cXyz**);
103+
dCloth_packet_c* dCloth_packet_create(
104+
ResTIMG* i_flagimage, ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr
105+
);
84106

85107
class dCloth_packetXlu_c : public dCloth_packet_c {
86-
virtual void init();
87-
virtual void cloth_move();
88108
virtual void cloth_draw();
89-
virtual void TexObjInit(ResTIMG*);
90-
virtual void TexObjLoad();
91109
virtual void TevSetting();
110+
111+
private:
112+
dCloth_packetXlu_c(ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr)
113+
: dCloth_packet_c(i_toonimage, flyGridSize, hoistGridSize, flyLength, hoistLength, tevstr, posArr) {}
114+
115+
friend dCloth_packetXlu_c* dCloth_packetXlu_create(ResTIMG*, ResTIMG*, int, int, float, float, dKy_tevstr_c*, cXyz**);
116+
117+
private:
118+
u32 field_0xFC;
92119
};
93-
dCloth_packetXlu_c* dCloth_packetXlu_create(ResTIMG*, ResTIMG*, int, int, float, float, dKy_tevstr_c*, cXyz**);
120+
121+
dCloth_packetXlu_c* dCloth_packetXlu_create(
122+
ResTIMG* i_flagimage, ResTIMG* i_toonimage, int flyGridSize, int hoistGridSize, float flyLength, float hoistLength, dKy_tevstr_c* tevstr, cXyz** posArr
123+
);
94124

95125
class dClothVobj03_c : public dCloth_packet_c {
96126
virtual void init();
97127
virtual void cloth_move();
98-
virtual void cloth_draw();
99128
virtual void TexObjInit(ResTIMG*);
100129
virtual void TexObjLoad();
101-
virtual void TevSetting();
102130
void cloth_copy();
103131

104-
public:
105-
static void* top_pointer;
106-
static const s32 cloth_counter;
132+
private:
133+
dClothVobj03_c(ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr)
134+
: dCloth_packet_c(i_toonimage, 5, 5, 120.0f, 60.0f, tevstr, posArr) {
135+
if (posArr) {
136+
mIsStandItem = true;
137+
} else {
138+
mIsStandItem = false;
139+
}
140+
}
141+
142+
private:
143+
static dClothVobj03_c* top_pointer;
144+
static s32 cloth_counter;
145+
146+
friend dClothVobj03_c* dClothVobj03_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
147+
148+
private:
149+
GXTlutObj mTlutObj;
150+
bool mIsStandItem;
151+
bool mIsIndoors;
107152
};
108-
dClothVobj03_c* dClothVobj03_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
153+
dClothVobj03_c* dClothVobj03_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr);
109154

110155
class dClothVobj04_c : public dCloth_packet_c {
111156
virtual void init();
112157
virtual void cloth_move();
113-
virtual void cloth_draw();
114158
virtual void TexObjInit(ResTIMG*);
115159
virtual void TexObjLoad();
116-
virtual void TevSetting();
117160
void cloth_copy();
118161

119-
public:
120-
static void* top_pointer;
121-
static const s32 cloth_counter;
162+
private:
163+
dClothVobj04_c(ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr)
164+
: dCloth_packet_c(i_toonimage, 5, 5, 120.0f, 60.0f, tevstr, posArr) {
165+
if (posArr) {
166+
mIsStandItem = true;
167+
} else {
168+
mIsStandItem = false;
169+
}
170+
};
171+
172+
private:
173+
static dClothVobj04_c* top_pointer;
174+
static s32 cloth_counter;
175+
176+
friend dClothVobj04_c* dClothVobj04_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
177+
178+
private:
179+
GXTlutObj mTlutObj;
180+
bool mIsStandItem;
181+
bool mIsIndoors;
122182
};
123-
dClothVobj04_c* dClothVobj04_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
183+
dClothVobj04_c* dClothVobj04_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr);
124184

125185
class dClothVobj05_c : public dCloth_packet_c {
126186
virtual void init();
127187
virtual void cloth_move();
128-
virtual void cloth_draw();
129188
virtual void TexObjInit(ResTIMG*);
130189
virtual void TexObjLoad();
131-
virtual void TevSetting();
132190
void cloth_copy();
133191

134-
public:
135-
static void* top_pointer;
136-
static const s32 cloth_counter;
192+
private:
193+
dClothVobj05_c(ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr)
194+
: dCloth_packet_c(i_toonimage, 5, 5, 50.0f, 120.0f, tevstr, posArr) {
195+
if (posArr) {
196+
mIsStandItem = true;
197+
} else {
198+
mIsStandItem = false;
199+
}
200+
}
201+
202+
private:
203+
static dClothVobj05_c* top_pointer;
204+
static s32 cloth_counter;
205+
206+
friend dClothVobj05_c* dClothVobj05_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
207+
208+
private:
209+
GXTlutObj mTlutObj;
210+
bool mIsStandItem;
211+
bool mIsIndoors;
137212
};
138-
dClothVobj05_c* dClothVobj05_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
213+
dClothVobj05_c* dClothVobj05_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr);
139214

140215
class dClothVobj07_0_c : public dCloth_packet_c {
141216
virtual void init();
142217
virtual void cloth_move();
143-
virtual void cloth_draw();
144218
virtual void TexObjInit(ResTIMG*);
145219
virtual void TexObjLoad();
146-
virtual void TevSetting();
147220
void cloth_copy();
148221

149-
public:
150-
static void* top_pointer;
151-
static const s32 cloth_counter;
222+
private:
223+
dClothVobj07_0_c(ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr)
224+
: dCloth_packet_c(i_toonimage, 5, 5, 120.0f, 70.0f, tevstr, posArr) {
225+
if (posArr) {
226+
mIsStandItem = true;
227+
} else {
228+
mIsStandItem = false;
229+
}
230+
}
231+
232+
private:
233+
static dClothVobj07_0_c* top_pointer;
234+
static s32 cloth_counter;
235+
236+
friend dClothVobj07_0_c* dClothVobj07_0_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
237+
238+
private:
239+
GXTlutObj mTlutObj;
240+
bool mIsStandItem;
241+
bool mIsIndoors;
152242
};
153-
dClothVobj07_0_c* dClothVobj07_0_create(ResTIMG*, ResTIMG*, dKy_tevstr_c*, cXyz**);
243+
dClothVobj07_0_c* dClothVobj07_0_create(ResTIMG* i_flagimage, ResTIMG* i_toonimage, dKy_tevstr_c* tevstr, cXyz** posArr);
154244

155245
#endif /* D_A_CLOTH_PACKET_H */

0 commit comments

Comments
 (0)