diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 3e7bac852..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,128 +0,0 @@ - - -### Summary - - - -### Environment - - - - - Source code Git tag: - - POV-Ray version: - - Operating system: - - Hardware platform: - - Compiler: - - Regression from: - - - - - -### Windows Build Settings - - - - - Configuration: - - Platform: - -### Unix Build Command Sequence - - - -~~~ -cd unix ; prebuild.sh ; cd .. -./configure COMPILED_BY="John Doe " -make check -sudo make install -~~~ - -### Unix Pre-Build Output - - - -~~~ -~~~ - -### Unix Configure Output - - - -~~~ -~~~ - -### Compiler/Linker Output - - - -~~~ -~~~ - - - - - -### Steps to Reproduce - - - - 1. - 2. - 3. - -### Expected Behavior - - - -### Actual Behavior - - - - - - - -### Render Settings - - - -~~~ -~~~ - -### Scene - - - -~~~ -~~~ - -### Output - - - -~~~ -~~~ - - - - -### Workaround - - - - -### Suggested Solution - - - - - diff --git a/.github/ISSUE_TEMPLATE/bug_report_render.md b/.github/ISSUE_TEMPLATE/bug_report_render.md new file mode 100644 index 000000000..96223f0b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_render.md @@ -0,0 +1,82 @@ +--- +name: Bug report (Render) +about: Report unexpected behavior during parsing or rendering of a scene +title: "[BUG] " +labels: 'bug?' +assignees: '' + +--- + + + +**Summary** + +[Briefly describe your issue here.] + +**POV-Ray Version** + + - Incarnation: [e.g. POV-Ray for Unix, POV-Ray for Windows] + - Affected build version: [e.g. v3.7.1-beta.9+msvc14.win64] + - Known working build version: [e.g. v3.6.2.msvc9.win64] + +**Runtime Environment** + + - Operating system: [e.g. Windows 10 Pro 20H2 64 bit, Ubuntu 14.04] + - Hardware architecture: [e.g. x86, x86-64, armv8] + - CPU model: [e.g. Intel Core i7-5820K @ 3.30GHz] + +**Scene**
+~~~ +[Please copy a minimal scene here, demonstrating the unexpected behavior as concisely as possible. +Alternatively, especially if your scene file is large and/or needs other resources such as include +files or input images, please attach the scene and other files to the issue report as a zip file.] +~~~ +
+ +**Preset Render Options** + +[Please specify your preset render options here, or delete this section if you are using a +command line version of POV-Ray.] + +**Command Line Options** +~~~ +[Please copy your command line parameters (switches and/or INI-style options) here.] +~~~ + +**Expected Behavior** + +[Please describe what you expected to happen.] + +**Actual Behavior** + +[Please describe what actually happened.] + +**Output**
+~~~ +[Please copy the terminal output / message pane contents here, and attach the output image file to +the issue report if relevant.] +~~~ +
+ +**Additional context** (optional) + +[Please add any other context about the problem here, or delete this section.] + +**Workaround** (optional) + +[If you have managed to work around the issue, please describe that workaround here. +Otherwise please delete this section.] + +**Suggested Solution** (optional) + +[If you have an idea how to solve the issue for good, please describe it here. +Otherwise please delete this section.] + + diff --git a/.github/ISSUE_TEMPLATE/bug_report_unix.md b/.github/ISSUE_TEMPLATE/bug_report_unix.md new file mode 100644 index 000000000..8734e9fc5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_unix.md @@ -0,0 +1,76 @@ +--- +name: Bug report (Unix) +about: Report some other problem with POV-Ray for Unix +title: "[BUG][UNIX] " +labels: 'bug?' +assignees: '' + +--- + + + +**Summary** + +[Briefly describe your issue here.] + +**POV-Ray Version** + + - Incarnation: POV-Ray for Unix + - Affected build version: [as reported by `povray --version`, e.g. v3.7.1-beta.9.unofficial] + - Known working build version: [ditto, e.g. v3.6.2.unofficial] + +**Runtime Environment** + + - Operating system: [Ubuntu 14.04] + - Hardware architecture: [e.g. x86, x86-64, armv8] + - CPU model: [e.g. Intel Core i7-5820K @ 3.30GHz] + +**Steps to Reproduce** + + 1. [First step] + 2. [Second step] + 3. [Third step] + 4. [etc; please add or delete lines as appropriate] + +**Command Line**
+~~~ +[Please copy your terminal input here.] +~~~ +
+ +**Expected Behavior** + +[Please describe what you expected to happen.] + +**Actual Behavior** + +[Please describe what actually happened.] + +**Output**
+~~~ +[Please copy your terminal output here.] +~~~ +
+ +**Additional context** (optional) + +[Please add any other context about the problem here, or delete this section.] + +**Workaround** (optional) + +[If you have managed to work around the issue, please describe that workaround here. +Otherwise please delete this section.] + +**Suggested Solution** (optional) + +[If you have an idea how to solve the issue for good, please describe it here. +Otherwise please delete this section.] + + diff --git a/.github/ISSUE_TEMPLATE/bug_report_windows.md b/.github/ISSUE_TEMPLATE/bug_report_windows.md new file mode 100644 index 000000000..14256a627 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_windows.md @@ -0,0 +1,70 @@ +--- +name: Bug report (Windows) +about: Report some other problem with POV-Ray for Windows +title: "[BUG][WINDOWS] " +labels: 'bug?' +assignees: '' + +--- + + + +**Summary** + +[Briefly describe your issue here.] + +**POV-Ray Version** + + - Incarnation: POV-Ray for Windows + - Affected build version: [as per "About" window (Alt+B), e.g. v3.7.1-beta.9+msvc14.win64] + - Known working build version: [ditto, e.g. v3.6.2.msvc9.win64] + +**Runtime Environment** + + - Operating system: [e.g. Windows 10 Pro 20H2 64 bit] + - Hardware architecture: [e.g. x86, x86-64] + - CPU model: [e.g. Intel Core i7-5820K @ 3.30GHz] + +**Steps to Reproduce** + + 1. [First step] + 2. [Second step] + 3. [Third step] + 4. [etc; please add or delete lines as appropriate] + +**Expected Behavior** + +[Please describe what you expected to happen.] + +**Actual Behavior** + +[Please describe what actually happened.] + +**Output**
+~~~ +[Please copy the contents of your message window here.] +~~~ +
+ +**Additional context** (optional) + +[Please add any other context about the problem here, or delete this section.] + +**Workaround** (optional) + +[If you have managed to work around the issue, please describe that workaround here. +Otherwise please delete this section.] + +**Suggested Solution** (optional) + +[If you have an idea how to solve the issue for good, please describe it here. +Otherwise please delete this section.] + + diff --git a/.github/ISSUE_TEMPLATE/build_error_report_unix.md b/.github/ISSUE_TEMPLATE/build_error_report_unix.md new file mode 100644 index 000000000..47a883bd8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/build_error_report_unix.md @@ -0,0 +1,80 @@ +--- +name: Build error report (Unix) +about: Report a problem with compiling POV-Ray for Unix +title: "[BUILD][UNIX] " +labels: 'compatibility?, OS: Unix' +assignees: '' + +--- + + + +**Summary** + +[Briefly describe your issue here.] + +**POV-Ray Version** + + - Incarnation: POV-Ray for Unix + - Affected source version: [as per Git tag, e.g. v3.8.0-alpha.10023456] + - Known working source version: [e.g. v3.8.0-alpha.9987654, commit 6789abcd, or N/A] + +**Build Environment** + + - Operating system: [e.g. HP-UX 11.31] + - Hardware architecture: [e.g. pa-risc-2-0, ia64] + - Compiler: [e.g. clang 3.8] + +**Build Command Sequence**
+~~~ +[Please copy the actual command sequence you were using to build POV-Ray here, e.g. +cd unix ; prebuild.sh ; cd .. +./configure --prefix="~/some/where" COMPILED_BY="John Doe " +make check +sudo make install +] +~~~ +
+ +**Pre-Build Output**
+~~~ +[If you experience errors in `./configure`, or suspect the root cause to be in `prebuild.sh`, +please copy the _complete_ output of `prebuild.sh` here. Otherwise, please delete this section.] +~~~ +
+ +**Configure Output**
+~~~ +[Please copy the complete output of `./configure` here.] +~~~ +
+ +**Make Output**
+~~~ +[Please copy any compiler/linker errors and other relevant messages here. +If you experience errors in an earlier build step, please disregard and delete this section.] +~~~ +
+ +**Additional context** (optional) + +[Please add any other context about the problem here, or delete this section.] + +**Workaround** (optional) + +[If you have managed to work around the issue, please describe that workaround here. +Otherwise please delete this section.] + +**Suggested Solution** (optional) + +[If you have an idea how to solve the issue for good, please describe it here. +Otherwise please delete this section.] + + diff --git a/.github/ISSUE_TEMPLATE/build_error_report_windows.md b/.github/ISSUE_TEMPLATE/build_error_report_windows.md new file mode 100644 index 000000000..c0baea6e5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/build_error_report_windows.md @@ -0,0 +1,59 @@ +--- +name: Build error report (Windows) +about: Report a problem with compiling POV-Ray for Windows +title: "[BUILD][WINDOWS] " +labels: 'compatibility?, OS: Windows' +assignees: '' + +--- + + + +**Summary** + +[Briefly describe your issue here.] + +**POV-Ray Version** + + - Incarnation: POV-Ray for Windows + - Affected source version: [as per Git tag, e.g. v3.8.0-alpha.10023456] + - Known working source version: [e.g. v3.8.0-alpha.9987654, commit 6789abcd, or N/A] + +**Build Environment** + + - Operating system: [e.g. Windows 10 Pro 20H2 64 bit] + - Compiler: [e.g. Visual Studio 2015 SP2] + +**Build Settings** + + - Solution Configuration: [e.g. Debug, Release, Release-SSE2] + - Solution Platform: [e.g. Win32, x64] + +**Build Output**
+~~~ +[Please copy any compiler/linker errors and other relevant messages here.] +~~~ +
+ +**Additional context** (optional) + +[Please add any other context about the problem here, or delete this section.] + +**Workaround** (optional) + +[If you have managed to work around the issue, please describe that workaround here. +Otherwise please delete this section.] + +**Suggested Solution** (optional) + +[If you have an idea how to solve the issue for good, please describe it here. +Otherwise please delete this section.] + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..e35a1f622 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for POV-Ray +title: "[FEATURE] " +labels: 'feature' +assignees: '' + +--- + +**Is your feature request related to a problem?** + +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** + +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** + +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** + +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index ceb02f724..2cdfda3ed 100644 --- a/.gitignore +++ b/.gitignore @@ -150,6 +150,11 @@ $RECYCLE.BIN/ # POV-Ray Windows build artefacts # =============================== +/libraries/ilmbase/Half/eLut.h +/libraries/ilmbase/Half/toFloat.h +/libraries/png/pnglibconf.h +/libraries/tiff/libtiff/tif_config.h +/libraries/tiff/libtiff/tiffconf.h /windows/vs*/.vs/ /windows/vs*/bin32/ /windows/vs*/bin64/ @@ -175,7 +180,6 @@ $RECYCLE.BIN/ /VERSION /aclocal.m4 /bootstrap -/config.h.in /configure /configure.ac /kde_install.sh @@ -189,6 +193,7 @@ $RECYCLE.BIN/ /source/Makefile.in /unix/Makefile.am /unix/Makefile.in +/unix/config.h.in /unix/config/ar-lib /unix/config/compile /unix/config/config.guess @@ -207,23 +212,22 @@ $RECYCLE.BIN/ # Files created by configure script in main directory /Makefile -/config.h /config.status -/stamp-h1 # Files created by configure script in specific subdirectories /platform/Makefile /source/Makefile /unix/Makefile +/unix/config.h +/unix/stamp-h1 /vfe/Makefile # Directories created by configure script .deps/ -# Files created by make in main directory -/povray.ini -# Files created by make in specific subdirectories +# Files created by make /unix/povray -# Files created by make in various subdirectories .dirstamp +# Files created by make check +/povray.ini # ========================== # POV-Ray meta-make detritus @@ -254,3 +258,10 @@ $RECYCLE.BIN/ /tools/windows/htmlhelp/output /tools/windows/htmlhelp/debug.txt /tools/windows/htmlhelp/filelist.txt + +# ======================== +# GitHub Actions artefacts +# ======================== + +# Used specifically by our own workflows +/artifact* diff --git a/README.md b/README.md index 0480be11d..56cd9cf75 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ ======================================================================= [![Semaphore Build Status](https://semaphoreci.com/api/v1/pov-ray/povray/branches/master/shields_badge.svg?label=Semaphore)](https://semaphoreci.com/pov-ray/povray "Semaphore: Ubuntu 14.04 LTE 64-bit with gcc 4.8") -[![AppVeyor Build status](https://img.shields.io/appveyor/ci/c-lipka/povray-exwy4.svg?label=appveyor)](https://ci.appveyor.com/project/c-lipka/povray-exwy4 "AppVeyor: Windows Server 2012 with Visual Studio 2015") -[![Travis CI Build Status](https://img.shields.io/travis/POV-Ray/povray.svg?label=travis%20ci)](https://travis-ci.org/POV-Ray/povray "Travis CI: Ubuntu 12.04 LTE 64-bit with gcc 4.6; OS X 10.11 with clang 4.2") +[![AppVeyor Build status](https://img.shields.io/appveyor/ci/c-lipka/povray-exwy4.svg?label=appveyor)](https://ci.appveyor.com/project/c-lipka/povray-exwy4 "AppVeyor: Windows Server 2012 R2 with Visual Studio 2015") +[![Travis CI Build Status](https://img.shields.io/travis/POV-Ray/povray.svg?label=travis%20ci)](https://travis-ci.com/POV-Ray/povray "Travis CI: Ubuntu 14.04 LTE 64-bit with gcc 4.8.4; OS X 10.13 with clang ?.?") [![Coverity Code Analysis](https://scan.coverity.com/projects/269/badge.svg)](https://scan.coverity.com/projects/pov-ray "Coverity: Static Code Analysis") -[![Maintenance Status](https://img.shields.io/maintenance/yes/2019.svg)](README.md "Last edited 2019-01-03") +[![Maintenance Status](https://img.shields.io/maintenance/yes/2021.svg)](README.md "Last edited 2021-05-28") - [License](#license) - [Forums](#forums) diff --git a/changes.txt b/changes.txt index 13ab3e037..e869d3c88 100644 --- a/changes.txt +++ b/changes.txt @@ -133,6 +133,8 @@ Reported via GitHub: -lboost_system with Boost 1.66) - #342 ("AX_FIX_INCORRECT_PATH is broken", configure script failing to properly handle `.` directory in `C_INCLUDE_PATH` or `CPLUS_INCLUDE_PATH`) + - #400 ("Building on postmarketOS on PinePhone") + - #403 ("povray 3.7.0.8 does not build on macOS 11.0 Big Sur"). Reported via the Newsgroups: diff --git a/source/base/configbase.h b/source/base/configbase.h index d83b18e06..1b37487f1 100644 --- a/source/base/configbase.h +++ b/source/base/configbase.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -903,6 +903,24 @@ #define POV_STRING_DEBUG POV_DEBUG #endif +/// @def POV_BOMB_ON_ERROR +/// Fail hard on all errors, allowing a debugger to kick in. +/// +/// Define as non-zero integer to enable, or zero to disable. +/// +/// If left undefined by system-specific configurations, this setting defaults to `0`. +/// +/// @attention +/// This setting is _strictly_ for debugging purposes only. It should _never ever_ be enabled +/// in _any_ builds released to end users, be it release builds or otherwise! +/// +/// @note +/// At present, this is not yet supported by all error conditions. +/// +#ifndef POV_BOMB_ON_ERROR + #define POV_BOMB_ON_ERROR 0 +#endif + /// @} /// //****************************************************************************** diff --git a/source/base/image/targa.cpp b/source/base/image/targa.cpp index 85b489e6f..dbaca8d11 100644 --- a/source/base/image/targa.cpp +++ b/source/base/image/targa.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -135,7 +135,7 @@ void Write (OStream *file, const Image *image, const ImageWriteOptions& options) { pix current; pix next; - bool opaque = options.AlphaIsEnabled(); + bool opaque = !options.AlphaIsEnabled(); bool compress = (options.compression > 0); vector header; vector line; diff --git a/source/core/configcore.h b/source/core/configcore.h index ef3ef3bf4..830065620 100644 --- a/source/core/configcore.h +++ b/source/core/configcore.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -47,9 +47,17 @@ /// @defgroup PovCoreConfig Core Compile-Time Configuration /// @ingroup PovCore /// @ingroup PovConfig +/// Compile-Time Configuration of the @ref PovCore. /// /// @{ +/// @def POV_EXPERIMENTAL_BRILLIANCE_OUT +/// Whether experimental second brilliance parameter should be enabled. +/// +#ifndef POV_EXPERIMENTAL_BRILLIANCE_OUT + #define POV_EXPERIMENTAL_BRILLIANCE_OUT 0 +#endif + //****************************************************************************** /// /// @name PooledSimpleVector Sizes @@ -62,44 +70,44 @@ /// @{ #ifndef MEDIA_VECTOR_SIZE -#define MEDIA_VECTOR_SIZE 256 + #define MEDIA_VECTOR_SIZE 256 #endif #ifndef MEDIA_INTERVAL_VECTOR_SIZE -#define MEDIA_INTERVAL_VECTOR_SIZE 256 + #define MEDIA_INTERVAL_VECTOR_SIZE 256 #endif #ifndef LIT_INTERVAL_VECTOR_SIZE -#define LIT_INTERVAL_VECTOR_SIZE 512 + #define LIT_INTERVAL_VECTOR_SIZE 512 #endif #ifndef LIGHT_INTERSECTION_VECTOR_SIZE -#define LIGHT_INTERSECTION_VECTOR_SIZE 512 // TODO - I think this should be LIGHTSOURCE_VECTOR_SIZE*2 [CLi] + #define LIGHT_INTERSECTION_VECTOR_SIZE 512 // TODO - I think this should be LIGHTSOURCE_VECTOR_SIZE*2 [CLi] #endif #ifndef LIGHTSOURCE_VECTOR_SIZE -#define LIGHTSOURCE_VECTOR_SIZE 1024 + #define LIGHTSOURCE_VECTOR_SIZE 1024 #endif #ifndef WEIGHTEDTEXTURE_VECTOR_SIZE -#define WEIGHTEDTEXTURE_VECTOR_SIZE 512 + #define WEIGHTEDTEXTURE_VECTOR_SIZE 512 #endif #ifndef RAYINTERIOR_VECTOR_SIZE -#define RAYINTERIOR_VECTOR_SIZE 512 + #define RAYINTERIOR_VECTOR_SIZE 512 #endif /// @def POV_VECTOR_POOL_SIZE /// Initial size of @ref PooledSimpleVector pools. #ifndef POV_VECTOR_POOL_SIZE -#define POV_VECTOR_POOL_SIZE 16 + #define POV_VECTOR_POOL_SIZE 16 #endif /// @def POV_SIMPLE_VECTOR /// Vector type optimized for performance. /// May be either `std::vector`, `pov::SimpleVector`, or a compatible template. #ifndef POV_SIMPLE_VECTOR -#define POV_SIMPLE_VECTOR pov::SimpleVector + #define POV_SIMPLE_VECTOR pov::SimpleVector #endif /// @} @@ -282,24 +290,6 @@ /// /// @{ -/// @def POV_BOMB_ON_ERROR -/// Fail hard on all errors, allowing a debugger to kick in. -/// -/// Define as non-zero integer to enable, or zero to disable. -/// -/// If left undefined by system-specific configurations, this setting defaults to `0`. -/// -/// @attention -/// This setting is _strictly_ for debugging purposes only, and should _never ever_ be enabled -/// in a release build! -/// -/// @note -/// At present, this is not yet supported by all error conditions. -/// -#ifndef POV_BOMB_ON_ERROR - #define POV_BOMB_ON_ERROR 0 -#endif - /// @def POV_CORE_DEBUG /// Default setting for enabling or disabling @ref PovCore debugging aids. /// diff --git a/source/core/lighting/lightsource.cpp b/source/core/lighting/lightsource.cpp index c4b86c8aa..df671c1ca 100644 --- a/source/core/lighting/lightsource.cpp +++ b/source/core/lighting/lightsource.cpp @@ -658,10 +658,10 @@ DBL Attenuate_Light (const LightSource *Light, const Ray &ray, DBL Distance) * ******************************************************************************/ -void LightSource::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void LightSource::UVCoord(Vector2d& Result, const Intersection *Inter) const { if(!children.empty()) - children[0]->UVCoord(Result, Inter, Thread); + children[0]->UVCoord(Result, Inter); } } diff --git a/source/core/material/normal.cpp b/source/core/material/normal.cpp index 25bd58e1b..53ae230d3 100644 --- a/source/core/material/normal.cpp +++ b/source/core/material/normal.cpp @@ -803,7 +803,7 @@ void Perturb_Normal(Vector3d& Layer_Normal, const TNORMAL *Tnormal, const Vector Vector2d UV_Coords; /* Don't bother warping, simply get the UV vect of the intersection */ - Intersection->Object->UVCoord(UV_Coords, Intersection, Thread); + Intersection->Object->UVCoord(UV_Coords, Intersection); TPoint[X] = UV_Coords[U]; TPoint[Y] = UV_Coords[V]; TPoint[Z] = 0; diff --git a/source/core/material/pigment.cpp b/source/core/material/pigment.cpp index 088fef7a9..780948849 100644 --- a/source/core/material/pigment.cpp +++ b/source/core/material/pigment.cpp @@ -608,7 +608,7 @@ bool PigmentBlendMap::ComputeUVMapped(TransColour& colour, const Intersection *I const BlendMapEntry* Cur = &(Blend_Map_Entries[0]); /* Don't bother warping, simply get the UV vect of the intersection */ - Intersect->Object->UVCoord(UV_Coords, Intersect, Thread); + Intersect->Object->UVCoord(UV_Coords, Intersect); TPoint[X] = UV_Coords[U]; TPoint[Y] = UV_Coords[V]; TPoint[Z] = 0; diff --git a/source/core/material/texture.cpp b/source/core/material/texture.cpp index 561054693..ec7a4aa27 100644 --- a/source/core/material/texture.cpp +++ b/source/core/material/texture.cpp @@ -19,7 +19,7 @@ /// ---------------------------------------------------------------------------- /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -241,7 +241,7 @@ FINISH *Create_Finish() New->Diffuse = 0.6; New->DiffuseBack = 0.0; New->Brilliance = 1.0; -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT New->BrillianceOut = 1.0; #endif New->BrillianceAdjust = 1.0; diff --git a/source/core/material/texture.h b/source/core/material/texture.h index 98ce7cbb4..96fcec650 100644 --- a/source/core/material/texture.h +++ b/source/core/material/texture.h @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -119,7 +119,7 @@ struct Texture_Struct final : public Pattern_Struct struct Finish_Struct final { SNGL Diffuse, DiffuseBack, Brilliance; -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT SNGL BrillianceOut; #endif SNGL BrillianceAdjust, BrillianceAdjustRad; diff --git a/source/core/render/trace.cpp b/source/core/render/trace.cpp index eb48d4f27..aa1330ce8 100644 --- a/source/core/render/trace.cpp +++ b/source/core/render/trace.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -506,7 +506,7 @@ void Trace::ComputeTextureColour(Intersection& isect, MathColour& colour, Colour // This causes slopes do be applied in the wrong directions. // get the UV vect of the intersection - isect.Object->UVCoord(uvcoords, &isect, threadData); + isect.Object->UVCoord(uvcoords, &isect); // save the normal and UV coords into Intersection isect.Iuv = uvcoords; @@ -639,7 +639,7 @@ void Trace::ComputeOneTextureColour(MathColour& resultColour, ColourChannel& res // This causes slopes do be applied in the wrong directions. // Don't bother warping, simply get the UV vect of the intersection - isect.Object->UVCoord(uvcoords, &isect, threadData); + isect.Object->UVCoord(uvcoords, &isect); tpoint = Vector3d(uvcoords[U], uvcoords[V], 0.0); cur = &(texture->Blend_Map->Blend_Map_Entries[0]); ComputeOneTextureColour(resultColour, resultTransm, cur->Vals, warps, tpoint, rawnormal, ray, weight, isect, shadowflag, photonPass); @@ -953,7 +953,7 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul radiosityContribution += (layCol.colour() * ambBackCol) * (att * diffuse); } -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT if((sceneData->radiositySettings.brilliance) && (layer->Finish->BrillianceOut != 1.0)) radiosityContribution *= pow(fabs(cos_Angle_Incidence), layer->Finish->BrillianceOut-1.0) * (layer->Finish->BrillianceOut+7.0)/8.0; #endif @@ -1025,7 +1025,7 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul ComputeDiffuseLight(layer->Finish, isect.IPoint, ray, layNormal, layCol.colour(), classicContribution, att, isect.Object, relativeIor); -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT if(layer->Finish->BrillianceOut != 1.0) { double cos_angle_of_incidence = dot(ray.Direction, layNormal); @@ -1046,7 +1046,7 @@ void Trace::ComputeLightedTexture(MathColour& resultColour, ColourChannel& resul ComputePhotonDiffuseLight(layer->Finish, isect.IPoint, ray, layNormal, rawnormal, layCol.colour(), photonsContribution, att, isect.Object, relativeIor, *surfacePhotonGatherer); -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT if(layer->Finish->BrillianceOut != 1.0) { double cos_angle_of_incidence = dot(ray.Direction, layNormal); @@ -2356,7 +2356,7 @@ void Trace::ComputeShadowColour(const LightSource &lightsource, Intersection& is // This causes slopes do be applied in the wrong directions. // get the UV vect of the intersection - isect.Object->UVCoord(uv_Coords, &isect, threadData); + isect.Object->UVCoord(uv_Coords, &isect); // save the normal and UV coords into Intersection isect.Iuv = uv_Coords; diff --git a/source/core/scene/object.cpp b/source/core/scene/object.cpp index 7cb81c84d..873cfa761 100644 --- a/source/core/scene/object.cpp +++ b/source/core/scene/object.cpp @@ -879,7 +879,7 @@ double ObjectBase::GetPotential (const Vector3d& p, bool subtractThreshold, Trac * ******************************************************************************/ -void ObjectBase::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *) const +void ObjectBase::UVCoord(Vector2d& Result, const Intersection *Inter) const { Result[U] = Inter->IPoint[X]; Result[V] = Inter->IPoint[Y]; diff --git a/source/core/scene/object.h b/source/core/scene/object.h index 9ad1efa27..985422200 100644 --- a/source/core/scene/object.h +++ b/source/core/scene/object.h @@ -173,6 +173,7 @@ namespace pov class ObjectBase { public: + int Type; // TODO - make obsolete TEXTURE *Texture; TEXTURE *Interior_Texture; @@ -232,13 +233,13 @@ class ObjectBase /// /// @return True if object parameters are within reasonable limits. /// - virtual bool Precompute() { return true; }; + virtual bool Precompute() { return true; } virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) = 0; // could be "const", if it wasn't for isosurface max_gradient estimation stuff virtual double GetPotential (const Vector3d&, bool subtractThreshold, TraceThreadData *) const; virtual bool Inside(const Vector3d&, TraceThreadData *) const = 0; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const = 0; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const; + virtual void UVCoord(Vector2d&, const Intersection *) const; virtual void Translate(const Vector3d&, const TRANSFORM *) = 0; virtual void Rotate(const Vector3d&, const TRANSFORM *) = 0; virtual void Scale(const Vector3d&, const TRANSFORM *) = 0; @@ -281,6 +282,7 @@ class ObjectBase virtual bool IsOpaque() const; protected: + explicit ObjectBase(const ObjectBase&) { } }; @@ -340,7 +342,7 @@ class LightSource final : public CompoundObject virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/scene/tracethreaddata.cpp b/source/core/scene/tracethreaddata.cpp index 2a0dc567f..f314724bc 100644 --- a/source/core/scene/tracethreaddata.cpp +++ b/source/core/scene/tracethreaddata.cpp @@ -50,7 +50,6 @@ #include "core/scene/scenedata.h" #include "core/shape/blob.h" #include "core/shape/fractal.h" -#include "core/shape/isosurface.h" #include "core/support/cracklecache.h" // this must be the last file included @@ -76,14 +75,6 @@ TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : Blob_Queue = reinterpret_cast(POV_MALLOC(sizeof(void *), "Blob Queue")); Blob_Coefficients = reinterpret_cast(POV_MALLOC(sizeof(DBL) * Blob_Coefficient_Count, "Blob Coefficients")); Blob_Intervals = new Blob_Interval_Struct [Blob_Interval_Count]; - isosurfaceData = reinterpret_cast(POV_MALLOC(sizeof(ISO_ThreadData), "Isosurface Data")); - isosurfaceData->pFn = nullptr; - isosurfaceData->current = nullptr; - isosurfaceData->cache = false; - isosurfaceData->Inv3 = 1; - isosurfaceData->fmax = 0.0; - isosurfaceData->tl = 0.0; - isosurfaceData->Vlength = 0.0; BCyl_Intervals.reserve(4*sceneData->Max_Bounding_Cylinders); BCyl_RInt.reserve(2*sceneData->Max_Bounding_Cylinders); @@ -111,7 +102,6 @@ TraceThreadData::TraceThreadData(std::shared_ptr sd, size_t seed) : passThruPrev = false; // was the previous object pass-through? Light_Is_Global = false; // is the current light global? (not part of a light_group?) - CrCache_MaxAge = 1; progress_index = 0; surfacePhotonMap = new PhotonMap(); @@ -128,7 +118,6 @@ TraceThreadData::~TraceThreadData() POV_FREE(Blob_Coefficients); POV_FREE(Blob_Queue); - POV_FREE(isosurfaceData); Fractal::Free_Iteration_Stack(Fractal_IStack); delete surfacePhotonMap; delete mediaPhotonMap; diff --git a/source/core/scene/tracethreaddata.h b/source/core/scene/tracethreaddata.h index e9d9714b4..ae7fa68fd 100644 --- a/source/core/scene/tracethreaddata.h +++ b/source/core/scene/tracethreaddata.h @@ -71,8 +71,6 @@ namespace pov using namespace pov_base; -struct ISO_ThreadData; - class PhotonMap; struct Blob_Interval_Struct; @@ -101,7 +99,6 @@ class TraceThreadData : public ThreadData Blob_Interval_Struct *Blob_Intervals; int Blob_Coefficient_Count; int Blob_Interval_Count; - ISO_ThreadData *isosurfaceData; ///< @todo We may want to move this data block to the isosurface code as a local variable. std::vector BCyl_Intervals; std::vector BCyl_RInt; std::vector BCyl_HInt; @@ -182,8 +179,6 @@ class TraceThreadData : public ThreadData TraceThreadData(const TraceThreadData&) = delete; TraceThreadData& operator=(const TraceThreadData&) = delete; - /// current number of Tiles to expire crackle cache entries after - size_t CrCache_MaxAge; /// current tile index (for crackle cache expiry) size_t progress_index; }; diff --git a/source/core/shape/bezier.cpp b/source/core/shape/bezier.cpp index dbabce6fe..527390fdf 100644 --- a/source/core/shape/bezier.cpp +++ b/source/core/shape/bezier.cpp @@ -2137,7 +2137,7 @@ void BicubicPatch::Compute_BBox() * ******************************************************************************/ -void BicubicPatch::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void BicubicPatch::UVCoord(Vector2d& Result, const Intersection *Inter) const { /* Use preocmputed uv coordinates. */ diff --git a/source/core/shape/bezier.h b/source/core/shape/bezier.h index 41725d7d1..ac97baf9a 100644 --- a/source/core/shape/bezier.h +++ b/source/core/shape/bezier.h @@ -121,7 +121,7 @@ class BicubicPatch final : public NonsolidObject virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/shape/blob.cpp b/source/core/shape/blob.cpp index 5850ed575..94cda6f23 100644 --- a/source/core/shape/blob.cpp +++ b/source/core/shape/blob.cpp @@ -1173,10 +1173,10 @@ int Blob::intersect_sphere(const Blob_Element *Element, const Vector3d& P, const * ******************************************************************************/ -int Blob::intersect_element(const Vector3d& P, const Vector3d& D, const Blob_Element *Element, DBL mindist, DBL *tmin, DBL *tmax, TraceThreadData *Thread) +int Blob::intersect_element(const Vector3d& P, const Vector3d& D, const Blob_Element *Element, DBL mindist, DBL *tmin, DBL *tmax, RenderStatistics& stats) { #ifdef BLOB_EXTRA_STATS - Thread->Stats()[Blob_Element_Tests]++; + stats[Blob_Element_Tests]++; #endif *tmin = BOUND_HUGE; @@ -1223,7 +1223,7 @@ int Blob::intersect_element(const Vector3d& P, const Vector3d& D, const Blob_Ele } #ifdef BLOB_EXTRA_STATS - Thread->Stats()[Blob_Element_Tests_Succeeded]++; + stats[Blob_Element_Tests_Succeeded]++; #endif return (true); @@ -1282,7 +1282,7 @@ int Blob::determine_influences(const Vector3d& P, const Vector3d& D, DBL mindist for (vector::iterator i = Data->Entry.begin(); i != Data->Entry.end(); ++i) { - if (intersect_element(P, D, &(*i), mindist, &t0, &t1, Thread)) + if (intersect_element(P, D, &(*i), mindist, &t0, &t1, Thread->Stats())) { insert_hit(&(*i), t0, t1, intervals, &cnt); } @@ -1306,7 +1306,7 @@ int Blob::determine_influences(const Vector3d& P, const Vector3d& D, DBL mindist { /* Test element. */ - if (intersect_element(P, D, reinterpret_cast(Tree->Node), mindist, &t0, &t1, Thread)) + if (intersect_element(P, D, reinterpret_cast(Tree->Node), mindist, &t0, &t1, Thread->Stats())) { insert_hit(reinterpret_cast(Tree->Node), t0, t1, intervals, &cnt); } diff --git a/source/core/shape/blob.h b/source/core/shape/blob.h index 6d5bfdb06..218984ad1 100644 --- a/source/core/shape/blob.h +++ b/source/core/shape/blob.h @@ -180,7 +180,7 @@ class Blob final : public ObjectBase static void Transform_Blob_Element(Blob_Element *Element, const TRANSFORM *Trans); private: static void element_normal(Vector3d& Result, const Vector3d& P, const Blob_Element *Element); - static int intersect_element(const Vector3d& P, const Vector3d& D, const Blob_Element *Element, DBL mindist, DBL *t0, DBL *t1, TraceThreadData *Thread); + static int intersect_element(const Vector3d& P, const Vector3d& D, const Blob_Element *Element, DBL mindist, DBL *t0, DBL *t1, RenderStatistics& stats); static void insert_hit(const Blob_Element *Element, DBL t0, DBL t1, Blob_Interval_Struct *intervals, unsigned int *cnt); int determine_influences(const Vector3d& P, const Vector3d& D, DBL mindist, Blob_Interval_Struct *intervals, TraceThreadData *Thread) const; DBL calculate_field_value(const Vector3d& P, TraceThreadData *Thread) const; diff --git a/source/core/shape/box.cpp b/source/core/shape/box.cpp index 245b920d5..98a393945 100644 --- a/source/core/shape/box.cpp +++ b/source/core/shape/box.cpp @@ -1025,7 +1025,7 @@ void Box::Compute_BBox() * ******************************************************************************/ -void Box::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Box::UVCoord(Vector2d& Result, const Intersection *Inter) const { Vector3d P, Box_Diff; diff --git a/source/core/shape/box.h b/source/core/shape/box.h index 045845030..6f7db92ca 100644 --- a/source/core/shape/box.h +++ b/source/core/shape/box.h @@ -97,7 +97,7 @@ class Box final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/shape/cone.cpp b/source/core/shape/cone.cpp index b0b8b3bf4..d602d99b5 100644 --- a/source/core/shape/cone.cpp +++ b/source/core/shape/cone.cpp @@ -108,7 +108,7 @@ bool Cone::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat Intersection_Found = false; - if ((cnt = Intersect(ray, I, Thread)) != 0) + if ((cnt = Intersect(ray, I, Thread->Stats())) != 0) { for (i = 0; i < cnt; i++) { @@ -153,14 +153,14 @@ bool Cone::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat * ******************************************************************************/ -int Cone::Intersect(const BasicRay& ray, CONE_INT *Intersection, TraceThreadData *Thread) const +int Cone::Intersect(const BasicRay& ray, CONE_INT *Intersection, RenderStatistics& stats) const { int i = 0; DBL a, b, c, z, t1, t2, len; DBL d; Vector3d P, D; - Thread->Stats()[Ray_Cone_Tests]++; + stats[Ray_Cone_Tests]++; /* Transform the ray into the cones space */ @@ -297,7 +297,7 @@ int Cone::Intersect(const BasicRay& ray, CONE_INT *Intersection, TraceThreadData } if (i) - Thread->Stats()[Ray_Cone_Tests_Succeeded]++; + stats[Ray_Cone_Tests_Succeeded]++; return (i); } @@ -962,7 +962,7 @@ void Cone::Compute_BBox() * ******************************************************************************/ -void Cone::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Cone::UVCoord(Vector2d& Result, const Intersection *Inter) const { CalcUV(Inter->IPoint, Result); } diff --git a/source/core/shape/cone.h b/source/core/shape/cone.h index 27b81ea54..eb28bd802 100644 --- a/source/core/shape/cone.h +++ b/source/core/shape/cone.h @@ -99,7 +99,7 @@ class Cone final : public ObjectBase /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; #endif // POV_ENABLE_CONE_UV virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; @@ -110,7 +110,7 @@ class Cone final : public ObjectBase void Compute_Cone_Data(); void Compute_Cylinder_Data(); protected: - int Intersect(const BasicRay& ray, CONE_INT *Intersection, TraceThreadData *Thread) const; + int Intersect(const BasicRay& ray, CONE_INT *Intersection, RenderStatistics& stats) const; #ifdef POV_ENABLE_CONE_UV void CalcUV(const Vector3d& IPoint, Vector2d& Result) const; #endif // POV_ENABLE_CONE_UV diff --git a/source/core/shape/disc.h b/source/core/shape/disc.h index 8a9aafebb..74fca63e2 100644 --- a/source/core/shape/disc.h +++ b/source/core/shape/disc.h @@ -90,7 +90,7 @@ class Disc final : public ObjectBase // NOTE: UV mapping of this primitive should not be implemented without also amending // the primary parameterization so that users have full control over the primitive's // orientation, rather than just the normal vector. - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + // virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/shape/isosurface.cpp b/source/core/shape/isosurface.cpp index d0aedb96c..487f70b7a 100644 --- a/source/core/shape/isosurface.cpp +++ b/source/core/shape/isosurface.cpp @@ -64,6 +64,28 @@ namespace pov using std::min; using std::max; +struct IsosurfaceCache final +{ + const IsoSurface *current; + Vector3d Pglobal; + Vector3d Dglobal; + DBL fmax; + IsosurfaceCache(); +}; + +IsosurfaceCache::IsosurfaceCache() : + current(nullptr) +{} + +struct ISO_ThreadData final +{ + IsosurfaceCache cache; + GenericScalarFunctionInstance* pFn; + DBL Vlength; + DBL tl; + int Inv3; +}; + /***************************************************************************** * Local preprocessor defines ******************************************************************************/ @@ -137,6 +159,7 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr int begin = 0, end = 0; bool in_shadow_test = false; Vector3d VTmp; + thread_local ISO_ThreadData isoData; Thread->Stats()[Ray_IsoSurface_Bound_Tests]++; @@ -162,7 +185,7 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr Dlocal = ray.Direction; } - Thread->isosurfaceData->Inv3 = 1; + isoData.Inv3 = 1; if(closed != false) { @@ -178,7 +201,7 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr Depth_Stack->push(Intersection(Depth1, IPoint, this, 1, Side1)); IFound = true; itrace++; - Thread->isosurfaceData->Inv3 *= -1; + isoData.Inv3 *= -1; } } } @@ -189,7 +212,7 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr Depth1 = accuracy * 5.0; VTmp = Plocal + Depth1 * Dlocal; if (IsInside (fn, VTmp)) - Thread->isosurfaceData->Inv3 = -1; + isoData.Inv3 = -1; /* Change the sign of the function (IPoint is in the bounding shpae.)*/ } VTmp = Plocal + Depth2 * Dlocal; @@ -215,7 +238,7 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr return (false); } Thread->Stats()[Ray_IsoSurface_Tests]++; - if((Depth1 < accuracy) && (Thread->isosurfaceData->Inv3 == 1)) + if((Depth1 < accuracy) && (isoData.Inv3 == 1)) { /* IPoint is on the isosurface */ VTmp = Plocal + tmin * Dlocal; @@ -224,16 +247,16 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr tmin = accuracy * 5.0; VTmp = Plocal + tmin * Dlocal; if (IsInside (fn, VTmp)) - Thread->isosurfaceData->Inv3 = -1; + isoData.Inv3 = -1; /* change the sign and go into the isosurface */ } } - Thread->isosurfaceData->pFn = &fn; + isoData.pFn = &fn; for (; itrace < max_trace; itrace++) { - if(Function_Find_Root(*(Thread->isosurfaceData), Plocal, Dlocal, &tmin, &tmax, maxg, in_shadow_test, Thread) == false) + if(Function_Find_Root(isoData, Plocal, Dlocal, &tmin, &tmax, maxg, in_shadow_test, Thread) == false) break; else { @@ -247,13 +270,13 @@ bool IsoSurface::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThr tmin += accuracy * 5.0; if((tmax - tmin) < accuracy) break; - Thread->isosurfaceData->Inv3 *= -1; + isoData.Inv3 *= -1; } if(IFound) Thread->Stats()[Ray_IsoSurface_Tests_Succeeded]++; - Thread->isosurfaceData->pFn = nullptr; + isoData.pFn = nullptr; } if(eval == true) @@ -849,29 +872,29 @@ bool IsoSurface::Function_Find_Root(ISO_ThreadData& itd, const Vector3d& PP, con itd.Vlength = DD.length(); - if((itd.cache == true) && (itd.current == this)) + if(itd.cache.current == this) { pThreadData->Stats()[Ray_IsoSurface_Cache]++; VTmp = PP + *Depth1 * DD; - VTmp -= itd.Pglobal; + VTmp -= itd.cache.Pglobal; l_b = VTmp.length(); VTmp = PP + *Depth2 * DD; - VTmp -= itd.Dglobal; + VTmp -= itd.cache.Dglobal; l_e = VTmp.length(); - if((itd.fmax - maxg * max(l_b, l_e)) > 0.0) + if((itd.cache.fmax - maxg * max(l_b, l_e)) > 0.0) { pThreadData->Stats()[Ray_IsoSurface_Cache_Succeeded]++; return false; } } - itd.Pglobal = PP; - itd.Dglobal = DD; + itd.cache.Pglobal = PP; + itd.cache.Dglobal = DD; - itd.cache = false; + itd.cache.current = nullptr; EP1.t = *Depth1; EP1.f = Float_Function(itd, *Depth1); - itd.fmax = EP1.f; + itd.cache.fmax = EP1.f; if((closed == false) && (EP1.f < 0.0)) { itd.Inv3 *= -1; @@ -880,7 +903,7 @@ bool IsoSurface::Function_Find_Root(ISO_ThreadData& itd, const Vector3d& PP, con EP2.t = *Depth2; EP2.f = Float_Function(itd, *Depth2); - itd.fmax = min(EP2.f, itd.fmax); + itd.cache.fmax = min(EP2.f, itd.cache.fmax); oldmg = maxg; t21 = (*Depth2 - *Depth1); @@ -909,10 +932,9 @@ bool IsoSurface::Function_Find_Root(ISO_ThreadData& itd, const Vector3d& PP, con } else if(!in_shadow_test) { - itd.cache = true; - itd.Pglobal = PP + EP1.t * DD; - itd.Dglobal = PP + EP2.t * DD; - itd.current = this; + itd.cache.Pglobal = PP + EP1.t * DD; + itd.cache.Dglobal = PP + EP2.t * DD; + itd.cache.current = this; return false; } @@ -979,7 +1001,7 @@ bool IsoSurface::Function_Find_Root_R(ISO_ThreadData& itd, const ISO_Pair* EP1, EPa.t = EP1->t + t21; EPa.f = Float_Function(itd, EPa.t); - itd.fmax = min(EPa.f, itd.fmax); + itd.cache.fmax = min(EPa.f, itd.cache.fmax); if(!Function_Find_Root_R(itd, EP1, &EPa, dt, t21, len * 2.0, maxg, pThreadData)) return (Function_Find_Root_R(itd, &EPa, EP2, dt, t21, len * 2.0,maxg, pThreadData)); else @@ -1020,7 +1042,7 @@ DBL IsoSurface::Float_Function(ISO_ThreadData& itd, DBL t) const { Vector3d VTmp; - VTmp = itd.Pglobal + t * itd.Dglobal; + VTmp = itd.cache.Pglobal + t * itd.cache.Dglobal; return ((DBL)itd.Inv3 * EvaluatePolarized (*itd.pFn, VTmp)); } diff --git a/source/core/shape/isosurface.h b/source/core/shape/isosurface.h index eae370554..be454b675 100644 --- a/source/core/shape/isosurface.h +++ b/source/core/shape/isosurface.h @@ -97,19 +97,7 @@ struct ISO_Pair final }; struct ISO_Max_Gradient; - -struct ISO_ThreadData final -{ - const IsoSurface *current; - GenericScalarFunctionInstance* pFn; - Vector3d Pglobal; - Vector3d Dglobal; - DBL Vlength; - DBL tl; - DBL fmax; - bool cache; - int Inv3; -}; +struct ISO_ThreadData; class IsoSurface final : public ObjectBase { diff --git a/source/core/shape/lathe.cpp b/source/core/shape/lathe.cpp index 6f1f2ba56..d31c25256 100644 --- a/source/core/shape/lathe.cpp +++ b/source/core/shape/lathe.cpp @@ -959,7 +959,7 @@ void Lathe::Compute_BBox() * ******************************************************************************/ -void Lathe::Compute_Lathe(Vector2d *P, TraceThreadData *Thread) +void Lathe::Compute_Lathe(Vector2d *P, RenderStatistics& stats) { int i, i1, i2, i3, n, segment, number_of_segments; DBL x[4], y[4]; @@ -1164,7 +1164,7 @@ void Lathe::Compute_Lathe(Vector2d *P, TraceThreadData *Thread) c[1] = 2.0 * B[X]; c[2] = C[X]; - n = Solve_Polynomial(2, c, r, false, 0.0, Thread->Stats()); + n = Solve_Polynomial(2, c, r, false, 0.0, stats); while (n--) { @@ -1178,7 +1178,7 @@ void Lathe::Compute_Lathe(Vector2d *P, TraceThreadData *Thread) c[1] = 2.0 * B[Y]; c[2] = C[Y]; - n = Solve_Polynomial(2, c, r, false, 0.0, Thread->Stats()); + n = Solve_Polynomial(2, c, r, false, 0.0, stats); while (n--) { @@ -1341,7 +1341,7 @@ bool Lathe::test_hit(const BasicRay &ray, IStack& Depth_Stack, DBL d, DBL w, int * ******************************************************************************/ -void Lathe::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *) const +void Lathe::UVCoord(Vector2d& Result, const Intersection *Inter) const { DBL len, theta; Vector3d P; diff --git a/source/core/shape/lathe.h b/source/core/shape/lathe.h index 180537e34..ca1177c39 100644 --- a/source/core/shape/lathe.h +++ b/source/core/shape/lathe.h @@ -117,14 +117,14 @@ class Lathe final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; virtual void Transform(const TRANSFORM *) override; virtual void Compute_BBox() override; - void Compute_Lathe(Vector2d *P, TraceThreadData *); + void Compute_Lathe(Vector2d *P, RenderStatistics& stats); protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); bool test_hit(const BasicRay&, IStack&, DBL, DBL, int, TraceThreadData *Thread); diff --git a/source/core/shape/lemon.cpp b/source/core/shape/lemon.cpp index 712fbaadd..a023bbf09 100644 --- a/source/core/shape/lemon.cpp +++ b/source/core/shape/lemon.cpp @@ -114,7 +114,7 @@ bool Lemon::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa Intersection_Found = false; - if ((cnt = Intersect(P, D, I, Thread)) != 0) + if ((cnt = Intersect(P, D, I, Thread->Stats())) != 0) { for (i = 0; i < cnt; i++) { @@ -161,7 +161,7 @@ bool Lemon::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa * ******************************************************************************/ -int Lemon::Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersection, TraceThreadData *Thread) const +int Lemon::Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersection, RenderStatistics& stats) const { int i = 0; DBL a, b, c[5], r[4]; @@ -196,7 +196,7 @@ int Lemon::Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersecti c[4] = k1 * k1 + 4.0 * R2 * (Pz2 - r2); - n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), ROOT_TOLERANCE, Thread->Stats()); + n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), ROOT_TOLERANCE, stats); while (n--) { // here we only keep the 'lemon' inside the torus @@ -784,7 +784,7 @@ void Lemon::Compute_BBox() * ******************************************************************************/ -void Lemon::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Lemon::UVCoord(Vector2d& Result, const Intersection *Inter) const { CalcUV(Inter->IPoint, Result); } diff --git a/source/core/shape/lemon.h b/source/core/shape/lemon.h index 42b882169..9f44fa8f2 100644 --- a/source/core/shape/lemon.h +++ b/source/core/shape/lemon.h @@ -95,7 +95,7 @@ class Lemon final : public ObjectBase /// UV mapping of this primitive should not be enabled until the primary /// parameterization has been amended so that users have full control over the /// primitive's orientation, rather than just the axis of rotational symmetry. - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; #endif // POV_ENABLE_LEMON_UV virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; @@ -113,7 +113,7 @@ class Lemon final : public ObjectBase DBL HorizontalPosition; /* horizontal position of the center of the inner circle */ DBL VerticalPosition; /* vertical position of the center of the inner circle */ protected: - int Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersection, TraceThreadData *Thread) const; + int Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersection, RenderStatistics& stats) const; #ifdef POV_ENABLE_LEMON_UV void CalcUV(const Vector3d& IPoint, Vector2d& Result) const; #endif // POV_ENABLE_LEMON_UV diff --git a/source/core/shape/mesh.cpp b/source/core/shape/mesh.cpp index 34641e831..fc126ce5c 100644 --- a/source/core/shape/mesh.cpp +++ b/source/core/shape/mesh.cpp @@ -300,7 +300,7 @@ bool Mesh::Inside(const Vector3d& IPoint, TraceThreadData *Thread) const else { /* Use the mesh's bounding hierarchy. */ - inside = inside_bbox_tree(ray, Thread); + inside = inside_bbox_tree(ray, Thread->Stats()); } if (Test_Flag(this, INVERTED_FLAG)) @@ -2253,7 +2253,7 @@ bool Mesh::IsOpaque() const * ******************************************************************************/ -void Mesh::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *) const +void Mesh::UVCoord(Vector2d& Result, const Intersection *Inter) const { DBL w1, w2, w3, t1, t2; Vector3d vA, vB; @@ -2363,7 +2363,7 @@ void Mesh::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData * ******************************************************************************/ -bool Mesh::inside_bbox_tree(const BasicRay &ray, TraceThreadData *Thread) const +bool Mesh::inside_bbox_tree(const BasicRay &ray, RenderStatistics& stats) const { MeshIndex i, found; DBL Best, Depth; @@ -2379,14 +2379,14 @@ bool Mesh::inside_bbox_tree(const BasicRay &ray, TraceThreadData *Thread) const Best = BOUND_HUGE; #ifdef BBOX_EXTRA_STATS - Thread->Stats()[totalQueueResets]++; + stats[totalQueueResets]++; #endif /* Check top node. */ Root = Data->Tree; /* Set the root object infinite to avoid a test. */ - Check_And_Enqueue(*mtpQueue, Root, &Root->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Root, &Root->BBox, &rayinfo, stats); /* Check elements in the priority queue. */ while (!mtpQueue->IsEmpty()) @@ -2398,7 +2398,7 @@ bool Mesh::inside_bbox_tree(const BasicRay &ray, TraceThreadData *Thread) const { /* This is a node containing leaves to be checked. */ for (i = 0; i < Node->Entries; i++) - Check_And_Enqueue(*mtpQueue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, Thread->Stats()); + Check_And_Enqueue(*mtpQueue, Node->Node[i], &Node->Node[i]->BBox, &rayinfo, stats); } else { diff --git a/source/core/shape/mesh.h b/source/core/shape/mesh.h index 4a75843f0..96cbff696 100644 --- a/source/core/shape/mesh.h +++ b/source/core/shape/mesh.h @@ -151,7 +151,7 @@ class Mesh final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; @@ -184,7 +184,7 @@ class Mesh final : public ObjectBase bool test_hit(const MESH_TRIANGLE *Triangle, const BasicRay& OrigRay, DBL Depth, DBL len, IStack& Depth_Stack, TraceThreadData *Thread); void get_triangle_bbox(const MESH_TRIANGLE *Triangle, BoundingBox *BBox) const; bool intersect_bbox_tree(const BasicRay& ray, const BasicRay& Orig_Ray, DBL len, IStack& Depth_Stack, TraceThreadData *Thread); - bool inside_bbox_tree(const BasicRay& ray, TraceThreadData *Thread) const; + bool inside_bbox_tree(const BasicRay& ray, RenderStatistics& stats) const; void get_triangle_vertices(const MESH_TRIANGLE *Triangle, Vector3d& P1, Vector3d& P2, Vector3d& P3) const; void get_triangle_normals(const MESH_TRIANGLE *Triangle, Vector3d& N1, Vector3d& N2, Vector3d& N3) const; void get_triangle_uvcoords(const MESH_TRIANGLE *Triangle, Vector2d& U1, Vector2d& U2, Vector2d& U3) const; diff --git a/source/core/shape/ovus.cpp b/source/core/shape/ovus.cpp index ffec245a4..4469e31ca 100644 --- a/source/core/shape/ovus.cpp +++ b/source/core/shape/ovus.cpp @@ -99,7 +99,7 @@ namespace pov void Ovus::Intersect_Ovus_Spheres(const Vector3d& P, const Vector3d& D, DBL * Depth1, DBL * Depth2, DBL * Depth3, DBL * Depth4, DBL * Depth5, DBL * Depth6, - TraceThreadData *Thread) const + RenderStatistics& stats) const { DBL OCSquared, t_Closest_Approach, Half_Chord, t_Half_Chord_Squared; Vector3d Padj; @@ -205,14 +205,14 @@ void Ovus::Intersect_Ovus_Spheres(const Vector3d& P, const Vector3d& D, c[4] = k1 * k1 + 4.0 * R2 * (Py2 - r2); - n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), RootTolerance, Thread->Stats()); + n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), RootTolerance, stats); while (n--) { // here we only keep the 'lemon' inside the torus // and dismiss the 'apple' // If you find a solution to resolve the rotation of // (x + r)^2 + y^2 = R^2 around y (so replacing x by sqrt(x^2+z^2)) - // with something which is faster than a 4th degree polynome, + // with something which is faster than a 4th degree polynomial, // please feel welcome to update and share... IPoint = P + r[n] * D; @@ -285,7 +285,7 @@ bool Ovus::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat D /= len; Intersect_Ovus_Spheres(P, D, &Depth1, &Depth2, &Depth3, - &Depth4, &Depth5, &Depth6, Thread); + &Depth4, &Depth5, &Depth6, Thread->Stats()); if (Depth1 > EPSILON) { IPoint = P + Depth1 * D; @@ -879,7 +879,7 @@ void Ovus::Compute_BBox() * ******************************************************************************/ -void Ovus::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Ovus::UVCoord(Vector2d& Result, const Intersection *Inter) const { CalcUV(Inter->IPoint, Result); } diff --git a/source/core/shape/ovus.h b/source/core/shape/ovus.h index b89663d91..2bd3ff266 100644 --- a/source/core/shape/ovus.h +++ b/source/core/shape/ovus.h @@ -84,7 +84,7 @@ class Ovus final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; @@ -116,7 +116,7 @@ class Ovus final : public ObjectBase void Intersect_Ovus_Spheres(const Vector3d&, const Vector3d&, DBL * Depth1,DBL *Depth2, DBL * Depth3, DBL * Depth4, DBL * Depth5, DBL * Depth6, - TraceThreadData *Thread) const; + RenderStatistics& stats) const; }; diff --git a/source/core/shape/parametric.cpp b/source/core/shape/parametric.cpp index f815d7a07..05341e9ee 100644 --- a/source/core/shape/parametric.cpp +++ b/source/core/shape/parametric.cpp @@ -783,7 +783,7 @@ Parametric::Parametric() : NonsolidObject(PARAMETRIC_OBJECT) * ******************************************************************************/ -void Parametric::UVCoord(Vector2d& Result, const Intersection *inter, TraceThreadData *Thread) const +void Parametric::UVCoord(Vector2d& Result, const Intersection *inter) const { Result = inter->Iuv; } diff --git a/source/core/shape/parametric.h b/source/core/shape/parametric.h index b51186936..acbe927a5 100644 --- a/source/core/shape/parametric.h +++ b/source/core/shape/parametric.h @@ -109,7 +109,7 @@ class Parametric final : public NonsolidObject virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/shape/plane.cpp b/source/core/shape/plane.cpp index 376d92c27..a79fadd3c 100644 --- a/source/core/shape/plane.cpp +++ b/source/core/shape/plane.cpp @@ -94,7 +94,7 @@ bool Plane::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa DBL Depth; Vector3d IPoint; - if (Intersect(ray, &Depth, Thread)) + if (Intersect(ray, &Depth, Thread->Stats())) { IPoint = ray.Evaluate(Depth); @@ -136,12 +136,12 @@ bool Plane::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa * ******************************************************************************/ -bool Plane::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const +bool Plane::Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const { DBL NormalDotOrigin, NormalDotDirection; Vector3d P, D; - Thread->Stats()[Ray_Plane_Tests]++; + stats[Ray_Plane_Tests]++; if (Trans == nullptr) { @@ -173,7 +173,7 @@ bool Plane::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) if ((*Depth >= DEPTH_TOLERANCE) && (*Depth <= MAX_DISTANCE)) { - Thread->Stats()[Ray_Plane_Tests_Succeeded]++; + stats[Ray_Plane_Tests_Succeeded]++; return (true); } else diff --git a/source/core/shape/plane.h b/source/core/shape/plane.h index cc8de3041..607ba6209 100644 --- a/source/core/shape/plane.h +++ b/source/core/shape/plane.h @@ -84,7 +84,7 @@ class Plane final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - document that it uses the default (it does, right?) [trf] + // virtual void UVCoord(Vector2d&, const Intersection *) const override; // TODO FIXME - document that it uses the default (it does, right?) [trf] virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; @@ -93,7 +93,7 @@ class Plane final : public ObjectBase virtual void Compute_BBox() override; virtual bool Intersect_BBox(BBoxDirection, const BBoxVector3d&, const BBoxVector3d&, BBoxScalar) const override; protected: - bool Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; + bool Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const; }; /// @} diff --git a/source/core/shape/polygon.cpp b/source/core/shape/polygon.cpp index 5964bc52b..78e64e1d7 100644 --- a/source/core/shape/polygon.cpp +++ b/source/core/shape/polygon.cpp @@ -133,7 +133,7 @@ bool Polygon::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThread DBL Depth; Vector3d IPoint; - if (Intersect(ray, &Depth, Thread)) + if (Intersect(ray, &Depth, Thread->Stats())) { IPoint = ray.Evaluate(Depth); @@ -184,7 +184,7 @@ bool Polygon::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThread * ******************************************************************************/ -bool Polygon::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const +bool Polygon::Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const { DBL x, y, len; Vector3d p, d; @@ -194,7 +194,7 @@ bool Polygon::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread if (Test_Flag(this, DEGENERATE_FLAG)) return(false); - Thread->Stats()[Ray_Polygon_Tests]++; + stats[Ray_Polygon_Tests]++; /* Transform the ray into the polygon space. */ @@ -223,7 +223,7 @@ bool Polygon::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread if (in_polygon(Data->Number, Data->Points, x, y)) { - Thread->Stats()[Ray_Polygon_Tests_Succeeded]++; + stats[Ray_Polygon_Tests_Succeeded]++; *Depth /= len; diff --git a/source/core/shape/polygon.h b/source/core/shape/polygon.h index 3252b0d9c..e0b4e0373 100644 --- a/source/core/shape/polygon.h +++ b/source/core/shape/polygon.h @@ -97,7 +97,7 @@ class Polygon final : public NonsolidObject virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - does this use the default mapping? [trf] + // virtual void UVCoord(Vector2d&, const Intersection *) const override; // TODO FIXME - does this use the default mapping? [trf] virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; @@ -106,7 +106,7 @@ class Polygon final : public NonsolidObject void Compute_Polygon(int number, Vector3d *points); protected: - bool Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; + bool Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const; static bool in_polygon(int number, Vector2d *points, DBL u, DBL v); }; diff --git a/source/core/shape/polynomial.cpp b/source/core/shape/polynomial.cpp index 2f82214e3..5c742be61 100644 --- a/source/core/shape/polynomial.cpp +++ b/source/core/shape/polynomial.cpp @@ -243,7 +243,7 @@ bool Poly::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDat default: - cnt = intersect(New_Ray, Order, Coeffs, Test_Flag(this, STURM_FLAG), Depths, Thread); + cnt = intersect(New_Ray, Order, Coeffs, Test_Flag(this, STURM_FLAG), Depths, Thread->Stats()); } if (cnt > 0) @@ -653,7 +653,7 @@ DBL Poly::inside(const Vector3d& IPoint, int Order, const DBL *Coeffs) * ******************************************************************************/ -int Poly::intersect(const BasicRay &ray, int Order, const DBL *Coeffs, int Sturm_Flag, DBL *Depths, TraceThreadData *Thread) +int Poly::intersect(const BasicRay &ray, int Order, const DBL *Coeffs, int Sturm_Flag, DBL *Depths, RenderStatistics& stats) { DBL eqn_v[3][MAX_ORDER+1], eqn_vt[3][MAX_ORDER+1]; DBL eqn[MAX_ORDER+1]; @@ -765,7 +765,7 @@ int Poly::intersect(const BasicRay &ray, int Order, const DBL *Coeffs, int Sturm if (j > 1) { - return(Solve_Polynomial(j, &eqn[i], Depths, Sturm_Flag, ROOT_TOLERANCE, Thread->Stats())); + return(Solve_Polynomial(j, &eqn[i], Depths, Sturm_Flag, ROOT_TOLERANCE, stats)); } else { diff --git a/source/core/shape/polynomial.h b/source/core/shape/polynomial.h index d4e9c61c7..593275598 100644 --- a/source/core/shape/polynomial.h +++ b/source/core/shape/polynomial.h @@ -105,7 +105,7 @@ class Poly final : public ObjectBase bool Set_Coeff(const unsigned int x,const unsigned int y, const unsigned int z, const DBL value); protected: - static int intersect(const BasicRay &Ray, int Order, const DBL *Coeffs, int Sturm_Flag, DBL *Depths, TraceThreadData *Thread); + static int intersect(const BasicRay &Ray, int Order, const DBL *Coeffs, int Sturm_Flag, DBL *Depths, RenderStatistics& stats); static void normal0(Vector3d& Result, int Order, const DBL *Coeffs, const Vector3d& IPoint); static void normal1(Vector3d& Result, int Order, const DBL *Coeffs, const Vector3d& IPoint); static DBL inside(const Vector3d& IPoint, int Order, const DBL *Coeffs); diff --git a/source/core/shape/prism.cpp b/source/core/shape/prism.cpp index 274c4a2bb..8e558ddfd 100644 --- a/source/core/shape/prism.cpp +++ b/source/core/shape/prism.cpp @@ -260,7 +260,7 @@ bool Prism::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa u = P[X] + k * D[X]; v = P[Z] + k * D[Z]; - if (in_curve(u, v, Thread)) + if (in_curve(u, v, Thread->Stats())) { distance = k / len; if ((distance > DEPTH_TOLERANCE) && (distance < MAX_DISTANCE)) @@ -284,7 +284,7 @@ bool Prism::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa u = P[X] + k * D[X]; v = P[Z] + k * D[Z]; - if (in_curve(u, v, Thread)) + if (in_curve(u, v, Thread->Stats())) { distance = k / len; if ((distance > DEPTH_TOLERANCE) && (distance < MAX_DISTANCE)) @@ -437,7 +437,7 @@ bool Prism::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa u = (P[X] + k * D[X]) / Height2; v = (P[Z] + k * D[Z]) / Height2; - if (in_curve(u, v, Thread)) + if (in_curve(u, v, Thread->Stats())) { distance = k / len; if ((distance > DEPTH_TOLERANCE) && (distance < MAX_DISTANCE)) @@ -464,7 +464,7 @@ bool Prism::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa u = (P[X] + k * D[X]) / Height1; v = (P[Z] + k * D[Z]) / Height1; - if (in_curve(u, v, Thread)) + if (in_curve(u, v, Thread->Stats())) { distance = k / len; if ((distance > DEPTH_TOLERANCE) && (distance < MAX_DISTANCE)) @@ -662,7 +662,7 @@ bool Prism::Inside(const Vector3d& IPoint, TraceThreadData *Thread) const } } - if (in_curve(P[X], P[Z], Thread)) + if (in_curve(P[X], P[Z], Thread->Stats())) { return(!Test_Flag(this, INVERTED_FLAG)); } @@ -1151,7 +1151,7 @@ void Prism::Compute_BBox() * ******************************************************************************/ -int Prism::in_curve(DBL u, DBL v, TraceThreadData *Thread) const +int Prism::in_curve(DBL u, DBL v, RenderStatistics& stats) const { int i, n, NC; DBL k, w; @@ -1179,7 +1179,7 @@ int Prism::in_curve(DBL u, DBL v, TraceThreadData *Thread) const x[2] = Entry.C[Y]; x[3] = Entry.D[Y] - v; - n = Solve_Polynomial(3, x, y, Test_Flag(this, STURM_FLAG), 0.0, Thread->Stats()); + n = Solve_Polynomial(3, x, y, Test_Flag(this, STURM_FLAG), 0.0, stats); while (n--) { @@ -1372,7 +1372,7 @@ bool Prism::test_rectangle(const Vector3d& P, const Vector3d& D, DBL x1, DBL z1, * ******************************************************************************/ -void Prism::Compute_Prism(Vector2d *P, TraceThreadData *Thread) +void Prism::Compute_Prism(Vector2d *P, RenderStatistics& stats) { int i, n, number_of_splines; int i1, i2, i3; @@ -1562,7 +1562,7 @@ void Prism::Compute_Prism(Vector2d *P, TraceThreadData *Thread) c[1] = 2.0 * B[X]; c[2] = C[X]; - n = Solve_Polynomial(2, c, r, false, 0.0, Thread->Stats()); + n = Solve_Polynomial(2, c, r, false, 0.0, stats); while (n--) { @@ -1576,7 +1576,7 @@ void Prism::Compute_Prism(Vector2d *P, TraceThreadData *Thread) c[1] = 2.0 * B[Y]; c[2] = C[Y]; - n = Solve_Polynomial(2, c, r, false, 0.0, Thread->Stats()); + n = Solve_Polynomial(2, c, r, false, 0.0, stats); while (n--) { diff --git a/source/core/shape/prism.h b/source/core/shape/prism.h index c134a40fa..6ef97809d 100644 --- a/source/core/shape/prism.h +++ b/source/core/shape/prism.h @@ -128,9 +128,9 @@ class Prism final : public ObjectBase virtual void Transform(const TRANSFORM *) override; virtual void Compute_BBox() override; - void Compute_Prism(Vector2d *P, TraceThreadData *Thread); + void Compute_Prism(Vector2d *P, RenderStatistics& stats); protected: - int in_curve(DBL u, DBL v, TraceThreadData *Thread) const; + int in_curve(DBL u, DBL v, RenderStatistics& stats) const; static bool test_rectangle(const Vector3d& P, const Vector3d& D, DBL x1, DBL y1, DBL x2, DBL y2); }; diff --git a/source/core/shape/sor.cpp b/source/core/shape/sor.cpp index 04fc53ccd..33dcf4a1f 100644 --- a/source/core/shape/sor.cpp +++ b/source/core/shape/sor.cpp @@ -957,7 +957,7 @@ void Sor::Compute_BBox() * ******************************************************************************/ -void Sor::Compute_Sor(Vector2d *P, TraceThreadData *Thread) +void Sor::Compute_Sor(Vector2d *P, RenderStatistics& stats) { int i, n; DBL *tmp_r1; @@ -1073,7 +1073,7 @@ void Sor::Compute_Sor(Vector2d *P, TraceThreadData *Thread) c[1] = 2.0 * B; c[2] = C; - n = Solve_Polynomial(2, c, r, false, 0.0, Thread->Stats()); + n = Solve_Polynomial(2, c, r, false, 0.0, stats); while (n--) { @@ -1242,7 +1242,7 @@ bool Sor::test_hit(const BasicRay &ray, IStack& Depth_Stack, DBL d, DBL k, int t * ******************************************************************************/ -void Sor::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Sor::UVCoord(Vector2d& Result, const Intersection *Inter) const { DBL len, theta; DBL h, v_per_segment; diff --git a/source/core/shape/sor.h b/source/core/shape/sor.h index 794c39d95..2bd21dd6e 100644 --- a/source/core/shape/sor.h +++ b/source/core/shape/sor.h @@ -113,14 +113,14 @@ class Sor final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; virtual void Transform(const TRANSFORM *) override; virtual void Compute_BBox() override; - void Compute_Sor(Vector2d *P, TraceThreadData *Thread); + void Compute_Sor(Vector2d *P, RenderStatistics& stats); protected: bool Intersect(const BasicRay& ray, IStack& Depth_Stack, TraceThreadData *Thread); bool test_hit(const BasicRay&, IStack&, DBL, DBL, int, int, TraceThreadData *Thread); diff --git a/source/core/shape/sphere.cpp b/source/core/shape/sphere.cpp index 788cd3a33..6e19a6c93 100644 --- a/source/core/shape/sphere.cpp +++ b/source/core/shape/sphere.cpp @@ -685,7 +685,7 @@ void Sphere::Compute_BBox() * ******************************************************************************/ -void Sphere::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Sphere::UVCoord(Vector2d& Result, const Intersection *Inter) const { DBL len, phi, theta; DBL x,y,z; diff --git a/source/core/shape/sphere.h b/source/core/shape/sphere.h index 088f83115..59b1c712d 100644 --- a/source/core/shape/sphere.h +++ b/source/core/shape/sphere.h @@ -83,7 +83,7 @@ class Sphere final : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/core/shape/spheresweep.cpp b/source/core/shape/spheresweep.cpp index 03c8f929f..489e945de 100644 --- a/source/core/shape/spheresweep.cpp +++ b/source/core/shape/spheresweep.cpp @@ -215,7 +215,7 @@ bool SphereSweep::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceTh for(i = 0; i < Num_Segments; i++) { // Are there intersections with this segment? - Num_Seg_Isect = Intersect_Segment(New_Ray, &Segment[i], Segment_Isect, Thread); + Num_Seg_Isect = Intersect_Segment(New_Ray, &Segment[i], Segment_Isect, Thread->Stats()); // Test for end of vector if(Num_Isect + Num_Seg_Isect <= SPHSWEEP_MAX_ISECT) @@ -401,7 +401,7 @@ bool SphereSweep::Intersect_Sphere(const BasicRay &ray, const SPHSWEEP_SPH *Sphe /// The current implementation exhibits numeric instabilities for 3rd order polynomial splines. /// (See GitHub issue #147.) /// -int SphereSweep::Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segment, SPHSWEEP_INT *Isect, TraceThreadData *Thread) +int SphereSweep::Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segment, SPHSWEEP_INT *Isect, RenderStatistics& stats) { int Isect_Count; DBL Dot1, Dot2; @@ -524,7 +524,7 @@ int SphereSweep::Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segm Coef[1] = 4.0 * d * e - 2.0 * b * c * d; Coef[2] = Sqr(e) - b * c * e + Sqr(b) * f; - Num_Poly_Roots = Solve_Polynomial(2, Coef, Root, true, 1e-10, Thread->Stats()); + Num_Poly_Roots = Solve_Polynomial(2, Coef, Root, true, 1e-10, stats); break; case 4: // Third order polynomial @@ -600,7 +600,7 @@ int SphereSweep::Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segm Coef[9] = 4.0 * j * k - 2.0 * c * k * e - 2.0 * d * j * e + 4.0 * c * d * l; Coef[10] = Sqr(k) - d * k * e + l * Sqr(d); - Num_Poly_Roots = bezier_01(10, Coef, Root, true, 1e-10, Thread); + Num_Poly_Roots = bezier_01(10, Coef, Root, true, 1e-10, stats); break; default: @@ -859,7 +859,7 @@ bool SphereSweep::Inside(const Vector3d& IPoint, TraceThreadData *Thread) const Coef[6] -= Sqr(Segment[i].Radius_Coef[0]); // Find roots - Num_Poly_Roots = bezier_01(6, Coef, Root, true, 1e-10, Thread); + Num_Poly_Roots = bezier_01(6, Coef, Root, true, 1e-10, Thread->Stats()); // Test for interval [0, 1] for(j = 0; j < Num_Poly_Roots; j++) @@ -1800,7 +1800,7 @@ const int lcm_bezier_01[] = 2520, 252, 56, 21, 12, 10, 12, 21, 56, 252, 2520 }; -int SphereSweep::bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, DBL tolerance, TraceThreadData *Thread) +int SphereSweep::bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, DBL tolerance, RenderStatistics& stats) { DBL d[11]; bool non_negative = true, non_positive = true; @@ -1816,7 +1816,7 @@ int SphereSweep::bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, non_positive = (non_positive && (d[degree - i] <= 0)); if(!(non_negative || non_positive)) - return Solve_Polynomial(degree, Coef, Roots, sturm, tolerance, Thread->Stats()); + return Solve_Polynomial(degree, Coef, Roots, sturm, tolerance, stats); for(j = 0; j < degree - i; ++j) d[j] += d[j+1]; diff --git a/source/core/shape/spheresweep.h b/source/core/shape/spheresweep.h index 00a23abd9..184b61253 100644 --- a/source/core/shape/spheresweep.h +++ b/source/core/shape/spheresweep.h @@ -162,7 +162,7 @@ class SphereSweep final : public ObjectBase /// (if any), even in the case of a "glancing blow", and with surface normals oriented /// away from the spline "backbone". /// - static int Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segment, SPHSWEEP_INT *Isect, TraceThreadData *Thread); + static int Intersect_Segment(const BasicRay &ray, const SPHSWEEP_SEG *Segment, SPHSWEEP_INT *Isect, RenderStatistics& stats); /// Eliminate interior surfaces. /// @@ -176,7 +176,7 @@ class SphereSweep final : public ObjectBase static int Find_Valid_Points(SPHSWEEP_INT *Inter, int Num_Inter, const BasicRay &ray); static int Comp_Isects(const void *Intersection_1, const void *Intersection_2); - static int bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, DBL tolerance, TraceThreadData *Thread); + static int bezier_01(int degree, const DBL* Coef, DBL* Roots, bool sturm, DBL tolerance, RenderStatistics& stats); }; /// @} diff --git a/source/core/shape/torus.cpp b/source/core/shape/torus.cpp index e881d2bd8..ceced2a09 100644 --- a/source/core/shape/torus.cpp +++ b/source/core/shape/torus.cpp @@ -138,7 +138,7 @@ bool Torus::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceThreadDa Found = false; - if ((max_i = Intersect(ray, Depth, Thread)) > 0) + if ((max_i = Intersect(ray, Depth, Thread->Stats())) > 0) { for (i = 0; i < max_i; i++) { @@ -167,7 +167,7 @@ bool SpindleTorus::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceT Found = false; - if ((max_i = Intersect(ray, Depth, Thread)) > 0) + if ((max_i = Intersect(ray, Depth, Thread->Stats())) > 0) { for (i = 0; i < max_i; i++) { @@ -238,7 +238,7 @@ bool SpindleTorus::All_Intersections(const Ray& ray, IStack& Depth_Stack, TraceT * ******************************************************************************/ -int Torus::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const +int Torus::Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const { int i, n; DBL len, R2, Py2, Dy2, PDy2, k1, k2; @@ -250,7 +250,7 @@ int Torus::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) c DBL BoundingSphereRadius; // Sphere fully (amply) enclosing torus. DBL Closer; // P is moved Closer*D closer to torus. - Thread->Stats()[Ray_Torus_Tests]++; + stats[Ray_Torus_Tests]++; /* Transform the ray into the torus space. */ @@ -274,13 +274,13 @@ int Torus::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) c r2 = Sqr(MajorRadius + MinorRadius); #ifdef TORUS_EXTRA_STATS - Thread->Stats()[Torus_Bound_Tests]++; + stats[Torus_Bound_Tests]++; #endif if (Test_Thick_Cylinder(P, D, y1, y2, r1, r2)) { #ifdef TORUS_EXTRA_STATS - Thread->Stats()[Torus_Bound_Tests_Succeeded]++; + stats[Torus_Bound_Tests_Succeeded]++; #endif // Move P close to bounding sphere to have more precise root calculation. @@ -316,14 +316,14 @@ int Torus::Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) c c[4] = k1 * k1 + 4.0 * R2 * (Py2 - r2); - n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), ROOT_TOLERANCE, Thread->Stats()); + n = Solve_Polynomial(4, c, r, Test_Flag(this, STURM_FLAG), ROOT_TOLERANCE, stats); while(n--) Depth[i++] = (r[n] + Closer) / len; } if (i) - Thread->Stats()[Ray_Torus_Tests_Succeeded]++; + stats[Ray_Torus_Tests_Succeeded]++; return(i); } @@ -1083,7 +1083,7 @@ bool Torus::Test_Thick_Cylinder(const Vector3d& P, const Vector3d& D, DBL h1, DB * ******************************************************************************/ -void Torus::UVCoord(Vector2d& Result, const Intersection *Inter, TraceThreadData *Thread) const +void Torus::UVCoord(Vector2d& Result, const Intersection *Inter) const { CalcUV(Inter->IPoint, Result); } diff --git a/source/core/shape/torus.h b/source/core/shape/torus.h index 8d60b93be..f2a48d16c 100644 --- a/source/core/shape/torus.h +++ b/source/core/shape/torus.h @@ -87,14 +87,14 @@ class Torus : public ObjectBase virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; + virtual void UVCoord(Vector2d&, const Intersection *) const override; virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; virtual void Transform(const TRANSFORM *) override; virtual void Compute_BBox() override; protected: - int Intersect(const BasicRay& ray, DBL *Depth, TraceThreadData *Thread) const; + int Intersect(const BasicRay& ray, DBL *Depth, RenderStatistics& stats) const; bool Test_Thick_Cylinder(const Vector3d& P, const Vector3d& D, DBL h1, DBL h2, DBL r1, DBL r2) const; void CalcUV(const Vector3d& IPoint, Vector2d& Result) const; }; diff --git a/source/core/shape/triangle.h b/source/core/shape/triangle.h index 0f633fed0..0a899db24 100644 --- a/source/core/shape/triangle.h +++ b/source/core/shape/triangle.h @@ -90,7 +90,7 @@ class Triangle : public NonsolidObject virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *) override; virtual bool Inside(const Vector3d&, TraceThreadData *) const override; virtual void Normal(Vector3d&, Intersection *, TraceThreadData *) const override; - // virtual void UVCoord(Vector2d&, const Intersection *, TraceThreadData *) const override; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] + // virtual void UVCoord(Vector2d&, const Intersection *) const override; // TODO FIXME - why is there no UV-mapping for this trivial object? [trf] virtual void Translate(const Vector3d&, const TRANSFORM *) override; virtual void Rotate(const Vector3d&, const TRANSFORM *) override; virtual void Scale(const Vector3d&, const TRANSFORM *) override; diff --git a/source/parser/configparser.h b/source/parser/configparser.h index c89a7c8f6..dd33f331c 100644 --- a/source/parser/configparser.h +++ b/source/parser/configparser.h @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -51,13 +51,6 @@ /// /// @{ -/// @def POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT -/// Whether experimental second brilliance parameter should be enabled. -/// -#ifndef POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT - #define POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT 0 -#endif - /// @def POV_PARSER_EXPERIMENTAL_OBJ_IMPORT /// Whether experimental Wavefront OBJ import should be enabled. /// diff --git a/source/parser/parser.cpp b/source/parser/parser.cpp index f2ab0fd0a..20fcd4f19 100644 --- a/source/parser/parser.cpp +++ b/source/parser/parser.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -2973,7 +2973,7 @@ ObjectPtr Parser::Parse_Lathe() /* Compute spline segments. */ - Object->Compute_Lathe(Points, GetParserDataPtr()); + Object->Compute_Lathe(Points, GetParserDataPtr()->Stats()); /* Compute bounding box. */ @@ -5491,7 +5491,7 @@ ObjectPtr Parser::Parse_Prism() /* Compute spline segments. */ - Object->Compute_Prism(Points, GetParserDataPtr()); + Object->Compute_Prism(Points, GetParserDataPtr()->Stats()); /* Compute bounding box. */ @@ -5688,7 +5688,7 @@ ObjectPtr Parser::Parse_Sor() /* Compute spline segments. */ - Object->Compute_Sor(Points, GetParserDataPtr()); + Object->Compute_Sor(Points, GetParserDataPtr()->Stats()); /* Compute bounding box. */ @@ -6202,6 +6202,11 @@ ObjectPtr Parser::Parse_TrueType () { auto controlPoints = fontFace->GetCubicBezierOutline(glyph); + if (controlPoints.size() == 0) + // glyph is whitespace + continue; + + // Font module produces control points in the wrong order. for (size_t i = 0; i < controlPoints.size() / 2; ++i) std::swap(controlPoints[i], controlPoints[controlPoints.size() - i - 1]); diff --git a/source/parser/parser_materials.cpp b/source/parser/parser_materials.cpp index 8fc1ddd16..ef86ae964 100644 --- a/source/parser/parser_materials.cpp +++ b/source/parser/parser_materials.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -2270,7 +2270,7 @@ void Parser::Parse_Finish (FINISH **Finish_Ptr) CASE (BRILLIANCE_TOKEN) New->Brilliance = Parse_Float (); -#if POV_PARSER_EXPERIMENTAL_BRILLIANCE_OUT +#if POV_EXPERIMENTAL_BRILLIANCE_OUT Parse_Comma(); New->BrillianceOut = Allow_Float(1.0); #endif diff --git a/source/parser/symboltable.cpp b/source/parser/symboltable.cpp index d028a54ff..3716830b1 100644 --- a/source/parser/symboltable.cpp +++ b/source/parser/symboltable.cpp @@ -8,7 +8,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -434,8 +434,8 @@ void SymbolTable::Remove_Symbol(const char *Name, bool is_array_elem, void **Dat { POV_EXPERIMENTAL_ASSERT(DataPtr != nullptr); - POV_EXPERIMENTAL_ASSERT((ttype != FLOAT_TOKEN_CATEGORY) && - (ttype != FLOAT_ID_TOKEN) && + POV_EXPERIMENTAL_ASSERT((ttype != SIGNATURE_TOKEN_CATEGORY) && + (ttype != FLOAT_TOKEN_CATEGORY) && (ttype != VECTOR_TOKEN_CATEGORY) && (ttype != COLOUR_TOKEN_CATEGORY)); diff --git a/unix/config/ax_check_libjpeg.m4 b/unix/config/ax_check_libjpeg.m4 index 08a077c02..3fa99b94e 100644 --- a/unix/config/ax_check_libjpeg.m4 +++ b/unix/config/ax_check_libjpeg.m4 @@ -40,7 +40,7 @@ AC_DEFUN([AX_CHECK_LIBJPEG], [jpeglib.h], [ # check library version, update LIBS - if test x"$1" != x"$ax_check_libjpeg_version_num"; then + if test x"$1" != x"$ax_check_libjpeg_version_num"; then AC_MSG_CHECKING([for libjpeg version >= $1 ($ax_check_libjpeg_version_num)]) else AC_MSG_CHECKING([for libjpeg version >= $1]) diff --git a/unix/config/ax_check_openexr.m4 b/unix/config/ax_check_openexr.m4 index 69a2cb646..468294ee8 100644 --- a/unix/config/ax_check_openexr.m4 +++ b/unix/config/ax_check_openexr.m4 @@ -50,7 +50,7 @@ AC_DEFUN([AX_CHECK_OPENEXR], # FIXME: workaround for versions >= 1.4.0 AX_COMPARE_VERSION([$ax_check_openexr_version], [ge], [1.4], [LIBS="$ax_check_openexr_libs -lIlmThread $LIBS"], - [LIBS="$ax_check_openexr_libs $LIBS"] + [LIBS="$ax_check_openexr_libs $LIBS"] ) # check include file diff --git a/unix/configure.ac b/unix/configure.ac index 23c33b08e..59d29de29 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -50,7 +50,7 @@ VERSION_BASE=`echo $PACKAGE_VERSION | sed 's,\([[0-9]]*.[[0-9]]*\).*,\1,g'` AC_SUBST([VERSION_BASE]) AC_DEFINE_UNQUOTED([VERSION_BASE], ["$VERSION_BASE"], [Base version number of package.]) AC_CONFIG_AUX_DIR([unix/config]) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([unix/config.h]) AC_CONFIG_SRCDIR([unix/disp_text.cpp]) # Additional autoconf macros. @@ -220,11 +220,16 @@ echo "trying stat --format='%u,%g' ." >>config.log if stat --format='%u,%g' . >>config.log 2>>config.log && test x`stat --format=Foo .` = x"Foo"; then stat_format="--format=" else - echo "trying stat --f '%u,%g' ." >>config.log + echo "trying stat -f '%u,%g' ." >>config.log if stat -f '%u,%g' . >>config.log 2>>config.log && test x`stat -f Foo .` = x"Foo"; then stat_format="-f " else - AC_MSG_FAILURE([stat command does not behave as required]) + echo "trying stat -c'%u,%g' ." >>config.log + if stat -c '%u,%g' . >>config.log 2>>config.log && test x`stat -c Foo .` = x"Foo"; then + stat_format="-c " + else + AC_MSG_FAILURE([stat command does not behave as required]) + fi fi fi AC_MSG_RESULT([$stat_format]) diff --git a/unix/prebuild.sh b/unix/prebuild.sh index 12721376c..a6cd631a3 100755 --- a/unix/prebuild.sh +++ b/unix/prebuild.sh @@ -91,6 +91,8 @@ if test x"$1" = x""; then autoconf=`echo $autoconf | sed -e 's,\([0-9]*\),Z\1Z,g' -e 's,Z\([0-9]\)Z,Z0\1Z,g' -e 's,[^0-9],,g'` required=`echo $required_autoconf | sed -e 's,\([0-9]*\),Z\1Z,g' -e 's,Z\([0-9]\)Z,Z0\1Z,g' -e 's,[^0-9],,g'` expr $autoconf \>= $required > /dev/null || autoconf="" + else + echo "Failed to detect autoconf" fi if test x"$autoconf" = x""; then echo "$scriptname: error: requires autoconf $required_autoconf or above" @@ -104,6 +106,8 @@ if test x"$1" = x""; then automake=`echo $automake | sed -e 's,\([0-9]*\),Z\1Z,g' -e 's,Z\([0-9]\)Z,Z0\1Z,g' -e 's,[^0-9],,g'` required=`echo $required_automake | sed -e 's,\([0-9]*\),Z\1Z,g' -e 's,Z\([0-9]\)Z,Z0\1Z,g' -e 's,[^0-9],,g'` expr $automake \>= $required > /dev/null || automake="" + else + echo "Failed to detect automake" fi if test x"$automake" = x""; then echo "$scriptname: error: requires automake $required_automake or above" @@ -453,7 +457,6 @@ endif # Include paths for headers. AM_CPPFLAGS = \\ -I\$(top_srcdir)/unix/povconfig \\ - -I\$(top_srcdir) \\ -I\$(top_srcdir)/source \\ -I\$(top_builddir)/source \\ -I\$(top_srcdir)/platform/unix \\ @@ -825,7 +828,6 @@ endif # Include paths for headers. AM_CPPFLAGS = \\ -I\$(top_srcdir)/unix/povconfig \\ - -I\$(top_srcdir) \\ -I\$(top_srcdir)/platform/unix \\ \$(cppflags_platformcpu) \\ -I\$(top_srcdir)/unix \\ diff --git a/windows/povconfig/syspovconfig.h b/windows/povconfig/syspovconfig.h index eb2ceed09..fe73f229e 100644 --- a/windows/povconfig/syspovconfig.h +++ b/windows/povconfig/syspovconfig.h @@ -13,7 +13,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -117,6 +117,9 @@ namespace povwin { + // Debugging aids. + // These are not normally called from the POV-Ray code, but are kept around as useful helpers + // during debug sessions. void WIN_Debug_Log(unsigned int from, const char *msg) ; void WIN32_DEBUG_OUTPUT(const char *format,...) ; void WIN32_DEBUG_FILE_OUTPUT(const char *format,...) ; @@ -169,7 +172,7 @@ namespace povwin #define POV_MALLOC(size,msg) std::malloc (size) #define POV_REALLOC(ptr,size,msg) std::realloc ((ptr), (size)) #define POV_FREE(ptr) do { std::free (static_cast(ptr)); (ptr) = NULL; } while(false) -#define POV_STRDUP(str) std::strdup(str) +#define POV_STRDUP(str) _strdup(str) #define NO_RTR 1 #define MEM_STATS 0 diff --git a/windows/povconfig/syspovconfig_msvc.h b/windows/povconfig/syspovconfig_msvc.h index 7f3e77998..92589a000 100644 --- a/windows/povconfig/syspovconfig_msvc.h +++ b/windows/povconfig/syspovconfig_msvc.h @@ -11,7 +11,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -93,75 +93,43 @@ #pragma warning(disable : 4305) /* truncation from 'type1' to 'type2' (mostly double to float) */ #pragma warning(disable : 4244) /* possible loss of data (converting ints to shorts) */ - #if _MSC_VER >= 1400 && _MSC_VER < 1500 && !defined (_WIN64) - // MS Visual C++ 2005 (aka 8.0), compiling for 32 bit target - #define POV_COMPILER_VER "msvc8" - #define METADATA_COMPILER_STRING "msvc 8" - #define NEED_INVHYP - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - #elif _MSC_VER >= 1400 && _MSC_VER < 1500 && defined (_WIN64) - // MS Visual C++ 2005 (aka 8.0), compiling for 64 bit target - #define POV_COMPILER_VER "msvc8" - #define METADATA_COMPILER_STRING "msvc 8" - inline const int& max(const int& _X, const int& _Y) {return (_X < _Y ? _Y : _X); } - inline const int& min(const int& _X, const int& _Y) {return (_Y < _X ? _Y : _X); } - inline const unsigned int& max(const unsigned int& _X, const unsigned int& _Y) {return (_X < _Y ? _Y : _X); } - inline const unsigned int& min(const unsigned int& _X, const unsigned int& _Y) {return (_Y < _X ? _Y : _X); } - inline const long& max(const long& _X, const long& _Y) {return (_X < _Y ? _Y : _X); } - inline const long& min(const long& _X, const long& _Y) {return (_Y < _X ? _Y : _X); } - inline const unsigned long& max(const unsigned long& _X, const unsigned long& _Y) {return (_X < _Y ? _Y : _X); } - inline const unsigned long& min(const unsigned long& _X, const unsigned long& _Y) {return (_Y < _X ? _Y : _X); } - #define NEED_INVHYP - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - #elif _MSC_VER >= 1500 && _MSC_VER < 1600 - // MS Visual C++ 2008 (aka 9.0) - #define POV_COMPILER_VER "msvc9" - #define METADATA_COMPILER_STRING "msvc 9" - #define NEED_INVHYP - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - #elif _MSC_VER >= 1600 && _MSC_VER < 1700 - // MS Visual C++ 2010 (aka 10.0) - #define POV_COMPILER_VER "msvc10" - #define METADATA_COMPILER_STRING "msvc 10" - // msvc10 defines std::hash<> as a class, while boost's flyweight_fwd.hpp may forward-declare it as a struct; - // this is valid according to the C++ standard, but causes msvc10 to issue warnings. - #pragma warning(disable : 4099) - #define NEED_INVHYP - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - #elif _MSC_VER >= 1700 && _MSC_VER < 1800 - // MS Visual C++ 2012 (aka 11.0) - #define POV_COMPILER_VER "msvc11" - #define METADATA_COMPILER_STRING "msvc 11" - #error "Please update syspovconfig_msvc.h to include this version of MSVC" - // The following settings are just guesswork, and have never been tested: - #define NEED_INVHYP - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - #elif _MSC_VER >= 1800 && _MSC_VER < 1900 - // MS Visual C++ 2013 (aka 12.0) - #define POV_COMPILER_VER "msvc12" - #define METADATA_COMPILER_STRING "msvc 12" - #error "Please update syspovconfig_msvc.h to include this version of MSVC" - // The following settings are just guesswork, and have never been tested: - #define POV_CPP11_SUPPORTED 0 - #define POV_CPP14_SUPPORTED 0 - // NB: The Microsoft Visual Studio developers seem to have skipped internal version number 13 entirely. - #elif _MSC_VER >= 1900 && _MSC_VER < 2000 + #if _MSC_VER < 1900 + // Visual C++ 2013 and earlier do not comply with C++11, + // which as of v3.8.0 is a prerequisite for compiling POV-Ray. + #error "This software no longer supports your version of MS Visual C++" + #elif _MSC_VER >= 1900 && _MSC_VER < 1910 // MS Visual C++ 2015 (aka 14.0) #define POV_COMPILER_VER "msvc14" - #define METADATA_COMPILER_STRING "msvc 14" + #define METADATA_COMPILER_STRING "msvc 14.0" + // Visual C++ 2015 defines `__cplusplus` as `199711L` (C++98), + // but supports all the C++11 features we need #define POV_CPP11_SUPPORTED 1 - #define POV_CPP14_SUPPORTED 1 #ifndef DEBUG // Suppress erroneous warning about `string` having different alignment in base and parser. #pragma warning(disable : 4742) // 'var' has different alignment in 'file1' and 'file2': number and number #endif + #elif _MSC_VER >= 1910 && _MSC_VER < 1920 + // MS Visual C++ 2017 (aka 14.1x) + #define POV_COMPILER_VER "msvc141" + #define METADATA_COMPILER_STRING "msvc 14.1x" + // Visual C++ 2017 15.6 (and earlier) defines `__cplusplus` as `199711L` (C++98), + // but supports all the C++11 features we need (and also pretty much all of C++14) + #define POV_CPP11_SUPPORTED 1 + #define POV_CPP14_SUPPORTED 1 + // TODO - This compiler version has been tested, but no effort has been made yet + // to iron out any inconveniences such as unwarranted warnings or the like. + #elif _MSC_VER >= 1920 && _MSC_VER < 1930 + // MS Visual C++ 2019 (aka 14.2x) + #define POV_COMPILER_VER "msvc142" + #define METADATA_COMPILER_STRING "msvc 14.2x" + // (no need to set `POV_*_SUPPORTED for VS 2019 and later, we can probe `__cplusplus`) + // TODO - This compiler version has been tested, but no effort has been made yet + // to iron out any inconveniences such as unwarranted warnings or the like. #else - #error "Please update syspovconfig_msvc.h to include this version of MSVC" + // Unrecognized version of MS Visual C++ + #error("Your version of MS Visual C++ is still unknown to us. Proceed at your own risk.") + #define POV_COMPILER_VER "msvc" + #define METADATA_COMPILER_STRING "msvc" #endif #define COMPILER_NAME "Microsoft Visual C++" #define COMPILER_VERSION _MSC_VER diff --git a/windows/pvedit.cpp b/windows/pvedit.cpp index 20f434388..4c12f934d 100644 --- a/windows/pvedit.cpp +++ b/windows/pvedit.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -259,6 +259,7 @@ bool LoadEditorDLL (char *path, bool errorOK) return (true) ; } +// TODO FIXME - This is almost identical to Parser::Get_Reserved_Words() in parser/parser_tokenizer.cpp. char *Get_Reserved_Words (const char *additional_words) { int length = 0 ; diff --git a/windows/pvengine.cpp b/windows/pvengine.cpp index 2aa31190c..42a12daa7 100644 --- a/windows/pvengine.cpp +++ b/windows/pvengine.cpp @@ -10,7 +10,7 @@ /// @parblock /// /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8. -/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd. +/// Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd. /// /// POV-Ray is free software: you can redistribute it and/or modify /// it under the terms of the GNU Affero General Public License as @@ -375,7 +375,7 @@ CRITICAL_SECTION critical_section ; // key is the name of an included file (all lower case). // content is the name of the most recent rendered file that caused it to be included. map IncludeToSourceMap; -map IncludeAlternateDecisionMap; +map IncludeAlternateDecisionMap; char queued_files [MAX_QUEUE] [_MAX_PATH] ; char dir [_MAX_PATH] ;