TechnicalitiesMC / SuperCircuitMaker

Tiny Circuits Galore!
25 stars 3 forks source link

Lag caused by render #2

Closed KindarConrath closed 2 years ago

KindarConrath commented 2 years ago

Minecraft: 1.18.1 Forge: 39.0.8 SCM2: 0.0.3 Tested with other mods: just JEI

2021-12-23_20 17 46

amadornes commented 2 years ago

Yep. This is a thing. Not really a bug, but circuit rendering is "just working" for the time being.

I plan on investing a lot more time into testing and optimizing to try to get the rendering code to be as efficient as possible in the near future, but for now it's bundled with chunk rendering, so any updates to the chunk the circuit is in will trigger the whole circuit to re-render and vice versa, which understandably can be a bit heavy.

I'll keep this issue open to log development progress around this topic.

XFactHD commented 2 years ago

I have encountered this issue as well, though I am very confident that the cause is a completely different one: 2021-12-24_21 14 02 Putting the circuit in the screenshot together with a running piston clock in the same chunk doesn't influence my frame rate at all. But as soon as my crosshair enters the block space of the circuit (even the empty area), my FPS crash from 120 down to 1. The most likely cause of this is here: https://github.com/TechnicalitiesMC/SuperCircuitMaker/blob/main/src/main/java/com/technicalitiesmc/scm/block/CircuitBlock.java#L163-L194. Calculating a VoxelShape is a really expensive operation and you are building the shape from scratch multiple times per frame due to the many things that call Block#getShape().

The versions are exactly the same as OP's, with the only difference being that I don't have JEI installed.

amadornes commented 2 years ago

That is a very good point.
It's an optimization I was planning to make soon-ish, but I'll push it up the priority list.

amadornes commented 2 years ago

v0.1.1 is now live with the fix:
CurseForge: https://mc-mods.cf/super-circuit-maker/files/3599322
GitHub: https://github.com/TechnicalitiesMC/SuperCircuitMaker/releases/tag/v0.1.1