Skip to content

Commit 12fbab3

Browse files
committed
Change camera right default length to output image aspect ratio.
1 parent 17e3f64 commit 12fbab3

File tree

7 files changed

+61
-20
lines changed

7 files changed

+61
-20
lines changed

changes.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ should be located in the same directory as this file is.
3232
Changes between v3.7.1-rc.1 and v3.8.0-???
3333
==========================================
3434

35+
This version is still under active development, and not finalized yet.
36+
3537
NOTE: This release cycle has been redesignated v3.8.0. There will not be a
3638
v3.7.1 release proper.
3739

@@ -48,6 +50,11 @@ Changed Behaviour
4850
- Any new behaviour formerly activated by `#version 3.71` now requires
4951
`#version 3.8` (or higher); specifying `#version 3.71` will trigger a
5052
corresponding warning.
53+
- Some defaults have been changed (requires `#version 3.8` as the _very first_
54+
statement of the scene, or a corresponding command line / INI setting):
55+
- `ambient` now defaults to 0.0 instead of 0.1.
56+
- Camera `right` vector length now defaults to the output image aspect
57+
ratio (presuming square pixels) instead of 1.33.
5158

5259
Other Noteworthy
5360
----------------

source/backend/control/scene.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ void Scene::StartParser(POVMS_Object& parseOptions)
9999
sceneData->inputFile = parseOptions.TryGetUCS2String(kPOVAttrib_InputFile, "object.pov");
100100
sceneData->headerFile = parseOptions.TryGetUCS2String(kPOVAttrib_IncludeHeader, "");
101101

102+
DBL outputWidth = parseOptions.TryGetFloat(kPOVAttrib_Width, 160);
103+
DBL outputHeight = parseOptions.TryGetFloat(kPOVAttrib_Height, 120);
104+
sceneData->aspectRatio = outputWidth / outputHeight;
105+
102106
sceneData->defaultFileType = parseOptions.TryGetInt(kPOVAttrib_OutputFileType, DEFAULT_OUTPUT_FORMAT); // TODO - should get DEFAULT_OUTPUT_FORMAT from the front-end
103107
sceneData->clocklessAnimation = parseOptions.TryGetBool(kPOVAttrib_ClocklessAnimation, false); // TODO - experimental code
104108

source/core/scene/scenedata.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct Skysphere_Struct;
7070
/// This class just provides access to scene specific data
7171
/// needed in many parts of the code. Be aware that while most
7272
/// data is members are public, they shall **not** be modified
73-
/// carelessly. Code from POV-Ray 3.6 and earlier does depend
73+
/// carelessly. Code from POV-Ray v3.6 and earlier does depend
7474
/// on simple access of this data all over the old code, so
7575
/// this provides an efficient way to reuse all the old code.
7676
/// By no means shall this way of data access be used for any
@@ -166,7 +166,7 @@ class SceneData
166166
bool realTimeRaytracing;
167167

168168
// ********************************************************************************
169-
// Old globals from 3.6 and earlier are temporarily kept below. Please carefully
169+
// Old globals from v3.6 and earlier are temporarily kept below. Please carefully
170170
// consider what is added and mark it accordingly if it needs to go away again
171171
// prior to final release! [trf]
172172
// ********************************************************************************
@@ -196,6 +196,9 @@ class SceneData
196196
UCS2String inputFile; // TODO - handle differently
197197
UCS2String headerFile;
198198

199+
/// Aspect ratio of the output image.
200+
DBL aspectRatio;
201+
199202
int defaultFileType;
200203

201204
FrameSettings frameSettings; // TODO - move ???
@@ -227,13 +230,13 @@ class SceneData
227230

228231
/// Convenience function to determine the effective SDL version.
229232
///
230-
/// Given that version 3.7 and later require the first statement in the file to be
233+
/// Given that version v3.7 and later require the first statement in the file to be
231234
/// a `#version` statement, the absence of such a statement can be presumed to
232-
/// indicate a pre-3.7 scene; this function assumes version 3.62 in that case
233-
/// (which was the latest 3.6 version when 3.7.0 was released).
235+
/// indicate a pre-v3.7 scene; this function assumes v3.6.2 in that case
236+
/// (which was the latest version before v3.7.0).
234237
/// @note It is recommended to use this function only where behaviour differs
235-
/// significantly from pre-3.7 versions.
236-
/// @return The current language version in integer format (e.g. 370 for 3.70)
238+
/// significantly from pre-v3.7 versions.
239+
/// @return The current language version in integer format (e.g. 370 for v3.7.0)
237240
/// if explicitly specified, or 362 otherwise.
238241
///
239242
inline unsigned int EffectiveLanguageVersion() const

source/parser/parser.cpp

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,9 @@ void Parser::Run()
184184
Default_Texture->Pigment = Create_Pigment();
185185
Default_Texture->Tnormal = NULL;
186186
Default_Texture->Finish = Create_Finish();
187-
// [JG] If the version has been *explictly* set in the ini or command line,
188-
// override the default ambient (rgb 0.1) (in Create_Finish) to 0.0
189-
if ((sceneData->languageVersionSet) && (sceneData->languageVersion >= 380))
190-
{
191-
Default_Texture->Finish->Ambient.Clear();
192-
}
187+
188+
// Initialize various defaults depending on language version as per command line / INI settings.
189+
InitDefaults(sceneData->EffectiveLanguageVersion());
193190

194191
Not_In_Default = true;
195192
Ok_To_Declare = true;
@@ -513,6 +510,34 @@ void Parser::Frame_Init()
513510
}
514511

515512

513+
/****************************************************************************/
514+
515+
void Parser::InitDefaults(int version)
516+
{
517+
// Initialize defaults depending on version:
518+
// As of v3.8...
519+
// - `ambient` defaults to 0.0.
520+
// - Camera `right` length defaults to output image aspect ratio.
521+
// Prior to that...
522+
// - `ambient` defaulted to 0.1.
523+
// - Camera `right` length defaulted to 1.33.
524+
525+
double ambientLevel;
526+
double rightLength;
527+
if (version >= 380)
528+
{
529+
ambientLevel = 0.0;
530+
rightLength = sceneData->aspectRatio;
531+
}
532+
else
533+
{
534+
ambientLevel = 0.1;
535+
rightLength = 1.33;
536+
}
537+
Default_Texture->Finish->Ambient = MathColour(ambientLevel);
538+
Default_Camera.Right = Vector3d(rightLength, 0.0, 0.0);
539+
}
540+
516541

517542
/*****************************************************************************
518543
*
@@ -4883,7 +4908,6 @@ TEXTURE *Parser::Parse_Mesh_Texture (TEXTURE **t2, TEXTURE **t3)
48834908

48844909
ObjectPtr Parser::Parse_Ovus()
48854910
{
4886-
DBL distance;
48874911
Ovus *Object;
48884912

48894913
Parse_Begin();

source/parser/parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ class Parser : public SceneTask
633633

634634
// parse.h/parse.cpp
635635
void Frame_Init(void);
636+
void InitDefaults(int version);
636637
void Parse_Coeffs(int order, DBL *Coeffs);
637638

638639
ObjectPtr Parse_Bicubic_Patch(void);

source/parser/parser_expressions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ void Parser::Parse_Num_Factor (EXPRESS& Express,int *Terms)
10401040
if (!parsingVersionDirective)
10411041
{
10421042
// Normally, the `version` pseudo-variable needs to return the effective language version
1043-
// (which now defaults to 3.6.2) so that include files can properly switch back after
1043+
// (which now defaults to v3.6.2) so that include files can properly switch back after
10441044
// temporarily overriding the `#version` setting.
10451045
Val = sceneData->EffectiveLanguageVersion() / 100.0;
10461046
}
@@ -2661,7 +2661,7 @@ void Parser::Parse_Colour (RGBFTColour& colour, bool expectFT)
26612661
// Note: Setting up for potential warning on single value float promote to
26622662
// five value color vector. Any single float will be promoted to the full
26632663
// 'tgtTerms' value. This usually results in filter and trasmit values >0,
2664-
// which caused shadow artifacts back to at least version 3.6.1.
2664+
// which caused shadow artifacts back to at least version v3.6.1.
26652665
if ((Token.Token_Id==FLOAT_FUNCT_TOKEN) || (Token.Token_Id==FUNCT_ID_TOKEN))
26662666
sawFloatOrFloatFnct = true;
26672667
else

source/parser/parser_tokenizer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,10 +2432,12 @@ void Parser::Parse_Directive(int After_Hash)
24322432
"statement in the scene file. If your scene will adapt to whatever version "
24332433
"is in use dynamically, start your scene with '#version version'.");
24342434
}
2435-
else if ((!sceneData->languageVersionSet) && (sceneData->languageVersion >= 380))
2436-
{// [JG] first item, not languageVersionLate : override the default ambient (rgb 0.1) (in Create_Finish) for 0.0
2437-
// Do not bother to create a copy, it has not been used yet
2438-
Default_Texture->Finish->Ambient.Clear();
2435+
2436+
if (!sceneData->languageVersionLate && !sceneData->languageVersionSet)
2437+
{
2438+
// Got `#version` as the first statement of the file.
2439+
// Initialize various defaults depending on language version specified.
2440+
InitDefaults(sceneData->languageVersion);
24392441
}
24402442

24412443
// NB: This must be set _after_ parsing the value, in order for the `#version version`

0 commit comments

Comments
 (0)