leozide / leocad

A CAD application for creating virtual LEGO models
https://www.leocad.org
2.49k stars 211 forks source link

Conditional lines #60

Closed leozide closed 3 years ago

leozide commented 7 years ago

Fix conditional lines Add option to preferences Optimize

rsbx commented 3 years ago

Any progress on this?

Attached: Test model to demonstrate need.

CondEdge.mpd.txt

nathaneltitane commented 3 years ago

Seems the latest changes to color handling through that new automated algorithm also messed with edge lines not being entirely visible using certain background colors... conditional lines nad edge mapping should be better integrated to analyze all colors and not result in lines not being visible under certain circumstances.

rsbx commented 3 years ago

If your intended use case is wire-frame mode then Auto Edge Color really provides no benefit. This is because all line color calculations are relative to the part surface color.

When in wire-frame mode, assuming you want it part color related, there's always going to be contrast issues with some combinations of background and part colors.

If the wire-frame doesn't need to be part color related the a since high contrast color can be used. But you'd lose all of the color information.

Nathanel, if you can list your needs, wants, and nice (to haves), I'll see what I can come up with since I think it'll be an interesting problem.

On 2/26/21 10:25 AM, Nathanel Titane wrote:

Seems the latest changes to color handling through that new automated algorithm also messed with edge lines not being entirely visible using certain background colors... conditional lines nad edge mapping should be better integrated to analyze all colors and not result in lines not being visible under certain circumstances.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786714414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ.

nathaneltitane commented 3 years ago

If your intended use case is wire-frame mode then Auto Edge Color really provides no benefit. This is because all line color calculations are relative to the part surface color. When in wire-frame mode, assuming you want it part color related, there's always going to be contrast issues with some combinations of background and part colors. If the wire-frame doesn't need to be part color related the a since high contrast color can be used. But you'd lose all of the color information. Nathanel, if you can list your needs, wants, and nice (to haves), I'll see what I can come up with since I think it'll be an interesting problem. On 2/26/21 10:25 AM, Nathanel Titane wrote: Seems the latest changes to color handling through that new automated algorithm also messed with edge lines not being entirely visible using certain background colors... conditional lines nad edge mapping should be better integrated to analyze all colors and not result in lines not being visible under certain circumstances. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#60 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ.

This is obviously related to wireframe view and custom background color selection - wireframe is essential to align things through complex assemblies and it'S a shame to not be able to leverage these enhancements without having to manually change/toggle or avoid certain colors manually.

nathaneltitane commented 3 years ago

ref #508

leozide commented 3 years ago

Wireframe doesn't use edge colors. If there's a specific problem that needs to be addressed let's start a new bug with an example.

rsbx commented 3 years ago

Wire-frame mode is a challenge since there is less information presented on the screen and what is presented has less redundant information.

You mentioned a singe use case: adjusting something relative to everything else. On the surface this appears simple but I suspect I do not full understand all the nuances of the task. Are you only concerned with aligning relative geometry? Or is there also a need to align relative to color differentiated sub-geometries. The first is easy; the second isn't.

On 2/26/21 11:34 AM, Nathanel Titane wrote:

If your intended use case is wire-frame mode then Auto Edge Color
really provides no benefit. This is because all line color
calculations are relative to the part surface color. When in
wire-frame mode, assuming you want it part color related, there's
always going to be contrast issues with some combinations of
background and part colors. If the wire-frame doesn't need to be
part color related the a since high contrast color can be used. But
you'd lose all of the color information. Nathanel, if you can list
your needs, wants, and nice (to haves), I'll see what I can come up
with since I think it'll be an interesting problem.
… <#>
On 2/26/21 10:25 AM, Nathanel Titane wrote: Seems the latest changes
to color handling through that new automated algorithm also messed
with edge lines not being entirely visible using certain background
colors... conditional lines nad edge mapping should be better
integrated to analyze all colors and not result in lines not being
visible under certain circumstances. — You are receiving this
because you commented. Reply to this email directly, view it on
GitHub <#60 (comment)
<https://github.com/leozide/leocad/issues/60#issuecomment-786714414>>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ
<https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ>.

This is obviously related to wireframe view and custom background color selection - wireframe is essential to align things through complex assemblies and it'S a shame to not be able to leverage these enhancements without having to manually change/toggle or avoid certain colors manually.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786754319, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNHHFKWGTL7AWMRPU63TA7EP5ANCNFSM4DQKZZTQ.

nathaneltitane commented 3 years ago

Wire-frame mode is a challenge since there is less information presented on the screen and what is presented has less redundant information. You mentioned a singe use case: adjusting something relative to everything else. On the surface this appears simple but I suspect I do not full understand all the nuances of the task. Are you only concerned with aligning relative geometry? Or is there also a need to align relative to color differentiated sub-geometries. The first is easy; the second isn't. On 2/26/21 11:34 AM, Nathanel Titane wrote: If your intended use case is wire-frame mode then Auto Edge Color really provides no benefit. This is because all line color calculations are relative to the part surface color. When in wire-frame mode, assuming you want it part color related, there's always going to be contrast issues with some combinations of background and part colors. If the wire-frame doesn't need to be part color related the a since high contrast color can be used. But you'd lose all of the color information. Nathanel, if you can list your needs, wants, and nice (to haves), I'll see what I can come up with since I think it'll be an interesting problem. … <#> On 2/26/21 10:25 AM, Nathanel Titane wrote: Seems the latest changes to color handling through that new automated algorithm also messed with edge lines not being entirely visible using certain background colors... conditional lines nad edge mapping should be better integrated to analyze all colors and not result in lines not being visible under certain circumstances. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#60 (comment) <#60 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ https://github.com/notifications/unsubscribe-auth/AAECJNEQTQNEHDMJ6P4CDBDTA64QJANCNFSM4DQKZZTQ. This is obviously related to wireframe view and custom background color selection - wireframe is essential to align things through complex assemblies and it'S a shame to not be able to leverage these enhancements without having to manually change/toggle or avoid certain colors manually. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#60 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNHHFKWGTL7AWMRPU63TA7EP5ANCNFSM4DQKZZTQ.

without going into super complex geometry lingo let me try to illustrate a very sensible use case: HINGES, JOINTS and CLIPS used within models and submodels for articulation:

If a hing or a clip is used within (middle or inside of a sub-model) and needs to be angled or positioned, I will switch to wireframe to position the model assemblies and set the angle at which they need to be presented.

The control point often times needs to be adjusted during or prior to osetting the position and angle and that will often depend on the parts being used for a joint.

See below the difference in between flat view (no lights) and wireframe, with and without parts being selected... Wireframe should be able to reperesnet all parts in the view regardless of selection.

Why does the selection (absolute or relative show the entirety of the parts being selected but now wireframe then? And if it has to do with the background color selection (as mentioned earlier) shouldn'T the new algorithm compensate and contrast the wireframe view as well?

Pics below depict a mecha knee joint that needs to be positioned into its socket and rotated - wireframe is less than optimal in this case given the way lines/contrast is drawn in that mode and the color og the BG.

Screenshot_20210226-120935_VNC Viewer

Screenshot_20210226-120952_VNC Viewer

Screenshot_20210226-121016_VNC Viewer

Screenshot_20210226-121022_VNC Viewer

rsbx commented 3 years ago

Some narration on the screenshot differences and issues would help.

nathaneltitane commented 3 years ago

Some narration on the screenshot differences and issues would help.

The screenshots were meant to illustrate the lack of visibility of model/submodel lines when wireframe view is activated.

One can only properly distinguish all part geometries when selection is made (blue or red)...

rsbx commented 3 years ago

The first 3 screenshots each have something highlighted and the last 3 are wire-frame. Other than than that I can't really tell what display features are enabled.

nathaneltitane commented 3 years ago

The first 3 screenshots each have something highlighted and the last 3 are wire-frame. Other than than that I can't really tell what display features are enabled.

first one is flat shade, all other 3 are wireframe...

rsbx commented 3 years ago

Sorry! My browser crashed while editing that.

What display features are enabled in the 3 wire-frame screenshots?

On 2/26/21 2:07 PM, Nathanel Titane wrote:

The first 3 screenshots each have something highlighted and the last
3 are wire-frame. Other than than that I can't really tell what
display features are enabled.

first one is flat shade, all other 3 are wireframe...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786838393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ.

nathaneltitane commented 3 years ago

Sorry! My browser crashed while editing that.

What display features are enabled in the 3 wire-frame screenshots?

On 2/26/21 2:07 PM, Nathanel Titane wrote:

The first 3 screenshots each have something highlighted and the last
3 are wire-frame. Other than than that I can't really tell what
display features are enabled.

first one is flat shade, all other 3 are wireframe...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786838393, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ.

What do you mean by 'display features' ?

rsbx commented 3 years ago

Pending further information, this appears to be the simple situation of aligning relative geometry: where only 2 mutually contrasting colors that also contrast with the background color are needed. One for the main assembly and the other for what's selected.

If that is the situation, the easiest way to implement (I think) would be to:

rsbx commented 3 years ago

Anything that affects the rendering: auto edge, fade, highlight, ...

On 2/26/21 3:21 PM, Nathanel Titane wrote:

Sorry! My browser crashed while editing that.

What display features are enabled in the 3 wire-frame screenshots?

On 2/26/21 2:07 PM, Nathanel Titane wrote:

    |The first 3 screenshots each have something highlighted and the
    last 3 are wire-frame. Other than than that I can't really tell
    what display features are enabled. |

    first one is flat shade, all other 3 are wireframe...

    —
    You are receiving this because you commented.
    Reply to this email directly, view it on GitHub
    #60 (comment)
    <https://github.com/leozide/leocad/issues/60#issuecomment-786838393>,
    or
    unsubscribe
    https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ
    <https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ>.

What do you mean by 'display features' ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786874003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNGHDQC6ZHDATDDOHSLTA77GHANCNFSM4DQKZZTQ.

nathaneltitane commented 3 years ago

Anything that affects the rendering: auto edge, fade, highlight, ...

On 2/26/21 3:21 PM, Nathanel Titane wrote:

Sorry! My browser crashed while editing that.

What display features are enabled in the 3 wire-frame screenshots?

On 2/26/21 2:07 PM, Nathanel Titane wrote:

    |The first 3 screenshots each have something highlighted and the
    last 3 are wire-frame. Other than than that I can't really tell
    what display features are enabled. |

    first one is flat shade, all other 3 are wireframe...

    —
    You are receiving this because you commented.
    Reply to this email directly, view it on GitHub
    #60 (comment)
    <https://github.com/leozide/leocad/issues/60#issuecomment-786838393>,
    or
    unsubscribe
    https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ
    <https://github.com/notifications/unsubscribe-auth/AAECJNGCBT6YDBDQK3O52KDTA7WQTANCNFSM4DQKZZTQ>.

What do you mean by 'display features' ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-786874003, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNGHDQC6ZHDATDDOHSLTA77GHANCNFSM4DQKZZTQ.

leocad.conf relevant contents:

AASamples=1 ActiveViewColor=-4620247 AllowLOD=1 AutoLoadMostRecent=0 AutomateEdgeColor=0 AxesColor=-1 BackgroundColor=-14080477 BackgroundGradient=0 BlackEdgeColor=-1 CheckUpdates=1 ColorTheme=0 DarkEdgeColor=-13358565 DrawAxes=0 DrawEdgeLines=1 DrawPreviewAxis=0 FadeSteps=0 FadeStepsColor=- FixedAxes=1 GradientColorBottom=-13159375 GradientColorTop=-10532810 GridLineColor=-15198184 GridLineSpacing=5 GridLines=0 GridOrigin=1 GridStudColor=-1072162792 GridStuds=0 HighlightNewParts=0 HighlightNewPartsColor=-1056964609 InactiveViewColor=-12237499 LODDistance=@Variant(\0\0\0\x87\0\0\0\0) Language= LineWidth=@Variant(\0\0\0\x87?\x80\0\0) MarqueeBorderColor=-1 MarqueeFillColor=16777215 MinifigSettings= MouseSensitivity=1 MouseShortcuts="Pan=3", "Orbit=2" OverlayColor=-1 PartEdgeColor=-16777216 PartEdgeContrast=@Variant(\0\0\0\x87?\x80\0\0) PartsLibrary=/media/Internal/Drive/Lego/ldraw.zip PartsListIcons=96 PreviewViewSphereLocation=2 PreviewViewSphereSize=100

nathaneltitane commented 3 years ago

@rsbx was the config info sufficient?

rsbx commented 3 years ago

@nathaneltitane, yes it was. Your use case is the simple one I outlined a solution for 2 replies ago (starts with Pending futher information...). I think it would be a good feature to have since it could simplify alignments of large and/or complex sub-models but it's also a new feature request.

We also got off-topic and I'm still wondering about conditional line support.

leozide commented 3 years ago

There's a prototype you can enable with a global variable (in lc_scene.cpp I think) but it's only good for checking the math, it's too slow to be usable.

rsbx commented 3 years ago

I'll check it out tomorrow. Are there plans to improve it and make it usable?

On 3/1/21 8:47 PM, Leonardo Zide wrote:

There's a prototype you can enable with a global variable (in lc_scene.cpp I think) but it's only good for checking the math, it's too slow to be usable.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-788510866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEWUYSHUNTKSJC4TKDTBQ7U7ANCNFSM4DQKZZTQ.

rsbx commented 3 years ago

Definitely a significant slowdown with large models. Too slow for interactive work but could still be used to significantly improve generated images with round/curved parts.

The math still has issues. Some edge lines come and go; easily seen with Brick or Tile 2 x 2 Round parts when you slowly rotate them.

What is it that's killing performance? Even if it can't be made fast enough, it'd still be useful for image rendering once the math is fixed. There's also some mitigations that could be employed for interactive use; such as, not rendering cond lines until interactive manipulations are paused (ldglite does this). The may be others also.

On 3/1/21 8:47 PM, Leonardo Zide wrote:

There's a prototype you can enable with a global variable (in lc_scene.cpp I think) but it's only good for checking the math, it's too slow to be usable.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-788510866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEWUYSHUNTKSJC4TKDTBQ7U7ANCNFSM4DQKZZTQ.

rsbx commented 3 years ago

Definitely has problems with the math. An easy way to see it is to slowly rotate around a single Tile 1 x 1 Round part in wireframe mode and without the grid.

On 3/2/21 10:11 AM, Raymond S Brand wrote:

Definitely a significant slowdown with large models. Too slow for interactive work but could still be used to significantly improve generated images with round/curved parts.

The math still has issues. Some edge lines come and go; easily seen with Brick or Tile 2 x 2 Round parts when you slowly rotate them.

What is it that's killing performance? Even if it can't be made fast enough, it'd still be useful for image rendering once the math is fixed. There's also some mitigations that could be employed for interactive use; such as, not rendering cond lines until interactive manipulations are paused (ldglite does this). The may be others also.

On 3/1/21 8:47 PM, Leonardo Zide wrote:

There's a prototype you can enable with a global variable (in lc_scene.cpp I think) but it's only good for checking the math, it's too slow to be usable.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/leozide/leocad/issues/60#issuecomment-788510866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAECJNEWUYSHUNTKSJC4TKDTBQ7U7ANCNFSM4DQKZZTQ.

rsbx commented 3 years ago

@leozide is there an easy way (working code snippit?) to get it to draw the (P1, P3) and (P1, P4) lines also as an aid to debug the math?

rsbx commented 3 years ago

@leozide nevermind; I found the math fix. Patch forthcoming.

rsbx commented 3 years ago

Here's the patch that fixes the conditional edge line math and also a stab at improving performance some:

cond_edge.patch.txt

I'd like to have conditional edge lines be a supported feature option since it does significantly improve renderings of curved parts.

The performance hit is a problem for large models and for less powerful systems so some mitigations are desirable. The mitigations I've thought of are:

My preference is for both User Decides and Delayed since it'd give the best experience for most users while not impacting experienced/power users. The toggle and the delay time would be the preference items.

rsbx commented 3 years ago

Attached is an improved conditional edge patch. All previous comments still apply.

cond_edge.patch.txt