-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Added samples info for REALISTIC shading #28432
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,18 @@ function ViewportInfo( editor ) { | |
const verticesText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' ); | ||
const trianglesText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' ); | ||
const frametimeText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' ); | ||
const samplesText = new UIText( '0' ).setTextAlign( 'right' ).setWidth( '60px' ).setMarginRight( '6px' ).setHidden( true ); | ||
|
||
const objectsUnitText = new UIText( strings.getKey( 'viewport/info/objects' ) ); | ||
const verticesUnitText = new UIText( strings.getKey( 'viewport/info/vertices' ) ); | ||
const trianglesUnitText = new UIText( strings.getKey( 'viewport/info/triangles' ) ); | ||
const samplesUnitText = new UIText( strings.getKey( 'viewport/info/samples' ) ).setHidden( true ); | ||
|
||
container.add( objectsText, objectsUnitText, new UIBreak() ); | ||
container.add( verticesText, verticesUnitText, new UIBreak() ); | ||
container.add( trianglesText, trianglesUnitText, new UIBreak() ); | ||
container.add( frametimeText, new UIText( strings.getKey( 'viewport/info/rendertime' ) ), new UIBreak() ); | ||
container.add( samplesText, samplesUnitText, new UIBreak() ); | ||
|
||
signals.objectAdded.add( update ); | ||
signals.objectRemoved.add( update ); | ||
|
@@ -35,6 +38,10 @@ function ViewportInfo( editor ) { | |
|
||
// | ||
|
||
const pluralRules = new Intl.PluralRules( editor.config.getKey( 'language' ) ); | ||
|
||
// | ||
|
||
function update() { | ||
|
||
const scene = editor.scene; | ||
|
@@ -98,6 +105,30 @@ function ViewportInfo( editor ) { | |
|
||
} | ||
|
||
// | ||
|
||
editor.signals.pathTracerUpdated.add( function ( samples ) { | ||
|
||
samples = Math.floor( samples ); | ||
|
||
samplesText.setValue( samples ); | ||
|
||
const samplesStringKey = ( pluralRules.select( samples ) === 'one' ) ? 'viewport/info/oneSample' : 'viewport/info/samples'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems the plural logic is still in place though.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
^^^^^^^ :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current plural code is fine (with the clean up). The refactoring was over engineering. |
||
samplesUnitText.setValue( strings.getKey( samplesStringKey ) ); | ||
|
||
} ); | ||
|
||
editor.signals.viewportShadingChanged.add( function () { | ||
|
||
const isRealisticShading = ( editor.viewportShading === 'realistic' ); | ||
|
||
samplesText.setHidden( ! isRealisticShading ); | ||
samplesUnitText.setHidden( ! isRealisticShading ); | ||
|
||
container.setBottom( isRealisticShading ? '32px' : '20px' ); | ||
|
||
} ); | ||
|
||
return container; | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,8 @@ class UIElement { | |
|
||
this.dom.hidden = isHidden; | ||
|
||
return this; | ||
|
||
} | ||
|
||
isHidden() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsidering #28245.
Do we really need this distinction? Stuff like that creates an unnecessary complexity. Why not just using
Sample(s)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vertex(ices) then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we just always use the plural? I personally don't see
1
samples as an issue which should be fixed with a separate code path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue about using
(s)
for just 'Sample(s)' is that, that unit will be inconsistent with other units formatted in the same area:The reason that we can't apply
(s)
for other units has been mentioned #28432 (comment)If handling of plural rules causes readability problems, then I prefer taking them into a function: (update: this function is now implemented in 54a4957)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I vote for always using plural (without brackets).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the transition from 0 > 1 > 2 samples is noticeable in low-end devices, so 'always use plural' like
1samples
will confuse users that the quantity is incorrect.