Project Red - Fabrication

Project Red - Fabrication

19M Downloads

Lamp rendering at distant coordinates

Gwani opened this issue ยท 3 comments

commented

Hi there!

I noticed that the luminous box around lamps is not rendered correctly at distant world coordinates (x, z >> 1 Million). When moving or changing the viewing angle it starts jerking wildly. The effect worsens at even higher coordinates.

I'm currently using ProjectRed-1.7.10-4.5.10.61.

It appears the problem might be caused due to floating point variables losing precision at high values.
If that is the case, it might be a good idea to avoid using any absolute block coordinates when calculating box vertices/translation - even as intermediary values (if all else fails - double precision might alleviate the problem).

Cheers,
Gwani

BTW: Great mod and worthy replacement for RP! Especially your pipe system is totally kick-ass when it comes to retrofitting a complex factory ;-)

commented

Duplicate of issue #401

It seems to be an issue with MC 1.7, hopefully it is fixed in 1.8

commented

Alright. Haven't looked at closed issues, since problem persisted with latest version. Closing this now.

commented

Having had a look at the ProjectRed and CodeChickenLib source code i have strong doubts that a Minecraft patch will fix this problem magically (I'd be happy to be proven wrong).

However, i forked the repo and fixed the issue by changing just a few lines of code - most of it excessive comments on how and why i did it, since i only fixes this particular problem when the halo box is rendered (only in onRenderWorldLast(), not for any other halo rendering).

The idea is to do the calculations for the box transformation in local camera coordinates (relative to the currrent view) instead of world coordinates. Those have far smaller values than the world coordinates and are therefore less prone to precision loss (leading higher roundoff errors).

It generally seems advisable to use this (or a similar) method whenever sub-block precision is needed (less than 1.0), like for block translation which needs to be virtually pixel-exact. Otherwise, similar issues might occur (and even at smaller distances, if one is unlucky with the formula).

I'll just be so brazen and open this issue again and create a pull request... please forgive my insolence ;-)

Cheers,
Gwani

PS: Tested the fix at near-zero and coordinates up to 29 million with all types of halo-creating lamps/buttons/levers... all appear to work just as intended.