simple shadow :)#746
Conversation
SquareMan
left a comment
There was a problem hiding this comment.
Thanks for this and welcome to the project! I haven't fully reviewed the function code yet as there are some major structural issues introduced by these struct edits you've made. Feel free to ask for more help in the discord if you need it but once this PR passes CI one of us will give it a more thorough review.
|
thank you so much for the feedback !! |
|
| Section | From | To | Bytes | |
|---|---|---|---|---|
| ✅ | .bss |
99.69% | 100.00% | +44 |
| ✅ | .rodata |
14.29% | 100.00% | +13 |
| 📈 | .sdata2 |
50.00% | 77.27% | +13 |
| 📈 | .text |
14.98% | 96.07% | +4093 |
| Function | From | To | Bytes | |
|---|---|---|---|---|
| 📈 | shadowRayEntCB(xEnt*, void*) |
0.00% | 94.18% | +794 |
| 📈 | xShadowSimple_SceneCollide(xShadowSimpleCache*, xVec3*, float) |
0.00% | 97.70% | +484 |
| 📈 | xShadowSimple_CalcCorners(xShadowSimpleCache*, xEnt*, float, float) |
0.00% | 98.35% | +476 |
| 📈 | xShadowSimple_AddVerts(xShadowSimpleCache*) |
0.00% | 89.67% | +326 |
| 📈 | xShadowSimple_Init() |
40.35% | 92.94% | +172 |
| 📈 | xShadowSimple_CacheInit(xShadowSimpleCache*, xEnt*, unsigned char) |
56.84% | 98.75% | +147 |
| 📈 | xShadowSimple_Add(xShadowSimpleCache*, xEnt*, float, float) |
0.00% | 94.52% | +1111 |
| ✅ | xShadowSimpleQueue::operator=(const xShadowSimpleQueue&) |
0.00% | 100.00% | +44 |
| ✅ | xShadowSimple_Render() |
0.00% | 100.00% | +536 |
| union { | ||
| xEnv* env; | ||
| xClumpCollBSPTree* scenecoll; | ||
| }; |
There was a problem hiding this comment.
ok so this is pretty sus. We're gonna focus on figuring out what's really going on
| struct shadowRayEntData { | ||
| xShadowSimpleCache* cache; | ||
| const RwLine* line; | ||
| }; |
There was a problem hiding this comment.
can you tell me where this struct came from?
| class xNPCBasic : public xEnt { | ||
| public: | ||
| u32 SelfType() const; | ||
| }; |
There was a problem hiding this comment.
Missed this before. xNPCBasic is decarled in xNPCBasic.h, you should remove this and include that header instead.
| norm = (xVec3*)&tri->normal; | ||
| } | ||
|
|
||
| if (dist >= *testdist || (norm->y < 0.0871557f)) |
There was a problem hiding this comment.
can you try using DEG2RAD(5) here instead of 0.0871557?
| if (*(RpAtomic**)((char*)clump + 0x10)) { | ||
| xClumpColl_ForAllIntersections(*(xClumpCollBSPTree**)((char*)*(RpAtomic**)((char*)clump + 0x10) + 0x10), &isx, shadowRayCB, cache); | ||
| } else { | ||
| RpCollisionWorldForAllIntersections(*(RpWorld**)clump, &isx, shadowRayCB, cache); | ||
| } |
There was a problem hiding this comment.
This is a mess and needs to be cleaned. In doing so I think we can solve our scenecoll mystery with xScene. It's not unheard of to see crazy pointer math like this with Renderware, but usually it's handled by a macro from one of the rw headers if necessary.
| #pragma push | ||
| #pragma optimization_level 1 | ||
| #pragma optimize_for_size on | ||
|
|
There was a problem hiding this comment.
This is probably not accurate. I'd rather it be removed at the cost of a lower match percentage but others might disagree.
| U32 flags = 0; | ||
| U32 var_r20 = 0; | ||
|
|
||
| S32 count = xSTAssetCountByType('SHDW'); | ||
| for (i = 0; i < count; i++) | ||
| { | ||
| sst = (zSimpleShadowTableHeader*)xSTFindAssetByType('SHDW', i, &size); | ||
| var_r24 = 0; | ||
| for (j = 0; j < (U32)sst->num; j += 1) | ||
| for (j = 0; j < (U32)sst->num; j++) | ||
| { | ||
| if ((U32)ent->model->modelID == 0) | ||
| U32 offset = j * sizeof(zSimpleShadowTableEntry); | ||
|
|
||
| U32 entry_modelID = *(U32*)((char*)sst + 4 + offset); | ||
|
|
||
| if ((U32)ent->model->modelID == entry_modelID) | ||
| { | ||
| if (xSTFindAsset(sst->num, NULL) != NULL) | ||
| U32 entry_assetID = *(U32*)((char*)sst + 8 + offset); | ||
| RwTexture* tex = (RwTexture*)xSTFindAsset(entry_assetID, NULL); | ||
| if (tex != NULL) | ||
| { | ||
| flags = (U32)xSTFindAsset(sst->num, NULL); | ||
| var_r20 = sst->num; | ||
| flags = (U32)tex->raster; | ||
| var_r20 = *(U32*)((char*)sst + 12 + offset); | ||
| } | ||
| else | ||
| { | ||
| flags = 0xDEADBEEFU; | ||
| flags = 0xDEADBEEF; | ||
| } | ||
| } | ||
|
|
||
| if (flags != 0) | ||
| { | ||
| break; | ||
| } | ||
| } | ||
| if (flags != 0) | ||
| { | ||
| break; | ||
| } | ||
| } | ||
| if ((flags == 0U) || ((U32)(flags + 0x21530000) == -0x4111U)) | ||
|
|
||
| if ((flags == 0) || (flags == 0xDEADBEEF)) | ||
| { | ||
| flags = sShadRaster->width; | ||
| flags = (U32)sShadRaster; | ||
| } | ||
| cache->corner[1].x = flags; | ||
| cache->flags |= (S16)var_r20; | ||
|
|
||
| cache->raster = flags; | ||
| cache->flags |= (U16)var_r20; | ||
| ent->model->shadowID = flags; |
There was a problem hiding this comment.
I think you should give this one another go. The last three lines here are a big tell. Looks like the current flags var is actually raster, var_r20 is flags. Not sure about the last line since it seems to match but it's odd too.
| struct zSimpleShadowTableEntry { | ||
| U32 modelID; | ||
| U32 assetID; | ||
| U32 flags; | ||
| }; | ||
|
|
There was a problem hiding this comment.
Also curious about this struct, since it's not in DWARF.
PLEASE oh PLEASE review my code i dont wanna screw anything up 😔