POV-Ray / povray

The Persistence of Vision Raytracer: http://www.povray.org/
GNU Affero General Public License v3.0
1.35k stars 282 forks source link

Investigate and review use of CRITICAL_LENGTH in code. #379

Open wfpokorny opened 5 years ago

wfpokorny commented 5 years ago

Summary

Issue originally raised by Andreas Kaiser in a post to povray.bugreports news group. See the thread at:

http://news.povray.org/povray.bugreports/thread/%3C5d5d186c%241%40news.povray.org%3E/

Not really a bug as when the value is reduced to 1e-6 with the test scene attached the code pushes objects in the csg into the infinite object bucket as looks to be the intent. The run times jump as one might expect.

No reason obvious to us for this treatment and the normal magic 1e+6 value (how can such a magic value be general even if something needed) with only csg and the quadratic. If none can be found, the code should probably be removed or disabled until such time as someone complains about changed or invalid behavior.

Asides:

  1. The Doxygen header comments in configcore.h related to CRITICAL_LENGTH are incomplete as the control does NOT generally apply.

  2. Further the comment for @def BOUND_HUGE just below looks to have been copied from the CRITICAL_LENGTH one above and and so is inaccurate as written.

  3. The code is similar too and tangled in bounding volume tests - as questionably happens too at the end of parsing. These volume tests can lead to situations where folks cannot override default bounding because POV-Ray thinks it knows better by a volume calculation. Potential confusing results for the end user (and developers) as there is no indication user bounding was ignored.

Environment

Any and all. Also any version starting way back with v3.0 of POV-Ray where CRITICAL_LENGTH appeared.

Steps to Reproduce

  1. With attached scene run once and note objects all classified as finite.
  2. Change CRITICAL_LENGTH to 1e-6 in configcore.h and run again. The csg objects become infinite ones while the sphere and box continue to have bounding.

No scene created to test the quadric though that should be done to be sure that code also pushes objects into the infinite bucket. Also wondering about the quadric plane special bounds handling. Not sure what that's about.

Anyway, this really just the starting point to try and understand whether there is today a reason for this code to exist. Perhaps only one dimension being >CRITICAL_LENGTH has something to do with objects like planes where one bbox dimension is perhaps 0 - don't know. With csg is there perhaps an issue if part of the csg bboxes are outside MAX_DISTANCE - don't know. Just fishing. If the person looking at this has access to the old perforce commit logs maybe a reason got listed on the commit?

Expected Behavior

IF, a reason can be found for CRITICAL_LENGTH, it should be made more general and suppose be a user control and not a compile time one.

Render Settings

povray tmpCRIT.pov 

Scene

tmpCRIT.pov.txt

c-lipka commented 3 years ago

For the records: I consider this a precision issue that we don't want to tackle in a hurry while we prepare for v3.8.0 release.