Commit Graph

807 Commits (fbc5bfc27f7e7ba860c1e62a66af07fc16c0a07e)

Author SHA1 Message Date
whitequark c84a3b6de3 Call constructors and destructors in List and IdList.
This is necessary to store non-POD classes in these containers.

Note that List and IdList do not use MemRealloc anymore;
this is necessarily (slightly) less efficient, but is the right
semantics, as you cannot just move non-POD types, e.g. std::string,
around in memory. All STL containers provide the same guarantees
and share the performance hit.

The slowdown is mostly mitigated by moving the contained objects,
so that no additional heap allocations or copies occur beyond
that of the object itself.
2016-01-13 06:45:16 +00:00
whitequark 97fa6355cc Fix memory leaks in IdList::{MoveSelfInto,DeepCopyInto}.
Note that this requires IdLists to be zero-initialized
to work correctly.
2016-01-13 06:45:16 +00:00
whitequark 45f056c852 Replace all ZERO and memset with C++11 brace-initialization.
This will allow us to use non-POD classes inside these objects
in future and is otherwise functionally equivalent, as well
as more concise.

Note that there are some subtleties with handling of
brace-initialization. Specifically:

On aggregates (e.g. simple C-style structures) using an empty
brace-initializer zero-initializes the aggregate, i.e. it makes
all members zero.

On non-aggregates an empty brace-initializer calls the default
constructor. And if the constructor doesn't explicitly initialize
the members (which the auto-generated constructor doesn't) then
the members will be constructed but otherwise uninitialized.

So, what is an aggregate class? To quote the C++ standard
(C++03 8.5.1 §1):

An aggregate is an array or a class (clause 9) with no
user-declared constructors (12.1), no private or protected
non-static data members (clause 11), no base classes (clause 10),
and no virtual functions (10.3).

In SolveSpace, we only have to handle the case of base classes;
Constraint and Entity have those. Thus, they had to gain a default
constructor that does nothing but initializes the members to zero.
2016-01-13 06:45:16 +00:00
whitequark 02c30e6f87 Rewrite ttf2c to use GNU Unifont and merge with pngchar2c.pl.
After this change, SolveSpace does not contain nonfree assets.
Additionally, Perl is not required for the build.

Note that in the US, case law suggests that copyright does
not apply to bitmap fonts:
  http://www.renpy.org/wiki/renpy/misc/Bitmap_Fonts_and_Copyright

Nevertheless, it was prudent to replace the asset with something
that is unambiguously free.
2015-12-29 11:15:50 +08:00
whitequark f76f76ff60 Rewrite png2c.pl in C++.
This allows us to always generate icons during build,
and in the future remove a Perl dependency.
2015-12-29 11:15:50 +08:00
ruevs b23336b589 Add a new length-difference constraint.
This constraint requires the lengths of two line segments to
differ by a constant.
It can be useful to define the tolerances when making joints.
2015-12-28 21:37:07 +08:00
whitequark 8c2e94a01a Add a shortcut for drawing construction line segments.
Almost all construction requests are lines, and allowing to
draw them as construction obviates the need to select them one
by one afterwards to convert them. Also, it removes the "not closed
contour" error message, which is a nice usability improvement.
2015-12-28 21:37:07 +08:00
whitequark e40929afca Add a shortcut for adding a reference dimension or angle.
This is equivalent to adding a constraint, then making it a reference.
The benefits are that:
 * it's quicker;
 * it avoids having an over-constrained system, with an associated
   angry red flash and a regeneration delay.
The latter in particular is a very substantial usability improvement.

The reference distance command is useful most of the time,
but the reference angle one is also added for consistency.
2015-12-28 21:37:07 +08:00
William D. Jones 4b02bf1e81 Implement Three.js export. 2015-12-28 21:37:07 +08:00
EvilSpirit 3c917ebac9 Use relative tolerance for axis-parallel autoconstrainter.
This works better than absolute tolerance in display pixels
for small lines.
2015-12-28 21:37:07 +08:00
whitequark c6194d439c Allow using the constant "pi" in expressions. 2015-12-28 21:37:07 +08:00
EvilSpirit ef3ee55d42 Optimize Expr::From(double) by statically allocating common constants. 2015-12-28 21:37:07 +08:00
whitequark 0933bbf687 Add Windows nightly builds. 2015-12-28 21:37:07 +08:00
whitequark 09c072fdfd Add Debian nightly builds. 2015-12-28 21:37:07 +08:00
whitequark cdc384e44d Add OS X nightly builds. 2015-12-28 21:37:07 +08:00
whitequark 7c3c20161b Allow building on FreeBSD. 2015-12-28 21:37:07 +08:00
ruevs 922a6260d7 Allow building with MinGW on Windows. 2015-12-28 21:37:06 +08:00
whitequark 28166e6200 Use C++ std::{min,max,swap} instead of custom ones.
The main benefit is that std::swap will ensure that the type
of arguments is copy-constructible and move-constructible.
It is more concise as well.

When min and max are defined as macros, they will conflict
with STL header files included by other C++ libraries;
in this case STL will #undef any other definition.
2015-12-28 21:37:06 +08:00
whitequark 063dfc4f98 Require cmake 3.1.0 and C++11.
We plan to use C++11 features in the future. Moreover, recent gtkmm
has a hard requirement on C++11.
2015-12-28 21:37:06 +08:00
whitequark 1b6cd0d632 Make in-tree zlib more robust. 2015-12-28 21:37:06 +08:00
EvilSpirit 4d5a92e9b2 Make faces selectable again after undo. 2015-12-28 21:37:06 +08:00
whitequark fdc39edfd8 Fix AllocTemporary on *nix. 2015-12-28 21:37:06 +08:00
whitequark 06be0d1157 Fix read of uninitialized memory. 2015-12-28 21:37:06 +08:00
whitequark 1422d3abd2 Fix initialization order issue. 2015-12-28 21:37:06 +08:00
whitequark 4260a91a99 Update libpng to 1.6.20.
libpng <=1.6.19 has security vulnerabilities.
2015-12-26 14:07:11 +08:00
whitequark 68f85587cb SourceForge is dead; fix libpng submodule URL.
https://github.com/glennrp/libpng is the official libpng repository.
2015-12-26 00:08:34 +08:00
whitequark 0159a87a8a Add support for cross-compiling from Linux.
As a side effect, zlib and libpng are now git submodules,
based on their respective official git repositories.
This is necessary, because MinGW has a different ABI and
it cannot use the prebuilt binaries built by MSVC.

The submodules are also used for Windows, for several reasons:
  * to allow 64-bit builds;
  * to allow using newer MSVC, which doesn't like the prebuilt
    libraries;
  * to keep the libraries updated.
2015-07-10 15:59:12 +03:00
whitequark 5e7c7fce7e Rename RgbColor to RgbaColor. 2015-07-10 15:59:12 +03:00
whitequark 75a3936b64 Add support for transparent solids.
Some extra code is necessary to determine that the back faces
should not be drawn in red for transparent solids. It is expected
that the user will first ensure that the shell is watertight
and then set the opacity; back faces are still drawn if
the opacity is exactly 1.

The savefile format is changed backwards-compatibly by stashing
the alpha value in uppermost byte of 4-byte hex color value
in Surface and Triangle clauses. The existing files have 00
in the high byte, so RgbColor::FromPackedInt treats that
as "opaque".
2015-07-10 15:59:12 +03:00
whitequark 1b69032d99 Allow displaying and editing diameter constraints as radius.
The savefile format is not changed; the display option is
stored in Constraint::other.
2015-07-10 15:59:12 +03:00
whitequark f62e95d7b6 Replace \ with / slashes in assembly relative paths on *nix.
This is done specifically targeting the case where an assembly
initially made on Windows is transported to an *nix machine.
On *nix, the paths will be already saved with /, and correctly
read on Windows. On Windows however / is not a first-class separator,
in particular it cannot be used in UNC-style paths \\?\ (which
are the only paths that work with Unicode).

See also:
http://msdn.microsoft.com/en-us/library/aa365247.aspx
2015-07-10 15:59:12 +03:00
whitequark 69c509064c Automatically add horz/vert constraints to lines if close enough. 2015-07-10 15:59:12 +03:00
whitequark f89020ad26 Highlight pending operation on toolbar, even if started via keyboard. 2015-07-10 15:59:12 +03:00
whitequark 46db5378dc Add Travis CI and Appveyor CI configurations. 2015-07-10 15:59:12 +03:00
whitequark 71b7ad7f99 Add an autosave timer.
Original patch by Marc Britten <marc.britten@gmail.com>.
2015-07-10 15:59:12 +03:00
whitequark 22d43d5b83 Remember the last format used to export 2D Views.
This helps a lot when exporting a lot of views, e.g.
for shop drawings.
2015-07-10 15:59:12 +03:00
whitequark d585f0d1ff Make "Align view onto workplane" switch to locked workplane, if any.
Original patch by yugami
(http://solvespace.com/forum.pl?action=viewthread&parent=508).
2015-07-10 15:59:12 +03:00
whitequark 636b20bfa9 Add README. 2015-07-10 15:59:12 +03:00
whitequark d0c0a7ae5a Remove FLTK port.
It provides no value over the native GTK and Cocoa ports.
2015-07-10 15:59:12 +03:00
whitequark bbe4999033 Make sure all DrawOrGetDistance style code only draws in Paint();
Otherwise, GL reports errors when used with FBOs, as well as
creates visual artifacts, especially when UI is also drawn
with OpenGL.
2015-07-10 15:59:12 +03:00
whitequark 4b86fb89f8 Make "Show Menu Bar" and "Full Screen" use Ctrl/Cmd+Fn.
On OS X F11 and F12 are system-global shortcuts. I could switch
them only on Apple platforms, but for consistency I decided not to.
Anyway, neither of those appeared in an official release.
2015-07-10 15:59:12 +03:00
whitequark d76d59ea64 Build Mac OS X dmg installation image. 2015-07-10 15:59:12 +03:00
whitequark 95ab80d0ee Implement OS X port. 2015-07-10 15:59:12 +03:00
whitequark 5d7a5bf3a7 Pack everything into `namespace SolveSpace`.
This is required to avoid name conflicts with the Cocoa libraries
on OS X.

I renamed the `class SolveSpace` to `class SolveSpaceUI`, because
that's what it does, and because otherwise the namespace would
have to be called something else than `namespace SolveSpace`.
2015-07-10 15:59:12 +03:00
whitequark 0807c2fdfe Add a native Debian package. 2015-07-10 15:59:12 +03:00
whitequark d3dbf23725 Add a desktop file in the format understandable by Ubuntu. 2015-07-10 15:59:12 +03:00
whitequark 2ce12155bf Add bug compatibility with Chromium GL (VirtualBox).
I question the life choices that led me here.
2015-07-10 15:59:12 +03:00
whitequark 88e4163970 Use the extension version of FBO extension instead of core.
This will allow solvespace to run on pre-OpenGL 3.0 implementations,
such as VirtualBox (and possibly others).

However, VirtualBox's handling of framebuffer objects is buggy;
it tries to draw over our X window and fails to do either.

I hate OpenGL.
2015-07-10 15:59:12 +03:00
whitequark e27c6b56c3 Implement offscreen rendering using GL framebuffer objects.
Apparently pbuffers are also a deprecated and unportable
way of offscreen rendering. They're not supported by
Chromium OpenGL implementation, which is what 3D-accelerated
VirtualBox uses.

This would also help a future OS X port.
2015-07-10 15:59:12 +03:00
whitequark 622c9efadb Use GL pbuffers instead of GLX pixmaps.
Apparently GLX pixmaps are an antiquated and unsupported method
for offscreen rendering in OpenGL. Specifically this broke
software and VirtualBox accelerated rendering in Ubuntu trusty
and who knows which other systems.

This commit switches the rendering to use pbuffers instead,
while retaining all other logic. The pbuffers are fixed-size,
because reallocating pbuffers during a resize sometimes results
in segfaults in glXMakeCurrent despite apparently correct
API usage.
2015-07-10 15:59:12 +03:00