Skip to content

Precompute cumulative weights for weighted block-model selection - #577

Open
BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium-weighted-pick-table
Open

BonsUnleashed wants to merge 1 commit into
FiniteReality:20.1/forgefrom
BonsUnleashed:bons-furious/embeddium-weighted-pick-table

Conversation

@BonsUnleashed

Copy link
Copy Markdown

Proposed Changes

Picking a weighted block model walks its entries and reads each weight again for every face and render-layer query. This computes the running totals once when the model is built, then searches that small array. The random draw and selected variant stay the same.

Checks on the compiled mixin, applied to Minecraft's model class, covered about 1.3 million picks: identical variants, exceptions and random draws, including zero weights and the negative Math.abs(Integer.MIN_VALUE) case.

The equivalent patch ships in Bons and Furious 1.0.26 for Embeddium 0.3.31. In a separate benchmark of this port, a mixed set of model lists took about 30 ns per pick instead of 54 ns. Whole-frame differences were too small to measure in game.

Compiles on 20.1/forge (compileJava). Not tested in game on this branch.

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