mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-14 19:04:44 +00:00
Tesselation tolerance of 0.0f (or negative) disables curve drawing for num_segments = 0 #5713
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#5713
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version: v1.88
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: any
Compiler: any
Operating System: windows
My Issue/Question:
Currently trying to build out some utility functions to render svgs. What I found is that when using:
There's a defaulted num_segment value of 0 which eventually uses the functionality from https://github.com/ocornut/imgui/issues/3127
Quick eyeballing of the code and you'll notice that with a tessellation tolerance <= 0.0f no points will ever be added, this includes the start and end point of the curve (presumably the start of the curve has already been added). I'm not sure if this is intended, I'd assume a failover of at least a line drawn to the end point? I ran into this by accident because I didn't specifically set the tessellation value and apparently it was zeroed out. In my case it clearly broke drawings with a start point followed by a curve because the resulting path only contained the start point, which of course doesn't end up rendering much of anything to notice visually.
Screenshots/Video

For reference...my svg renderer is not complete and is still buggy, but here's what I was dealing with:
Compared to:

The original svg was a chess piece, in case that isn't clear.
Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)
Hello,
Thanks for reporting.
A zero of negative tessellation tolerance is invalid, for the global setting we are asserting in
NewFrame():And this is where the value is pulled from.
I don't expect us to magically positively react to people randomly zeroing memory. I am guessing it is slightly more likely to happen if the underlying
ImDrawListSharedDatabacking is swapped or modified. I am not sure what you are trying to solve here. We could indeed add more assert in entry point function, which is what I did now (56c3eae) but I don't think there's more than that to do.Ah ok, so my suspicion that it was intended was correct. Do you have a general sense of the minimum/maximum value should be? EG: if before the call I instead the tolerance was clamped?
No I wouldn't imagine you would. I ran into this by accident.
You can leave the default value which is 1.25 and tweak the value in style editor. I don’t know off hand of there’s a meaningful “min” and “max” there, its a tradeoff.
It looked like the math behind it was doing some form of quick check against distances between points, not exactly studied it completely so I'm guessing it's some estimation along the bezier compared against the actual bezier curve? And then presumably when the estimated point fails distance wise it subdivides between that section of the curve (generating more points tighter to the curve). I was wondering if the tolerance value (or starting level) is something that could be dynamically adjusted by the start and end points.
What are you trying to solve?
Well I'm trying to work out in my head how I might set some minimum value so that that particular function always at least draws a line, I'm somewhat trying to figure out how I can maintain some minimum level of detail. The issue I have is that svgs aren't consistent in the slightest, I can trust the points are relative to where the should be to other points, but that's about it. The defaulted num_segments = 0 drawing a dynamic number of points seems handy to me, but now i know I can't rely on it directly, because I just had it not draw anything.
Just leave it to the default value. It should always draw something given g.Style.CurveTessellationTol is left on default. You should investigate why you were clearing that data. Anyhow I don't imagine you can draw SVG with only available ImDrawList function you'll probably need to get lower level anyhow.
Suppose I write a custom function which does this instead? That would force drawing points along the curve if it goes to the maximum level but fails to find anything...that should be how this works right?
What was the original curve drawing function supposed to do with num_segments=0? Would that have not drawn anything eaither? Because then the recursive function could be split into two: