Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve FPS in JEI by culling quads of BakedSimpleItem when in the GUI #3182

Merged
merged 2 commits into from Oct 1, 2017

Conversation

mezz
Copy link
Contributor

@mezz mezz commented Sep 30, 2017

Fixes #3176

This basically implements the same culling logic found in fry's fix here:
MinecraftForge/MinecraftForge@f421379
The gist of it is that you can cull most of the quads off of items when they are in the gui because you can't see the sides.

Combined with the previous fixes (48b420b and #3180), this brings my FPS over 60 even when rendering every single Tinker's item at once in JEI!
Before this PR I got about 40 FPS, before all the fixes together I was getting like 9. Not bad :D

public TextureAtlasSprite getParticleTexture() { return particle; }
public ItemOverrideList getOverrides() { return overrides; }
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if(side == null) return quads;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really mezz, no braces? You're better than that ;P

}

public BakedSimpleItem(List<net.minecraft.client.renderer.block.model.BakedQuad> quads, ImmutableMap<net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType, net.minecraftforge.common.model.TRSRTransformation> transforms, net.minecraft.client.renderer.block.model.IBakedModel base) {
super(quads, transforms, base);
private BakedSimpleItem(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms, ItemOverrideList overrides, @Nullable IBakedModel unculledModel) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without looking at forge code.. when is this constructor ever called with a culled model? I couldn't find where it all comes together in the forge PR, kinda feels like something is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code to do this is tricky af, you use the public constructor to create the unculled model.
That constructor calls the private one to create the culled model.
The two are referencing each other, and switch depending on if you are rendering in GUI or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I expected it to do. Apparently I overlooked that part in the constructor. Thanks

@bonii-xx bonii-xx merged commit 2938cad into SlimeKnights:1.12 Oct 1, 2017
@KnightMiner KnightMiner added 1.12 Issue affects Minecraft 1.12 Enhancement Issue or pull request addresses a change to an existing functional feature labels Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.12 Issue affects Minecraft 1.12 Enhancement Issue or pull request addresses a change to an existing functional feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tinker's weapons have one quad per pixel and repeat them 7 times
3 participants