|
14 | 14 | /// ---------------------------------------------------------------------------- |
15 | 15 | /// |
16 | 16 | /// Persistence of Vision Ray Tracer ('POV-Ray') version 3.7. |
17 | | -/// Copyright 1991-2016 Persistence of Vision Raytracer Pty. Ltd. |
| 17 | +/// Copyright 1991-2017 Persistence of Vision Raytracer Pty. Ltd. |
18 | 18 | /// |
19 | 19 | /// POV-Ray is free software: you can redistribute it and/or modify |
20 | 20 | /// it under the terms of the GNU Affero General Public License as |
@@ -202,7 +202,7 @@ static ColourBlendMapConstPtr gpDefaultBlendMap_Wood (new ColourBlendMap(2, gaDe |
202 | 202 | * Static functions |
203 | 203 | ******************************************************************************/ |
204 | 204 |
|
205 | | -static const ClassicTurbulence* SearchForTurb(const WarpList warps); |
| 205 | +static inline const ClassicTurbulence* GetTurb(const WarpList warps); |
206 | 206 | static unsigned short ReadUShort(IStream *pInFile); |
207 | 207 | static unsigned int ReadUInt(IStream *pInFile); |
208 | 208 |
|
@@ -268,6 +268,11 @@ BasicPattern::~BasicPattern() |
268 | 268 | Destroy_Warps(warps); |
269 | 269 | } |
270 | 270 |
|
| 271 | +bool BasicPattern::Precompute() |
| 272 | +{ |
| 273 | + return true; |
| 274 | +} |
| 275 | + |
271 | 276 | int BasicPattern::GetNoiseGen(const TraceThreadData *pThread) const |
272 | 277 | { |
273 | 278 | int noise_gen = noiseGenerator; |
@@ -387,8 +392,15 @@ bool AveragePattern::HasSpecialTurbulenceHandling() const { return false; } |
387 | 392 |
|
388 | 393 |
|
389 | 394 | AgatePattern::AgatePattern() : agateTurbScale(1.0) {} |
| 395 | + |
| 396 | +bool AgatePattern::Precompute() |
| 397 | +{ |
| 398 | + return (!warps.empty() && dynamic_cast<ClassicTurbulence*>(*warps.begin())); |
| 399 | +} |
| 400 | + |
390 | 401 | ColourBlendMapConstPtr AgatePattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Agate; } |
391 | 402 |
|
| 403 | + |
392 | 404 | ColourBlendMapConstPtr BozoPattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Bozo; } |
393 | 405 |
|
394 | 406 | BrickPattern::BrickPattern() : brickSize(8.0,3.0,4.5), mortar(0.5-EPSILON*2.0) {} |
@@ -557,7 +569,18 @@ DBL ImagePattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsect |
557 | 569 | } |
558 | 570 |
|
559 | 571 |
|
560 | | -MarblePattern::MarblePattern() { waveType = kWaveType_Triangle; } |
| 572 | +MarblePattern::MarblePattern() : |
| 573 | + hasTurbulence() // no explicit default; set by Precompute() |
| 574 | +{ |
| 575 | + waveType = kWaveType_Triangle; |
| 576 | +} |
| 577 | + |
| 578 | +bool MarblePattern::Precompute() |
| 579 | +{ |
| 580 | + hasTurbulence = (!warps.empty() && dynamic_cast<ClassicTurbulence*>(*warps.begin())); |
| 581 | + return true; |
| 582 | +} |
| 583 | + |
561 | 584 | ColourBlendMapConstPtr MarblePattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Marble; } |
562 | 585 |
|
563 | 586 |
|
@@ -649,18 +672,38 @@ SlopePattern::SlopePattern() : |
649 | 672 |
|
650 | 673 |
|
651 | 674 | SpiralPattern::SpiralPattern() : |
652 | | - arms() // no explicit default; must be set by caller |
| 675 | + arms(), // no explicit default; must be set by caller |
| 676 | + hasTurbulence() // no explicit default; set by Precompute() |
653 | 677 | { |
654 | 678 | waveType = kWaveType_Triangle; |
655 | 679 | } |
656 | 680 |
|
| 681 | +bool SpiralPattern::Precompute() |
| 682 | +{ |
| 683 | + hasTurbulence = (!warps.empty() && dynamic_cast<ClassicTurbulence*>(*warps.begin())); |
| 684 | + return true; |
| 685 | +} |
| 686 | + |
| 687 | + |
657 | 688 | ColourBlendMapConstPtr SquarePattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Square; } |
658 | 689 | unsigned int SquarePattern::NumDiscreteBlendMapEntries() const { return 4; } |
659 | 690 |
|
660 | 691 | ColourBlendMapConstPtr TriangularPattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Triangular; } |
661 | 692 | unsigned int TriangularPattern::NumDiscreteBlendMapEntries() const { return 6; } |
662 | 693 |
|
663 | | -WoodPattern::WoodPattern() { waveType = kWaveType_Triangle; } |
| 694 | + |
| 695 | +WoodPattern::WoodPattern() : |
| 696 | + hasTurbulence() // no explicit default; set by Precompute() |
| 697 | +{ |
| 698 | + waveType = kWaveType_Triangle; |
| 699 | +} |
| 700 | + |
| 701 | +bool WoodPattern::Precompute() |
| 702 | +{ |
| 703 | + hasTurbulence = (!warps.empty() && dynamic_cast<ClassicTurbulence*>(*warps.begin())); |
| 704 | + return true; |
| 705 | +} |
| 706 | + |
664 | 707 | ColourBlendMapConstPtr WoodPattern::GetDefaultBlendMap() const { return gpDefaultBlendMap_Wood; } |
665 | 708 |
|
666 | 709 |
|
@@ -1076,12 +1119,11 @@ template void BlendMap<TexturePtr> ::Search (DBL value, EntryConstPtr& rpPrev, |
1076 | 1119 | * |
1077 | 1120 | ******************************************************************************/ |
1078 | 1121 |
|
1079 | | -static const ClassicTurbulence *SearchForTurb(const WarpList warps) |
| 1122 | +static inline const ClassicTurbulence *GetTurb(const WarpList warps) |
1080 | 1123 | { |
1081 | | - if(warps.empty()) |
1082 | | - return NULL; |
1083 | | - else |
1084 | | - return dynamic_cast<const ClassicTurbulence*>(*warps.begin()); |
| 1124 | + POV_PATTERN_ASSERT(!warps.empty()); |
| 1125 | + POV_PATTERN_ASSERT(dynamic_cast<const ClassicTurbulence*>(*warps.begin())); |
| 1126 | + return static_cast<const ClassicTurbulence*>(*warps.begin()); |
1085 | 1127 | } |
1086 | 1128 |
|
1087 | 1129 |
|
@@ -5345,8 +5387,7 @@ DBL AgatePattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsect |
5345 | 5387 | register DBL noise, turb_val; |
5346 | 5388 | const ClassicTurbulence* Turb; |
5347 | 5389 |
|
5348 | | - Turb=SearchForTurb(warps); |
5349 | | - POV_PATTERN_ASSERT(Turb != NULL); // Parser must make sure that a pattern-associated classic turbulence warp exists. |
| 5390 | + Turb = GetTurb(warps); |
5350 | 5391 |
|
5351 | 5392 | turb_val = agateTurbScale * Turbulence(EPoint,Turb,noise_generator); |
5352 | 5393 |
|
@@ -7790,8 +7831,9 @@ DBL MarblePattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsec |
7790 | 7831 | register DBL turb_val; |
7791 | 7832 | const ClassicTurbulence *Turb; |
7792 | 7833 |
|
7793 | | - if ((Turb=SearchForTurb(warps)) != NULL) |
| 7834 | + if (hasTurbulence) |
7794 | 7835 | { |
| 7836 | + Turb = GetTurb(warps); |
7795 | 7837 | turb_val = Turb->Turbulence[X] * Turbulence(EPoint,Turb,GetNoiseGen(pThread)); |
7796 | 7838 | } |
7797 | 7839 | else |
@@ -8357,8 +8399,9 @@ DBL Spiral1Pattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIse |
8357 | 8399 | DBL z = EPoint[Z]; |
8358 | 8400 | const ClassicTurbulence *Turb; |
8359 | 8401 |
|
8360 | | - if ((Turb=SearchForTurb(warps)) != NULL) |
| 8402 | + if (hasTurbulence) |
8361 | 8403 | { |
| 8404 | + Turb = GetTurb(warps); |
8362 | 8405 | turb_val = Turb->Turbulence[X] * Turbulence(EPoint,Turb,GetNoiseGen(pThread)); |
8363 | 8406 | } |
8364 | 8407 | else |
@@ -8433,8 +8476,9 @@ DBL Spiral2Pattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIse |
8433 | 8476 | DBL z = EPoint[Z]; |
8434 | 8477 | const ClassicTurbulence *Turb; |
8435 | 8478 |
|
8436 | | - if ((Turb=SearchForTurb(warps)) != NULL) |
| 8479 | + if (hasTurbulence) |
8437 | 8480 | { |
| 8481 | + Turb = GetTurb(warps); |
8438 | 8482 | turb_val = Turb->Turbulence[X] * Turbulence(EPoint,Turb,GetNoiseGen(pThread)); |
8439 | 8483 | } |
8440 | 8484 | else |
@@ -8611,8 +8655,9 @@ DBL WoodPattern::EvaluateRaw(const Vector3d& EPoint, const Intersection *pIsecti |
8611 | 8655 | DBL y=EPoint[Y]; |
8612 | 8656 | const ClassicTurbulence *Turb; |
8613 | 8657 |
|
8614 | | - if ((Turb=SearchForTurb(warps)) != NULL) |
| 8658 | + if (hasTurbulence) |
8615 | 8659 | { |
| 8660 | + Turb = GetTurb(warps); |
8616 | 8661 | DTurbulence (WoodTurbulence, EPoint, Turb); |
8617 | 8662 | point[X] = cycloidal((x + WoodTurbulence[X]) * Turb->Turbulence[X]); |
8618 | 8663 | point[Y] = cycloidal((y + WoodTurbulence[Y]) * Turb->Turbulence[Y]); |
|
0 commit comments