The counter was added solely as a debug feature in commit e7c8c1c8,
which introduced the new Canvas system. It doesn't work all that well
and brings little value, so let's get rid of the visual noise.
This commit continues the work started in commits 521473ee and
e84fd464 that parallelizes certain geometric operations. This commit
cleans up the temporary arena implementations and makes them
thread-safe.
Also, in commit 521473ee, a call to FreeAllTemporary() was added
during initialization to create the heap on Windows. This is now
not necessary as the heap is created transparently on the first call
to AllocTemporary().
When checking the dot product of the tangents `tu` and `tv` to decide
in which direction to split a quad compare it to to LENGTH_EPS instead
of zero to avoid alternating triangle "orientations" when the tangents
are orthogonal (revolve, lathe etc.).
This improves the quality of the resulting triangle mesh.
Commit ea6db67 added an unusual isnan macro:
#define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))
Commit 8bc322e adds a preprocessor guard that looks like it would
cause the isnan function from math.h to be preferred, but doesn't
actually do that on many platforms, e.g. glibc:
#ifndef isnan
# define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))
#endif
This commit renames our isnan() to make it clear that it differs
from the standard library operation, and makes it a function.
Fixes#603.
We use std::fabs, but <math.h> doesn't provide it; it worked by accident.
Include <cmath> that provides std::fabs, and switch all other headers to
their C++ variants, too.
* Don't use a reserved identifier in include guards.
* Use fabs() from <cmath> instead of our own ffabs().
This shouldn't make any difference with modern toolchains.
* Convert a few preprocessor macros to constexprs.
After this commit, dbp() is renamed to DebugPrint() and moved to
platform.cpp, next to other similar functions. The existing short
name is provided by a preprocessor macro, similar to ssassert().
This leaves just the (rather hacky) temporary heap in util*.cpp.
This commit performs three related cleanups:
* The slvs library no longer uses explicit platform initialization
(which drags in the side effects of InitPlatform that are not
desirable in a library). Instead, it just ensures that it has
the temporary heap, which is what it was callingInitPlatform for.
* InitPlatform is simplified and moved to platform.cpp, next to
other path related functions.
* InitPlatform is renamed to InitCli and is called from InitGui
implementations. GUI toolkits sometimes have options they use
internally (that's the case for for GTK and Cocoa at least),
and we shouldn't try to parse those as a file to open.
Historically SolveSpace used its own heap on Windows since it gave
better control and debugging options, but a lot of development these
days happens on Linux, where that heap was a stub around malloc/free,
and also Windows debugging tools got a lot better.
In terms of immediate benefit, this commit fixes heap corruption
on Windows introduced in commits b4e1ce44 and 47e82798, caused
by allocating with HEAP_NO_SERIALIZE in parallel from OpenMP threads.
Without HEAP_NO_SERIALIZE there's no performance benefit to keeping
our own heap, either.
The vl() function is also removed because for development there are
better tools now, and the only place where it was permanently called
from became a no-op, since temporary heap always validates after
FreeAllTemporary() recreates it.
This changes all the lambdas to have explicit captures, since the use of
implicit captures has led to some memory errors, especially segfaults in
the right-click menu.
I'm not 100% sure that the code is correct anyway - it really needs auditing
to ensure all referenced values are still valid when the menu item is clicked
(e.g. can you change stuff with keyboard shortcuts while the context menu is
visible?), but it should at least be *more* correct!
This was incorrectly capturing `r` by reference and using it after it left
its scope. Changed to capture by value, and also explicitly capture `this`
in case we were accidentally capturing any other scope variables by reference.
Fixes#571
* Limit u,v range between 0 and 1 in Newton. Fixes issue #471
* Change the math for projecting a point onto a plane to work better with non-orthogonal U,V derivatives in several places. Fixes#472.
See:
https://github.com/solvespace/solvespace/issues/92#issuecomment-567831112
The problem was first introduced here:
dabd57847e
and later "fixed" here:
f324477dd0
by setting the stack size to /STACK:33554432
Solvespace now starts up even with /STACK:554432
According to this:
https://en.cppreference.com/w/cpp/language/value_initialization
```
"2) if T is a class type with a default constructor that is neither user-provided nor deleted (that is, it may be a class with an implicitly-defined or defaulted default constructor), the object is zero-initialized and then it is default-initialized if it has a non-trivial default constructor; "
```
So removing the `{}` should leave both the `System` and `TextWindow` class instances properly initialized.
A warning found with /W4 by MSVC 2019 (Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314)
is an actual bug. How does the SpaceMouse (I do not have one) work at all when the global `hSpaceWareDriverClass` is NULL?!
.\src\platform\guiwin.cpp(1392,34): warning C4459: declaration of 'hSpaceWareDriverClass' hides global declaration
.\src\platform\guiwin.cpp(1389,13): message : see declaration of 'SolveSpace::Platform::hSpaceWareDriverClass'
Found with /W4 by MSVC 2019 (Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314)
A bunch of implicit casts 'double' to 'float' and one 'int64_t' to 'unsigned'.
.\src\platform\guiwin.cpp(1237): warning C4701: potentially uninitialized local variable 'cursorName' used
.\src\platform\guiwin.cpp(1237): warning C4703: potentially uninitialized local pointer variable 'cursorName' used
.\src\solvespace.cpp(805,30): warning C4456: declaration of 'gs' hides previous local declaration
.\src\solvespace.cpp(715,17): message : see declaration of 'gs'
.\src\solvespace.cpp(849,47): warning C4456: declaration of 'e' hides previous local declaration
.\src\solvespace.cpp(847,29): message : see declaration of 'e'
.\src\render\render.h(288,51): warning C4458: declaration of 'camera' hides class member
.\src\render\render.h(271,17): message : see declaration of 'SolveSpace::SurfaceRenderer::camera'
.\src\render\render.h(289,57): warning C4458: declaration of 'lighting' hides class member
.\src\render\render.h(272,17): message : see declaration of 'SolveSpace::SurfaceRenderer::lighting'
GetIdent is called from an UI event callback, at which point there
might well not be an active GL context. Before this commit, that
would return a NULL pointer and result in a crash.
Before this commit, certain fonts (e.g. Terminus) would appear in
the selector but cause a crash (assertion failure) if they are used.
After this commit, we make sure all preconditions are met before
showing a font there.
Also, improve error reporting to always print font filename.
This was originally changed in 74aa80b6, but the fix broke stipping
because it incorrectly changed the logic. Revert that, and just make
the textures smaller instead.
Before this commit, resizing the property browser would cut off
the rows at the bottom, or else add black space, until next refresh.
This could be perhaps more elegantly done by adding an onResize event
but given that each of them would be followed by onRender anyway, it
seems there's no benefit to adding onResize.
As I understand it, both glGetError() and glFinish() are serializing
and blockig, so it makes more sense to call them at the same time.
glFlush() does not block.
Since Catalina or earlier this no longer causes artifacts when Cocoa
controls are overlaid on a GL layer. Conversely, offscreen rendering
is very slow, especially on HiDPI screens.
Co-Authored-By: Koen Schmeets <hello@koenschmeets.nl>
When drawing the graphics window, we flush it twice: once to draw
the geometry, and another time to draw the UI overlay (toolbar,
selection marquee, and FPS counter). Calling glFinish() each time
is (on most platforms) just pointlessly slow, but on macOS Catalina,
without offscreen rendering, it causes the toolbar to flicker.
Instead of calling glFinish() twice per frame in that case, call
glFlush() twice and then glFinish() once we really are done.
Union and difference are optimized by replacing the expression
(!inShell && !inFace)
which is equivqlent to
(!inShell && !inSame && !inOpp)
with
outSide
which is equivalent, since SShell::Class::OUTSIDE is the only remaining possibility.
Per the OpenGL documentation:
> GL_INVALID_VALUE may be generated if level is greater than
> log2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE.
Although we always passed `log2(max) + 1` as `level`, for some reason
none of the GL implementations we run on ever returned an error.
It also appears there is a bug in ANGLE that crashes the process
instead in this case if the C++ runtime performs bound checks on
vector::operator[]=.
Was getting segfaults near here with another patch since removed from the branch.
Moving these assignments after the memfree means they still have
useful data when debugging a crash in memfree.
Allows distancing users from the internal "elem" member.
Add Get() and operator[].
Replace direct references to elem.
Make elem and elemsAllocated private in IdList/List.
In other words, Ctrl inverts the normal action of LMB. It is already
possible to deselect entities through the context menu, but that
can be very awkward on laptop touchpads with a crowded sketch; with
Ctrl, a misclick is easily corrected without moving cursor at all.
This means that automatically added H/V constraints now will never
cause the sketch to become overconstrained, which currently makes
that feature almost unusable.
It makes no sense to solve by substitution (therefore weakening rank
check) in SolveRank(), since that's the whole point of SolveRank().
In addition, because SolveRank() is currently always called right
after AddConstraint(), forceDofCheck would always be true anyway.
In addition, it makes no sense to have TestRankForGroup() dependent
on the result of the previous solve. (For SolveGroup(), solving by
substitution after we know that rank test succeeds makes dragging
points much faster.)
Clarify the name of the command, as the old name is not strictly
correct. E.g. consider a vertical line with a midpoint constraint to
origin has 1 DOF, but 2 highlights are shown. Conversely, a single
datum point has 2 DOF, but 1 highlight is shown.
Supported metric units: km, m, cm, mm, µm, nm.
Supported USCS units: in, mil, µin.
Also, use the newly introduced unit formatting machinery in tools for
measuring perimeter, area and volume, so that e.g. volume is not
displayed in millions of cubic millimeters.
It's not very obvious if the extrusion failed because in a later
group, the solid (by default) uses a very dark gray color that blends
into the black background.
This needs to be done separately because, while we already warn on
broken polygons in workplanes, many more groups can be extruded, e.g.
the canonical way (for now) to mirror a group is to use a rotation,
and that doesn't get checked for closed contour, since most rotations
won't get extruded.
MSVC has a long history of value initialization bugs, and this one is
no exception. In this case, when some MSVC versions (at least up to
2013) are instructed to value-initialize a non-POD class with
a compiler generated non-trivial constructor, it does not zero out
the POD members.
Its only use was in a context where it was completely equivalent to
MemFree, so just use that instead, and keep the temporary heap as
purely an arena allocator, that could use something like bump
pointer.
This is useful in niche cases, like making angular measurement tools.
Also, use simpler and more principled code for numeric precision
while editing constraints: don't special-case angles, but use up to
10 digits after the decimal point for everything.
This is currently necessary to get repeatable results when exporting
assemblies as a part of a batch process, since the mesh geometry in
imported files is not regenerated for export.
Also, mark not just curves, but also points and normals derived from
construction requests as construction.
Also, don't always mark arc center point as construction just to
exclude it from chord tolerance bounding box calculation; instead,
special-case it there.
If a sketch has a "minor" problem, such as being self-intersecting,
this can cause considerably confusion in subsequent groups, yet is
not indicated in the group list.
This commit makes the "err" yellow in such cases. Note that the
indication may not change immediately when a change leading to
trouble is made, since the dependent groups are not recalculated
on all changes.
By setting WINVER=0x0501 (Windows XP) in CMakeLists.txt and adding a few
missing defines in guiwin.cpp and configuring OPENGL=1 in CMake
Solvespace (3.0~25b6eba1) compiles and works perfectly on Windows XP.
Tested with MinGW GCC-6.3.0-1
Before this commit it would prompt for top left and bottom left
corner, neither of which was what in fact was being used. Those two
specific points cannot be used because of the way equations are
written, so instead change that to top left and bottom right, which
is more convenient anyway.
This fixes an elusive GTK issue where tooltips would be spuriously
displayed, and makes tooltips behave nicer on Windows.
Unfortunately the macOS code is unchanged as the macOS tooltip
implementation seems seriously broken in ways I do not understand.
After this commit, if the target system does have modern OpenGL
drivers installed, ANGLE is configured to use them, bypassing most
translation (shaders still have to be translated from ESSL to GLSL).
If there are no OpenGL drivers, such as if the graphics drivers were
installed via Windows Update, DirectX translation is still used. This
results in a very noticeable startup delay and minor performance
degradation.
In addition it is no longer necessary to build with -DOPENGL=1 to be
able to run the binary in wine; everything works out of the box.
Before, wine's incomplete HLSL translator would crash.
This change required renaming the variable `texture` in shaders,
since it shadows the Core GLSL function with the same name, and ANGLE
translates texture2D() calls to texture() calls.
It is not clear why this code was added (I don't remember) and
the normal parent-child relationship should be sufficient for
the task of keeping property browser on top of the main window.
With SetWindowPos(hwnd, HWND_TOPMOST) though, the property browser
window stays on top of *anything*, even if the user switches to
an entirely different application.
This function showed up surprisingly high on a CPU time profile
when the GUI was unresponsive "doing things". Removed a duplicated
difference in the not-equal case, and switched to abs and a single compare
instead of two compares with a negation. It seems to have moved the
function further down in the profile.
Ubuntu 18.04 uses GTKMM 3.22.2-2, which doesn't support native file chooser.
Commit bc3e09edbf checks if native file chooser
is available, but the result is overridden with a hardcoded define,
probably for debugging.
Removing the debugging code fixes build on Ubuntu 18.04.
Before this commit, if the sketch contain no entities with starting
points off of the axis of revolution, the revolution may fail, which
manifests as the face normals being inverted. The code at the top of
MakeFromRevolutionOf() takes the furthest point from the axis,
projects it on that axis to get a vector. In this case that vector
is essentially zero length except for rounding errors.
After this commit, instead of only considering start points of
beziers, all control points are considered.
Fix by @phkahler.
We plan to use flatbuffers in the future for the next generation of
the .slvs file format, so flatbuffers are built unconditionally; and
the Q3DO exporter itself is tiny.
Before this commit, the default font chosen for TTF text is Arial
(chosen by the basename of arial.ttf), which isn't present on most
Linux systems, and cannot be redistributed. After this commit, it is
replaced with Bitstream Vera Sans, which can be. Existing files
are not affected.
The font name in the TTF file was artificially modified to add
the (built-in) suffix, which will need to be done if more built-in
fonts are added.
Modifying the original entities instead of deleting them, retains the
original associated constraints. This makes creating rounded rectangles
a lot easier.