open-goal / jak-project

Reviving the language that brought us the Jak & Daxter Series
https://opengoal.dev
ISC License
2.73k stars 165 forks source link

[buildactor] support generating `collide-mesh`es for custom models #3540

Closed Hat-Kid closed 1 month ago

Hat-Kid commented 1 month ago

This adds support for generating collide meshes when importing custom models. A couple of things to keep in mind:

~One annoying problem that I haven't fully figured out yet (unrelated to the actual functionality): collide-meshes are stored in art groups as an (array collide-mesh) in the art-joint-geo's extra, so I had to add a new Res type to support this. The way that arrays are stored in res-lumps is a bit of a hack right now. The lump only stores a pointer to the array, so the size of that is 4 bytes, but because we have to generate all the actual array data too, the current ResLump code in C++ doesn't handle this case well and would assert, so I decided to omit the asserts if an array tag is present and "fake" the size so the object file is generated more closely to how the game expects it until we figure out something better.~ This was fixed by generating the array data beforehand and creating a ResRef class that takes the pointer to the array data and adds it to the lump.