Skip to content

Cleanup: object.c - #218

Open
unofficial-fish wants to merge 3 commits into
phoboslab:masterfrom
unofficial-fish:cleanup-object
Open

Cleanup: object.c#218
unofficial-fish wants to merge 3 commits into
phoboslab:masterfrom
unofficial-fish:cleanup-object

Conversation

@unofficial-fish

@unofficial-fish unofficial-fish commented Aug 26, 2026

Copy link
Copy Markdown

Instead of tagged-type-puns, primitives are now tagged unions. This means all primitives are the same size, which in turn means we can keep them in simple arrays. That allows mem_bump_unaligned to be retired, and means primitives can be indexed the normal way, rather than using an increment for each type.

Using fixed-width primitives comes with a memory penalty, but it is not very much in practice (on Altima VII, 19% more total memory spent on objects.) This is partially because I have thrown out both light-sourced polygons and light source primitives. wipeout-rewrite does not support them, but still had loading code for them. wipEout, Wipeout 2097, and Wipeout 64 never use them. I have also removed padding and the mysterious, unused cba/tsb fields.

I've checked that all the dynamic effects from #217 still work.

Rolling up the individual structs (u0 v0 u1 v1 u2 v2 u3 v3 is not ideal) could be a good idea, but it looks like a project in and of itself.

This will conflict with #216.

@unofficial-fish

Copy link
Copy Markdown
Author

Completely converting the models at load time turned out to be easier than rolling up the primitive structs. We now have three primitive types used by the whole game: triangle, quadrilateral, billboard. Aurora borealis was simplest to rewrite from scratch.

The memory penalty last I checked was 2% (I commented out the spline struct since we don't yet have an implementation for it.)

This will also conflict with #215.

@unofficial-fish

Copy link
Copy Markdown
Author

The enum and flags for PSX primitives are now in object.c, so it is impossible for other code to even think about touching any legacy PSX stuff.

Backface culling is now accurate to PSX using PRM_SINGLE_SIDED and the 'draw twice' method mentioned in #150.
Of course the geometry itself is still janky, but now accurately so! Double-sided polys are a little strange themselves. Arridos IV girders aren't double-sided, and the mountains are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant