g3d source (#123)

* g3d_calcvtx

GetData seems to have changed -> dwarf says r is a local and using ofs_to_ptr didnt work

* g3d_light and g3d_fog

sdata2 splits and func ordering

* g3d_scnproc

* g3d_init

* g3d_scnmdl

* g3d_scnmdlsmpl

* g3d_scnroot

* g3d_scnobj

* g3d_res* progress

* g3d_resmdl OK

* g3d_restev OK

* g3d_resmat OK

* g3d_resvtx and g3d_restex OK

* g3d_resnode OK

* g3d_resanm OK

* g3d_resanmchr Progress

* the rest of g3d_res* OK

* g3d_anmvis OK

* g3d_anmclr OK

* Some Splitting

* more OK, Inline Issue in g3d_anmtexsrt

* g3d_obj, g3d_anmobj, g3d_gpu, g3d_tmem, g3d_cpu OK

* g3d_state OK

* g3d/dcc OK

* Include fixup

* More Fixups

* g3d_camera OK

* g3d_draw OK

* g3d_calcworld OK

* g3d_calcworld actually OK

* g3d_workmem, g3d_dcc OK

* g3d_calcview OK

* g3d_anmtexsrt OK with DONT_INLINE

* g3d_transform OK (Feels Cheaty)

* g3d_resanmchr OK

* g3d_draw1mat1shp Close

* g3d_draw1mat1shp OK (Thanks Lago!). Ran symbol applying script
This commit is contained in:
Elijah Thomas
2025-03-16 11:26:15 -04:00
committed by GitHub
parent fbc35aefd2
commit 9c3c480b24
140 changed files with 4887 additions and 3523 deletions
+4 -5
View File
@@ -24,8 +24,7 @@ AllowShortLoopsOnASingleLine: False
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: True
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: True
BinPackParameters: True
BinPackArguments: True
BitFieldColonSpacing: Both
BreakBeforeBraces: Custom
BraceWrapping:
@@ -93,15 +92,15 @@ IncludeCategories:
Priority: 0
CaseSensitive: true
- Regex: '<egg\/[[:lower:].]+h>' # EGG public headers
- Regex: '"egg\/[[:lower:].]+h"' # EGG public headers
Priority: 2
CaseSensitive: true
- Regex: '<nw4r\/[[:lower:].]+h>' # NW4R public headers
- Regex: '"nw4r\/[[:lower:].]+h"' # NW4R public headers
Priority: 3
CaseSensitive: true
- Regex: '^<rvl\/[[:upper:].]+h>' # RVL SDK public headers
- Regex: '^"rvl\/[[:upper:].]+h"' # RVL SDK public headers
Priority: 4
CaseSensitive: true
+3 -3
View File
@@ -14,9 +14,9 @@ fn_187_570 = .text:0x00000570; // type:function size:0x5C
fn_187_5D0 = .text:0x000005D0; // type:function size:0x70
getStateID__76sStateMgr_c<8dAcEsm_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000640; // type:function size:0x10
fn_187_650 = .text:0x00000650; // type:function size:0x164
fn_187_7C0 = .text:0x000007C0; // type:function size:0x714
actorCreate__8dAcEsm_cFv = .text:0x000007C0; // type:function size:0x714
changeState__76sStateMgr_c<8dAcEsm_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000EE0; // type:function size:0x10
fn_187_EF0 = .text:0x00000EF0; // type:function size:0x160
actorPostCreate__8dAcEsm_cFv = .text:0x00000EF0; // type:function size:0x160
fn_187_1050 = .text:0x00001050; // type:function size:0x34
fn_187_1090 = .text:0x00001090; // type:function size:0x1224
executeState__76sStateMgr_c<8dAcEsm_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000022C0; // type:function size:0x10
@@ -77,7 +77,7 @@ fn_187_5B00 = .text:0x00005B00; // type:function size:0xE8
fn_187_5BF0 = .text:0x00005BF0; // type:function size:0x1A0
fn_187_5D90 = .text:0x00005D90; // type:function size:0x1D8
fn_187_5F70 = .text:0x00005F70; // type:function size:0x1D8
fn_187_6150 = .text:0x00006150; // type:function size:0x60
fixBoundingBox__8dAcEsm_cFv = .text:0x00006150; // type:function size:0x60
fn_187_61B0 = .text:0x000061B0; // type:function size:0x958
fn_187_6B10 = .text:0x00006B10; // type:function size:0x10C
fn_187_6C20 = .text:0x00006C20; // type:function size:0xEC
@@ -14,7 +14,7 @@ fn_256_5E0 = .text:0x000005E0; // type:function size:0x4
__dt__13dAcOivyRope_cFv = .text:0x000005F0; // type:function size:0x1F4
AcOivyRope__initTightRope = .text:0x000007F0; // type:function size:0x54C
AcOivyRope__handleSubtype1update = .text:0x00000D40; // type:function size:0x37C
fn_256_10C0 = .text:0x000010C0; // type:function size:0xDC
fn_256_10C0__13dAcOivyRope_cFv = .text:0x000010C0; // type:function size:0xDC
fn_256_11A0 = .text:0x000011A0; // type:function size:0x94
fn_256_1240 = .text:0x00001240; // type:function size:0x23C
fn_256_1480 = .text:0x00001480; // type:function size:0xCD4
@@ -71,7 +71,7 @@ finalizeState_TerryRopePlayerCarry__13dAcOivyRope_cFv = .text:0x00006630; // typ
initializeState_TerryRopeWait__13dAcOivyRope_cFv = .text:0x00006640; // type:function size:0x74
executeState_TerryRopeWait__13dAcOivyRope_cFv = .text:0x000066C0; // type:function size:0x5C
finalizeState_TerryRopeWait__13dAcOivyRope_cFv = .text:0x00006720; // type:function size:0x4
AcOivyRope__initModels = .text:0x00006730; // type:function size:0x478
createHeap__13dAcOivyRope_cFv = .text:0x00006730; // type:function size:0x478
AcOivyRope__init = .text:0x00006BB0; // type:function size:0x748
fn_256_7300 = .text:0x00007300; // type:function size:0x8
fn_256_7310 = .text:0x00007310; // type:function size:0xB8
@@ -99,47 +99,47 @@ fn_256_9120 = .text:0x00009120; // type:function size:0x160
fn_256_9280 = .text:0x00009280; // type:function size:0x1D0
fn_256_9450 = .text:0x00009450; // type:function size:0x82C
fn_256_9C80 = .text:0x00009C80; // type:function size:0x3BC
fn_256_A040 = .text:0x0000A040; // type:function size:0x27C
fn_256_A2C0 = .text:0x0000A2C0; // type:function size:0x488
fn_256_A750 = .text:0x0000A750; // type:function size:0x2E4
fn_256_AA40 = .text:0x0000AA40; // type:function size:0x64
fn_256_AAB0 = .text:0x0000AAB0; // type:function size:0x38
fn_256_AAF0 = .text:0x0000AAF0; // type:function size:0xA8
fn_256_ABA0 = .text:0x0000ABA0; // type:function size:0x5C
fn_256_AC00 = .text:0x0000AC00; // type:function size:0x1FC
fn_256_AE00 = .text:0x0000AE00; // type:function size:0x4A8
fn_256_B2B0 = .text:0x0000B2B0; // type:function size:0x7F4
fn_256_BAB0 = .text:0x0000BAB0; // type:function size:0xB4
fn_256_BB70 = .text:0x0000BB70; // type:function size:0x304
fn_256_BE80 = .text:0x0000BE80; // type:function size:0x170
fn_256_BFF0 = .text:0x0000BFF0; // type:function size:0x204
fn_256_C200 = .text:0x0000C200; // type:function size:0x210
fn_256_C410 = .text:0x0000C410; // type:function size:0x2DC
fn_256_C6F0 = .text:0x0000C6F0; // type:function size:0x44
fn_256_C740 = .text:0x0000C740; // type:function size:0xD0
fn_256_C810 = .text:0x0000C810; // type:function size:0x144
fn_256_C960 = .text:0x0000C960; // type:function size:0x14
fn_256_C980 = .text:0x0000C980; // type:function size:0x30
fn_256_C9B0 = .text:0x0000C9B0; // type:function size:0x384
fn_256_CD40 = .text:0x0000CD40; // type:function size:0xDC
fn_256_CE20 = .text:0x0000CE20; // type:function size:0x17C
fn_256_CFA0 = .text:0x0000CFA0; // type:function size:0xAC
fn_256_D050 = .text:0x0000D050; // type:function size:0xB8
fn_256_D110 = .text:0x0000D110; // type:function size:0x94
fn_256_D1B0 = .text:0x0000D1B0; // type:function size:0xF8
fn_256_D2B0 = .text:0x0000D2B0; // type:function size:0x118
fn_256_D3D0 = .text:0x0000D3D0; // type:function size:0x35C
fn_256_D730 = .text:0x0000D730; // type:function size:0x70
fn_256_D7A0 = .text:0x0000D7A0; // type:function size:0xA4
fn_256_D850 = .text:0x0000D850; // type:function size:0x244
fn_256_DAA0 = .text:0x0000DAA0; // type:function size:0x3D8
fn_256_DE80 = .text:0x0000DE80; // type:function size:0x58
fn_256_DEE0 = .text:0x0000DEE0; // type:function size:0x4C
fn_256_DF30 = .text:0x0000DF30; // type:function size:0x4A4
fn_256_E3E0 = .text:0x0000E3E0; // type:function size:0x3A8
fn_256_E790 = .text:0x0000E790; // type:function size:0xB4
fn_256_E850 = .text:0x0000E850; // type:function size:0x68
fn_256_E8C0 = .text:0x0000E8C0; // type:function size:0x88
fn_256_A040__13dAcOivyRope_cFv = .text:0x0000A040; // type:function size:0x27C
fn_256_A2C0__13dAcOivyRope_cFb = .text:0x0000A2C0; // type:function size:0x488
fn_256_A750__13dAcOivyRope_cFbf = .text:0x0000A750; // type:function size:0x2E4
fn_256_AA40__13dAcOivyRope_cFv = .text:0x0000AA40; // type:function size:0x64
fn_256_AAB0__13dAcOivyRope_cFff = .text:0x0000AAB0; // type:function size:0x38
fn_256_AAF0__13dAcOivyRope_cFff = .text:0x0000AAF0; // type:function size:0xA8
fn_256_ABA0__13dAcOivyRope_cFv = .text:0x0000ABA0; // type:function size:0x5C
fn_256_AC00__13dAcOivyRope_cFv = .text:0x0000AC00; // type:function size:0x1FC
fn_256_AE00__13dAcOivyRope_cFv = .text:0x0000AE00; // type:function size:0x4A8
fn_256_B2B0__13dAcOivyRope_cFv = .text:0x0000B2B0; // type:function size:0x7F4
fn_256_BAB0__13dAcOivyRope_cFR7mVec3_ciss = .text:0x0000BAB0; // type:function size:0xB4
fn_256_BB70__13dAcOivyRope_cFv = .text:0x0000BB70; // type:function size:0x304
fn_256_BE80__13dAcOivyRope_cFv = .text:0x0000BE80; // type:function size:0x170
fn_256_BFF0__13dAcOivyRope_cFiff = .text:0x0000BFF0; // type:function size:0x204
fn_256_C200__13dAcOivyRope_cFi = .text:0x0000C200; // type:function size:0x210
fn_256_C410__13dAcOivyRope_cFv = .text:0x0000C410; // type:function size:0x2DC
fn_256_C6F0__13dAcOivyRope_cFv = .text:0x0000C6F0; // type:function size:0x44
fn_256_C740__13dAcOivyRope_cFv = .text:0x0000C740; // type:function size:0xD0
fn_256_C810__13dAcOivyRope_cFR7mVec3_ci = .text:0x0000C810; // type:function size:0x144
fn_256_C960__13dAcOivyRope_cFv = .text:0x0000C960; // type:function size:0x14
fn_256_C980__13dAcOivyRope_cFff = .text:0x0000C980; // type:function size:0x30
fn_256_C9B0__13dAcOivyRope_cFv = .text:0x0000C9B0; // type:function size:0x384
fn_256_CD40__13dAcOivyRope_cFv = .text:0x0000CD40; // type:function size:0xDC
fn_256_CE20__13dAcOivyRope_cFPfPfPf = .text:0x0000CE20; // type:function size:0x17C
fn_256_CFA0__13dAcOivyRope_cFb = .text:0x0000CFA0; // type:function size:0xAC
fn_256_D050__13dAcOivyRope_cFv = .text:0x0000D050; // type:function size:0xB8
fn_256_D110__13dAcOivyRope_cFv = .text:0x0000D110; // type:function size:0x94
fn_256_D1B0__13dAcOivyRope_cFv = .text:0x0000D1B0; // type:function size:0xF8
fn_256_D2B0__13dAcOivyRope_cFv = .text:0x0000D2B0; // type:function size:0x118
fn_256_D3D0__13dAcOivyRope_cFR7mVec3_cR7mVec3_csbf = .text:0x0000D3D0; // type:function size:0x35C
fn_256_D730__13dAcOivyRope_cFl = .text:0x0000D730; // type:function size:0x70
fn_256_D7A0__13dAcOivyRope_cFlRC7mVec3_c = .text:0x0000D7A0; // type:function size:0xA4
fn_256_D850__13dAcOivyRope_cFv = .text:0x0000D850; // type:function size:0x244
fn_256_DAA0__13dAcOivyRope_cFbbff = .text:0x0000DAA0; // type:function size:0x3D8
fn_256_DE80__13dAcOivyRope_cFv = .text:0x0000DE80; // type:function size:0x58
fn_256_DEE0__13dAcOivyRope_cFv = .text:0x0000DEE0; // type:function size:0x4C
fn_256_DF30__13dAcOivyRope_cFv = .text:0x0000DF30; // type:function size:0x4A4
fn_256_E3E0__13dAcOivyRope_cFv = .text:0x0000E3E0; // type:function size:0x3A8
fn_256_E790__13dAcOivyRope_cFv = .text:0x0000E790; // type:function size:0xB4
canBeLinkedToWoodTag__13dAcOivyRope_cFv = .text:0x0000E850; // type:function size:0x68
drop__13dAcOivyRope_cFv = .text:0x0000E8C0; // type:function size:0x88
build__29sFStateFct_c<13dAcOivyRope_c>FRC12sStateIDIf_c = .text:0x0000E950; // type:function size:0x60
dispose__29sFStateFct_c<13dAcOivyRope_c>FRP10sStateIf_c = .text:0x0000E9B0; // type:function size:0xC
initialize__26sFState_c<13dAcOivyRope_c>Fv = .text:0x0000E9C0; // type:function size:0x1C
+95 -2
View File
@@ -1460,169 +1460,262 @@ nw4r/g3d/res/g3d_resdict.cpp:
nw4r/g3d/res/g3d_resfile.cpp:
.text start:0x80439420 end:0x80439FC4
.data start:0x8056D020 end:0x8056D180
nw4r/g3d/res/g3d_resmdl.cpp:
.text start:0x80439FD0 end:0x8043B244
.sdata start:0x80574E30 end:0x80574E38
nw4r/g3d/res/g3d_resshp.cpp:
.text start:0x8043B250 end:0x8043BD48
nw4r/g3d/res/g3d_restev.cpp:
.text start:0x8043BD50 end:0x8043C2B8
.rodata start:0x804F6FF0 end:0x804F7050
.data start:0x8056D180 end:0x8056D190
nw4r/g3d/res/g3d_resmat.cpp:
.text start:0x8043C2C0 end:0x8043E17C
.data start:0x8056D190 end:0x8056D1E4
.sdata2 start:0x8057EC18 end:0x8057EC4C
nw4r/g3d/res/g3d_resvtx.cpp:
.text start:0x8043E180 end:0x8043E5B8
.text start:0x8043E180 end:0x8043E598
nw4r/g3d/res/g3d_restex.cpp:
.text start:0x8043E5C0 end:0x8043E74C
.text start:0x8043E5A0 end:0x8043E74C
nw4r/g3d/res/g3d_resnode.cpp:
.text start:0x8043E750 end:0x8043EA58
.sdata2 start:0x8057EC50 end:0x8057EC5C
nw4r/g3d/res/g3d_resanm.cpp:
.text start:0x8043EA60 end:0x8043ECB8
.sdata2 start:0x8057EC60 end:0x8057EC74
nw4r/g3d/res/g3d_resanmvis.cpp:
.text start:0x8043ECC0 end:0x8043EDE0
.sdata2 start:0x8057EC78 end:0x8057EC88
nw4r/g3d/res/g3d_resanmclr.cpp:
.text start:0x8043EDE0 end:0x8043EF4C
.sdata2 start:0x8057EC88 end:0x8057EC98
nw4r/g3d/res/g3d_resanmtexpat.cpp:
.text start:0x8043EF50 end:0x8043F320
nw4r/g3d/res/g3d_resanmtexsrt.cpp:
.text start:0x8043F320 end:0x8043F734
.sdata2 start:0x8057EC98 end:0x8057ECA0
nw4r/g3d/res/g3d_resanmchr.cpp:
.text start:0x8043F740 end:0x804419EC
.rodata start:0x804F7050 end:0x804F7070
.sdata2 start:0x8057ECA0 end:0x8057ECCC
nw4r/g3d/res/g3d_reslightset.cpp:
.text start:0x804419F0 end:0x80441B5C
nw4r/g3d/res/g3d_resanmamblight.cpp:
.text start:0x80441B60 end:0x80441C30
.sdata2 start:0x8057ECD0 end:0x8057ECE0
nw4r/g3d/res/g3d_resanmlight.cpp:
.text start:0x80441C30 end:0x80442018
.sdata2 start:0x8057ECE0 end:0x8057ECF0
nw4r/g3d/res/g3d_resanmcamera.cpp:
.text start:0x80442020 end:0x80442330
nw4r/g3d/res/g3d_resanmscn.cpp:
.text start:0x80442330 end:0x8044297C
.data start:0x8056D200 end:0x8056D280
nw4r/g3d/res/g3d_resanmshp.cpp:
.text start:0x80442980 end:0x80442AE8
.sdata2 start:0x8057ECF0 end:0x8057ECF4
nw4r/g3d/g3d_transform.cpp:
.text start:0x80442AF0 end:0x80442DF4
.sdata2 start:0x8057ECF8 end:0x8057ECFC
nw4r/g3d/g3d_anmvis.cpp:
.text start:0x80442E00 end:0x8044358C
.rodata start:0x804F7070 end:0x804F7094
.data start:0x8056D280 end:0x8056D308
.sdata start:0x80574E38 end:0x80574E40
.sdata2 start:0x8057ED00 end:0x8057ED10
nw4r/g3d/g3d_anmclr.cpp:
.text start:0x80443590 end:0x80444D5C
.rodata start:0x804F7098 end:0x804F7100
.data start:0x8056D308 end:0x8056D428
.sdata2 start:0x8057ED10 end:0x8057ED20
nw4r/g3d/g3d_anmtexpat.cpp:
.text start:0x80444D60 end:0x8044635C
.rodata start:0x804F7100 end:0x804F7168
.data start:0x8056D428 end:0x8056D548
.sdata2 start:0x8057ED20 end:0x8057ED30
nw4r/g3d/g3d_anmtexsrt.cpp:
.text start:0x80446360 end:0x804479AC
.rodata start:0x804F7168 end:0x804F71D0
.data start:0x8056D548 end:0x8056D668
.sdata2 start:0x8057ED30 end:0x8057ED50
nw4r/g3d/g3d_anmchr.cpp:
.text start:0x804479B0 end:0x804499CC
.rodata start:0x804F71D0 end:0x804F721C
.data start:0x8056D668 end:0x8056D7C8
.sdata2 start:0x8057ED50 end:0x8057ED68
nw4r/g3d/g3d_anmshp.cpp:
.text start:0x804499D0 end:0x8044A3BC
.rodata start:0x804F7220 end:0x804F7244
.data start:0x8056D7C8 end:0x8056D868
.sdata2 start:0x8057ED68 end:0x8057ED78
nw4r/g3d/g3d_anmscn.cpp:
.text start:0x8044A3C0 end:0x8044A6E8
nw4r/g3d/g3d_obj.cpp:
.text start:0x8044A6F0 end:0x8044A85C
.rodata start:0x804F7248 end:0x804F7254
.data start:0x8056D868 end:0x8056D884
nw4r/g3d/g3d_anmobj.cpp:
.text start:0x8044A860 end:0x8044A928
.rodata start:0x804F7258 end:0x804F7264
.sdata start:0x80574E40 end:0x80574E44
.sdata2 start:0x8057ED78 end:0x8057ED7C
nw4r/g3d/platform/g3d_gpu.cpp:
.text start:0x8044A930 end:0x8044AE50
.sdata2 start:0x8057ED80 end:0x8057ED98
nw4r/g3d/platform/g3d_tmem.cpp:
.text start:0x8044AE50 end:0x8044B1B0
.rodata start:0x804F7268 end:0x804F79E8
.sbss start:0x80576618 end:0x80576628
.bss start:0x8063B560 end:0x8063B9A0
nw4r/g3d/platform/g3d_cpu.cpp:
.text start:0x8044B1B0 end:0x8044B35C
.sdata2 start:0x8057ED98 end:0x8057ED9C
nw4r/g3d/g3d_state.cpp:
.text start:0x8044B360 end:0x8044EAB0
.ctors start:0x804DB954 end:0x804DB958
.rodata start:0x804F79E8 end:0x804F7A18
.data start:0x8056D888 end:0x8056D8A0
.sdata start:0x80574E48 end:0x80574E50
.sbss start:0x80576628 end:0x80576648
.sdata2 start:0x8057EDA0 end:0x8057EDC8
.bss start:0x8063B9A0 end:0x80640F44
nw4r/g3d/g3d_draw1mat1shp.cpp:
.text start:0x8044EAB0 end:0x8044F7F4
.rodata start:0x804F7A18 end:0x804F7A28
.sdata2 start:0x8057EDC8 end:0x8057EDE8
nw4r/g3d/g3d_calcview.cpp:
.text start:0x8044F800 end:0x80451A9C
.rodata start:0x804F7A28 end:0x804F7A44
.sdata2 start:0x8057EDE8 end:0x8057EDF4
nw4r/g3d/g3d_dcc.cpp:
.text start:0x80451AA0 end:0x80451B84
nw4r/g3d/g3d_workmem.cpp:
.text start:0x80451B90 end:0x80451BDC
.bss start:0x80640F80 end:0x80658F80
nw4r/g3d/g3d_calcworld.cpp:
.text start:0x80451BE0 end:0x8045274C
.data start:0x8056D8A0 end:0x8056D8A9
.sdata start:0x80574E50 end:0x80574E58
.sdata2 start:0x8057EDF8 end:0x8057EE00
nw4r/g3d/g3d_draw.cpp:
.text start:0x80452750 end:0x804545F0
.sdata start:0x80574E58 end:0x80574E60
.sdata2 start:0x8057EE00 end:0x8057EE0C
nw4r/g3d/g3d_camera.cpp:
.text start:0x804545F0 end:0x804556AC
.sdata2 start:0x8057EE10 end:0x8057EE48
nw4r/g3d/dcc/g3d_basic.cpp:
.text start:0x804556B0 end:0x80455978
.sdata2 start:0x8057EE48 end:0x8057EE54
nw4r/g3d/dcc/g3d_maya.cpp:
.text start:0x80455980 end:0x80456684
.rodata start:0x804F7A48 end:0x804F7A80
.sdata2 start:0x8057EE58 end:0x8057EE6C
nw4r/g3d/dcc/g3d_xsi.cpp:
.text start:0x80456690 end:0x804572A4
.rodata start:0x804F7A80 end:0x804F7AB8
.sdata2 start:0x8057EE70 end:0x8057EE7C
nw4r/g3d/dcc/g3d_3dsmax.cpp:
.text start:0x804572B0 end:0x80457DCC
.rodata start:0x804F7AB8 end:0x804F7AF0
.sdata2 start:0x8057EE80 end:0x8057EE94
nw4r/g3d/g3d_scnobj.cpp:
.text start:0x80457DD0 end:0x8045980C
.rodata start:0x804F7AF0 end:0x804F7B20
.data start:0x8056D8B0 end:0x8056D9A8
.sbss start:0x80576648 end:0x8057664C
.sdata2 start:0x8057EE98 end:0x8057EEA0
nw4r/g3d/g3d_scnroot.cpp:
.text start:0x80459810 end:0x8045B1BC
.rodata start:0x804F7B20 end:0x804F7B30
.data start:0x8056D9A8 end:0x8056DA18
.sdata start:0x80574E60 end:0x80574E70
.sdata2 start:0x8057EEA0 end:0x8057EEA4
nw4r/g3d/g3d_scnmdlsmpl.cpp:
.text start:0x8045B1C0 end:0x8045D25C
.rodata start:0x804F7B30 end:0x804F7B48
.data start:0x8056DA18 end:0x8056DA70
.sdata start:0x80574E70 end:0x80574E88
.sdata2 start:0x8057EEA8 end:0x8057EEAC
nw4r/g3d/g3d_scnmdl.cpp:
.text start:0x8045D260 end:0x8045FDAC
.rodata start:0x804F7B48 end:0x804F7B58
.data start:0x8056DA70 end:0x8056DAB8
nw4r/g3d/g3d_calcmaterial.cpp:
.text start:0x8045FDB0 end:0x8045FFE4
nw4r/g3d/g3d_init.cpp:
.text start:0x8045FFF0 end:0x804600E8
.data start:0x8056DAB8 end:0x8056DAFE
.sdata start:0x80574E88 end:0x80574E8C
nw4r/g3d/g3d_scnproc.cpp:
.text start:0x804600F0 end:0x804603F0
.rodata start:0x804F7B70 end:0x804F7B80
.data start:0x8056DB00 end:0x8056DB34
.sdata2 start:0x8057EEB0 end:0x8057EEB4
nw4r/g3d/g3d_fog.cpp:
.text start:0x804603F0 end:0x80460560
.sdata2 start:0x8057EEB8 end:0x8057EEBC
nw4r/g3d/g3d_light.cpp:
.text start:0x80460560 end:0x80460F68
.sdata2 start:0x8057EEC0 end:0x8057EEEC
nw4r/g3d/g3d_calcvtx.cpp:
.text start:0x80460F70 end:0x804616F8
.sdata2 start:0x8057EEF0 end:0x8057EEF4
nw4r/snd/snd_AnimSound.cpp:
.text start:0x80461700 end:0x804630D4
+334 -333
View File
File diff suppressed because it is too large Load Diff
+66 -62
View File
@@ -645,68 +645,72 @@ config.libs = [
nw4rLib(
"g3d",
[
Object(NonMatching, "nw4r/g3d/res/g3d_rescommon.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resdict.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resfile.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resmdl.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resshp.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_restev.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resmat.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resvtx.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_restex.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resnode.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanm.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmvis.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmclr.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmtexpat.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmtexsrt.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmchr.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_reslightset.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmamblight.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmlight.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmfog.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmcamera.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmscn.cpp"),
Object(NonMatching, "nw4r/g3d/res/g3d_resanmshp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_transform.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmvis.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmclr.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmtexpat.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmtexsrt.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmchr.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmshp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmscn.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_obj.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_anmobj.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_gpu.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_tmem.cpp"),
Object(NonMatching, "nw4r/g3d/platform/g3d_cpu.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_state.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_draw1mat1shp.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcview.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_dcc.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_workmem.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcworld.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_draw.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_camera.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_basic.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_maya.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_xsi.cpp"),
Object(NonMatching, "nw4r/g3d/dcc/g3d_3dsmax.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnobj.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnroot.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdlsmpl.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdl.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnchoice.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scngroupex.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdl1mat1shp.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_scnmdlexpand.cpp: .tex"),
Object(NonMatching, "nw4r/g3d/g3d_calcmaterial.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_init.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_scnproc.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_fog.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_light.cpp"),
Object(NonMatching, "nw4r/g3d/g3d_calcvtx.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_rescommon.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resdict.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resfile.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resmdl.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resshp.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_restev.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resmat.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resvtx.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_restex.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resnode.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanm.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmvis.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmclr.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmtexpat.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmtexsrt.cpp"),
Object(
Matching,
"nw4r/g3d/res/g3d_resanmchr.cpp",
extra_cflags=["-opt level=3"],
),
Object(Matching, "nw4r/g3d/res/g3d_reslightset.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmamblight.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmlight.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmfog.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmcamera.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmscn.cpp"),
Object(Matching, "nw4r/g3d/res/g3d_resanmshp.cpp"),
Object(Matching, "nw4r/g3d/g3d_transform.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmvis.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmclr.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmtexpat.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmtexsrt.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmchr.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmshp.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmscn.cpp"),
Object(Matching, "nw4r/g3d/g3d_obj.cpp"),
Object(Matching, "nw4r/g3d/g3d_anmobj.cpp"),
Object(Matching, "nw4r/g3d/platform/g3d_gpu.cpp"),
Object(Matching, "nw4r/g3d/platform/g3d_tmem.cpp"),
Object(Matching, "nw4r/g3d/platform/g3d_cpu.cpp"),
Object(Matching, "nw4r/g3d/g3d_state.cpp"),
Object(Matching, "nw4r/g3d/g3d_draw1mat1shp.cpp"),
Object(Matching, "nw4r/g3d/g3d_calcview.cpp"),
Object(Matching, "nw4r/g3d/g3d_dcc.cpp"),
Object(Matching, "nw4r/g3d/g3d_workmem.cpp"),
Object(Matching, "nw4r/g3d/g3d_calcworld.cpp"),
Object(Matching, "nw4r/g3d/g3d_draw.cpp"),
Object(Matching, "nw4r/g3d/g3d_camera.cpp"),
Object(Matching, "nw4r/g3d/dcc/g3d_basic.cpp"),
Object(Matching, "nw4r/g3d/dcc/g3d_maya.cpp"),
Object(Matching, "nw4r/g3d/dcc/g3d_xsi.cpp"),
Object(Matching, "nw4r/g3d/dcc/g3d_3dsmax.cpp"),
Object(Matching, "nw4r/g3d/g3d_scnobj.cpp"),
Object(Matching, "nw4r/g3d/g3d_scnroot.cpp"),
Object(Matching, "nw4r/g3d/g3d_scnmdlsmpl.cpp"),
Object(Matching, "nw4r/g3d/g3d_scnmdl.cpp"),
# Object(NonMatching, "nw4r/g3d/g3d_scnchoice.cpp"),
# Object(NonMatching, "nw4r/g3d/g3d_scngroupex.cpp"),
# Object(NonMatching, "nw4r/g3d/g3d_scnmdl1mat1shp.cpp"),
# Object(NonMatching, "nw4r/g3d/g3d_scnmdlexpand.cpp"),
Object(Matching, "nw4r/g3d/g3d_calcmaterial.cpp"),
Object(Matching, "nw4r/g3d/g3d_init.cpp"),
Object(Matching, "nw4r/g3d/g3d_scnproc.cpp"),
Object(Matching, "nw4r/g3d/g3d_fog.cpp"),
Object(Matching, "nw4r/g3d/g3d_light.cpp"),
Object(Matching, "nw4r/g3d/g3d_calcvtx.cpp"),
],
),
nw4rLib(
+7 -3
View File
@@ -6,11 +6,11 @@
#define CLAMP(low, high, x) ((x) > (high) ? (high) : ((x) < (low) ? (low) : (x)))
#define ROUND_UP(x, align) (((x) + (align)-1) & (-(align)))
#define ROUND_UP_PTR(x, align) ((void *)((((u32)(x)) + (align)-1) & (~((align)-1))))
#define ROUND_UP(x, align) (((x) + (align) - 1) & (-(align)))
#define ROUND_UP_PTR(x, align) ((void *)((((u32)(x)) + (align) - 1) & (~((align) - 1))))
#define ROUND_DOWN(x, align) ((x) & (-(align)))
#define ROUND_DOWN_PTR(x, align) ((void *)(((u32)(x)) & (~((align)-1))))
#define ROUND_DOWN_PTR(x, align) ((void *)(((u32)(x)) & (~((align) - 1))))
#define ARRAY_LENGTH(x) (sizeof((x)) / sizeof((x)[0]))
@@ -44,6 +44,8 @@
#define DECOMP_FORCEACTIVE(module, ...)
#define DECOMP_FORCELITERAL(module, x)
#define DECOMP_FORCEDTOR(module, cls)
#define DECOMP_INLINE
#define DECOMP_DONT_INLINE
#else
// Force reference specific data
#define __CONCAT(x, y) x##y
@@ -69,6 +71,8 @@
cls dummy; \
dummy.~cls(); \
}
#define DECOMP_INLINE inline
#define DECOMP_DONT_INLINE __attribute__((never_inline))
#endif
#include "stddef.h"
+66 -62
View File
@@ -1,40 +1,42 @@
#ifndef NW4R_PUBLIC_G3D_H
#define NW4R_PUBLIC_G3D_H
#include <nw4r/g3d/g3d_3dsmax.h>
#include <nw4r/g3d/g3d_anmchr.h>
#include <nw4r/g3d/g3d_anmclr.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/g3d_anmscn.h>
#include <nw4r/g3d/g3d_anmshp.h>
#include <nw4r/g3d/g3d_anmtexpat.h>
#include <nw4r/g3d/g3d_anmtexsrt.h>
#include <nw4r/g3d/g3d_anmvis.h>
#include <nw4r/g3d/g3d_basic.h>
#include <nw4r/g3d/g3d_calcmaterial.h>
#include <nw4r/g3d/g3d_calcview.h>
#include <nw4r/g3d/g3d_calcvtx.h>
#include <nw4r/g3d/g3d_calcworld.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_dcc.h>
#include <nw4r/g3d/g3d_draw.h>
#include <nw4r/g3d/g3d_draw1mat1shp.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_init.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_maya.h>
#include <nw4r/g3d/g3d_obj.h>
#include <nw4r/g3d/g3d_rtti.h>
#include <nw4r/g3d/g3d_scnmdl.h>
#include <nw4r/g3d/g3d_scnmdl1mat1shp.h>
#include <nw4r/g3d/g3d_scnmdlsmpl.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/g3d_scnproc.h>
#include <nw4r/g3d/g3d_scnrfl.h>
#include <nw4r/g3d/g3d_scnroot.h>
#include <nw4r/g3d/g3d_state.h>
#include <nw4r/g3d/g3d_workmem.h>
#include <nw4r/g3d/g3d_xsi.h>
// IWYU pragma: begin_keep
#include "nw4r/g3d/g3d_3dsmax.h"
#include "nw4r/g3d/g3d_anmchr.h"
#include "nw4r/g3d/g3d_anmclr.h"
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_anmscn.h"
#include "nw4r/g3d/g3d_anmshp.h"
#include "nw4r/g3d/g3d_anmtexpat.h"
#include "nw4r/g3d/g3d_anmtexsrt.h"
#include "nw4r/g3d/g3d_anmvis.h"
#include "nw4r/g3d/g3d_basic.h"
#include "nw4r/g3d/g3d_calcmaterial.h"
#include "nw4r/g3d/g3d_calcview.h"
#include "nw4r/g3d/g3d_calcvtx.h"
#include "nw4r/g3d/g3d_calcworld.h"
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_dcc.h"
#include "nw4r/g3d/g3d_draw.h"
#include "nw4r/g3d/g3d_draw1mat1shp.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/g3d_init.h"
#include "nw4r/g3d/g3d_light.h"
#include "nw4r/g3d/g3d_maya.h"
#include "nw4r/g3d/g3d_obj.h"
#include "nw4r/g3d/g3d_rtti.h"
#include "nw4r/g3d/g3d_scnmdl.h"
#include "nw4r/g3d/g3d_scnmdl1mat1shp.h"
#include "nw4r/g3d/g3d_scnmdlsmpl.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/g3d_scnproc.h"
#include "nw4r/g3d/g3d_scnrfl.h"
#include "nw4r/g3d/g3d_scnroot.h"
#include "nw4r/g3d/g3d_state.h"
#include "nw4r/g3d/g3d_transform.h"
#include "nw4r/g3d/g3d_workmem.h"
#include "nw4r/g3d/g3d_xsi.h"
/******************************************************************************
*
@@ -42,30 +44,31 @@
*
******************************************************************************/
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_resanmamblight.h>
#include <nw4r/g3d/res/g3d_resanmcamera.h>
#include <nw4r/g3d/res/g3d_resanmchr.h>
#include <nw4r/g3d/res/g3d_resanmclr.h>
#include <nw4r/g3d/res/g3d_resanmfog.h>
#include <nw4r/g3d/res/g3d_resanmlight.h>
#include <nw4r/g3d/res/g3d_resanmscn.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include <nw4r/g3d/res/g3d_resanmtexpat.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resanmvis.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include <nw4r/g3d/res/g3d_resfile.h>
#include <nw4r/g3d/res/g3d_reslightset.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include <nw4r/g3d/res/g3d_respltt.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include <nw4r/g3d/res/g3d_restev.h>
#include <nw4r/g3d/res/g3d_restex.h>
#include <nw4r/g3d/res/g3d_resvtx.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_resanmamblight.h"
#include "nw4r/g3d/res/g3d_resanmcamera.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"
#include "nw4r/g3d/res/g3d_resanmclr.h"
#include "nw4r/g3d/res/g3d_resanmfog.h"
#include "nw4r/g3d/res/g3d_resanmlight.h"
#include "nw4r/g3d/res/g3d_resanmscn.h"
#include "nw4r/g3d/res/g3d_resanmshp.h"
#include "nw4r/g3d/res/g3d_resanmtexpat.h"
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_resanmvis.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_reslightset.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resnode.h"
#include "nw4r/g3d/res/g3d_respltt.h"
#include "nw4r/g3d/res/g3d_resshp.h"
#include "nw4r/g3d/res/g3d_restev.h"
#include "nw4r/g3d/res/g3d_restex.h"
#include "nw4r/g3d/res/g3d_resuser.h"
#include "nw4r/g3d/res/g3d_resvtx.h"
/******************************************************************************
*
@@ -73,9 +76,10 @@
*
******************************************************************************/
#include <nw4r/g3d/platform/g3d_allocator.h>
#include <nw4r/g3d/platform/g3d_cpu.h>
#include <nw4r/g3d/platform/g3d_gpu.h>
#include <nw4r/g3d/platform/g3d_tmem.h>
#include "nw4r/g3d/platform/g3d_allocator.h"
#include "nw4r/g3d/platform/g3d_cpu.h"
#include "nw4r/g3d/platform/g3d_gpu.h"
#include "nw4r/g3d/platform/g3d_tmem.h"
// IWYU pragma: end_keep
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_3DSMAX_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANMCAMERA_H
#include "common.h"
#include "rvl/GX.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+2 -2
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANM_CHR_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmchr.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmchr.h"
namespace nw4r {
namespace g3d {
+3 -3
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_ANM_CLR_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmclr.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmclr.h"
#include "nw4r/g3d/res/g3d_resmat.h"
namespace nw4r {
namespace g3d {
+1
View File
@@ -2,6 +2,7 @@
#define NW4R_G3D_ANMFOG_H
#include "common.h"
#include "nw4r/ut/ut_Color.h"
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
+2 -2
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANM_OBJ_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_obj.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include "nw4r/g3d/g3d_obj.h"
#include "nw4r/g3d/res/g3d_resanm.h"
namespace nw4r {
namespace g3d {
+5 -5
View File
@@ -2,11 +2,11 @@
#define NW4R_G3D_ANM_SCN_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_obj.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/g3d_light.h"
#include "nw4r/g3d/g3d_obj.h"
namespace nw4r {
namespace g3d {
+2 -2
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANM_SHP_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmshp.h"
namespace nw4r {
namespace g3d {
+2 -2
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANM_TEX_PAT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmtexpat.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmtexpat.h"
namespace nw4r {
namespace g3d {
+4 -4
View File
@@ -2,15 +2,15 @@
#define NW4R_G3D_ANM_TEX_SRT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_resmat.h"
namespace nw4r {
namespace g3d {
void ApplyTexSrtAnmResult(ResTexSrt srt, const TexSrtAnmResult *pResult);
void ApplyTexSrtAnmResult(ResTexSrt srt, ResMatIndMtxAndScale ind, const TexSrtAnmResult *pResult);
void ApplyTexSrtAnmResult(ResTexSrt srt, const TexSrtAnmResult *pResult) DECOMP_DONT_INLINE;
/******************************************************************************
*
+2 -2
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_ANM_VIS_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_anmobj.h>
#include <nw4r/g3d/res/g3d_resanmvis.h>
#include "nw4r/g3d/g3d_anmobj.h"
#include "nw4r/g3d/res/g3d_resanmvis.h"
namespace nw4r {
namespace g3d {
+5 -1
View File
@@ -2,7 +2,9 @@
#define NW4R_G3D_BASIC_H
#include <nw4r/types_nw4r.h>
#include <nw4r/math.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -13,6 +15,8 @@ struct ChrAnmResult;
namespace detail {
namespace dcc {
bool CalcTexMtx_Basic(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag);
u32 CalcWorldMtx_Basic(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_CALC_MATERIAL_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include "nw4r/g3d/res/g3d_resmdl.h"
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_CALC_VIEW_H
#include <nw4r/types_nw4r.h>
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_CALC_VTX_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include "nw4r/g3d/res/g3d_resmdl.h"
namespace nw4r {
namespace g3d {
+5 -5
View File
@@ -2,10 +2,10 @@
#define NW4R_G3D_CALC_WORLD_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -40,7 +40,7 @@ void CalcSkinning(math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const
******************************************************************************/
class ICalcWorldCallback {
public:
virtual ~ICalcWorldCallback(){}; // at 0x8
virtual ~ICalcWorldCallback() {}; // at 0x8
virtual void ExecCallbackA(ChrAnmResult *pResult, ResMdl mdl,
FuncObjCalcWorld *pFuncObj) = 0; // at 0xC
@@ -61,7 +61,7 @@ class WorldMtxManip {
public:
WorldMtxManip(math::MTX34 *pM, math::VEC3 *pS, u32 *pWMAttr) : mpM(pM), mpS(pS), mpWMAttr(pWMAttr) {}
void SetScale(f32, f32, f32);
void SetScale(f32 x, f32 y, f32 z);
void GetMtx(nw4r::math::MTX34 *out) {
if (out != nullptr) {
PSMTXCopy(*mpM, *out);
+6 -3
View File
@@ -2,11 +2,11 @@
#define NW4R_G3D_CAMERA_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/MTX.h>
#include "rvl/MTX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -89,6 +89,7 @@ public:
void SetPerspective(f32 fovy, f32 aspect, f32 near, f32 far);
void SetOrtho(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
void SetProjectionMtxDirectly(const math::MTX44 *pMtx);
void SetTexMtxParam(f32 lightScaleS, f32 lightScaleT, f32 lightTransS, f32 lightTransT);
void SetScissor(u32 x, u32 y, u32 width, u32 height);
void SetScissorBoxOffset(s32 ox, s32 oy);
@@ -97,6 +98,8 @@ public:
void SetViewportZRange(f32 near, f32 far);
void GetViewport(f32 *pX, f32 *pY, f32 *pWidth, f32 *pHeight, f32 *pNear, f32 *pFar) const;
void Project(math::VEC3 *pSrcPos, const math::VEC3 &worldPos) const;
void GetCameraMtx(math::MTX34 *pMtx) const;
void GetProjectionMtx(math::MTX44 *pMtx) const;
void GetProjectionTexMtx(math::MTX34 *pMtx) const;
+4 -3
View File
@@ -2,13 +2,14 @@
#define NW4R_G3D_DCC_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_resnode.h"
namespace nw4r {
namespace g3d {
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag, TexSrtTypedef::TexMatrixMode mode);
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag);
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag, TexSrt::TexMatrixMode mode);
namespace detail {
+21 -20
View File
@@ -2,12 +2,12 @@
#define NW4R_G3D_DRAW_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resnode.h"
#include "nw4r/g3d/res/g3d_resshp.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -24,21 +24,22 @@ G3DState::IndMtxOp *GetIndMtxOp(ResMat mat, ResNode node, ResShp shp);
} // namespace detail
struct DrawResMdlReplacement {
u8 *visArray; // at 0x0
ResTexObjData *texObjDataArray; // at 0x4
ResTlutObjData *tlutObjDataArray; // at 0x8
ResTexSrtData *texSrtDataArray; // at 0xC
ResChanData *chanDataArray; // at 0x10
ResGenModeData *genModeDataArray; // at 0x14
ResMatMiscData *matMiscDataArray; // at 0x18
ResPixDL *pixDLArray; // at 0x1C
ResTevColorDL *tevColorDLArray; // at 0x20
ResIndMtxAndScaleDL *indMtxAndScaleDLArray; // at 0x24
ResTexCoordGenDL *texCoordGenDLArray; // at 0x28
ResTevData *tevDataArray; // at 0x2C
ResVtxPosData **vtxPosTable; // at 0x30
ResVtxNrmData **vtxNrmTable; // at 0x34
ResVtxClrData **vtxClrTable; // at 0x38
u32 flag; // at 0x0
u8 *visArray; // at 0x4
ResTexObjData *texObjDataArray; // at 0x8
ResTlutObjData *tlutObjDataArray; // at 0xC
ResTexSrtData *texSrtDataArray; // at 0x10
ResChanData *chanDataArray; // at 0x14
ResGenModeData *genModeDataArray; // at 0x18
ResMatMiscData *matMiscDataArray; // at 0x1C
ResPixDL *pixDLArray; // at 0x20
ResTevColorDL *tevColorDLArray; // at 0x24
ResIndMtxAndScaleDL *indMtxAndScaleDLArray; // at 0x28
ResTexCoordGenDL *texCoordGenDLArray; // at 0x2C
ResTevData *tevDataArray; // at 0x30
ResVtxPosData **vtxPosTable; // at 0x34
ResVtxNrmData **vtxNrmTable; // at 0x38
ResVtxClrData **vtxClrTable; // at 0x3C
};
void DrawResMdlDirectly(
+4 -3
View File
@@ -2,10 +2,10 @@
#define NW4R_G3D_DRAW_1MAT_1SHP_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resshp.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -20,6 +20,7 @@ enum Draw1Mat1ShpCtrl {
DRAW1MAT1SHP_CTRL_NOSWAPSHP = (1 << 1),
DRAW1MAT1SHP_CTRL_CULL_FRONT = (1 << 2),
DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF = (1 << 3),
DRAW1MAT1SHP_CTRL_IGNORE_MAT = (1 << 4),
};
struct Draw1Mat1ShpSwap {
+4 -4
View File
@@ -2,12 +2,12 @@
#define NW4R_G3D_FOG_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include <nw4r/ut.h>
#include "nw4r/math.h" // IWYU pragma: export
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_INIT_H
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
#include "rvl/OS.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+3 -3
View File
@@ -2,10 +2,10 @@
#define NW4R_G3D_LIGHT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_state.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/g3d_state.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_MAYA_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
namespace nw4r {
namespace g3d {
+3 -3
View File
@@ -2,8 +2,8 @@
#define NW4R_G3D_OBJ_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_rtti.h>
#include <nw4r/g3d/platform/g3d_allocator.h>
#include "nw4r/g3d/g3d_rtti.h"
#include "nw4r/g3d/platform/g3d_allocator.h"
namespace nw4r {
namespace g3d {
@@ -114,7 +114,7 @@ public:
}
void Destroy();
void DetachFromParent();
G3dObj *DetachFromParent();
static void *Alloc(MEMAllocator *pAllocator, u32 size) {
return detail::AllocFromAllocator(pAllocator, size);
+45 -4
View File
@@ -3,9 +3,9 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_draw.h>
#include <nw4r/g3d/g3d_scnmdlsmpl.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include "nw4r/g3d/g3d_draw.h"
#include "nw4r/g3d/g3d_scnmdlsmpl.h"
#include "nw4r/g3d/res/g3d_resmat.h"
namespace nw4r {
namespace g3d {
@@ -23,11 +23,14 @@ public:
ResTexSrt GetResTexSrt(bool markDirty);
ResMatChan GetResMatChan(bool markDirty);
ResGenMode GetResGenMode(bool markDirty);
ResMatMisc GetResMatMisc(bool markDirty);
ResMatPix GetResMatPix(bool markDirty);
ResMatTevColor GetResMatTevColor(bool markDirty);
ResTev GetResTev(bool markDirty);
ResTexObj GetResTexObjEx();
ResTexSrt GetResTexSrtEx();
ResMatChan GetResMatChanEx();
private:
ScnMdl *mpScnMdl; // at 0x0
@@ -59,6 +62,41 @@ public:
u8 *mpVis; // at 0x8
};
class CopiedVtxAccess {
public:
ResVtxPos GetResVtxPos(u32 id);
ResVtxNrm GetResVtxNrm(u32 id);
ResVtxClr GetResVtxClr(u32 id);
ResVtxPos GetResVtxPosEx(u32 id);
ResVtxNrm GetResVtxNrmEx(u32 id);
ResVtxClr GetResVtxClrEx(u32 id);
// Needed an Inline
ResVtxPos GetPos(u32 id) {
if (mpScnMdl != NULL) {
if (id < mpScnMdl->GetResMdl().GetResVtxPosNumEntries()) {
return ResVtxPos(mpScnMdl->mReplacement.vtxPosTable[id]);
}
}
return ResVtxPos(NULL);
}
// Needed an Inline
ResVtxNrm GetNrm(u32 id) {
if (mpScnMdl != NULL) {
if (id < mpScnMdl->GetResMdl().GetResVtxNrmNumEntries()) {
return ResVtxNrm(mpScnMdl->mReplacement.vtxNrmTable[id]);
}
}
return ResVtxNrm(NULL);
}
private:
// Idk
ScnMdl *mpScnMdl; // at 0x0
};
#define OPT(KEY, VALUE) OPTION_##KEY = (0x30000 | (VALUE))
enum ScnMdlOption {
OPT(NONE, 0),
@@ -72,7 +110,7 @@ public:
ScnMdl(
MEMAllocator *pAllocator, ResMdl mdl, math::MTX34 *pWorldMtxArray, u32 *pWorldMtxAttribArray,
math::MTX34 *pViewPosMtxArray, math::MTX33 *pViewNrmMtxArray, math::MTX34 *pViewTexMtxArray, int numView,
int numViewMtx, DrawResMdlReplacement *pReplacement, u32 *pMatBufferDirtyFlag
int numViewMtx, DrawResMdlReplacement *pReplacement, u32 *pMatBufferDirtyFlag, u32 replacementFlag
);
virtual void G3dProc(u32 task, u32 param, void *pInfo); // at 0xC
@@ -128,6 +166,8 @@ private:
BUFOPTION_VTXPOS = (1 << 12),
BUFOPTION_VTXNRM = (1 << 13),
BUFOPTION_VTXCLR = (1 << 14),
BUFOPTION_0x1000000 = (1 << 24),
};
private:
@@ -153,6 +193,7 @@ private:
u32 mFlagVisBuffer; // at 0x13C
u32 *mpMatBufferDirtyFlag; // at 0x140
DrawResMdlReplacement mReplacement; // at 0x144
u32 mReplacementFlag; // at 0x184
NW4R_G3D_RTTI_DECL_DERIVED(ScnMdl, ScnMdlSimple);
};
+3 -3
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_SCN_MDL_1MAT_1SHP_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resshp.h"
namespace nw4r {
namespace g3d {
+4 -4
View File
@@ -2,11 +2,11 @@
#define NW4R_G3D_SCN_MDL_SMPL_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_calcview.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include "nw4r/g3d/g3d_calcview.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+10 -3
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_SCN_OBJ_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_obj.h>
#include "nw4r/g3d/g3d_obj.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -109,6 +109,7 @@ public:
void CalcViewMtx(const math::MTX34 *pCamera);
bool SetMtx(ScnObjMtxType type, const math::MTX34 *pMtx);
bool SetMtx(ScnObjMtxType type, const math::MTX34 &rMtx);
bool GetMtx(ScnObjMtxType type, math::MTX34 *pMtx) const;
const math::MTX34 *GetMtxPtr(ScnObjMtxType type) const {
return &mMtxArray[type];
@@ -125,6 +126,7 @@ public:
}
void EnableScnObjCallbackTiming(Timing timing);
void DisableScnObjCallbackTiming(Timing timing);
void EnableScnObjCallbackExecOp(ExecOp op);
bool SetBoundingVolume(ScnObjBoundingVolumeType type, const math::AABB *pAABB);
@@ -175,7 +177,7 @@ protected:
}
bool IsG3dProcDisabled(u32 task) const {
if (task < __G3DPROC_OPTIONAL_END && ((1 << task - 1) & mScnObjFlags)) {
if (task < __G3DPROC_OPTIONAL_END && ((1 << (task - 1)) & mScnObjFlags)) {
return true;
}
@@ -225,6 +227,11 @@ public:
CULLINGSTATUS_NOTEST
};
enum CheckStatus {
CHECKSTATUS_GATHER_SCNOBJ,
CHECKSTATUS_IGNORE_SCNOBJ
};
public:
virtual ~IScnObjGather() {} // at 0x8
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_SCN_PROC_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include "nw4r/g3d/g3d_scnobj.h"
namespace nw4r {
namespace g3d {
+7 -5
View File
@@ -2,11 +2,11 @@
#define NW4R_G3D_SCN_ROOT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/g3d_light.h>
#include <nw4r/g3d/g3d_scnobj.h>
#include <nw4r/g3d/g3d_state.h>
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/g3d_light.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/g3d_state.h"
namespace nw4r {
namespace g3d {
@@ -122,6 +122,8 @@ public:
virtual void DrawOpa(ResMdlDrawMode *pForceMode); // at 0x20
virtual void DrawXlu(ResMdlDrawMode *pForceMode); // at 0x24
virtual CheckStatus CheckScnObj(ScnObj *); // at 0x28
protected:
ScnObj **mpArrayOpa; // at 0x4
ScnObj **mpArrayXlu; // at 0x8
+5 -5
View File
@@ -2,13 +2,13 @@
#define NW4R_G3D_STATE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_camera.h>
#include <nw4r/g3d/g3d_fog.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include "nw4r/g3d/g3d_camera.h"
#include "nw4r/g3d/g3d_fog.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+18
View File
@@ -0,0 +1,18 @@
#ifndef NW4R_G3D_TRANSFORM_H
#define NW4R_G3D_TRANSFORM_H
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
namespace detail {
bool CalcViewNrmMtx(nw4r::math::MTX33 *pOut, const nw4r::math::MTX34 *pW);
bool CalcViewTexMtx(nw4r::math::MTX34 *pOut, const nw4r::math::MTX34 *pW);
bool CalcInvWorldMtx(nw4r::math::MTX34 *pOut, const nw4r::math::MTX34 *pW);
} // namespace detail
} // namespace g3d
} // namespace nw4r
#endif
+2 -2
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_WORK_MEM_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include "nw4r/g3d/res/g3d_resanmshp.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_XSI_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_PLATFORM_ALLOCATOR_H
#include <nw4r/types_nw4r.h>
#include <rvl/MEM.h>
#include "rvl/MEM.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_PLATFORM_CPU_H
#include <nw4r/types_nw4r.h>
#include <rvl/OS.h>
#include "rvl/OS.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+4 -6
View File
@@ -2,11 +2,9 @@
#define NW4R_G3D_PLATFORM_GPU_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <nw4r/math.h>
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -95,11 +93,11 @@ inline void GDSetChanCtrlLightOff(GXChannelID chan, u32 param, u32 lightMask) {
}
inline void GDSetChanAmbColor(GXChannelID chan, GXColor color) {
LoadXFCmd(GX_XF_REG_AMBIENT0 + chan, *reinterpret_cast<u32 *>(&color));
LoadXFCmd(GX_XF_REG_AMBIENT0 + (chan & 1), *reinterpret_cast<u32 *>(&color));
}
inline void GDSetChanMatColor(GXChannelID chan, GXColor color) {
LoadXFCmd(GX_XF_REG_MATERIAL0 + chan, *reinterpret_cast<u32 *>(&color));
LoadXFCmd(GX_XF_REG_MATERIAL0 + (chan & 1), *reinterpret_cast<u32 *>(&color));
}
} // namespace fifo
+4 -4
View File
@@ -2,12 +2,12 @@
#define NW4R_G3D_RES_RES_ANM_CAMERA_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+9 -5
View File
@@ -6,11 +6,11 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -49,11 +49,15 @@ struct ChrAnmResult {
math::MTX34 rt; // at 0x1C
void GetScale(math::VEC3 *pScale) const;
void GetMtx(math::MTX34 *pMtx) const;
bool GetRotateDeg(math::VEC3 *pRotate) const;
void GetTranslate(math::VEC3 *pTrans) const;
void GetTranslate(math::VEC3 *pTranslate) const;
void GetRotTrans(math::MTX34 *pRotTrans) const;
void SetScale(const math::VEC3 *pScale);
void SetMtx(const math::MTX34 *pMtx);
void SetRotateDeg(const math::VEC3 *pRotate);
void SetTranslate(const math::VEC3 *pTranslate);
void SetRotTrans(const math::MTX34 *pRotTrans);
};
+3 -3
View File
@@ -6,9 +6,9 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
namespace nw4r {
namespace g3d {
+4 -4
View File
@@ -2,12 +2,12 @@
#define NW4R_G3D_RES_RES_ANM_FOG_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+5 -5
View File
@@ -2,13 +2,13 @@
#define NW4R_G3D_RES_RES_ANM_LIGHT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include <nw4r/ut.h>
#include "nw4r/math.h" // IWYU pragma: export
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+14 -7
View File
@@ -6,13 +6,13 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_resanmamblight.h>
#include <nw4r/g3d/res/g3d_resanmcamera.h>
#include <nw4r/g3d/res/g3d_resanmfog.h>
#include <nw4r/g3d/res/g3d_resanmlight.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_reslightset.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_resanmamblight.h"
#include "nw4r/g3d/res/g3d_resanmcamera.h"
#include "nw4r/g3d/res/g3d_resanmfog.h"
#include "nw4r/g3d/res/g3d_resanmlight.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_reslightset.h"
namespace nw4r {
namespace g3d {
@@ -74,14 +74,21 @@ public:
ResLightSet GetResLightSet(u32 idx) const;
u32 GetResLightSetNumEntries() const;
ResAnmAmbLight GetResAnmAmbLight(const char *name) const;
ResAnmAmbLight GetResAnmAmbLight(const ResName name) const;
ResAnmAmbLight GetResAnmAmbLight(int idx) const;
ResAnmAmbLight GetResAnmAmbLight(u32 idx) const;
ResAnmLight GetResAnmLight(const char *name) const;
ResAnmLight GetResAnmLight(const ResName name) const;
ResAnmLight GetResAnmLight(int idx) const;
ResAnmLight GetResAnmLight(u32 idx) const;
ResAnmCamera GetResAnmCamera(const char *name) const;
ResAnmCamera GetResAnmCamera(const ResName name) const;
ResAnmCamera GetResAnmCamera(int idx) const;
ResAnmCamera GetResAnmCamera(u32 idx) const;
ResLightSet GetResLightSetByRefNumber(u32 refNumber) const;
ResAnmAmbLight GetResAnmAmbLightByRefNumber(u32 refNumber) const;
ResAnmLight GetResAnmLightByRefNumber(u32 refNumber) const;
+4 -4
View File
@@ -6,10 +6,10 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include <nw4r/g3d/res/g3d_resvtx.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
#include "nw4r/g3d/res/g3d_resvtx.h"
namespace nw4r {
namespace g3d {
+6 -6
View File
@@ -6,12 +6,12 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_respltt.h>
#include <nw4r/g3d/res/g3d_restex.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_respltt.h"
#include "nw4r/g3d/res/g3d_restex.h"
namespace nw4r {
namespace g3d {
+3 -3
View File
@@ -6,9 +6,9 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
namespace nw4r {
namespace g3d {
+3 -3
View File
@@ -6,9 +6,9 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanm.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include "nw4r/g3d/res/g3d_resanm.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
namespace nw4r {
namespace g3d {
+2 -1
View File
@@ -2,7 +2,8 @@
#define NW4R_G3D_RESCOMMON_H
#include "common.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
/******************************************************************************
*
* Macros
+1 -1
View File
@@ -2,7 +2,7 @@
#define NW4R_G3D_RES_RES_DICT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
+14 -12
View File
@@ -2,19 +2,19 @@
#define NW4R_G3D_RES_RES_FILE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmchr.h>
#include <nw4r/g3d/res/g3d_resanmclr.h>
#include <nw4r/g3d/res/g3d_resanmscn.h>
#include <nw4r/g3d/res/g3d_resanmshp.h>
#include <nw4r/g3d/res/g3d_resanmtexpat.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_resanmvis.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_respltt.h>
#include <nw4r/g3d/res/g3d_restex.h>
#include "nw4r/g3d/res/g3d_resanmchr.h"
#include "nw4r/g3d/res/g3d_resanmclr.h"
#include "nw4r/g3d/res/g3d_resanmscn.h"
#include "nw4r/g3d/res/g3d_resanmshp.h"
#include "nw4r/g3d/res/g3d_resanmtexpat.h"
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_resanmvis.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_respltt.h"
#include "nw4r/g3d/res/g3d_restex.h"
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -86,6 +86,8 @@ public:
ResAnmScn GetResAnmScn(int idx) const;
ResAnmScn GetResAnmScn(u32 idx) const;
void *GetExternalData(const char *pName) const;
u32 GetResMdlNumEntries() const;
u32 GetResPlttNumEntries() const;
u32 GetResTexNumEntries() const;
+3 -3
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_RES_RES_LIGHT_SET_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/g3d_state.h>
// #include <nw4r/g3d/res/g3d_resanmscn.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/g3d_state.h"
// #include "nw4r/g3d/res/g3d_resanmscn.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
+59 -8
View File
@@ -2,15 +2,16 @@
#define NW4R_G3D_RES_RES_MAT_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_resanmtexsrt.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_respltt.h>
#include <nw4r/g3d/res/g3d_restev.h>
#include <nw4r/g3d/res/g3d_restex.h>
#include "nw4r/g3d/res/g3d_resanmtexsrt.h"
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_respltt.h"
#include "nw4r/g3d/res/g3d_restev.h"
#include "nw4r/g3d/res/g3d_restex.h"
#include "nw4r/g3d/res/g3d_resuser.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -99,7 +100,11 @@ public:
ResMatMisc CopyTo(void *pDst) const;
GXBool GXGetZCompLoc() const;
void SetLightSetIdx(int idx);
int GetLightSetIdx() const;
void SetFogIdx(int idx);
int GetFogIdx() const;
void GetIndirectTexMtxCalcMethod(GXIndTexMtxID id, ResMatMiscData::IndirectMethod *pMethod, s8 *pLightRef);
@@ -127,6 +132,7 @@ class ResMatTexCoordGen : public ResCommon<ResTexCoordGenDL> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF_EX(ResMatTexCoordGen, ResTexCoordGenDL);
void Disable(GXTexCoordID coord);
void DCStore(bool sync);
ResMatTexCoordGen CopyTo(void *pDst) const;
@@ -429,6 +435,7 @@ public:
void CallDisplayList(u8 indNum, bool sync) const;
bool GXGetIndTexMtx(GXIndTexMtxID id, math::MTX34 *pMtx) const;
bool GXGetIndTexMtx(GXIndTexMtxID id, math::MTX34 *pMtx, s8 *pScaleExp) const;
void GXSetIndTexMtx(GXIndTexMtxID id, const math::MTX34 &rMtx, s8 scaleExp);
void EndEdit() {
@@ -496,6 +503,47 @@ private:
void BindPltt_(const ResPltt pltt, ResTlutObj tlutObj);
};
/******************************************************************************
*
* ResMatFur
*
******************************************************************************/
struct ResMatFurData {
enum LayerInterval {
UNIFORM = 0,
TIP = 1,
};
f32 length; // at 0x0
u32 lyrSize; // at 0x4
LayerInterval lyrInterval; // at 0x8
f32 alphaCurve; // at 0xC
f32 specCurve; // at 0x10
};
class ResMatFur : public ResCommon<ResMatFurData> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResMatFur);
void SetLength(f32 len);
f32 GetLength() const;
u32 GetLyrSize() const;
void SetLytInterval(ResMatFurData::LayerInterval interval);
ResMatFurData::LayerInterval GetLytInterval() const;
void SetAlphaCurve(f32 curve);
f32 GetAlphaCurve() const;
void SetSpecCurve(f32 curve);
f32 GetSpecCurve() const;
f32 GetLyrRate(u32 idx) const;
ResMatFur CopyTo(void *pDst) const;
};
/******************************************************************************
*
* ResMat
@@ -533,12 +581,12 @@ public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResMat);
void Init();
bool Bind(const ResFile file);
void Release();
bool IsOpaque() const;
ResMdl GetParent();
const ResMdl GetParent() const;
u32 GetID() const {
return ref().id;
@@ -555,6 +603,9 @@ public:
ResTev GetResTev();
ResTev GetResTev() const;
ResMatFur GetResMatFur();
ResUserData GetResUserData();
u32 GetNumResTexPlttInfo() const {
return ref().numResTexPlttInfo;
}
+30 -8
View File
@@ -6,14 +6,14 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include <nw4r/g3d/res/g3d_resdict.h>
#include <nw4r/g3d/res/g3d_resmat.h>
#include <nw4r/g3d/res/g3d_resnode.h>
#include <nw4r/g3d/res/g3d_resshp.h>
#include <nw4r/g3d/res/g3d_resvtx.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include "nw4r/g3d/res/g3d_resdict.h"
#include "nw4r/g3d/res/g3d_resmat.h"
#include "nw4r/g3d/res/g3d_resnode.h"
#include "nw4r/g3d/res/g3d_resshp.h"
#include "nw4r/g3d/res/g3d_resvtx.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -139,7 +139,7 @@ public:
bool Bind(const ResFile file);
void Release();
bool IsOpaque() const;
bool IsOpaque(u32 mat) const;
u32 GetRevision() const {
return ref().revision;
}
@@ -153,6 +153,7 @@ public:
}
const u8 *GetResByteCode(const char *pName) const;
u32 GetResByteCodeNumEntries() const;
ResNode GetResNode(const char *pName) const;
ResNode GetResNode(const ResName name) const;
@@ -178,6 +179,12 @@ public:
ResVtxTexCoord GetResVtxTexCoord(int idx) const;
u32 GetResVtxTexCoordNumEntries() const;
ResVtxFurPos GetResVtxFurPos(int idx) const;
u32 GetResVtxFurPosNumEntries() const;
ResVtxFurVec GetResVtxFurVec(int idx) const;
u32 GetResVtxFurVecNumEntries() const;
ResMat GetResMat(const char *pName) const;
ResMat GetResMat(const ResName name) const;
ResMat GetResMat(int idx) const;
@@ -198,6 +205,21 @@ public:
ResMdlInfo GetResMdlInfo() const {
return ResMdlInfo(const_cast<ResMdlInfoData *>(&ref().info));
}
class DrawEnumerator {
const u8 *drawOpa;
const u8 *drawXlu;
bool bOpa;
public:
DrawEnumerator(const u8 *pDrawOpa, const u8 *pDrawXlu);
bool IsValid() const;
void MoveNext();
u32 GetMatID() const;
u32 GetShpID() const;
u32 GetNodeID() const;
};
};
} // namespace g3d
+2 -2
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_RES_RES_NODE_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+2 -2
View File
@@ -5,9 +5,9 @@
/** NOTICE: Revision change from 1->??. Structures, Enums, and/or Functions may have changed and not yet done so
* (Zeldex72, Feb 1, 2025) */
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+12 -6
View File
@@ -3,11 +3,11 @@
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
// #include <nw4r/g3d/res/g3d_resmdl.h>
#include <nw4r/g3d/res/g3d_resvtx.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
// #include "nw4r/g3d/res/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resvtx.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -89,8 +89,10 @@ struct ResShpData {
s16 idVtxNormal; // at 0x4A
s16 idVtxColor[GX_VA_TEX0 - GX_VA_CLR0]; // at 0x4C
s16 idVtxTexCoord[GX_POS_MTX_ARRAY - GX_VA_TEX0]; // at 0x50
s32 toMtxSetUsed; // at 0x60
ResMtxSetUsed msu; // at 0x64
s16 idVtxFurVec; // at 0x60
s16 idVtxFurPos; // at 0x62
s32 toMtxSetUsed; // at 0x64
ResMtxSetUsed msu; // at 0x68
};
class ResShp : public ResCommon<ResShpData> {
@@ -111,6 +113,8 @@ public:
ResVtxNrm GetResVtxNrm() const;
ResVtxClr GetResVtxClr(u32 idx) const;
ResVtxTexCoord GetResVtxTexCoord(u32 idx) const;
ResVtxClr GetResVtxFurVec(u32 idx) const;
ResVtxFurPos GetResVtxFurPos() const;
void CallPrePrimitiveDisplayList(bool sync, bool cacheIsSame) const;
void CallPrimitiveDisplayList(bool sync) const;
@@ -143,6 +147,8 @@ public:
bool IsVisible() const {
return !(ref().flag & ResShpData::FLAG_INVISIBLE);
}
void DCStore(bool sync);
};
} // namespace g3d
+11 -4
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_RES_RES_TEV_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -55,9 +55,9 @@ struct ResTevData {
s32 toResMdlData; // at 0x4
u32 id; // at 0x8
u8 nStages; // at 0xC
u8 PADDING_0xD[0x10 - 0xD]; // at 0xD
u8 dummy_[0x10 - 0xD]; // at 0xD
u8 texCoordToTexMapID[GX_MAX_TEXCOORD]; // at 0x10
u8 PADDING_0x18[0x20 - 0x18]; // at 0x18
u8 dummy[0x20 - 0x18]; // at 0x18
ResTevDL dl; // at 0x20
};
@@ -65,6 +65,9 @@ class ResTev : public ResCommon<ResTevData> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResTev);
ResMdl GetParent();
const ResMdl GetParent() const;
bool GXGetTevSwapModeTable(
GXTevSwapSel swap, GXTevColorChan *pR, GXTevColorChan *pG, GXTevColorChan *pB, GXTevColorChan *pA
) const;
@@ -72,6 +75,10 @@ public:
GXSetTevSwapModeTable(GXTevSwapSel swap, GXTevColorChan r, GXTevColorChan g, GXTevColorChan b, GXTevColorChan a);
bool GXGetTevOrder(GXTevStageID stage, GXTexCoordID *pCoord, GXTexMapID *pMap, GXChannelID *pChannel) const;
void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXChannelID channel);
bool GXGetIndTexOrder(GXIndTexStageID stage, GXTexCoordID *pCoord, GXTexMapID *pMap) const;
void GXSetIndTexOrder(GXIndTexStageID stage, GXTexCoordID coord, GXTexMapID map);
void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, GXTevColorArg d);
+3 -3
View File
@@ -2,9 +2,9 @@
#define NW4R_G3D_RES_RES_TEX_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -25,7 +25,7 @@ struct ResTexData {
union {
GXTexFmt fmt;
GXCITexFmt cifmt;
}; // at 0x20
}; // at 0x20
u32 mipmap_level; // at 0x24
f32 min_lod; // at 0x28
f32 max_lod; // at 0x2C
+21
View File
@@ -0,0 +1,21 @@
#ifndef NW4R_G3D_RES_RES_USER_H
#define NW4R_G3D_RES_RES_USER_H
#include <nw4r/types_nw4r.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
namespace nw4r {
namespace g3d {
struct ResUserDataData {};
class ResUserData : public ResCommon<ResUserDataData> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResUserData);
// TODO
};
} // namespace g3d
} // namespace nw4r
#endif
+183 -11
View File
@@ -2,11 +2,11 @@
#define NW4R_G3D_RES_RES_VTX_H
#include <nw4r/types_nw4r.h>
#include <nw4r/g3d/res/g3d_rescommon.h>
#include "nw4r/g3d/res/g3d_rescommon.h"
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -50,10 +50,22 @@ public:
}
void *GetData() {
return ofs_to_ptr<void>(ref().toVtxPosArray);
ResVtxPosData &r = ref();
if (r.toVtxPosArray != 0) {
return reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toVtxPosArray);
}
return NULL;
}
const void *GetData() const {
return ofs_to_ptr<void>(ref().toVtxPosArray);
const ResVtxPosData &r = ref();
if (r.toVtxPosArray != 0) {
return reinterpret_cast<const void *>(reinterpret_cast<const u8 *>(&r) + r.toVtxPosArray);
}
return NULL;
}
u32 GetID() const {
@@ -102,10 +114,22 @@ public:
}
void *GetData() {
return ofs_to_ptr<void>(ref().toVtxNrmArray);
ResVtxNrmData &r = ref();
if (r.toVtxNrmArray != 0) {
return reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toVtxNrmArray);
}
return NULL;
}
const void *GetData() const {
return ofs_to_ptr<void>(ref().toVtxNrmArray);
const ResVtxNrmData &r = ref();
if (r.toVtxNrmArray != 0) {
return reinterpret_cast<const void *>(reinterpret_cast<const u8 *>(&r) + r.toVtxNrmArray);
}
return NULL;
}
u32 GetID() const {
@@ -154,10 +178,22 @@ public:
}
void *GetData() {
return ofs_to_ptr<void>(ref().toVtxClrArray);
ResVtxClrData &r = ref();
if (r.toVtxClrArray != 0) {
return reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toVtxClrArray);
}
return NULL;
}
const void *GetData() const {
return ofs_to_ptr<void>(ref().toVtxClrArray);
const ResVtxClrData &r = ref();
if (r.toVtxClrArray != 0) {
return reinterpret_cast<const void *>(reinterpret_cast<const u8 *>(&r) + r.toVtxClrArray);
}
return NULL;
}
u32 GetID() const {
@@ -205,10 +241,22 @@ public:
}
void *GetData() {
return ofs_to_ptr<void>(ref().toTexCoordArray);
ResVtxTexCoordData &r = ref();
if (r.toTexCoordArray != 0) {
return reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toTexCoordArray);
}
return NULL;
}
const void *GetData() const {
return ofs_to_ptr<void>(ref().toTexCoordArray);
const ResVtxTexCoordData &r = ref();
if (r.toTexCoordArray != 0) {
return reinterpret_cast<const void *>(reinterpret_cast<const u8 *>(&r) + r.toTexCoordArray);
}
return NULL;
}
u32 GetID() const {
@@ -220,6 +268,130 @@ public:
}
};
/******************************************************************************
*
* ResVtxFurPos
*
******************************************************************************/
struct ResVtxFurPosData {
u32 size; // at 0x0
s32 toResMdlData; // at 0x4
s32 toFurPosArray; // at 0x8
s32 name; // at 0xC
u32 id; // at 0x10
GXCompCnt cmpcnt; // at 0x14
GXCompType tp; // at 0x18
u8 frac; // at 0x1C
u8 stride; // at 0x1D
u16 numFurPos; // at 0x1E
u32 numLayer; // at 0x20
u32 ofsLayer; // at 0x24
};
class ResVtxFurPos : public ResCommon<ResVtxFurPosData> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResVtxFurPos);
void Init() {
DCStore(false);
}
void GetArray(const void **ppBase, u8 *pStride) const;
void SetArray(u16 idx);
void DCStore(bool sync);
u32 GetSize() const {
return ref().size;
}
void *GetData(int idx) {
ResVtxFurPosData &r = ref();
// ternary was required -_- Probably means other GetData funcs are ternaries
return (r.toFurPosArray != 0 && idx < (int)r.numLayer && idx >= 0) ?
reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toFurPosArray + idx * r.ofsLayer) :
NULL;
}
const void *GetData(int idx) const {
const ResVtxFurPosData &r = ref();
return (r.toFurPosArray != 0 && idx < (int)r.numLayer && idx >= 0) ?
reinterpret_cast<const void *>(
reinterpret_cast<const u8 *>(&r) + r.toFurPosArray + idx * r.ofsLayer
) :
NULL;
return NULL;
}
u32 GetID() const {
return ref().id;
}
u16 GetNumFurPos() const {
return ref().toFurPosArray;
}
u32 GetNumLayer() const {
return ref().numLayer;
}
};
/******************************************************************************
*
* ResVtxFurVec
*
******************************************************************************/
struct ResVtxFurVecData {
u32 size; // at 0x0
s32 toResMdlData; // at 0x4
s32 toFurVecArray; // at 0x8
s32 name; // at 0xC
u32 id; // at 0x10
u16 numFurVec; // at 0x14
};
class ResVtxFurVec : public ResCommon<ResVtxFurVecData> {
public:
NW4R_G3D_RESOURCE_FUNC_DEF(ResVtxFurVec);
void Init() {
DCStore(false);
}
void GetArray(const void **ppBase, u8 *pStride) const;
void DCStore(bool sync);
u32 GetSize() const {
return ref().size;
}
void *GetData() {
ResVtxFurVecData &r = ref();
if (r.toFurVecArray != 0) {
return reinterpret_cast<void *>(reinterpret_cast<u8 *>(&r) + r.toFurVecArray);
}
return NULL;
}
const void *GetData() const {
const ResVtxFurVecData &r = ref();
if (r.toFurVecArray != 0) {
return reinterpret_cast<const void *>(reinterpret_cast<const u8 *>(&r) + r.toFurVecArray);
}
return NULL;
}
u32 GetID() const {
return ref().id;
}
u16 GetNumFurVec() const {
return ref().toFurVecArray;
}
};
} // namespace g3d
} // namespace nw4r
+2 -6
View File
@@ -64,15 +64,11 @@ inline f32 FMod(f32 x, f32 y) {
}
inline f32 FModf(f32 x, f32 *y) {
return fmodff(x, y);
return modff(x, y);
}
inline f32 FSqrt(f32 x) {
if (x <= 0.0f) {
return 0.0f;
}
return x * FrSqrt(x);
return (x <= 0.0f) ? 0.0f : x * FrSqrt(x);
}
inline f32 FLog(f32 x) {
+3 -3
View File
@@ -10,7 +10,7 @@ namespace ut {
class Color : public GXColor {
public:
Color() {
*this = 0xFFFFFFFF;
*this = WHITE;
}
Color(u32 color) {
*this = color;
@@ -19,7 +19,7 @@ public:
Set(red, green, blue, alpha);
}
Color(const GXColor &clr) {
ToU32ref() = *(u32 *)&clr;
*this = clr;
}
~Color() {}
@@ -36,7 +36,7 @@ public:
}
Color &operator=(const GXColor &c) {
ToU32ref() = *(u32 *)&c; // TODO -> This Seems Maybe Wrong
*this = *reinterpret_cast<const u32 *>(&c);
return *this;
}
+1 -1
View File
@@ -13,7 +13,7 @@
#ifndef RVL_SDK_GX_HARDWARE_H
#define RVL_SDK_GX_HARDWARE_H
#include <rvl/GX/GXTypes.h>
#include "rvl/GX/GXTypes.h"
#include <common.h>
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef RVL_SDK_GX_HARDWARE_BP_H
#define RVL_SDK_GX_HARDWARE_BP_H
#include <rvl/GX/GXTypes.h>
#include "rvl/GX/GXTypes.h"
#include <common.h>
+1 -2
View File
@@ -1,10 +1,9 @@
#ifndef RVL_SDK_GX_HARDWARE_CP_H
#define RVL_SDK_GX_HARDWARE_CP_H
#include <rvl/GX/GXTypes.h>
#include "rvl/GX/GXTypes.h"
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
+1 -2
View File
@@ -1,10 +1,9 @@
#ifndef RVL_SDK_GX_HARDWARE_XF_H
#define RVL_SDK_GX_HARDWARE_XF_H
#include <rvl/GX/GXTypes.h>
#include "rvl/GX/GXTypes.h"
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif
+1 -1
View File
@@ -24,7 +24,7 @@ extern "C" {
*/
#define GX_DECL_PUBLIC_STRUCT(name, size) \
typedef struct _##name { \
u8 dummy[(size) - sizeof(name##Impl) + sizeof(name##Impl)]; \
u32 dummy[((size) - sizeof(name##Impl) + sizeof(name##Impl)) / sizeof(u32)]; \
} name;
typedef struct _GXFifoObjImpl {
+6 -1
View File
@@ -2,17 +2,22 @@
#define RVL_SDK_GX_TRANSFORM_H
#include "common.h"
#include "rvl/GX/GXTypes.h"
#include "rvl/MTX.h"
#include "rvl/MTX.h" // IWYU pragma: export
#ifdef __cplusplus
extern "C" {
#endif
#define GX_PROJECTION_SZ 7
#define GX_VIEWPORT_SZ 6
typedef enum {
GX_FIELD_EVEN,
GX_FIELD_ODD,
} GXInterlaceField;
void GXProject(f32 x, f32 y, f32 z, f32 mtx[3][4], f32 *pm, f32 *vp, f32 *sx, f32 *sy, f32 *sz);
void GXSetProjection(const Mtx44 proj, GXProjectionType type);
void GXSetProjectionv(const f32 proj[7]);
void GXGetProjectionv(f32 proj[7]);
+4 -3
View File
@@ -10,7 +10,8 @@ extern "C" {
* Value is shifted to the specified bit position.
* (Bit indices are LSB)
*/
#define GX_BITSET(field, pos, size, value) __rlwimi((field), (value), 31 - (pos) - (size) + 1, (pos), (pos) + (size)-1)
#define GX_BITSET(field, pos, size, value) \
__rlwimi((field), (value), 31 - (pos) - (size) + 1, (pos), (pos) + (size) - 1)
/**
* Compose value from bitfield.
@@ -24,7 +25,7 @@ extern "C" {
* Value is not shifted, only masked.
* (Bit indices are LSB)
*/
#define GX_BITSET_TRUNC(field, pos, size, value) __rlwimi((field), (value), 0, (pos), (pos) + (size)-1)
#define GX_BITSET_TRUNC(field, pos, size, value) __rlwimi((field), (value), 0, (pos), (pos) + (size) - 1)
/**
* Compose value from bitfield.
@@ -840,7 +841,7 @@ typedef enum _GXTexWrapMode {
GX_MAX_TEXWRAPMODE
} GXTexWrapMode;
typedef enum GXTlut {
typedef enum _GXTlut {
GX_TLUT0,
GX_TLUT1,
GX_TLUT2,
@@ -45,67 +45,83 @@ float fmodf(float, float);
float fmodff(float, float *);
extern float __fabsf(float);
inline double fabs(double f) { return __fabs(f); }
inline double fabsf2(float f) { return __fabsf(f); }
inline float fabsf(float f) { return fabsf2(f); }
inline double fabs(double f) {
return __fabs(f);
}
inline double fabsf2(float f) {
return __fabsf(f);
}
inline float fabsf(float f) {
return fabsf2(f);
}
inline float fmodf(float f1, float f2) { return fmod(f1, f2); }
inline float fmodf(float f1, float f2) {
return fmod(f1, f2);
}
inline float modff(float x, float *iptr) {
float frac;
double intg;
float frac;
double intg;
frac = modf((double)x, &intg);
*iptr = intg;
frac = modf((double)x, &intg);
*iptr = intg;
return frac;
return frac;
}
inline double sqrt_step(double tmpd, float mag) {
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
}
inline float floorf(float f) {
return floor(f);
}
extern inline float sqrtf(float x) {
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess =
_half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess =
_half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess =
_half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
}
extern inline double sqrt(double x) {
if (x > 0.0) {
double guess = __frsqrte(x); /* returns an approximation to */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 16 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 32 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have > 53 sig bits */
return x * guess;
} else if (x == 0) {
return 0;
} else if (x) {
return NAN;
}
if (x > 0.0) {
double guess = __frsqrte(x); /* returns an approximation to */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 16 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 32 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have > 53 sig bits */
return x * guess;
} else if (x == 0) {
return 0;
} else if (x) {
return NAN;
}
return HUGE_VALF;
return HUGE_VALF;
}
inline float atan2f(float y, float x) { return (float)atan2(y, x); }
inline float atan2f(float y, float x) {
return (float)atan2(y, x);
}
// these are duplicated due to sinf/cosf having a symbol, but
// still being used as inlines elsewhere
inline float i_sinf(float x) { return sin(x); }
inline float i_cosf(float x) { return cos(x); }
inline float i_tanf(float x) { return tanf(x); }
inline float i_sinf(float x) {
return sin(x);
}
inline float i_cosf(float x) {
return cos(x);
}
inline float i_tanf(float x) {
return tanf(x);
}
#ifdef __cplusplus
};
@@ -1,4 +1,4 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+90
View File
@@ -0,0 +1,90 @@
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
namespace detail {
namespace dcc {
bool CalcTexMtx_Basic(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag) {
// Extract S/R/T flags
u32 index = flag >> 1 & 0b111;
// Scale-one, no rotate/trans
if (index == 0b111) {
return false;
}
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
if (set) {
// clang-format off
pMtx->m[0][0] = rSrt.Su * cosR; pMtx->m[0][1] = -rSrt.Sv * sinR; pMtx->m[0][2] = 0.0f; pMtx->m[0][3] = rSrt.Tu;
pMtx->m[1][0] = rSrt.Su * sinR; pMtx->m[1][1] = rSrt.Sv * cosR; pMtx->m[1][2] = 0.0f; pMtx->m[1][3] = rSrt.Tv;
pMtx->m[2][0] = 0.0f; pMtx->m[2][1] = 0.0f; pMtx->m[2][2] = 1.0f; pMtx->m[2][3] = 0.0f;
// clang-format on
} else {
// clang-format off
math::MTX34 m;
m[0][0] = rSrt.Su * cosR; m[0][1] = -rSrt.Sv * sinR; m[0][2] = 0.0f; m[0][3] = rSrt.Tu;
m[1][0] = rSrt.Su * sinR; m[1][1] = rSrt.Sv * cosR; m[1][2] = 0.0f; m[1][3] = rSrt.Tv;
m[2][0] = 0.0f; m[2][1] = 0.0f; m[2][2] = 1.0f; m[2][3] = 0.0f;
// clang-format on
math::MTX34Mult(pMtx, &m, pMtx);
}
return true;
}
u32 CalcWorldMtx_Basic(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
) {
u32 flag = pResult->flags;
u32 newAttr = attr;
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) || (flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Copy(pW, pW1);
} else {
math::MTX34Scale(pW, pW1, pS1);
}
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::MTX34 temp;
math::MTX34Scale(&temp, pS1, &pResult->rt);
math::MTX34Mult(pW, pW1, &temp);
}
} else if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34Scale(pW, pW1, pS1);
math::MTX34Mult(pW, pW, &pResult->rt);
}
if (flag & ChrAnmResult::FLAG_SCALE_ONE) {
newAttr = detail::WorldMtxAttr::AnmScaleOne(newAttr);
pS->x = pS->y = pS->z = 1.0f;
} else {
newAttr = detail::WorldMtxAttr::AnmNotScaleOne(newAttr);
*pS = pResult->s;
}
if (flag & ChrAnmResult::FLAG_SCALE_UNIFORM) {
newAttr = detail::WorldMtxAttr::AnmScaleUniform(newAttr);
} else {
newAttr = detail::WorldMtxAttr::AnmNotScaleUniform(newAttr);
}
return newAttr;
}
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
@@ -1,4 +1,4 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -6,7 +6,7 @@ namespace detail {
namespace dcc {
namespace {
void MakeTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_S(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = rSrt.Su;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -18,7 +18,7 @@ void MakeTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = 1.0f - rSrt.Sv;
}
void MakeTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_R(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -36,7 +36,7 @@ void MakeTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = cosPart + sinPart;
}
void MakeTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_T(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = 1.0f;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -48,7 +48,7 @@ void MakeTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Tv;
}
void MakeTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_SR(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -68,7 +68,7 @@ void MakeTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = 0.5f * (svsr - svcr - rSrt.Sv) + 1.0f;
}
void MakeTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_RT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -86,7 +86,7 @@ void MakeTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = cosPart + sinPart + rSrt.Tv;
}
void MakeTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_ST(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = rSrt.Su;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -98,7 +98,7 @@ void MakeTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Sv * (rSrt.Tv - 1.0f) + 1.0f;
}
void MakeTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_SRT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -116,7 +116,7 @@ void MakeTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Sv * (cosPart + sinPart + rSrt.Tv) + 1.0f;
}
void ProductTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_S(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 *= rSrt.Su;
pMtx->_01 *= rSrt.Su;
pMtx->_02 *= rSrt.Su;
@@ -128,7 +128,7 @@ void ProductTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = 1.0f + pMtx->_13 * rSrt.Sv - rSrt.Sv;
}
void ProductTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_R(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -157,12 +157,12 @@ void ProductTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_T(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_03 += -rSrt.Tu;
pMtx->_13 += rSrt.Tv;
}
void ProductTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_SR(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -201,7 +201,7 @@ void ProductTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_RT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -230,7 +230,7 @@ void ProductTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_ST(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 *= rSrt.Su;
pMtx->_01 *= rSrt.Su;
pMtx->_02 *= rSrt.Su;
@@ -242,7 +242,7 @@ void ProductTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Sv * (pMtx->_13 + rSrt.Tv - 1.0f) + 1.0f;
}
void ProductTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_SRT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -267,11 +267,9 @@ void ProductTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_02 = _0x;
pMtx->_12 = _1x;
_0x = sucr * (pMtx->_03 - 0.5f) + susr * (pMtx->_13 - 0.5f) +
(0.5f - rSrt.Tu) * rSrt.Su;
_0x = sucr * (pMtx->_03 - 0.5f) + susr * (pMtx->_13 - 0.5f) + (0.5f - rSrt.Tu) * rSrt.Su;
_1x = -svsr * (0.5f + pMtx->_03) + svcr * (pMtx->_13 - 0.5f) -
(0.5f - rSrt.Tv) * rSrt.Sv + 1.0f;
_1x = -svsr * (0.5f + pMtx->_03) + svcr * (pMtx->_13 - 0.5f) - (0.5f - rSrt.Tv) * rSrt.Sv + 1.0f;
pMtx->_03 = _0x;
pMtx->_13 = _1x;
@@ -279,10 +277,9 @@ void ProductTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
} // namespace
typedef void (*CalcTexMtxFunc)(math::MTX34* pMtx, const TexSrt& rSrt);
typedef void (*CalcTexMtxFunc)(math::MTX34 *pMtx, const TexSrt &rSrt);
bool CalcTexMtx_Maya(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
TexSrt::Flag flag) {
bool CalcTexMtx_Maya(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag) {
// Extract S/R/T flags
u32 index = flag >> 1 & 0b111;
@@ -325,12 +322,39 @@ bool CalcTexMtx_Maya(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
return true;
}
u32 CalcWorldMtx_Maya_SSC_Apply(math::MTX34* pW, math::VEC3* pS,
const math::MTX34* pW1, const math::VEC3* pS1,
u32 attr, const ChrAnmResult* pResult) {
u32 CalcWorldMtx_Maya_SSC_Apply(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
) {
u32 flag = pResult->flags;
u32 newAttr = attr;
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) || (flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
math::MTX34Copy(pW, pW1);
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::VEC3 trans(pS1->x * pResult->rt._03, pS1->y * pResult->rt._13, pS1->z * pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
}
} else if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34 m;
math::MTX34Copy(&m, &pResult->rt);
m._03 *= pS1->x;
m._13 *= pS1->y;
m._23 *= pS1->z;
math::MTX34Mult(pW, pW1, &m);
}
if (flag & ChrAnmResult::FLAG_SCALE_ONE) {
newAttr = detail::WorldMtxAttr::AnmScaleOne(newAttr);
pS->x = pS->y = pS->z = 1.0f;
@@ -339,34 +363,6 @@ u32 CalcWorldMtx_Maya_SSC_Apply(math::MTX34* pW, math::VEC3* pS,
*pS = pResult->s;
}
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) ||
(flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
math::MTX34Copy(pW, pW1);
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::VEC3 trans(pS1->x * pResult->rt._03, pS1->y * pResult->rt._13,
pS1->z * pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
}
} else if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34Copy(pW, &pResult->rt);
pW->_03 *= pS1->x;
pW->_13 *= pS1->y;
pW->_23 *= pS1->z;
math::MTX34Mult(pW, pW1, pW);
}
if (flag & ChrAnmResult::FLAG_SCALE_UNIFORM) {
newAttr = detail::WorldMtxAttr::AnmScaleUniform(newAttr);
} else {
@@ -1,4 +1,4 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -6,7 +6,7 @@ namespace detail {
namespace dcc {
namespace {
void MakeTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_S(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = rSrt.Su;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -18,7 +18,7 @@ void MakeTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = 1.0f - rSrt.Sv;
}
void MakeTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_R(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -33,7 +33,7 @@ void MakeTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = 1.0f - cosR;
}
void MakeTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_T(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = 1.0f;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -45,7 +45,7 @@ void MakeTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Tv;
}
void MakeTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_SR(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -65,7 +65,7 @@ void MakeTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = -svcr + 1.0f;
}
void MakeTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_RT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -80,7 +80,7 @@ void MakeTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = (-cosR - sinR * rSrt.Tu) + cosR * rSrt.Tv + 1.0f;
}
void MakeTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_ST(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 = rSrt.Su;
pMtx->_01 = 0.0f;
pMtx->_02 = 0.0f;
@@ -92,7 +92,7 @@ void MakeTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Sv * (rSrt.Tv - 1.0f) + 1.0f;
}
void MakeTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
void MakeTexSrtMtx_SRT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -112,7 +112,7 @@ void MakeTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = (-svcr - svsr * rSrt.Tu) + svcr * rSrt.Tv + 1.0f;
}
void ProductTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_S(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 *= rSrt.Su;
pMtx->_01 *= rSrt.Su;
pMtx->_02 *= rSrt.Su;
@@ -124,7 +124,7 @@ void ProductTexSrtMtx_S(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = rSrt.Sv * (pMtx->_13 - 1.0f) + 1.0f;
}
void ProductTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_R(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -150,12 +150,12 @@ void ProductTexSrtMtx_R(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_T(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_T(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_03 -= rSrt.Tu;
pMtx->_13 += rSrt.Tv;
}
void ProductTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_SR(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -187,7 +187,7 @@ void ProductTexSrtMtx_SR(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_RT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -221,7 +221,7 @@ void ProductTexSrtMtx_RT(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = _1x;
}
void ProductTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_ST(math::MTX34 *pMtx, const TexSrt &rSrt) {
pMtx->_00 *= rSrt.Su;
pMtx->_01 *= rSrt.Su;
pMtx->_02 *= rSrt.Su;
@@ -233,7 +233,7 @@ void ProductTexSrtMtx_ST(math::MTX34* pMtx, const TexSrt& rSrt) {
pMtx->_13 = (pMtx->_13 + rSrt.Tv - 1.0f) * rSrt.Sv + 1.0f;
}
void ProductTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
void ProductTexSrtMtx_SRT(math::MTX34 *pMtx, const TexSrt &rSrt) {
f32 sinR, cosR;
f32 _0x, _1x;
math::SinCosDeg(&sinR, &cosR, rSrt.R);
@@ -274,10 +274,9 @@ void ProductTexSrtMtx_SRT(math::MTX34* pMtx, const TexSrt& rSrt) {
} // namespace
typedef void (*CalcTexMtxFunc)(math::MTX34* pMtx, const TexSrt& rSrt);
typedef void (*CalcTexMtxFunc)(math::MTX34 *pMtx, const TexSrt &rSrt);
bool CalcTexMtx_Xsi(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
TexSrt::Flag flag) {
bool CalcTexMtx_Xsi(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag) {
// Extract S/R/T flags
u32 index = flag >> 1 & 0b111;
@@ -320,12 +319,39 @@ bool CalcTexMtx_Xsi(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
return true;
}
u32 CalcWorldMtx_Xsi(math::MTX34* pW, math::VEC3* pS, const math::MTX34* pW1,
const math::VEC3* pS1, u32 attr,
const ChrAnmResult* pResult) {
u32 CalcWorldMtx_Xsi(
math::MTX34 *pW, math::VEC3 *pS, const math::MTX34 *pW1, const math::VEC3 *pS1, u32 attr,
const ChrAnmResult *pResult
) {
u32 flag = pResult->flags;
u32 newAttr = attr;
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) || (flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
math::MTX34Copy(pW, pW1);
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsAllScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::VEC3 trans(pS1->x * pResult->rt._03, pS1->y * pResult->rt._13, pS1->z * pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
}
} else if (detail::WorldMtxAttr::IsAllScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34 m;
math::MTX34Copy(&m, &pResult->rt);
m._03 *= pS1->x;
m._13 *= pS1->y;
m._23 *= pS1->z;
math::MTX34Mult(pW, pW1, &m);
}
if (flag & ChrAnmResult::FLAG_SCALE_ONE) {
newAttr = detail::WorldMtxAttr::AnmScaleOne(newAttr);
*pS = *pS1;
@@ -336,34 +362,6 @@ u32 CalcWorldMtx_Xsi(math::MTX34* pW, math::VEC3* pS, const math::MTX34* pW1,
pS->z = pS1->z * pResult->s.z;
}
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) ||
(flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
math::MTX34Copy(pW, pW1);
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsAllScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::VEC3 trans(pS1->x * pResult->rt._03, pS1->y * pResult->rt._13,
pS1->z * pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
}
} else if (detail::WorldMtxAttr::IsAllScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34Copy(pW, &pResult->rt);
pW->_03 *= pS1->x;
pW->_13 *= pS1->y;
pW->_23 *= pS1->z;
math::MTX34Mult(pW, pW1, pW);
}
if (flag & ChrAnmResult::FLAG_SCALE_UNIFORM) {
newAttr = detail::WorldMtxAttr::AnmScaleUniform(newAttr);
} else {
+42 -10
View File
@@ -1,8 +1,9 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include "nw4r/math/math_types.h"
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
#include <cmath.h>
@@ -78,7 +79,7 @@ AnmObjChrRes *AnmObjChr::Detach(int idx) {
return NULL;
}
void AnmObjChr::SetWeight(int idx, f32 weight){
void AnmObjChr::SetWeight(int idx, f32 weight) {
#pragma unused(idx)
#pragma unused(weight)
}
@@ -479,6 +480,17 @@ const ChrAnmResult *AnmObjChrBlend::GetResult(ChrAnmResult *pResult, u32 idx) {
f32 t = weight * invAddedWeight;
math::C_QUATSlerp(&rot, &rot, &q, t);
} else if (!(flags & ChrAnmResult::FLAG_ROT_ZERO)) {
if (i == 0) {
firstRot._00 = pMyResult->rt._00;
firstRot._01 = pMyResult->rt._01;
firstRot._02 = pMyResult->rt._02;
firstRot._10 = pMyResult->rt._10;
firstRot._11 = pMyResult->rt._11;
firstRot._12 = pMyResult->rt._12;
firstRot._20 = pMyResult->rt._20;
firstRot._21 = pMyResult->rt._21;
firstRot._22 = pMyResult->rt._22;
}
pResult->rt._00 += pMyResult->rt._00 * ratio;
pResult->rt._01 += pMyResult->rt._01 * ratio;
pResult->rt._02 += pMyResult->rt._02 * ratio;
@@ -487,6 +499,9 @@ const ChrAnmResult *AnmObjChrBlend::GetResult(ChrAnmResult *pResult, u32 idx) {
pResult->rt._11 += pMyResult->rt._11 * ratio;
pResult->rt._12 += pMyResult->rt._12 * ratio;
} else {
if (i == 0) {
math::MTX33Identity(&firstRot);
}
pResult->rt._00 += ratio;
pResult->rt._11 += ratio;
}
@@ -523,9 +538,21 @@ const ChrAnmResult *AnmObjChrBlend::GetResult(ChrAnmResult *pResult, u32 idx) {
math::VEC3 *pV2 = reinterpret_cast<math::VEC3 *>(&pResult->rt._20);
math::VEC3Cross(pV2, pV0, pV1);
math::VEC3Normalize(pV0, pV0);
math::VEC3Normalize(pV2, pV2);
math::VEC3Cross(pV1, pV2, pV0);
if (math::VEC3LenSq(pV0) == 0.f || math::VEC3LenSq(pV2) == 0.f) {
pResult->rt._00 = firstRot._00;
pResult->rt._01 = firstRot._01;
pResult->rt._02 = firstRot._02;
pResult->rt._10 = firstRot._10;
pResult->rt._11 = firstRot._11;
pResult->rt._12 = firstRot._12;
pResult->rt._20 = firstRot._20;
pResult->rt._21 = firstRot._21;
pResult->rt._22 = firstRot._22;
} else {
math::VEC3Normalize(pV0, pV0);
math::VEC3Normalize(pV2, pV2);
math::VEC3Cross(pV1, pV2, pV0);
}
}
pResult->flags &= ~ChrAnmResult::FLAG_ROT_RAW_FMT;
@@ -606,6 +633,9 @@ f32 AnmObjChrRes::GetFrame() const {
void AnmObjChrRes::SetUpdateRate(f32 rate) {
SetRate(rate);
if (rate == 0.f && mpResultCache != NULL) {
UpdateCache();
}
}
f32 AnmObjChrRes::GetUpdateRate() const {
@@ -613,10 +643,12 @@ f32 AnmObjChrRes::GetUpdateRate() const {
}
void AnmObjChrRes::UpdateFrame() {
UpdateFrm();
if (GetRate() != 0.f) {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
if (mpResultCache != NULL) {
UpdateCache();
}
}
}
+106 -127
View File
@@ -1,6 +1,6 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -15,12 +15,8 @@ NW4R_G3D_RTTI_DEF(AnmObjMatClrRes);
* AnmObjMatClr
*
******************************************************************************/
AnmObjMatClr::AnmObjMatClr(MEMAllocator* pAllocator, u16* pBindingBuf,
int numBinding)
: AnmObj(pAllocator, NULL),
mNumBinding(numBinding),
mpBinding(pBindingBuf) {
AnmObjMatClr::AnmObjMatClr(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding)
: AnmObj(pAllocator, NULL), mNumBinding(numBinding), mpBinding(pBindingBuf) {
Release();
}
@@ -40,14 +36,14 @@ void AnmObjMatClr::Release() {
SetAnmFlag(FLAG_ANM_BOUND, false);
}
AnmObjMatClrRes* AnmObjMatClr::Attach(int idx, AnmObjMatClrRes* pRes) {
AnmObjMatClrRes *AnmObjMatClr::Attach(int idx, AnmObjMatClrRes *pRes) {
#pragma unused(idx)
#pragma unused(pRes)
return NULL;
}
AnmObjMatClrRes* AnmObjMatClr::Detach(int idx) {
AnmObjMatClrRes *AnmObjMatClr::Detach(int idx) {
#pragma unused(idx)
return NULL;
@@ -60,14 +56,12 @@ void AnmObjMatClr::DetachAll() {}
* AnmObjMatClrNode
*
******************************************************************************/
AnmObjMatClrNode::AnmObjMatClrNode(MEMAllocator* pAllocator, u16* pBindingBuf,
int numBinding,
AnmObjMatClrRes** ppChildrenBuf,
int numChildren)
AnmObjMatClrNode::AnmObjMatClrNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjMatClrRes **ppChildrenBuf, int numChildren
)
: AnmObjMatClr(pAllocator, pBindingBuf, numBinding),
mChildrenArraySize(numChildren),
mpChildrenArray(ppChildrenBuf) {
for (int i = 0; i < mChildrenArraySize; i++) {
mpChildrenArray[i] = NULL;
}
@@ -77,8 +71,8 @@ AnmObjMatClrNode::~AnmObjMatClrNode() {
DetachAll();
}
AnmObjMatClrRes* AnmObjMatClrNode::Attach(int idx, AnmObjMatClrRes* pRes) {
AnmObjMatClrRes* pOld = Detach(idx);
AnmObjMatClrRes *AnmObjMatClrNode::Attach(int idx, AnmObjMatClrRes *pRes) {
AnmObjMatClrRes *pOld = Detach(idx);
bool hasAnm = false;
for (u32 i = 0; i < mNumBinding; i++) {
@@ -99,8 +93,8 @@ AnmObjMatClrRes* AnmObjMatClrNode::Attach(int idx, AnmObjMatClrRes* pRes) {
return pOld;
}
AnmObjMatClrRes* AnmObjMatClrNode::Detach(int idx) {
AnmObjMatClrRes* pOld = mpChildrenArray[idx];
AnmObjMatClrRes *AnmObjMatClrNode::Detach(int idx) {
AnmObjMatClrRes *pOld = mpChildrenArray[idx];
if (pOld != NULL) {
pOld->G3dProc(G3DPROC_DETACH_PARENT, 0, this);
@@ -111,7 +105,7 @@ AnmObjMatClrRes* AnmObjMatClrNode::Detach(int idx) {
u16 binding = BINDING_UNDEFINED;
for (int j = 0; j < mChildrenArraySize; j++) {
AnmObjMatClrRes* pChild = mpChildrenArray[j];
AnmObjMatClrRes *pChild = mpChildrenArray[j];
if (pChild == NULL || !pChild->TestDefined(i)) {
continue;
@@ -187,7 +181,7 @@ bool AnmObjMatClrNode::Bind(const ResMdl mdl) {
bool success = false;
for (int i = 0; i < mChildrenArraySize; i++) {
AnmObjMatClrRes* pChild = mpChildrenArray[i];
AnmObjMatClrRes *pChild = mpChildrenArray[i];
if (pChild == NULL) {
continue;
}
@@ -216,30 +210,30 @@ void AnmObjMatClrNode::Release() {
AnmObjMatClr::Release();
}
void AnmObjMatClrNode::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjMatClrNode::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < mChildrenArraySize; i++) {
if (mpChildrenArray[i] == pInfo) {
Detach(i);
return;
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < mChildrenArraySize; i++) {
if (mpChildrenArray[i] == pInfo) {
Detach(i);
return;
}
}
break;
}
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
@@ -248,9 +242,8 @@ void AnmObjMatClrNode::G3dProc(u32 task, u32 param, void* pInfo) {
* AnmObjMatClrOverride
*
******************************************************************************/
AnmObjMatClrOverride* AnmObjMatClrOverride::Construct(MEMAllocator* pAllocator,
u32* pSize, ResMdl mdl,
int numChildren) {
AnmObjMatClrOverride *
AnmObjMatClrOverride::Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren) {
if (!mdl.IsValid()) {
return NULL;
}
@@ -260,7 +253,7 @@ AnmObjMatClrOverride* AnmObjMatClrOverride::Construct(MEMAllocator* pAllocator,
u32 objSize = sizeof(AnmObjMatClrOverride);
u32 bindSize = bindNum * sizeof(u16);
u32 childrenSize = numChildren * sizeof(AnmObjMatClrRes*);
u32 childrenSize = numChildren * sizeof(AnmObjMatClrRes *);
u32 bindOfs = align4(objSize);
u32 childrenOfs = align4(bindOfs + bindSize);
@@ -274,7 +267,7 @@ AnmObjMatClrOverride* AnmObjMatClrOverride::Construct(MEMAllocator* pAllocator,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
@@ -289,16 +282,15 @@ AnmObjMatClrOverride* AnmObjMatClrOverride::Construct(MEMAllocator* pAllocator,
// clang-format on
}
const ClrAnmResult* AnmObjMatClrOverride::GetResult(ClrAnmResult* pResult,
u32 idx) {
const ClrAnmResult *AnmObjMatClrOverride::GetResult(ClrAnmResult *pResult, u32 idx) {
for (int i = mChildrenArraySize - 1; i >= 0; i--) {
AnmObjMatClrRes* pChild = mpChildrenArray[i];
AnmObjMatClrRes *pChild = mpChildrenArray[i];
if (pChild == NULL || !pChild->TestExistence(idx)) {
continue;
}
const ClrAnmResult* pChildResult = pChild->GetResult(pResult, idx);
const ClrAnmResult *pChildResult = pChild->GetResult(pResult, idx);
if (pChildResult->bRgbaExist != 0) {
return pChildResult;
@@ -314,9 +306,8 @@ const ClrAnmResult* AnmObjMatClrOverride::GetResult(ClrAnmResult* pResult,
* AnmObjMatClrRes
*
******************************************************************************/
AnmObjMatClrRes* AnmObjMatClrRes::Construct(MEMAllocator* pAllocator,
u32* pSize, ResAnmClr clr,
ResMdl mdl, bool cache) {
AnmObjMatClrRes *
AnmObjMatClrRes::Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmClr clr, ResMdl mdl, bool cache) {
if (!clr.IsValid() || !mdl.IsValid()) {
return NULL;
}
@@ -339,31 +330,25 @@ AnmObjMatClrRes* AnmObjMatClrRes::Construct(MEMAllocator* pAllocator,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
ClrAnmResult* pCacheBuf =
cache
? reinterpret_cast<ClrAnmResult*>(pBuffer + sizeof(AnmObjMatClrRes))
: NULL;
ClrAnmResult *pCacheBuf = cache ? reinterpret_cast<ClrAnmResult *>(pBuffer + sizeof(AnmObjMatClrRes)) : NULL;
u16* pBindingBuf =
reinterpret_cast<u16*>(cacheSize + (pBuffer + sizeof(AnmObjMatClrRes)));
u16 *pBindingBuf = reinterpret_cast<u16 *>(cacheSize + (pBuffer + sizeof(AnmObjMatClrRes)));
return new (pBuffer)
AnmObjMatClrRes(pAllocator, clr, pBindingBuf, bindNum, pCacheBuf);
return new (pBuffer) AnmObjMatClrRes(pAllocator, clr, pBindingBuf, bindNum, pCacheBuf);
}
AnmObjMatClrRes::AnmObjMatClrRes(MEMAllocator* pAllocator, ResAnmClr clr,
u16* pBindingBuf, int numBinding,
ClrAnmResult* pCacheBuf)
AnmObjMatClrRes::AnmObjMatClrRes(
MEMAllocator *pAllocator, ResAnmClr clr, u16 *pBindingBuf, int numBinding, ClrAnmResult *pCacheBuf
)
: AnmObjMatClr(pAllocator, pBindingBuf, numBinding),
FrameCtrl(0.0f, clr.GetNumFrame(), GetAnmPlayPolicy(clr.GetAnmPolicy())),
mRes(clr),
mpResultCache(pCacheBuf) {
if (mpResultCache != NULL) {
UpdateCache();
}
@@ -383,6 +368,9 @@ f32 AnmObjMatClrRes::GetFrame() const {
void AnmObjMatClrRes::SetUpdateRate(f32 rate) {
SetRate(rate);
if (rate == 0.f && mpResultCache != NULL) {
UpdateCache();
}
}
f32 AnmObjMatClrRes::GetUpdateRate() const {
@@ -390,10 +378,11 @@ f32 AnmObjMatClrRes::GetUpdateRate() const {
}
void AnmObjMatClrRes::UpdateFrame() {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
if (GetRate() != 0.f) {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
}
}
}
@@ -402,7 +391,7 @@ bool AnmObjMatClrRes::Bind(const ResMdl mdl) {
bool success = false;
for (u16 i = 0; i < numAnim; i++) {
const ResAnmClrMatData* pData = mRes.GetMatAnm(i);
const ResAnmClrMatData *pData = mRes.GetMatAnm(i);
// Seek back from name string to start of ResName
ResName name(ut::AddOffsetToPtr(pData, pData->name - 4));
@@ -420,7 +409,7 @@ bool AnmObjMatClrRes::Bind(const ResMdl mdl) {
return success;
}
const ClrAnmResult* AnmObjMatClrRes::GetResult(ClrAnmResult* pResult, u32 idx) {
const ClrAnmResult *AnmObjMatClrRes::GetResult(ClrAnmResult *pResult, u32 idx) {
u32 id = mpBinding[idx];
if (id & (BINDING_UNDEFINED | BINDING_INVALID)) {
@@ -449,24 +438,24 @@ void AnmObjMatClrRes::UpdateCache() {
}
}
void AnmObjMatClrRes::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjMatClrRes::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_UPDATEFRAME: {
UpdateFrame();
break;
}
case G3DPROC_UPDATEFRAME: {
UpdateFrame();
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
@@ -475,61 +464,51 @@ void AnmObjMatClrRes::G3dProc(u32 task, u32 param, void* pInfo) {
* ApplyClrAnmResult
*
******************************************************************************/
void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
const ClrAnmResult* pResult) {
void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev, const ClrAnmResult *pResult) {
ut::Color c;
if (pResult->bRgbaExist &
(1 << ClrAnmResult::CLA_CLR0 | 1 << ClrAnmResult::CLA_CLR1 |
1 << ClrAnmResult::CLA_AMB0 | 1 << ClrAnmResult::CLA_AMB1)) {
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_CLR0 | 1 << ClrAnmResult::CLA_CLR1 | 1 << ClrAnmResult::CLA_AMB0 |
1 << ClrAnmResult::CLA_AMB1)) {
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_CLR0)) {
GXColor& rMatColor = chan.ref().chan[0].matColor;
GXColor &rMatColor = chan.ref().chan[0].matColor;
c = rMatColor;
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_CLR0]) |
pResult->rgba[ClrAnmResult::CLA_CLR0];
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_CLR0]) | pResult->rgba[ClrAnmResult::CLA_CLR0];
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_AMB0)) {
GXColor& rMatColor = chan.ref().chan[0].ambColor;
GXColor &rMatColor = chan.ref().chan[0].ambColor;
c = rMatColor;
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_AMB0]) |
pResult->rgba[ClrAnmResult::CLA_AMB0];
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_AMB0]) | pResult->rgba[ClrAnmResult::CLA_AMB0];
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_CLR1)) {
GXColor& rMatColor = chan.ref().chan[1].matColor;
GXColor &rMatColor = chan.ref().chan[1].matColor;
c = rMatColor;
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_CLR1]) |
pResult->rgba[ClrAnmResult::CLA_CLR1];
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_CLR1]) | pResult->rgba[ClrAnmResult::CLA_CLR1];
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_AMB1)) {
GXColor& rMatColor = chan.ref().chan[1].ambColor;
GXColor &rMatColor = chan.ref().chan[1].ambColor;
c = rMatColor;
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_AMB1]) |
pResult->rgba[ClrAnmResult::CLA_AMB1];
rMatColor = (c & pResult->rgbaMask[ClrAnmResult::CLA_AMB1]) | pResult->rgba[ClrAnmResult::CLA_AMB1];
}
}
if (pResult->bRgbaExist &
(1 << ClrAnmResult::CLA_TEV0 | 1 << ClrAnmResult::CLA_TEV1 |
1 << ClrAnmResult::CLA_TEV2 | 1 << ClrAnmResult::CLA_TEVK0 |
1 << ClrAnmResult::CLA_TEVK1 | 1 << ClrAnmResult::CLA_TEVK2 |
1 << ClrAnmResult::CLA_TEVK3)) {
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEV0 | 1 << ClrAnmResult::CLA_TEV1 | 1 << ClrAnmResult::CLA_TEV2 |
1 << ClrAnmResult::CLA_TEVK0 | 1 << ClrAnmResult::CLA_TEVK1 |
1 << ClrAnmResult::CLA_TEVK2 | 1 << ClrAnmResult::CLA_TEVK3)) {
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEV0)) {
if (!tev.GXGetTevColor(GX_TEVREG0, &c)) {
c = ut::Color::BLACK;
}
tev.GXSetTevColor(GX_TEVREG0,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEV0] |
pResult->rgba[ClrAnmResult::CLA_TEV0]);
tev.GXSetTevColor(
GX_TEVREG0, c & pResult->rgbaMask[ClrAnmResult::CLA_TEV0] | pResult->rgba[ClrAnmResult::CLA_TEV0]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEV1)) {
@@ -537,9 +516,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevColor(GX_TEVREG1,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEV1] |
pResult->rgba[ClrAnmResult::CLA_TEV1]);
tev.GXSetTevColor(
GX_TEVREG1, c & pResult->rgbaMask[ClrAnmResult::CLA_TEV1] | pResult->rgba[ClrAnmResult::CLA_TEV1]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEV2)) {
@@ -547,9 +526,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevColor(GX_TEVREG2,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEV2] |
pResult->rgba[ClrAnmResult::CLA_TEV2]);
tev.GXSetTevColor(
GX_TEVREG2, c & pResult->rgbaMask[ClrAnmResult::CLA_TEV2] | pResult->rgba[ClrAnmResult::CLA_TEV2]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEVK0)) {
@@ -557,9 +536,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevKColor(GX_KCOLOR0,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK0] |
pResult->rgba[ClrAnmResult::CLA_TEVK0]);
tev.GXSetTevKColor(
GX_KCOLOR0, c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK0] | pResult->rgba[ClrAnmResult::CLA_TEVK0]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEVK1)) {
@@ -567,9 +546,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevKColor(GX_KCOLOR1,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK1] |
pResult->rgba[ClrAnmResult::CLA_TEVK1]);
tev.GXSetTevKColor(
GX_KCOLOR1, c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK1] | pResult->rgba[ClrAnmResult::CLA_TEVK1]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEVK2)) {
@@ -577,9 +556,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevKColor(GX_KCOLOR2,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK2] |
pResult->rgba[ClrAnmResult::CLA_TEVK2]);
tev.GXSetTevKColor(
GX_KCOLOR2, c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK2] | pResult->rgba[ClrAnmResult::CLA_TEVK2]
);
}
if (pResult->bRgbaExist & (1 << ClrAnmResult::CLA_TEVK3)) {
@@ -587,9 +566,9 @@ void ApplyClrAnmResult(ResMatChan chan, ResMatTevColor tev,
c = ut::Color::BLACK;
}
tev.GXSetTevKColor(GX_KCOLOR3,
c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK3] |
pResult->rgba[ClrAnmResult::CLA_TEVK3]);
tev.GXSetTevKColor(
GX_KCOLOR3, c & pResult->rgbaMask[ClrAnmResult::CLA_TEVK3] | pResult->rgba[ClrAnmResult::CLA_TEVK3]
);
}
tev.DCStore(false);
+2 -2
View File
@@ -1,6 +1,6 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
+9 -9
View File
@@ -1,11 +1,11 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <algorithm>
namespace nw4r {
namespace g3d {
void AnmScn::GetLightSetting(LightSetting* pSetting) {
void AnmScn::GetLightSetting(LightSetting *pSetting) {
const u32 numLightSet = GetLightSetMaxRefNumber();
const u32 numAmbLight = GetAmbLightMaxRefNumber();
const u32 numDiffLight = GetDiffuseLightMaxRefNumber();
@@ -21,18 +21,18 @@ void AnmScn::GetLightSetting(LightSetting* pSetting) {
}
if (numAmbLight > 0) {
AmbLightObj* pAmbObjArray = pSetting->GetAmbLightObjArray();
AmbLightObj *pAmbObjArray = pSetting->GetAmbLightObjArray();
const u32 numAmbObj = pSetting->GetNumLightObj();
const u32 numLoadableAmb = std::min(numAmbLight, numAmbObj);
for (u32 i = 0; i < numLoadableAmb; i++) {
AmbLightObj* pAmbObj = &pAmbObjArray[i];
*reinterpret_cast<u32*>(&pAmbObj->r) = GetAmbLightColor(i);
AmbLightObj *pAmbObj = &pAmbObjArray[i];
*reinterpret_cast<u32 *>(&pAmbObj->r) = GetAmbLightColor(i);
}
}
if (numDiffLight > 0) {
LightObj* pLightObjArray = pSetting->GetLightObjArray();
LightObj *pLightObjArray = pSetting->GetLightObjArray();
const u32 numLightObj = pSetting->GetNumLightObj();
const u32 numSpecLight = GetNumSpecularLight();
@@ -41,13 +41,13 @@ void AnmScn::GetLightSetting(LightSetting* pSetting) {
const u32 numLoadableLight = std::min(numLight, numLightObj);
for (u32 i = 0; i < numLoadableDiffLight; i++) {
LightObj* pObj = &pLightObjArray[i];
LightObj *pObj = &pLightObjArray[i];
pObj->Disable();
}
for (u32 i = 0; i < numLoadableDiffLight; i++) {
LightObj* pDiffObj = &pLightObjArray[i];
LightObj* pSpecObj = NULL;
LightObj *pDiffObj = &pLightObjArray[i];
LightObj *pSpecObj = NULL;
if (pDiffObj->IsEnable()) {
continue;
+84 -93
View File
@@ -1,4 +1,4 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -13,11 +13,8 @@ NW4R_G3D_RTTI_DEF(AnmObjShpRes);
* AnmObjShp
*
******************************************************************************/
AnmObjShp::AnmObjShp(MEMAllocator* pAllocator, u16* pBindingBuf, int numBinding)
: AnmObj(pAllocator, NULL),
mNumBinding(numBinding),
mpBinding(pBindingBuf) {
AnmObjShp::AnmObjShp(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding)
: AnmObj(pAllocator, NULL), mNumBinding(numBinding), mpBinding(pBindingBuf) {
Release();
}
@@ -37,14 +34,14 @@ void AnmObjShp::Release() {
SetAnmFlag(FLAG_ANM_BOUND, false);
}
AnmObjShpRes* AnmObjShp::Attach(int idx, AnmObjShpRes* pRes) {
AnmObjShpRes *AnmObjShp::Attach(int idx, AnmObjShpRes *pRes) {
#pragma unused(idx)
#pragma unused(pRes)
return NULL;
}
AnmObjShpRes* AnmObjShp::Detach(int idx) {
AnmObjShpRes *AnmObjShp::Detach(int idx) {
#pragma unused(idx)
return NULL;
@@ -68,13 +65,10 @@ void AnmObjShp::DetachAll() {}
* AnmObjShpNode
*
******************************************************************************/
AnmObjShpNode::AnmObjShpNode(MEMAllocator* pAllocator, u16* pBindingBuf,
int numBinding, AnmObjShpRes** ppChildrenBuf,
int numChildren)
: AnmObjShp(pAllocator, pBindingBuf, numBinding),
mChildrenArraySize(numChildren),
mpChildrenArray(ppChildrenBuf) {
AnmObjShpNode::AnmObjShpNode(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjShpRes **ppChildrenBuf, int numChildren
)
: AnmObjShp(pAllocator, pBindingBuf, numBinding), mChildrenArraySize(numChildren), mpChildrenArray(ppChildrenBuf) {
for (int i = 0; i < mChildrenArraySize; i++) {
mpChildrenArray[i] = NULL;
}
@@ -84,8 +78,8 @@ AnmObjShpNode::~AnmObjShpNode() {
DetachAll();
}
AnmObjShpRes* AnmObjShpNode::Attach(int idx, AnmObjShpRes* pRes) {
AnmObjShpRes* pOld = Detach(idx);
AnmObjShpRes *AnmObjShpNode::Attach(int idx, AnmObjShpRes *pRes) {
AnmObjShpRes *pOld = Detach(idx);
bool hasAnm = false;
for (u32 i = 0; i < mNumBinding; i++) {
@@ -106,8 +100,8 @@ AnmObjShpRes* AnmObjShpNode::Attach(int idx, AnmObjShpRes* pRes) {
return pOld;
}
AnmObjShpRes* AnmObjShpNode::Detach(int idx) {
AnmObjShpRes* pOld = mpChildrenArray[idx];
AnmObjShpRes *AnmObjShpNode::Detach(int idx) {
AnmObjShpRes *pOld = mpChildrenArray[idx];
if (pOld != NULL) {
pOld->G3dProc(G3DPROC_DETACH_PARENT, 0, this);
@@ -118,7 +112,7 @@ AnmObjShpRes* AnmObjShpNode::Detach(int idx) {
u16 binding = BINDING_UNDEFINED;
for (int j = 0; j < mChildrenArraySize; j++) {
AnmObjShpRes* pChild = mpChildrenArray[j];
AnmObjShpRes *pChild = mpChildrenArray[j];
if (pChild == NULL || !pChild->TestDefined(i)) {
continue;
@@ -194,7 +188,7 @@ bool AnmObjShpNode::Bind(const ResMdl mdl) {
bool success = false;
for (int i = 0; i < mChildrenArraySize; i++) {
AnmObjShpRes* pChild = mpChildrenArray[i];
AnmObjShpRes *pChild = mpChildrenArray[i];
if (pChild == NULL) {
continue;
}
@@ -223,30 +217,30 @@ void AnmObjShpNode::Release() {
AnmObjShp::Release();
}
void AnmObjShpNode::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjShpNode::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < mChildrenArraySize; i++) {
if (mpChildrenArray[i] == pInfo) {
Detach(i);
return;
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < mChildrenArraySize; i++) {
if (mpChildrenArray[i] == pInfo) {
Detach(i);
return;
}
}
break;
}
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
@@ -255,8 +249,7 @@ void AnmObjShpNode::G3dProc(u32 task, u32 param, void* pInfo) {
* AnmObjShpBlend
*
******************************************************************************/
AnmObjShpBlend* AnmObjShpBlend::Construct(MEMAllocator* pAllocator, u32* pSize,
ResMdl mdl, int numChildren) {
AnmObjShpBlend *AnmObjShpBlend::Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl, int numChildren) {
if (!mdl.IsValid()) {
return NULL;
}
@@ -264,7 +257,7 @@ AnmObjShpBlend* AnmObjShpBlend::Construct(MEMAllocator* pAllocator, u32* pSize,
int bindNum = mdl.GetResVtxPosNumEntries();
u32 bindSize = bindNum * sizeof(u16);
u32 childrenSize = numChildren * sizeof(AnmObjShpRes*);
u32 childrenSize = numChildren * sizeof(AnmObjShpRes *);
u32 weightSize = numChildren * sizeof(f32);
u32 bindOfs = ut::RoundUp(sizeof(AnmObjShpBlend), 4);
@@ -280,7 +273,7 @@ AnmObjShpBlend* AnmObjShpBlend::Construct(MEMAllocator* pAllocator, u32* pSize,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
@@ -296,28 +289,25 @@ AnmObjShpBlend* AnmObjShpBlend::Construct(MEMAllocator* pAllocator, u32* pSize,
// clang-format on
}
AnmObjShpBlend::AnmObjShpBlend(MEMAllocator* pAllocator, u16* pBindingBuf,
int numBinding, AnmObjShpRes** ppChildrenBuf,
int numChildren, f32* pWeightBuf)
: AnmObjShpNode(pAllocator, pBindingBuf, numBinding, ppChildrenBuf,
numChildren),
mpWeightArray(pWeightBuf) {
AnmObjShpBlend::AnmObjShpBlend(
MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding, AnmObjShpRes **ppChildrenBuf, int numChildren,
f32 *pWeightBuf
)
: AnmObjShpNode(pAllocator, pBindingBuf, numBinding, ppChildrenBuf, numChildren), mpWeightArray(pWeightBuf) {
for (int i = 0; i < mChildrenArraySize; i++) {
mpWeightArray[i] = 1.0f;
}
}
const ShpAnmResult* AnmObjShpBlend::GetResult(ShpAnmResult* pResult, u32 idx) {
detail::workmem::ShpAnmResultBuf* pWorkBuffer =
detail::workmem::GetShpAnmResultBufTemporary();
const ShpAnmResult *AnmObjShpBlend::GetResult(ShpAnmResult *pResult, u32 idx) {
detail::workmem::ShpAnmResultBuf *pWorkBuffer = detail::workmem::GetShpAnmResultBufTemporary();
int blendNum = 0;
f32 weightSum = 0.0f;
for (int i = 0; i < mChildrenArraySize; i++) {
f32 weight = mpWeightArray[i];
AnmObjShpRes* pChild = mpChildrenArray[i];
AnmObjShpRes *pChild = mpChildrenArray[i];
// @note Bitwise AND
if (!(pChild != NULL & weight != 0.0f)) {
@@ -328,10 +318,9 @@ const ShpAnmResult* AnmObjShpBlend::GetResult(ShpAnmResult* pResult, u32 idx) {
continue;
}
detail::workmem::ShpAnmResultBuf& rAnmBuf = pWorkBuffer[blendNum];
detail::workmem::ShpAnmResultBuf &rAnmBuf = pWorkBuffer[blendNum];
const ShpAnmResult* pMyResult =
pChild->GetResult(&rAnmBuf.resultBuf, idx);
const ShpAnmResult *pMyResult = pChild->GetResult(&rAnmBuf.resultBuf, idx);
if (!(pMyResult->flags & 1)) {
continue;
@@ -350,7 +339,7 @@ const ShpAnmResult* AnmObjShpBlend::GetResult(ShpAnmResult* pResult, u32 idx) {
}
if (blendNum == 1) {
detail::workmem::ShpAnmResultBuf& rAnmBuf = *pWorkBuffer;
detail::workmem::ShpAnmResultBuf &rAnmBuf = *pWorkBuffer;
if (rAnmBuf.pResult == &rAnmBuf.resultBuf) {
*pResult = *rAnmBuf.pResult;
@@ -368,14 +357,14 @@ const ShpAnmResult* AnmObjShpBlend::GetResult(ShpAnmResult* pResult, u32 idx) {
pResult->baseShapeWeight = 0.0f;
for (int i = 0; i < blendNum; i++) {
const ShpAnmResult* pMyResult = pWorkBuffer[i].pResult;
const ShpAnmResult *pMyResult = pWorkBuffer[i].pResult;
f32 weight = pWorkBuffer[i].weight;
f32 ratio = weight * invWeightSum;
pResult->baseShapeWeight += pMyResult->baseShapeWeight * ratio;
for (u32 myKey = 0; myKey < pMyResult->numKeyShape; myKey++) {
const BlendVtx& rMyKeyShape = pMyResult->keyShape[myKey];
const BlendVtx &rMyKeyShape = pMyResult->keyShape[myKey];
u32 otherKey;
for (otherKey = 0; otherKey < pResult->numKeyShape; otherKey++) {
@@ -410,8 +399,7 @@ f32 AnmObjShpBlend::GetWeight(int idx) const {
* AnmObjShpRes
*
******************************************************************************/
AnmObjShpRes* AnmObjShpRes::Construct(MEMAllocator* pAllocator, u32* pSize,
ResAnmShp shp, ResMdl mdl, bool cache) {
AnmObjShpRes *AnmObjShpRes::Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmShp shp, ResMdl mdl, bool cache) {
if (!shp.IsValid() || !mdl.IsValid()) {
return NULL;
}
@@ -439,33 +427,30 @@ AnmObjShpRes* AnmObjShpRes::Construct(MEMAllocator* pAllocator, u32* pSize,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
u16* const pBindingBuf = reinterpret_cast<u16*>(pBuffer + bindOfs);
u16 *const pBindingBuf = reinterpret_cast<u16 *>(pBuffer + bindOfs);
ShpAnmVtxSet* const pVtxSetBuf =
reinterpret_cast<ShpAnmVtxSet*>(pBuffer + vtxSetOfs);
ShpAnmVtxSet *const pVtxSetBuf = reinterpret_cast<ShpAnmVtxSet *>(pBuffer + vtxSetOfs);
ShpAnmResult* const pCacheBuf =
reinterpret_cast<ShpAnmResult*>(pBuffer + cacheOfs);
ShpAnmResult *const pCacheBuf = reinterpret_cast<ShpAnmResult *>(pBuffer + cacheOfs);
return new (pBuffer)
AnmObjShpRes(pAllocator, shp, pBindingBuf, pVtxSetBuf, bindNum,
cacheSize != 0 ? pCacheBuf : NULL);
AnmObjShpRes(pAllocator, shp, pBindingBuf, pVtxSetBuf, bindNum, cacheSize != 0 ? pCacheBuf : NULL);
}
AnmObjShpRes::AnmObjShpRes(MEMAllocator* pAllocator, ResAnmShp shp,
u16* pBindingBuf, ShpAnmVtxSet* pVtxSetBuf,
int numBinding, ShpAnmResult* pCacheBuf)
AnmObjShpRes::AnmObjShpRes(
MEMAllocator *pAllocator, ResAnmShp shp, u16 *pBindingBuf, ShpAnmVtxSet *pVtxSetBuf, int numBinding,
ShpAnmResult *pCacheBuf
)
: AnmObjShp(pAllocator, pBindingBuf, numBinding),
FrameCtrl(0.0f, shp.GetNumFrame(), GetAnmPlayPolicy(shp.GetAnmPolicy())),
mRes(shp),
mpVtxSetArray(pVtxSetBuf),
mpResultCache(pCacheBuf) {
if (mpResultCache != NULL) {
UpdateCache();
}
@@ -485,6 +470,10 @@ f32 AnmObjShpRes::GetFrame() const {
void AnmObjShpRes::SetUpdateRate(f32 rate) {
SetRate(rate);
if (rate == 0.f && mpResultCache != NULL) {
UpdateCache();
}
}
f32 AnmObjShpRes::GetUpdateRate() const {
@@ -492,10 +481,12 @@ f32 AnmObjShpRes::GetUpdateRate() const {
}
void AnmObjShpRes::UpdateFrame() {
UpdateFrm();
if (GetRate() != 0.f) {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
if (mpResultCache != NULL) {
UpdateCache();
}
}
}
@@ -504,7 +495,7 @@ bool AnmObjShpRes::Bind(const ResMdl mdl) {
u32 numAnim = mRes.GetShapeAnmNumEntries();
for (u16 i = 0; i < numAnim; i++) {
const ResAnmShpAnmData* pData = mRes.GetShapeAnm(i);
const ResAnmShpAnmData *pData = mRes.GetShapeAnm(i);
// Seek back from name string to start of ResName
ResName name(ut::AddOffsetToPtr(pData, pData->name - 4));
@@ -519,10 +510,10 @@ bool AnmObjShpRes::Bind(const ResMdl mdl) {
}
int nameNum = mRes.GetNumVtxNames();
const s32* pVtxNameArray = mRes.GetVtxNameArray();
const s32 *pVtxNameArray = mRes.GetVtxNameArray();
for (int i = 0; i < nameNum; i++) {
ShpAnmVtxSet& rSet = mpVtxSetArray[i];
ShpAnmVtxSet &rSet = mpVtxSetArray[i];
s32 offset = pVtxNameArray[i];
// Seek back from name string to start of ResName
@@ -537,7 +528,7 @@ bool AnmObjShpRes::Bind(const ResMdl mdl) {
return success;
}
const ShpAnmResult* AnmObjShpRes::GetResult(ShpAnmResult* pResult, u32 idx) {
const ShpAnmResult *AnmObjShpRes::GetResult(ShpAnmResult *pResult, u32 idx) {
u32 id = mpBinding[idx];
if (id & (BINDING_UNDEFINED | BINDING_INVALID)) {
@@ -566,24 +557,24 @@ void AnmObjShpRes::UpdateCache() {
}
}
void AnmObjShpRes::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjShpRes::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_UPDATEFRAME: {
UpdateFrame();
break;
}
case G3DPROC_UPDATEFRAME: {
UpdateFrame();
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
+11 -6
View File
@@ -1,8 +1,8 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -371,6 +371,9 @@ f32 AnmObjTexPatRes::GetFrame() const {
void AnmObjTexPatRes::SetUpdateRate(f32 rate) {
SetRate(rate);
if (rate == 0.f && mpResultCache != NULL) {
UpdateCache();
}
}
f32 AnmObjTexPatRes::GetUpdateRate() const {
@@ -378,10 +381,12 @@ f32 AnmObjTexPatRes::GetUpdateRate() const {
}
void AnmObjTexPatRes::UpdateFrame() {
UpdateFrm();
if (GetRate() != 0.f) {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
if (mpResultCache != NULL) {
UpdateCache();
}
}
}
+28 -22
View File
@@ -1,8 +1,8 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/GX.h>
#include "rvl/GX.h" // IWYU pragma: export
#include <cmath>
@@ -296,12 +296,13 @@ const TexSrtAnmResult *AnmObjTexSrtOverride::GetResult(TexSrtAnmResult *pResult,
const TexSrtAnmResult *pChildResult = pChild->GetResult(pResult, idx);
if (pChildResult->flags != 0) {
if (pChildResult->flags != 0 || pChildResult->indFlags != 0) {
return pChildResult;
}
}
pResult->flags = 0;
pResult->indFlags = 0;
return pResult;
}
@@ -372,6 +373,9 @@ f32 AnmObjTexSrtRes::GetFrame() const {
void AnmObjTexSrtRes::SetUpdateRate(f32 rate) {
SetRate(rate);
if (rate == 0.f && mpResultCache != NULL) {
UpdateCache();
}
}
f32 AnmObjTexSrtRes::GetUpdateRate() const {
@@ -379,10 +383,12 @@ f32 AnmObjTexSrtRes::GetUpdateRate() const {
}
void AnmObjTexSrtRes::UpdateFrame() {
UpdateFrm();
if (GetRate() != 0.f) {
UpdateFrm();
if (mpResultCache != NULL) {
UpdateCache();
if (mpResultCache != NULL) {
UpdateCache();
}
}
}
@@ -414,6 +420,7 @@ const TexSrtAnmResult *AnmObjTexSrtRes::GetResult(TexSrtAnmResult *pResult, u32
if (id & (BINDING_UNDEFINED | BINDING_INVALID)) {
pResult->flags = 0;
pResult->indFlags = 0;
return pResult;
}
@@ -466,12 +473,13 @@ void AnmObjTexSrtRes::G3dProc(u32 task, u32 param, void *pInfo) {
******************************************************************************/
void ApplyTexSrtAnmResult(ResTexSrt srt, const TexSrtAnmResult *pResult) {
ResTexSrtData &r = srt.ref();
u32 flags = pResult->flags;
u32 mdlFlags = r.flag;
u32 anmFlags = pResult->flags;
u32 mask = 0x0F;
for (int i = 0; flags != 0; flags >>= TexSrt::NUM_OF_FLAGS, mask <<= 4, i++) {
if (!(flags & 1)) {
for (int i = 0; mdlFlags != 0 && anmFlags != 0;
mdlFlags >>= TexSrt::NUM_OF_FLAGS, anmFlags >>= TexSrt::NUM_OF_FLAGS, mask <<= 4, i++) {
if (!(mdlFlags & TexSrt::FLAG_ANM_EXISTS) || !(anmFlags & TexSrt::FLAG_ANM_EXISTS)) {
continue;
}
@@ -482,6 +490,7 @@ void ApplyTexSrtAnmResult(ResTexSrt srt, const TexSrtAnmResult *pResult) {
}
void ApplyTexSrtAnmResult(ResTexSrt srt, ResMatIndMtxAndScale ind, const TexSrtAnmResult *pResult) {
// I need this to not inline :(
ApplyTexSrtAnmResult(srt, pResult);
u32 flags = pResult->indFlags;
@@ -493,23 +502,20 @@ void ApplyTexSrtAnmResult(ResTexSrt srt, ResMatIndMtxAndScale ind, const TexSrtA
math::MTX34 mtx;
CalcTexMtx(
&mtx, true, pResult->srt[i], static_cast<TexSrt::Flag>(flags & TexSrt::FLAGSET_IDENTITY),
TexSrtTypedef::TEXMATRIXMODE_MAYA
);
CalcTexMtx(&mtx, true, pResult->srt[i], static_cast<TexSrt::Flag>(flags & TexSrt::FLAGSET_IDENTITY));
s8 scaleExp;
f32 maxElem = 0.000000000000000001f;
maxElem = ut::Max(maxElem, math::FAbs(mtx._00));
maxElem = ut::Max(maxElem, math::FAbs(mtx._01));
maxElem = ut::Max(maxElem, math::FAbs(mtx._03));
maxElem = ut::Max(maxElem, math::FAbs(mtx._10));
maxElem = ut::Max(maxElem, math::FAbs(mtx._11));
maxElem = ut::Max(maxElem, math::FAbs(mtx._13));
maxElem = ut::Max(maxElem, ut::Abs(mtx._00));
maxElem = ut::Max(maxElem, ut::Abs(mtx._01));
maxElem = ut::Max(maxElem, ut::Abs(mtx._03));
maxElem = ut::Max(maxElem, ut::Abs(mtx._10));
maxElem = ut::Max(maxElem, ut::Abs(mtx._11));
maxElem = ut::Max(maxElem, ut::Abs(mtx._13));
scaleExp = static_cast<s8>(math::FGetExpPart(maxElem) + 1);
f32 invScale = 0.f; // TODO: ldexpf(1.0f, -scaleExp);
f32 invScale = std::ldexp(1.0f, -scaleExp); // TODO ldexpf rename
mtx._00 *= invScale;
mtx._01 *= invScale;
+60 -68
View File
@@ -1,6 +1,6 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -15,11 +15,8 @@ NW4R_G3D_RTTI_DEF(AnmObjVisRes);
* AnmObjVis
*
******************************************************************************/
AnmObjVis::AnmObjVis(MEMAllocator* pAllocator, u16* pBindingBuf, int numBinding)
: AnmObj(pAllocator, NULL),
mpBinding(pBindingBuf),
mNumBinding(numBinding) {
AnmObjVis::AnmObjVis(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding)
: AnmObj(pAllocator, NULL), mpBinding(pBindingBuf), mNumBinding(numBinding) {
Release();
}
@@ -39,14 +36,14 @@ void AnmObjVis::Release() {
SetAnmFlag(FLAG_ANM_BOUND, false);
}
AnmObjVisRes* AnmObjVis::Attach(int idx, AnmObjVisRes* pRes) {
AnmObjVisRes *AnmObjVis::Attach(int idx, AnmObjVisRes *pRes) {
#pragma unused(idx)
#pragma unused(pRes)
return NULL;
}
AnmObjVisRes* AnmObjVis::Detach(int idx) {
AnmObjVisRes *AnmObjVis::Detach(int idx) {
#pragma unused(idx)
return NULL;
@@ -58,24 +55,24 @@ void AnmObjVis::DetachAll() {
}
}
void AnmObjVis::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjVis::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_UPDATEFRAME: {
SetAnmFlag(FLAG_CACHE_OBSOLETE, true);
break;
}
case G3DPROC_UPDATEFRAME: {
SetAnmFlag(FLAG_CACHE_OBSOLETE, true);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
@@ -84,10 +81,8 @@ void AnmObjVis::G3dProc(u32 task, u32 param, void* pInfo) {
* AnmObjVisNode
*
******************************************************************************/
AnmObjVisNode::AnmObjVisNode(MEMAllocator* pAllocator, u16* pBindingBuf,
int numBinding)
AnmObjVisNode::AnmObjVisNode(MEMAllocator *pAllocator, u16 *pBindingBuf, int numBinding)
: AnmObjVis(pAllocator, pBindingBuf, numBinding) {
for (int i = 0; i < MAX_CHILD; i++) {
mpChildren[i] = NULL;
}
@@ -97,8 +92,8 @@ AnmObjVisNode::~AnmObjVisNode() {
DetachAll();
}
AnmObjVisRes* AnmObjVisNode::Attach(int idx, AnmObjVisRes* pRes) {
AnmObjVisRes* pOld = Detach(idx);
AnmObjVisRes *AnmObjVisNode::Attach(int idx, AnmObjVisRes *pRes) {
AnmObjVisRes *pOld = Detach(idx);
bool hasAnm = false;
for (u32 i = 0; i < mNumBinding; i++) {
@@ -119,8 +114,8 @@ AnmObjVisRes* AnmObjVisNode::Attach(int idx, AnmObjVisRes* pRes) {
return pOld;
}
AnmObjVisRes* AnmObjVisNode::Detach(int idx) {
AnmObjVisRes* pOld = mpChildren[idx];
AnmObjVisRes *AnmObjVisNode::Detach(int idx) {
AnmObjVisRes *pOld = mpChildren[idx];
if (pOld != NULL) {
pOld->G3dProc(G3DPROC_DETACH_PARENT, 0, this);
@@ -131,7 +126,7 @@ AnmObjVisRes* AnmObjVisNode::Detach(int idx) {
u16 binding = BINDING_UNDEFINED;
for (int j = 0; j < MAX_CHILD; j++) {
AnmObjVisRes* pChild = mpChildren[j];
AnmObjVisRes *pChild = mpChildren[j];
if (pChild == NULL || !pChild->TestDefined(i)) {
continue;
@@ -201,7 +196,7 @@ bool AnmObjVisNode::Bind(ResMdl mdl) {
bool success = false;
for (int i = 0; i < MAX_CHILD; i++) {
AnmObjVisRes* pChild = mpChildren[i];
AnmObjVisRes *pChild = mpChildren[i];
if (pChild == NULL) {
continue;
}
@@ -230,30 +225,30 @@ void AnmObjVisNode::Release() {
AnmObjVis::Release();
}
void AnmObjVisNode::G3dProc(u32 task, u32 param, void* pInfo) {
void AnmObjVisNode::G3dProc(u32 task, u32 param, void *pInfo) {
#pragma unused(param)
switch (task) {
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < MAX_CHILD; i++) {
if (mpChildren[i] == pInfo) {
Detach(i);
return;
case G3DPROC_CHILD_DETACHED: {
for (int i = 0; i < MAX_CHILD; i++) {
if (mpChildren[i] == pInfo) {
Detach(i);
return;
}
}
break;
}
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_DETACH_PARENT: {
SetParent(NULL);
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj*>(pInfo));
break;
}
case G3DPROC_ATTACH_PARENT: {
SetParent(static_cast<G3dObj *>(pInfo));
break;
}
}
}
@@ -262,8 +257,7 @@ void AnmObjVisNode::G3dProc(u32 task, u32 param, void* pInfo) {
* AnmObjVisOR
*
******************************************************************************/
AnmObjVisOR* AnmObjVisOR::Construct(MEMAllocator* pAllocator, u32* pSize,
ResMdl mdl) {
AnmObjVisOR *AnmObjVisOR::Construct(MEMAllocator *pAllocator, u32 *pSize, ResMdl mdl) {
if (!mdl.IsValid()) {
return NULL;
}
@@ -282,22 +276,21 @@ AnmObjVisOR* AnmObjVisOR::Construct(MEMAllocator* pAllocator, u32* pSize,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
u16* pBindingBuf = reinterpret_cast<u16*>(pBuffer + sizeof(AnmObjVisOR));
u16 *pBindingBuf = reinterpret_cast<u16 *>(pBuffer + sizeof(AnmObjVisOR));
AnmObjVisOR* pObjVis =
new (pBuffer) AnmObjVisOR(pAllocator, pBindingBuf, bindNum);
AnmObjVisOR *pObjVis = new (pBuffer) AnmObjVisOR(pAllocator, pBindingBuf, bindNum);
return pObjVis;
}
bool AnmObjVisOR::GetResult(u32 idx) {
for (int i = 0; i < MAX_CHILD; i++) {
AnmObjVisRes* pChild = mpChildren[i];
AnmObjVisRes *pChild = mpChildren[i];
if (pChild == NULL || !pChild->TestExistence(idx)) {
continue;
@@ -316,8 +309,7 @@ bool AnmObjVisOR::GetResult(u32 idx) {
* AnmObjVisRes
*
******************************************************************************/
AnmObjVisRes* AnmObjVisRes::Construct(MEMAllocator* pAllocator, u32* pSize,
ResAnmVis vis, ResMdl mdl) {
AnmObjVisRes *AnmObjVisRes::Construct(MEMAllocator *pAllocator, u32 *pSize, ResAnmVis vis, ResMdl mdl) {
if (!vis.IsValid() || !mdl.IsValid()) {
return NULL;
}
@@ -336,21 +328,19 @@ AnmObjVisRes* AnmObjVisRes::Construct(MEMAllocator* pAllocator, u32* pSize,
return NULL;
}
u8* pBuffer = reinterpret_cast<u8*>(Alloc(pAllocator, size));
u8 *pBuffer = reinterpret_cast<u8 *>(Alloc(pAllocator, size));
if (pBuffer == NULL) {
return NULL;
}
u16* pBindingBuf = reinterpret_cast<u16*>(pBuffer + sizeof(AnmObjVisRes));
u16 *pBindingBuf = reinterpret_cast<u16 *>(pBuffer + sizeof(AnmObjVisRes));
AnmObjVisRes* pObjVis =
new (pBuffer) AnmObjVisRes(pAllocator, vis, pBindingBuf, bindNum);
AnmObjVisRes *pObjVis = new (pBuffer) AnmObjVisRes(pAllocator, vis, pBindingBuf, bindNum);
return pObjVis;
}
AnmObjVisRes::AnmObjVisRes(MEMAllocator* pAllocator, ResAnmVis vis,
u16* pBindingBuf, int numBinding)
AnmObjVisRes::AnmObjVisRes(MEMAllocator *pAllocator, ResAnmVis vis, u16 *pBindingBuf, int numBinding)
: AnmObjVis(pAllocator, pBindingBuf, numBinding),
FrameCtrl(0.0f, vis.GetNumFrame(), GetAnmPlayPolicy(vis.GetAnmPolicy())),
mRes(vis) {}
@@ -373,8 +363,10 @@ f32 AnmObjVisRes::GetUpdateRate() const {
}
void AnmObjVisRes::UpdateFrame() {
UpdateFrm();
G3dProc(G3DPROC_UPDATEFRAME, 0, NULL);
if (GetRate() != 0.f) {
UpdateFrm();
G3dProc(G3DPROC_UPDATEFRAME, 0, NULL);
}
}
bool AnmObjVisRes::Bind(ResMdl mdl) {
@@ -382,7 +374,7 @@ bool AnmObjVisRes::Bind(ResMdl mdl) {
bool success = false;
for (u16 i = 0; i < numAnim; i++) {
const ResAnmVisAnmData* pData = mRes.GetNodeAnm(i);
const ResAnmVisAnmData *pData = mRes.GetNodeAnm(i);
// Seek back from name string to start of ResName
ResName name(ut::AddOffsetToPtr(pData, pData->name - 4));
@@ -415,7 +407,7 @@ bool AnmObjVisRes::GetResult(u32 idx) {
* ApplyVisAnmResult
*
******************************************************************************/
void ApplyVisAnmResult(ResMdl mdl, AnmObjVis* pObj) {
void ApplyVisAnmResult(ResMdl mdl, AnmObjVis *pObj) {
u32 numNode = mdl.GetResNodeNumEntries();
for (u32 i = 0; i < numNode; i++) {
@@ -428,7 +420,7 @@ void ApplyVisAnmResult(ResMdl mdl, AnmObjVis* pObj) {
}
}
void ApplyVisAnmResult(u8* byteVec, ResMdl mdl, AnmObjVis* pObj) {
void ApplyVisAnmResult(u8 *byteVec, ResMdl mdl, AnmObjVis *pObj) {
u32 numNode = mdl.GetResNodeNumEntries();
for (u32 i = 0; i < numNode; i++) {
-61
View File
@@ -1,61 +0,0 @@
#include <nw4r/g3d.h>
namespace nw4r {
namespace g3d {
namespace detail {
namespace dcc {
u32 CalcWorldMtx_Basic(math::MTX34* pW, math::VEC3* pS, const math::MTX34* pW1,
const math::VEC3* pS1, u32 attr,
const ChrAnmResult* pResult) {
u32 flag = pResult->flags;
u32 newAttr = attr;
if (flag & ChrAnmResult::FLAG_SCALE_ONE) {
newAttr = detail::WorldMtxAttr::AnmScaleOne(newAttr);
pS->x = pS->y = pS->z = 1.0f;
} else {
newAttr = detail::WorldMtxAttr::AnmNotScaleOne(newAttr);
*pS = pResult->s;
}
if ((flag & ChrAnmResult::FLAG_MTX_IDENT) ||
(flag & ChrAnmResult::FLAG_ROT_TRANS_ZERO)) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Copy(pW, pW1);
} else {
math::MTX34Scale(pW, pW1, pS1);
}
} else if (flag & ChrAnmResult::FLAG_ROT_ZERO) {
if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::VEC3 trans(pResult->rt._03, pResult->rt._13, pResult->rt._23);
math::MTX34Trans(pW, pW1, &trans);
} else {
math::MTX34 temp;
math::MTX34Scale(&temp, pS1, &pResult->rt);
math::MTX34Mult(pW, pW1, &temp);
}
} else if (detail::WorldMtxAttr::IsScaleOne(attr)) {
math::MTX34Mult(pW, pW1, &pResult->rt);
} else {
math::MTX34Scale(pW, pW1, pS1);
math::MTX34Mult(pW, pW, &pResult->rt);
}
if (flag & ChrAnmResult::FLAG_SCALE_UNIFORM) {
newAttr = detail::WorldMtxAttr::AnmScaleUniform(newAttr);
} else {
newAttr = detail::WorldMtxAttr::AnmNotScaleUniform(newAttr);
}
return newAttr;
}
} // namespace dcc
} // namespace detail
} // namespace g3d
} // namespace nw4r
+6 -9
View File
@@ -1,11 +1,9 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat* pAnmTexPat,
AnmObjTexSrt* pAnmTexSrt, AnmObjMatClr* pAnmMatClr) {
void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat *pAnmTexPat, AnmObjTexSrt *pAnmTexSrt, AnmObjMatClr *pAnmMatClr) {
u32 i;
u32 numMatID = mdl.GetResMatNumEntries();
@@ -14,12 +12,11 @@ void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat* pAnmTexPat,
if (pAnmTexPat != NULL && pAnmTexPat->TestExistence(i)) {
TexPatAnmResult result;
const TexPatAnmResult* pResult;
const TexPatAnmResult *pResult;
pResult = pAnmTexPat->GetResult(&result, i);
ApplyTexPatAnmResult(mat.GetResTexObj(), mat.GetResTlutObj(),
pResult);
ApplyTexPatAnmResult(mat.GetResTexObj(), mat.GetResTlutObj(), pResult);
mat.GetResTexObj().EndEdit();
mat.GetResTlutObj().EndEdit();
@@ -27,7 +24,7 @@ void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat* pAnmTexPat,
if (pAnmTexSrt != NULL && pAnmTexSrt->TestExistence(i)) {
TexSrtAnmResult result;
const TexSrtAnmResult* pResult;
const TexSrtAnmResult *pResult;
ResTexSrt srt = mat.GetResTexSrt();
ResMatIndMtxAndScale ind = mat.GetResMatIndMtxAndScale();
@@ -42,7 +39,7 @@ void CalcMaterialDirectly(ResMdl mdl, AnmObjTexPat* pAnmTexPat,
if (pAnmMatClr != NULL && pAnmMatClr->TestExistence(i)) {
ClrAnmResult result;
const ClrAnmResult* pResult;
const ClrAnmResult *pResult;
ResMatTevColor tevColor = mat.GetResMatTevColor();
ResMatChan chan = mat.GetResMatChan();
File diff suppressed because it is too large Load Diff
+45 -54
View File
@@ -1,13 +1,14 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
ResVtxNrmData** ppVtxNrmTable, ResVtxClrData** ppVtxClrTable) {
void CalcVtx(
ResMdl mdl, AnmObjShp *pAnmShp, ResVtxPosData **ppVtxPosTable, ResVtxNrmData **ppVtxNrmTable,
ResVtxClrData **ppVtxClrTable
) {
// Allows struct offsets inside assembly
using nw4r::math::VEC3;
using nw4r::ut::Color;
@@ -20,7 +21,7 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
}
ShpAnmResult result;
const ShpAnmResult* pResult = pAnmShp->GetResult(&result, id);
const ShpAnmResult *pResult = pAnmShp->GetResult(&result, id);
if (!(pResult->flags & ShpAnmResult::FLAG_ANM_EXISTS)) {
continue;
@@ -28,7 +29,7 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
if (pResult->flags & ShpAnmResult::FLAG_ANM_VTXPOS) {
struct KeyShape {
const math::VEC3* pVtx; // at 0x0
const math::VEC3 *pVtx; // at 0x0
f32 weight; // at 0x4
};
@@ -38,14 +39,13 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
int numKeyShape = 0;
ResVtxPos vtxPos(ppVtxPosTable[id]);
math::VEC3* pVtxPosBuf = static_cast<math::VEC3*>(vtxPos.GetData());
math::VEC3 *pVtxPosBuf = static_cast<math::VEC3 *>(vtxPos.GetData());
if (pResult->baseShapeWeight != 0.0f) {
const math::VEC3* pBase;
const math::VEC3 *pBase;
u8 stride;
basePos.GetArray(reinterpret_cast<const void**>(&pBase),
&stride);
basePos.GetArray(reinterpret_cast<const void **>(&pBase), &stride);
keyShape[numKeyShape].pVtx = pBase;
keyShape[numKeyShape].weight = pResult->baseShapeWeight;
@@ -58,10 +58,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
}
ResVtxPos key(pResult->keyShape[i].vtxSet.resVtxPos);
const void* pData = key.GetData();
const void *pData = key.GetData();
keyShape[numKeyShape].pVtx =
static_cast<const math::VEC3*>(pData);
keyShape[numKeyShape].pVtx = static_cast<const math::VEC3 *>(pData);
keyShape[numKeyShape].weight = pResult->keyShape[i].weight;
numKeyShape++;
}
@@ -73,14 +72,14 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(pVtxPosBuf) + numVtx * sizeof(math::VEC3));
// clang-format on
const KeyShape* const pKeyEnd = keyShape + numKeyShape;
const KeyShape *const pKeyEnd = keyShape + numKeyShape;
for (; pVtxPosBuf < pVtxPosBufEnd; pVtxPosBuf++) {
register f32 xy, z_;
KeyShape& rFirst = keyShape[0];
KeyShape &rFirst = keyShape[0];
register f32 firstWeight = rFirst.weight;
register const void* pVtx = rFirst.pVtx;
register const void *pVtx = rFirst.pVtx;
// clang-format off
asm {
@@ -96,9 +95,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(rFirst.pVtx) + sizeof(math::VEC3));
// clang-format on
for (KeyShape* pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
for (KeyShape *pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
register f32 keyWeight = pKey->weight;
register const void* pKeyVtx = pKey->pVtx;
register const void *pKeyVtx = pKey->pVtx;
register f32 key_xy, key_z_;
// clang-format off
@@ -116,7 +115,7 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
// clang-format on
}
register void* pDst = pVtxPosBuf;
register void *pDst = pVtxPosBuf;
// clang-format off
asm {
@@ -129,11 +128,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
DC::StoreRange(vtxPos.GetData(), numVtx * sizeof(math::VEC3));
}
if ((pResult->flags & ShpAnmResult::FLAG_ANM_VTXNRM) &&
ppVtxNrmTable != NULL) {
if ((pResult->flags & ShpAnmResult::FLAG_ANM_VTXNRM) && ppVtxNrmTable != NULL) {
struct KeyShape {
const math::VEC3* pVtx; // at 0x0
const math::VEC3 *pVtx; // at 0x0
f32 weight; // at 0x4
};
@@ -143,14 +140,13 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
int numKeyShape = 0;
ResVtxNrm vtxNrm(ppVtxNrmTable[baseNrm.GetID()]);
math::VEC3* pVtxNrmBuf = static_cast<math::VEC3*>(vtxNrm.GetData());
math::VEC3 *pVtxNrmBuf = static_cast<math::VEC3 *>(vtxNrm.GetData());
if (pResult->baseShapeWeight != 0.0f) {
const math::VEC3* pBase;
const math::VEC3 *pBase;
u8 stride;
baseNrm.GetArray(reinterpret_cast<const void**>(&pBase),
&stride);
baseNrm.GetArray(reinterpret_cast<const void **>(&pBase), &stride);
keyShape[numKeyShape].pVtx = pBase;
keyShape[numKeyShape].weight = pResult->baseShapeWeight;
@@ -163,10 +159,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
}
ResVtxNrm key(pResult->keyShape[i].vtxSet.resVtxNrm);
const void* pData = key.GetData();
const void *pData = key.GetData();
keyShape[numKeyShape].pVtx =
static_cast<const math::VEC3*>(pData);
keyShape[numKeyShape].pVtx = static_cast<const math::VEC3 *>(pData);
keyShape[numKeyShape].weight = pResult->keyShape[i].weight;
numKeyShape++;
}
@@ -178,14 +173,14 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(pVtxNrmBuf) + numVtx * sizeof(math::VEC3));
// clang-format on
const KeyShape* const pKeyEnd = keyShape + numKeyShape;
const KeyShape *const pKeyEnd = keyShape + numKeyShape;
for (; pVtxNrmBuf < pVtxNrmBufEnd; pVtxNrmBuf++) {
register f32 xy, z_;
KeyShape& rFirst = keyShape[0];
KeyShape &rFirst = keyShape[0];
register f32 firstWeight = rFirst.weight;
register const void* pVtx = rFirst.pVtx;
register const void *pVtx = rFirst.pVtx;
// clang-format off
asm {
@@ -201,9 +196,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(rFirst.pVtx) + sizeof(math::VEC3));
// clang-format on
for (KeyShape* pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
for (KeyShape *pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
register f32 keyWeight = pKey->weight;
register const void* pKeyVtx = pKey->pVtx;
register const void *pKeyVtx = pKey->pVtx;
register f32 key_xy, key_z_;
// clang-format off
@@ -221,7 +216,7 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
// clang-format on
}
register void* pDst = pVtxNrmBuf;
register void *pDst = pVtxNrmBuf;
// clang-format off
asm {
@@ -234,11 +229,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
DC::StoreRange(vtxNrm.GetData(), numVtx * sizeof(math::VEC3));
}
if ((pResult->flags & ShpAnmResult::FLAG_ANM_VTXCLR) &&
ppVtxClrTable != NULL) {
if ((pResult->flags & ShpAnmResult::FLAG_ANM_VTXCLR) && ppVtxClrTable != NULL) {
struct KeyShape {
const ut::Color* pVtx; // at 0x0
const ut::Color *pVtx; // at 0x0
f32 weight; // at 0x4
};
@@ -248,14 +241,13 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
int numKeyShape = 0;
ResVtxClr vtxClr(ppVtxClrTable[baseClr.GetID()]);
ut::Color* pVtxClrBuf = static_cast<ut::Color*>(vtxClr.GetData());
ut::Color *pVtxClrBuf = static_cast<ut::Color *>(vtxClr.GetData());
if (pResult->baseShapeWeight != 0.0f) {
const ut::Color* pBase;
const ut::Color *pBase;
u8 stride;
baseClr.GetArray(reinterpret_cast<const void**>(&pBase),
&stride);
baseClr.GetArray(reinterpret_cast<const void **>(&pBase), &stride);
keyShape[numKeyShape].pVtx = pBase;
keyShape[numKeyShape].weight = pResult->baseShapeWeight;
@@ -268,10 +260,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
}
ResVtxClr key(pResult->keyShape[i].vtxSet.resVtxClr);
const void* pData = key.GetData();
const void *pData = key.GetData();
keyShape[numKeyShape].pVtx =
static_cast<const ut::Color*>(pData);
keyShape[numKeyShape].pVtx = static_cast<const ut::Color *>(pData);
keyShape[numKeyShape].weight = pResult->keyShape[i].weight;
numKeyShape++;
}
@@ -283,14 +274,14 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(pVtxClrBuf) + numVtx * sizeof(ut::Color));
// clang-format on
const KeyShape* const pKeyEnd = keyShape + numKeyShape;
const KeyShape *const pKeyEnd = keyShape + numKeyShape;
for (; pVtxClrBuf < pVtxClrBufEnd; pVtxClrBuf++) {
register f32 rg, ba;
KeyShape& rFirst = keyShape[0];
KeyShape &rFirst = keyShape[0];
register f32 firstWeight = rFirst.weight;
register const void* pVtx = rFirst.pVtx;
register const void *pVtx = rFirst.pVtx;
// clang-format off
asm {
@@ -306,9 +297,9 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
reinterpret_cast<const u8*>(rFirst.pVtx) + sizeof(ut::Color));
// clang-format on
for (KeyShape* pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
for (KeyShape *pKey = &keyShape[1]; pKey < pKeyEnd; pKey++) {
register f32 keyWeight = pKey->weight;
register const void* pKeyVtx = pKey->pVtx;
register const void *pKeyVtx = pKey->pVtx;
register f32 key_rg, key_ba;
// clang-format off
@@ -326,7 +317,7 @@ void CalcVtx(ResMdl mdl, AnmObjShp* pAnmShp, ResVtxPosData** ppVtxPosTable,
// clang-format on
}
register void* pDst = pVtxClrBuf;
register void *pDst = pVtxClrBuf;
// clang-format off
asm {
+96 -67
View File
@@ -1,20 +1,38 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
const u8* pByteCode, const math::MTX34* pBaseMtx, ResMdl mdl,
AnmObjChr* pAnmChr, FuncObjCalcWorld* pFuncObj, u32 rootAttrib) {
void WorldMtxManip::SetScale(f32 x, f32 y, f32 z) {
mpS->x = x;
mpS->y = y;
mpS->z = z;
#define pCalcCmd reinterpret_cast<const ResByteCodeData::CalcParams*>(pByteCode)
#define pMtxDupCmd \
reinterpret_cast<const ResByteCodeData::MtxDupParams*>(pByteCode)
if (x == y && x == z) {
if (1.f == x) {
*mpWMAttr |= detail::WorldMtxAttr::ATTR_S_ONE;
} else {
*mpWMAttr |= detail::WorldMtxAttr::ATTR_S_UNIFORM;
*mpWMAttr &= ~(detail::WorldMtxAttr::ATTR_S_ONE | detail::WorldMtxAttr::ATTR_ALL_S_ONE);
}
} else {
*mpWMAttr &=
~(detail::WorldMtxAttr::ATTR_S_UNIFORM | detail::WorldMtxAttr::ATTR_ALL_S_UNIFORM |
detail::WorldMtxAttr::ATTR_S_ONE | detail::WorldMtxAttr::ATTR_ALL_S_ONE);
}
}
void CalcWorld(
math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const u8 *pByteCode, const math::MTX34 *pBaseMtx,
ResMdl mdl, AnmObjChr *pAnmChr, FuncObjCalcWorld *pFuncObj, u32 rootAttrib
) {
#define pCalcCmd reinterpret_cast<const ResByteCodeData::CalcParams *>(pByteCode)
#define pMtxDupCmd reinterpret_cast<const ResByteCodeData::MtxDupParams *>(pByteCode)
u8 c;
ChrAnmResult result;
const ChrAnmResult* pResult = NULL;
const ChrAnmResult *pResult = NULL;
if (pByteCode == NULL) {
pByteCode = mdl.GetResByteCode("NodeTree");
@@ -28,12 +46,12 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
bool ignoreTrans = detail::WorldMtxAttr::IsIgnoreTrans(rootAttrib);
math::VEC3* pScaleArray = detail::workmem::GetScaleTemporary();
math::VEC3 *pScaleArray = detail::workmem::GetScaleTemporary();
pScaleArray[0].x = pScaleArray[0].y = pScaleArray[0].z = 1.0f;
math::MTX34Copy(pModelMtxArray, pBaseMtx);
u32* pMtxIDArray = detail::workmem::GetMtxIDTemporary();
u32 *pMtxIDArray = detail::workmem::GetMtxIDTemporary();
u32 numMtxID = 0;
pModelMtxAttribArray[0] = rootAttrib;
@@ -42,19 +60,18 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
if (c == ResByteCodeData::CALC) {
u32 nodeID = (pCalcCmd->nodeIdHi << 8) + pCalcCmd->nodeIdLo;
u32 parentMtxID =
(pCalcCmd->parentMtxIdHi << 8) + pCalcCmd->parentMtxIdLo;
u32 parentMtxID = (pCalcCmd->parentMtxIdHi << 8) + pCalcCmd->parentMtxIdLo;
ResNode node = mdl.GetResNode(nodeID);
u32 mtxID = node.GetMtxID();
pMtxIDArray[numMtxID++] = mtxID;
math::MTX34* pModelMtx = &pModelMtxArray[mtxID];
math::VEC3* pScale = &pScaleArray[mtxID];
math::MTX34 *pModelMtx = &pModelMtxArray[mtxID];
math::VEC3 *pScale = &pScaleArray[mtxID];
math::MTX34* pParentModelMtx = &pModelMtxArray[parentMtxID];
math::VEC3* pParentScale = &pScaleArray[parentMtxID];
math::MTX34 *pParentModelMtx = &pModelMtxArray[parentMtxID];
math::VEC3 *pParentScale = &pScaleArray[parentMtxID];
u32 parentAttr = pModelMtxAttribArray[parentMtxID];
@@ -88,25 +105,23 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
if (xsi) {
pModelMtxAttribArray[mtxID] = detail::dcc::CalcWorldMtx_Xsi(
pModelMtx, pScale, pParentModelMtx, pParentScale,
parentAttr, pResult);
pModelMtx, pScale, pParentModelMtx, pParentScale, parentAttr, pResult
);
} else if (pResult->flags & ChrAnmResult::FLAG_SSC_APPLY) {
pModelMtxAttribArray[mtxID] =
detail::dcc::CalcWorldMtx_Maya_SSC_Apply(
pModelMtx, pScale, pParentModelMtx, pParentScale,
parentAttr, pResult);
pModelMtxAttribArray[mtxID] = detail::dcc::CalcWorldMtx_Maya_SSC_Apply(
pModelMtx, pScale, pParentModelMtx, pParentScale, parentAttr, pResult
);
} else {
pModelMtxAttribArray[mtxID] = detail::dcc::CalcWorldMtx_Basic(
pModelMtx, pScale, pParentModelMtx, pParentScale,
parentAttr, pResult);
pModelMtx, pScale, pParentModelMtx, pParentScale, parentAttr, pResult
);
}
pModelMtxAttribArray[mtxID] = detail::WorldMtxAttr::SetBillboard(
pModelMtxAttribArray[mtxID], node.GetBillboardMode());
pModelMtxAttribArray[mtxID] =
detail::WorldMtxAttr::SetBillboard(pModelMtxAttribArray[mtxID], node.GetBillboardMode());
if (pFuncObj != NULL) {
pFuncObj->CheckCallbackB(nodeID, pModelMtx, pScale,
&pModelMtxAttribArray[mtxID], mdl);
pFuncObj->CheckCallbackB(nodeID, pModelMtx, pScale, &pModelMtxAttribArray[mtxID], mdl);
}
pByteCode += sizeof(ResByteCodeData::CalcParams);
@@ -114,14 +129,12 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
} else /* Assume MTXDUP */ {
u32 toMtxID = (pMtxDupCmd->toMtxIdHi << 8) + pMtxDupCmd->toMtxIdLo;
u32 fromMtxID =
(pMtxDupCmd->fromMtxIdHi << 8) + pMtxDupCmd->fromMtxIdLo;
u32 fromMtxID = (pMtxDupCmd->fromMtxIdHi << 8) + pMtxDupCmd->fromMtxIdLo;
pMtxIDArray[numMtxID++] = toMtxID;
pModelMtxAttribArray[toMtxID] = pModelMtxAttribArray[fromMtxID];
math::MTX34Copy(&pModelMtxArray[toMtxID],
&pModelMtxArray[fromMtxID]);
math::MTX34Copy(&pModelMtxArray[toMtxID], &pModelMtxArray[fromMtxID]);
pScaleArray[toMtxID] = pScaleArray[fromMtxID];
@@ -132,13 +145,11 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
for (u32 i = 0; i < numMtxID; i++) {
u32 mtxID = pMtxIDArray[i];
if (pScaleArray[mtxID].x == 1.0f && pScaleArray[mtxID].y == 1.0f &&
pScaleArray[mtxID].z == 1.0f) {
if (pScaleArray[mtxID].x == 1.0f && pScaleArray[mtxID].y == 1.0f && pScaleArray[mtxID].z == 1.0f) {
continue;
}
math::MTX34Scale(&pModelMtxArray[mtxID], &pModelMtxArray[mtxID],
&pScaleArray[mtxID]);
math::MTX34Scale(&pModelMtxArray[mtxID], &pModelMtxArray[mtxID], &pScaleArray[mtxID]);
}
if (pFuncObj != NULL) {
@@ -149,26 +160,23 @@ void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
#undef pMtxDupCmd
}
void CalcWorld(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
const u8* pByteCode, const math::MTX34* pBaseMtx, ResMdl mdl,
AnmObjChr* pAnmChr, FuncObjCalcWorld* pFuncObj) {
CalcWorld(pModelMtxArray, pModelMtxAttribArray, pByteCode, pBaseMtx, mdl,
pAnmChr, pFuncObj, detail::WorldMtxAttr::GetRootMtxAttr());
void CalcWorld(
math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const u8 *pByteCode, const math::MTX34 *pBaseMtx,
ResMdl mdl, AnmObjChr *pAnmChr, FuncObjCalcWorld *pFuncObj
) {
CalcWorld(
pModelMtxArray, pModelMtxAttribArray, pByteCode, pBaseMtx, mdl, pAnmChr, pFuncObj,
detail::WorldMtxAttr::GetRootMtxAttr()
);
}
void CalcSkinning(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
const ResMdl mdl, const u8* pByteCode) {
void CalcSkinning(math::MTX34 *pModelMtxArray, u32 *pModelMtxAttribArray, const ResMdl mdl, const u8 *pByteCode) {
// Allows struct offsets inside assembly
using nw4r::math::MTX34;
#define pWeightCmd \
reinterpret_cast<const ResByteCodeData::WeightParams*>(pByteCode)
#define pWeightEntry \
reinterpret_cast<const ResByteCodeData::WeightEntry*>(pByteCode)
#define pEvpMtxCmd \
reinterpret_cast<const ResByteCodeData::EvpMtxParams*>(pByteCode)
#define pWeightCmd reinterpret_cast<const ResByteCodeData::WeightParams *>(pByteCode)
#define pWeightEntry reinterpret_cast<const ResByteCodeData::WeightEntry *>(pByteCode)
#define pEvpMtxCmd reinterpret_cast<const ResByteCodeData::EvpMtxParams *>(pByteCode)
u8 c;
@@ -180,15 +188,14 @@ void CalcSkinning(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
}
}
math::MTX34* pSkinMtxArray = detail::workmem::GetSkinningMtxTemporary();
math::MTX34 *pSkinMtxArray = detail::workmem::GetSkinningMtxTemporary();
while ((c = *pByteCode) != ResByteCodeData::END) {
if (c == ResByteCodeData::WEIGHT) {
u32 targetMtxID = (pWeightCmd->tgtIdHi << 8) + pWeightCmd->tgtIdLo;
u32 numBlendMtx = pWeightCmd->numBlendMtx;
pModelMtxAttribArray[targetMtxID] =
detail::WorldMtxAttr::GetRootMtxAttr();
pModelMtxAttribArray[targetMtxID] = detail::WorldMtxAttr::GetRootMtxAttr();
pByteCode += sizeof(ResByteCodeData::WeightParams);
@@ -210,21 +217,18 @@ void CalcSkinning(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
// clang-format on
for (u32 i = 0; i < numBlendMtx; i++) {
u32 mtxID =
(pWeightEntry->mtxIdHi << 8) + pWeightEntry->mtxIdLo;
u32 mtxID = (pWeightEntry->mtxIdHi << 8) + pWeightEntry->mtxIdLo;
u32 iraito = pWeightEntry->fWeight0 << 24 |
pWeightEntry->fWeight1 << 16 |
pWeightEntry->fWeight2 << 8 |
u32 iraito = pWeightEntry->fWeight0 << 24 | pWeightEntry->fWeight1 << 16 | pWeightEntry->fWeight2 << 8 |
pWeightEntry->fWeight3;
register f32 R = *reinterpret_cast<f32*>(&iraito);
register f32 R = *reinterpret_cast<f32 *>(&iraito);
register f32 T00, T02;
register f32 T10, T12;
register f32 T20, T22;
register math::MTX34* pT = &pSkinMtxArray[mtxID];
register math::MTX34 *pT = &pSkinMtxArray[mtxID];
// clang-format off
asm {
@@ -244,13 +248,12 @@ void CalcSkinning(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
}
// clang-format on
pModelMtxAttribArray[targetMtxID] &=
pModelMtxAttribArray[mtxID];
pModelMtxAttribArray[targetMtxID] &= pModelMtxAttribArray[mtxID];
pByteCode += sizeof(ResByteCodeData::WeightEntry);
}
register math::MTX34* pTargetMtx = &pModelMtxArray[targetMtxID];
register math::MTX34 *pTargetMtx = &pModelMtxArray[targetMtxID];
// clang-format off
asm {
@@ -267,13 +270,39 @@ void CalcSkinning(math::MTX34* pModelMtxArray, u32* pModelMtxAttribArray,
u32 mtxID = (pEvpMtxCmd->mtxIdHi << 8) + pEvpMtxCmd->mtxIdLo;
u32 nodeID = (pEvpMtxCmd->nodeIdHi << 8) + pEvpMtxCmd->nodeIdLo;
math::MTX34Mult(&pSkinMtxArray[mtxID], &pModelMtxArray[mtxID],
static_cast<const math::MTX34*>(
&mdl.GetResNode(nodeID).ref().invModelMtx));
math::MTX34Mult(
&pSkinMtxArray[mtxID], &pModelMtxArray[mtxID],
static_cast<const math::MTX34 *>(&mdl.GetResNode(nodeID).ref().invModelMtx)
);
pByteCode += sizeof(ResByteCodeData::EvpMtxParams);
}
}
ResMdlInfo mdlInfo = mdl.GetResMdlInfo();
switch (mdlInfo.GetEnvelopeMatrixMode()) {
case ResMdlInfo::EVPMATRIXMODE_NORMAL: {
return;
} break;
case ResMdlInfo::EVPMATRIXMODE_APPROX: {
u32 numWeighted = mdlInfo.GetNumPosNrmMtx() - mdl.GetResNodeNumEntries();
u32 end = mdlInfo.GetNumViewMtx();
u32 begin = end - numWeighted;
for (u32 i = begin; i < end; i++) {
pModelMtxAttribArray[i] |= detail::WorldMtxAttr::ATTR_S_UNIFORM;
pModelMtxAttribArray[i] |= detail::WorldMtxAttr::ATTR_ALL_S_UNIFORM;
}
} break;
case ResMdlInfo::EVPMATRIXMODE_EXACT: {
u32 numWeighted = mdlInfo.GetNumPosNrmMtx() - mdl.GetResNodeNumEntries();
u32 end = mdlInfo.GetNumViewMtx();
u32 begin = end - numWeighted;
for (u32 i = begin; i < end; i++) {
pModelMtxAttribArray[i] &= ~detail::WorldMtxAttr::ATTR_ALL_S_UNIFORM;
}
} break;
}
#undef pWeightCmd
#undef pWeightEntry
+49 -6
View File
@@ -1,9 +1,9 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
#include <rvl/GX.h>
#include <rvl/MTX.h>
#include "rvl/GX.h" // IWYU pragma: export
#include "rvl/MTX.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
@@ -224,6 +224,17 @@ void Camera::SetProjectionMtxDirectly(const math::MTX44 *pMtx) {
}
}
void Camera::SetTexMtxParam(f32 lightScaleS, f32 lightScaleT, f32 lightTransS, f32 lightTransT) {
if (IsValid()) {
CameraData &r = ref();
r.lightScaleS = lightScaleS;
r.lightScaleT = lightScaleT;
r.lightTransS = lightTransS;
r.lightTransT = lightTransT;
}
}
void Camera::SetScissor(u32 x, u32 y, u32 width, u32 height) {
if (!IsValid()) {
return;
@@ -303,8 +314,40 @@ void Camera::GetViewport(f32 *pX, f32 *pY, f32 *pWidth, f32 *pHeight, f32 *pNear
}
}
void Camera::Project(math::VEC3 *pSrcPos, const math::VEC3 &worldPos) const {
if (pSrcPos == NULL) {
return;
}
math::MTX34 cam;
math::MTX44 proj;
f32 vp[GX_VIEWPORT_SZ];
f32 p[GX_PROJECTION_SZ];
GetCameraMtx(&cam);
GetProjectionMtx(&proj);
p[0] = GetProjectionType();
p[1] = proj._00;
p[3] = proj._11;
p[5] = proj._22;
p[6] = proj._23;
if (p[0] == 1.0f) {
p[2] = proj._03;
p[4] = proj._13;
} else {
p[2] = proj._02;
p[4] = proj._12;
}
GetViewport(&vp[0], &vp[1], &vp[2], &vp[3], &vp[4], &vp[5]);
::GXProject(worldPos.x, worldPos.y, worldPos.z, cam, p, vp, &pSrcPos->x, &pSrcPos->y, &pSrcPos->z);
}
void Camera::GetCameraMtx(math::MTX34 *pMtx) const {
if (pMtx != NULL && IsValid()) {
if (pMtx && IsValid()) {
const CameraData &r = ref();
if (!(r.flags & CameraData::FLAG_CAM_MTX_READY)) {
@@ -316,7 +359,7 @@ void Camera::GetCameraMtx(math::MTX34 *pMtx) const {
}
void Camera::GetProjectionMtx(math::MTX44 *pMtx) const {
if (pMtx != NULL && IsValid()) {
if (pMtx && IsValid()) {
const CameraData &r = ref();
if (!(r.flags & CameraData::FLAG_PROJ_MTX_READY)) {
+13 -4
View File
@@ -1,12 +1,11 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/math.h>
#include "nw4r/math.h" // IWYU pragma: export
namespace nw4r {
namespace g3d {
void CalcTexMtx(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
TexSrt::Flag flag, TexSrtTypedef::TexMatrixMode mode) {
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag, TexSrtTypedef::TexMatrixMode mode) {
bool ident = true;
if (mode == TexSrtTypedef::TEXMATRIXMODE_MAYA) {
@@ -22,5 +21,15 @@ void CalcTexMtx(math::MTX34* pMtx, bool set, const TexSrt& rSrt,
}
}
void CalcTexMtx(math::MTX34 *pMtx, bool set, const TexSrt &rSrt, TexSrt::Flag flag) {
bool ident = true;
ident = !detail::dcc::CalcTexMtx_Basic(pMtx, set, rSrt, flag);
if (ident && set) {
math::MTX34Identity(pMtx);
}
}
} // namespace g3d
} // namespace nw4r
+73 -54
View File
@@ -1,8 +1,8 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/BASE.h>
#include "rvl/BASE.h" // IWYU pragma: export
#include <algorithm>
@@ -220,9 +220,15 @@ void SetupDraw1Mat1ShpSwap(Draw1Mat1ShpSwap *pSwap, DrawResMdlReplacement *pRepl
pSwap->tev = ResTev(NULL);
}
pSwap->vtxPosTable = pReplacement->vtxPosTable;
pSwap->vtxNrmTable = pReplacement->vtxNrmTable;
pSwap->vtxClrTable = pReplacement->vtxClrTable;
if (pReplacement->flag & 1) {
pSwap->vtxPosTable = NULL;
pSwap->vtxNrmTable = NULL;
pSwap->vtxClrTable = NULL;
} else {
pSwap->vtxPosTable = pReplacement->vtxPosTable;
pSwap->vtxNrmTable = pReplacement->vtxNrmTable;
pSwap->vtxClrTable = pReplacement->vtxClrTable;
}
}
inline bool FrontToBack(const detail::workmem::MdlZ &rLhs, const detail::workmem::MdlZ &rRhs) {
@@ -272,28 +278,30 @@ void DrawResMdlLoop(const ResMdl mdl, const u8 *pByteCode, u32 drawMode) {
ResShp shp;
ResNode node;
bool ignoreMat = (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL);
u32 ctrl = DRAW1MAT1SHP_CTRL_NOPPCSYNC;
if (drawMode & RESMDL_DRAWMODE_FORCE_LIGHTOFF) {
ctrl |= DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF;
}
if (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL) {
ctrl |= RESMDL_DRAWMODE_NOPPCSYNC;
}
for (; (c = *pByteCode) != ResByteCodeData::END; pByteCode += sizeof(ResByteCodeData::DrawParams)) {
node = mdl.GetResNode(pDrawCmd->nodeIdHi << 8 | pDrawCmd->nodeIdLo);
if (!node.IsVisible()) {
continue;
}
mat = mdl.GetResMat(pDrawCmd->matIdHi << 8 | pDrawCmd->matIdLo);
shp = mdl.GetResShp(pDrawCmd->shpIdHi << 8 | pDrawCmd->shpIdLo);
Draw1Mat1ShpDirectly(
ignoreMat || mat == prevMat ? ResMat(NULL) : mat, shp, NULL, NULL, ctrl, NULL,
detail::GetIndMtxOp(mat, node, shp)
);
if (node.IsVisible() && shp.IsVisible()) {
mat = mdl.GetResMat(pDrawCmd->matIdHi << 8 | pDrawCmd->matIdLo);
prevMat = mat;
Draw1Mat1ShpDirectly(
mat, shp, NULL, NULL, mat == prevMat ? ctrl | RESMDL_DRAWMODE_NOPPCSYNC : ctrl, NULL,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
}
}
#undef pDrawCmd
@@ -312,15 +320,19 @@ void DrawResMdlLoop(const ResMdl mdl, const u8 *pByteCode, DrawResMdlReplacement
Draw1Mat1ShpSwap swap;
bool ignoreMat = (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL);
u32 ctrl = DRAW1MAT1SHP_CTRL_NOPPCSYNC;
if (drawMode & RESMDL_DRAWMODE_FORCE_LIGHTOFF) {
ctrl |= DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF;
}
if (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL) {
ctrl |= RESMDL_DRAWMODE_NOPPCSYNC;
}
for (; (c = *pByteCode) != ResByteCodeData::END; pByteCode += sizeof(ResByteCodeData::DrawParams)) {
node = mdl.GetResNode(pDrawCmd->nodeIdHi << 8 | pDrawCmd->nodeIdLo);
shp = mdl.GetResShp(pDrawCmd->shpIdHi << 8 | pDrawCmd->shpIdLo);
bool visible;
// @bug Replacement pointer not validated
@@ -330,21 +342,18 @@ void DrawResMdlLoop(const ResMdl mdl, const u8 *pByteCode, DrawResMdlReplacement
visible = node.IsVisible();
}
if (!visible) {
continue;
if (visible && shp.IsVisible()) {
mat = mdl.GetResMat(pDrawCmd->matIdHi << 8 | pDrawCmd->matIdLo);
SetupDraw1Mat1ShpSwap(&swap, pReplacement, mat.GetID());
Draw1Mat1ShpDirectly(
mat, shp, NULL, NULL, mat == prevMat ? ctrl | RESMDL_DRAWMODE_NOPPCSYNC : ctrl, &swap,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
}
mat = mdl.GetResMat(pDrawCmd->matIdHi << 8 | pDrawCmd->matIdLo);
shp = mdl.GetResShp(pDrawCmd->shpIdHi << 8 | pDrawCmd->shpIdLo);
SetupDraw1Mat1ShpSwap(&swap, pReplacement, mat.GetID());
Draw1Mat1ShpDirectly(
ignoreMat || mat == prevMat ? ResMat(NULL) : mat, shp, NULL, NULL, ctrl, &swap,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
}
#undef pDrawCmd
@@ -359,26 +368,30 @@ void DrawResMdlLoop(const ResMdl mdl, const detail::workmem::MdlZ *pMdlZArray, u
ResShp shp;
ResNode node;
bool ignoreMat = (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL);
u32 ctrl = DRAW1MAT1SHP_CTRL_NOPPCSYNC;
if (drawMode & RESMDL_DRAWMODE_FORCE_LIGHTOFF) {
ctrl |= DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF;
}
if (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL) {
ctrl |= RESMDL_DRAWMODE_NOPPCSYNC;
}
for (i = 0; i < numMdlZ; i++) {
const detail::workmem::MdlZ &rMdlZ = pMdlZArray[i];
mat = mdl.GetResMat(rMdlZ.matID);
shp = mdl.GetResShp(rMdlZ.shpID);
node = mdl.GetResNode(rMdlZ.nodeID);
if (shp.IsVisible()) {
mat = mdl.GetResMat(rMdlZ.matID);
node = mdl.GetResNode(rMdlZ.nodeID);
Draw1Mat1ShpDirectly(
ignoreMat || mat == prevMat ? ResMat(NULL) : mat, shp, NULL, NULL, ctrl, NULL,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
Draw1Mat1ShpDirectly(
mat, shp, NULL, NULL, mat == prevMat ? ctrl | RESMDL_DRAWMODE_NOPPCSYNC : ctrl, NULL,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
}
}
}
@@ -396,28 +409,31 @@ void DrawResMdlLoop(
Draw1Mat1ShpSwap swap;
bool ignoreMat = (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL);
u32 ctrl = DRAW1MAT1SHP_CTRL_NOPPCSYNC;
if (drawMode & RESMDL_DRAWMODE_FORCE_LIGHTOFF) {
ctrl |= DRAW1MAT1SHP_CTRL_FORCE_LIGHTOFF;
}
if (drawMode & RESMDL_DRAWMODE_IGNORE_MATERIAL) {
ctrl |= RESMDL_DRAWMODE_NOPPCSYNC;
}
for (i = 0; i < numMdlZ; i++) {
const detail::workmem::MdlZ &rMdlZ = pMdlZArray[i];
mat = mdl.GetResMat(rMdlZ.matID);
shp = mdl.GetResShp(rMdlZ.shpID);
node = mdl.GetResNode(rMdlZ.nodeID);
if (shp.IsVisible()) {
mat = mdl.GetResMat(rMdlZ.matID);
node = mdl.GetResNode(rMdlZ.nodeID);
SetupDraw1Mat1ShpSwap(&swap, pReplacement, mat.GetID());
Draw1Mat1ShpDirectly(
ignoreMat || mat == prevMat ? ResMat(NULL) : mat, shp, NULL, NULL, ctrl, &swap,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
SetupDraw1Mat1ShpSwap(&swap, pReplacement, mat.GetID());
Draw1Mat1ShpDirectly(
mat, shp, NULL, NULL, mat == prevMat ? ctrl | RESMDL_DRAWMODE_NOPPCSYNC : ctrl, &swap,
detail::GetIndMtxOp(mat, node, shp)
);
prevMat = mat;
}
}
}
@@ -457,9 +473,12 @@ detail::workmem::MdlZ *SetUpMdlZ(
rMdlZ.matID = pDrawCmd->matIdHi << 8 | pDrawCmd->matIdLo;
rMdlZ.shpID = pDrawCmd->shpIdHi << 8 | pDrawCmd->shpIdLo;
// @bug Matrix ID not validated
mtxID = node.GetMtxID();
rMdlZ.Z = pViewPosMtxArray[mtxID]._23;
if (mtxID < viewMtxNum) {
rMdlZ.Z = pViewPosMtxArray[mtxID]._23;
} else {
rMdlZ.Z = 0.f;
}
rMdlZ.priority = pDrawCmd->priority;
+181 -37
View File
@@ -1,23 +1,18 @@
#include <nw4r/g3d.h>
#include "nw4r/g3d.h" // IWYU pragma: export
#include <nw4r/ut.h>
#include "nw4r/ut.h" // IWYU pragma: export
#include <rvl/BASE.h>
#include <rvl/GX.h>
#include "rvl/BASE.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
#include <cmath>
namespace nw4r {
namespace g3d {
namespace detail {
void Draw1Mat1ShpDirectly(
ResMat mat, ResShp shp, const math::MTX34 *pViewPos, const math::MTX34 *pViewNrm, u32 ctrl, Draw1Mat1ShpSwap *pSwap,
G3DState::IndMtxOp *pIndMtxOp
) {
if (!(ctrl & DRAW1MAT1SHP_CTRL_NOPPCSYNC)) {
ut::LC::QueueWait(0);
PPCSync();
}
if (mat.IsValid()) {
void LoadMaterial(ResMat mat, u32 ctrl, Draw1Mat1ShpSwap *pSwap, G3DState::IndMtxOp *pIndMtxOp, bool bIgnoreMaterial) {
if (!bIgnoreMaterial) {
ResMatMisc misc;
if (pSwap == NULL || !pSwap->misc.IsValid()) {
@@ -118,7 +113,6 @@ void Draw1Mat1ShpDirectly(
} else {
G3DState::LoadResTexSrt(pSwap->texSrt);
}
} else if (pIndMtxOp != NULL) {
if (pSwap == NULL || !pSwap->indMtxAndScale.IsValid()) {
G3DState::IndTexMtxInfo info;
@@ -128,46 +122,196 @@ void Draw1Mat1ShpDirectly(
G3DState::LoadResMatIndMtxAndScale(pSwap->indMtxAndScale, *pIndMtxOp);
}
}
}
} // namespace detail
void Draw1Mat1ShpDirectly(
ResMat mat, ResShp shp, const math::MTX34 *pViewPos, const math::MTX34 *pViewNrm, u32 ctrl, Draw1Mat1ShpSwap *pSwap,
G3DState::IndMtxOp *pIndMtxOp
) {
if (!(ctrl & DRAW1MAT1SHP_CTRL_NOPPCSYNC)) {
ut::LC::QueueWait(0);
PPCSync();
}
bool bIgnoreMaterial = false;
bool bFur = false;
ResMatFur fur;
if (mat.IsValid()) {
if (ctrl & DRAW1MAT1SHP_CTRL_IGNORE_MAT) {
bIgnoreMaterial = true;
}
fur = mat.GetResMatFur();
if (fur.IsValid()) {
bFur = true;
}
} else {
bIgnoreMaterial = true;
}
detail::LoadMaterial(mat, ctrl, pSwap, pIndMtxOp, bIgnoreMaterial);
if (shp.IsValid() && shp.IsVisible()) {
if (!(ctrl & DRAW1MAT1SHP_CTRL_NOSWAPSHP)) {
if (bFur) {
f32 rateBright, rateAlpha, rateSpec;
f32 alphaCurve, specCurve;
f32 rate, rateInv;
GXColor rootColor, tipColor, kcolor2;
u8 brightness;
GXColorSrc matSrc[4];
GXAttnFn attnFunc[4];
GXColor matColor[2];
bool bIndTexMtx[3];
math::MTX34 itm[3];
s8 scale_exp[3];
const GXChannelID targetChan[4] = {GX_COLOR0, GX_ALPHA0, GX_COLOR1, GX_ALPHA1};
alphaCurve = fur.ref().alphaCurve;
specCurve = fur.ref().specCurve;
const ResMatTevColor tevColor =
(!pSwap || !pSwap->tevColor.IsValid()) ? mat.GetResMatTevColor() : pSwap->tevColor;
tevColor.GXGetTevKColor(GX_KCOLOR0, &rootColor);
tevColor.GXGetTevKColor(GX_KCOLOR1, &tipColor);
tevColor.GXGetTevKColor(GX_KCOLOR2, &kcolor2);
brightness = kcolor2.g;
const ResMatChan chan = (!pSwap || !pSwap->chan.IsValid()) ? mat.GetResMatChan() : pSwap->chan;
chan.GXGetChanMatColor(GX_COLOR0, &matColor[0]);
chan.GXGetChanMatColor(GX_COLOR1, &matColor[1]);
for (u8 chanIdx = 0; chanIdx < 4; chanIdx++) {
chan.GXGetChanCtrl(targetChan[chanIdx], NULL, NULL, &matSrc[chanIdx], NULL, NULL, &attnFunc[chanIdx]);
}
ResMatMisc misc = (!pSwap || !pSwap->misc.IsValid()) ? mat.GetResMatMisc() : pSwap->misc;
ResMatIndMtxAndScale indMtxAndScale =
(!pSwap || !pSwap->indMtxAndScale.IsValid()) ? mat.GetResMatIndMtxAndScale() : pSwap->indMtxAndScale;
for (u32 itmIdx = 0; itmIdx < 3; itmIdx++) {
ResMatMiscData::IndirectMethod method;
s8 ref_light;
const GXIndTexMtxID id = static_cast<GXIndTexMtxID>(itmIdx + GX_ITM_0);
misc.GetIndirectTexMtxCalcMethod(id, &method, &ref_light);
if (method == ResMatMiscData::FUR) {
bIndTexMtx[itmIdx] = true;
indMtxAndScale.GXGetIndTexMtx(id, &itm[itmIdx], &scale_exp[itmIdx]);
} else {
bIndTexMtx[itmIdx] = false;
}
}
G3DState::LoadResShpPrePrimitive(shp);
if (ctrl & DRAW1MAT1SHP_CTRL_CULL_FRONT) {
fifo::GDSetCullMode(GX_CULL_FRONT);
G3DState::Invalidate(G3DState::INVALIDATE_SHP);
}
if (pSwap != NULL) {
if (pSwap->vtxPosTable != NULL) {
ResVtxPos(pSwap->vtxPosTable[shp.ref().idVtxPosition]).SetArray();
}
ResVtxFurPos furPos = shp.GetResVtxFurPos();
const u32 numLayer = furPos.ref().numLayer;
for (u16 i = 0; i < numLayer; i++) {
rate = fur.GetLyrRate(i);
rateInv = 1.f - rate;
rateAlpha = pow(rate, alphaCurve);
rateSpec = pow(rate, specCurve);
rateBright = pow(rate, 4.f);
if (pSwap->vtxNrmTable != NULL) {
int nrmID = shp.ref().idVtxNormal;
kcolor2.r = 255 * rate;
kcolor2.g = brightness * rateBright;
GXSetTevKColor(GX_KCOLOR2, kcolor2);
if (nrmID >= 0) {
ResVtxNrm(pSwap->vtxNrmTable[nrmID]).SetArray();
for (u8 itmIdx = 0; itmIdx < 3; itmIdx++) {
if (bIndTexMtx[itmIdx]) {
f32 newItm[2][3] = {
{
itm[itmIdx]._00 * rate,
itm[itmIdx]._01 * rate,
itm[itmIdx]._02,
},
{
itm[itmIdx]._10 * rate,
itm[itmIdx]._11 * rate,
itm[itmIdx]._12,
}
};
GXSetIndTexMtx(static_cast<GXIndTexMtxID>(itmIdx + GX_ITM_0), newItm, scale_exp[itmIdx]);
}
}
if (pSwap->vtxClrTable != NULL) {
int clrID = shp.ref().idVtxColor[0];
GXColor diffColor = {
rootColor.r * rateInv + tipColor.r * rate, rootColor.g * rateInv + tipColor.g * rate,
rootColor.b * rateInv + tipColor.b * rate, rootColor.a * (1.f - rateAlpha) + tipColor.a * rateAlpha
};
if (clrID >= 0) {
ResVtxClr(pSwap->vtxClrTable[clrID]).SetArray(GX_VA_CLR0);
for (u8 colorIdx = 0; colorIdx < 2; colorIdx++) {
u8 chanIdx = colorIdx * 2;
GXColor newMatColor;
if (matSrc[chanIdx] == GX_SRC_REG || matSrc[chanIdx + 1] == GX_SRC_REG) {
if (attnFunc[chanIdx] == GX_AF_SPEC) {
newMatColor.r = matColor[colorIdx].r * rateSpec;
newMatColor.g = matColor[colorIdx].g * rateSpec;
newMatColor.b = matColor[colorIdx].b * rateSpec;
} else {
newMatColor.r = diffColor.r;
newMatColor.g = diffColor.g;
newMatColor.b = diffColor.b;
}
newMatColor.a = attnFunc[chanIdx + 1] == GX_AF_SPEC ? matColor[colorIdx].a : diffColor.a;
fifo::GDSetChanMatColor(targetChan[chanIdx], newMatColor);
}
}
furPos.SetArray(i);
G3DState::LoadResShpPrimitive(shp, pViewPos, pViewNrm);
}
} else {
if (!(ctrl & DRAW1MAT1SHP_CTRL_NOSWAPSHP)) {
G3DState::LoadResShpPrePrimitive(shp);
if (pSwap != NULL) {
if (pSwap->vtxPosTable != NULL) {
ResVtxPos(pSwap->vtxPosTable[shp.ref().idVtxPosition]).SetArray();
}
clrID = shp.ref().idVtxColor[1];
if (pSwap->vtxNrmTable != NULL) {
int idVtxNormal = shp.ref().idVtxNormal;
if (clrID >= 0) {
ResVtxClr(pSwap->vtxClrTable[clrID]).SetArray(GX_VA_CLR1);
if (idVtxNormal >= 0) {
ResVtxNrm(pSwap->vtxNrmTable[idVtxNormal]).SetArray();
}
}
if (pSwap->vtxClrTable != NULL) {
int idVtxColor = shp.ref().idVtxColor[0];
if (idVtxColor >= 0) {
ResVtxClr(pSwap->vtxClrTable[idVtxColor]).SetArray(GX_VA_CLR0);
}
idVtxColor = shp.ref().idVtxColor[1];
if (idVtxColor >= 0) {
ResVtxClr(pSwap->vtxClrTable[idVtxColor]).SetArray(GX_VA_CLR1);
}
}
}
}
}
if (ctrl & DRAW1MAT1SHP_CTRL_CULL_FRONT) {
fifo::GDSetCullMode(GX_CULL_FRONT);
G3DState::Invalidate(G3DState::INVALIDATE_SHP);
}
if (ctrl & DRAW1MAT1SHP_CTRL_CULL_FRONT) {
fifo::GDSetCullMode(GX_CULL_FRONT);
G3DState::Invalidate(G3DState::INVALIDATE_SHP);
G3DState::LoadResShpPrimitive(shp, pViewPos, pViewNrm);
}
G3DState::LoadResShpPrimitive(shp, pViewPos, pViewNrm);
}
}

Some files were not shown because too many files have changed in this diff Show More