Commit Graph

72 Commits (f2645029b8598dbcfc3ecd0522731044fe0bf686)

Author SHA1 Message Date
Jonathan Westhues f2645029b8 Add a second light, and some little fixes, and remove dead code.
[git-p4: depot-paths = "//depot/solvespace/": change = 1782]
2008-06-09 01:03:21 -08:00
Jonathan Westhues 8498a99588 Add preliminary lathe (solid of revolution) support. I'm generating
just the mesh, no derived entities (but I suppose that I could turn
all points into circles).

And fix some bugs where equations didn't get unique IDs, and make
it possible to lock on to the group's workplane automatically, if
you press W while free in 3d with no workplane selected.

[git-p4: depot-paths = "//depot/solvespace/": change = 1780]
2008-06-06 03:35:28 -08:00
Jonathan Westhues ccbda13a03 Add point-face distance constraints.
[git-p4: depot-paths = "//depot/solvespace/": change = 1778]
2008-06-06 00:46:55 -08:00
Jonathan Westhues ab44c24cfc Major speedups, mostly by playing nicer with OpenGL; batch things
up more. Also change from stupid linear search lists to sorted
binary search lists, remove a stupid bug where I double-generated
entities, and don't do the triple drawing of entities (since
offsets on the Z buffer were doing the same job already).

[git-p4: depot-paths = "//depot/solvespace/": change = 1776]
2008-06-05 23:50:08 -08:00
Jonathan Westhues 48612bde3d Add undo/redo. This saves the param guesses, constraints, groups,
and requests to a separate list. It's messy, because I have to make
a deep copy (e.g. of the remap list for the groups, or Expr *
stuff) of some things. Others (e.g. the polygon or mesh) will be
regenerated, so they should be discarded, but they must not get
double-freed.

In any case, works superficially. And fix a few memory leaks
unrelated to this, and remove some dead code.

[git-p4: depot-paths = "//depot/solvespace/": change = 1775]
2008-06-04 02:22:30 -08:00
Jonathan Westhues 71391e6a55 Add an interference check for assembled parts. That's easy once the
BSP stuff works. The failures are reported with red stripes and no
depth buffering, and in a message in the text window.

Also improve convergence of point-on-line constraints, and don't
write triangles to export files with limited precision, because
that was making the coplanar tests fail.

[git-p4: depot-paths = "//depot/solvespace/": change = 1774]
2008-06-03 22:39:32 -08:00
Jonathan Westhues ea6db67c7d Improve convergence of constraints involving parallel vectors, by
using the initial numerical guess of whichever vector is already
known to choose our projection planes.

And add a mechanism to defer showing the text window or
regenerating, in order to simplify dependencies on valid actives.
Also yes/no/cancel when about to abandon an unsaved file, and a
bugfix when rotating a rot/trans point.

[git-p4: depot-paths = "//depot/solvespace/": change = 1772]
2008-06-03 10:28:41 -08:00
Jonathan Westhues 5bbb27fd8e Now requests don't have names anymore, because that didn't seem
useful. The description string is just the type of request.

[git-p4: depot-paths = "//depot/solvespace/": change = 1770]
2008-06-02 01:41:39 -08:00
Jonathan Westhues 236ee16da6 Consolidate the code that determines whether an entity is visible
in one place. And remove the ability to disable the solver, since
that's unlikely to be anything but confusing (and in any case, was
badly implemented). This is in preparation for selective solving,
of only the dirty groups.

[git-p4: depot-paths = "//depot/solvespace/": change = 1769]
2008-06-02 01:31:26 -08:00
Jonathan Westhues a084b32064 Stipple the selected/hovered faces, instead of drawing them in
solid red or yellow. And add user interface to `hide' the faces
(i.e., to make them unselectable), defaulting to hidden in
everything except extrudes or imports.

[git-p4: depot-paths = "//depot/solvespace/": change = 1768]
2008-06-01 21:38:12 -08:00
Jonathan Westhues 6748160026 Add selectable faces, by associating an hEntity with the triangle's
metadata. And add point-on-face constraints to go with that. Still
needs some cleanup for the user interface.

[git-p4: depot-paths = "//depot/solvespace/": change = 1766]
2008-06-01 19:31:37 -08:00
Jonathan Westhues 709b5ad80e Add an axis-angle transformation (rotation about an arbitrary
point), and use that to implement step and repeat rotating.

[git-p4: depot-paths = "//depot/solvespace/": change = 1762]
2008-06-01 00:29:59 -08:00
Jonathan Westhues 2cb4800fbf Start to describe the selected entities in the text window. Also
more starting work on the selectable faces, and fiddling in an
attempt to remove dependencies when stuff gets deleted.

[git-p4: depot-paths = "//depot/solvespace/": change = 1760]
2008-05-31 16:26:41 -08:00
Jonathan Westhues 69eb2273ac Add color. Now each triangle has metadata, which are preserved in
csg ops; so the union of a red part and a blue part has both red
and blue faces. And some user interface to pick the color in the
text window.

The metadata also include a face, which will be an entity; I can
use that to constrain against. But none of that is yet implemented.

[git-p4: depot-paths = "//depot/solvespace/": change = 1757]
2008-05-29 22:09:41 -08:00
Jonathan Westhues 4bd44bf18a Initial work on the assembly (`import') feature. I can import a
part, including all of its entities and the triangle mesh. These
are transformed by a rotation and translation, and appear in the
sketch; the transformation may be set with constraints.

[git-p4: depot-paths = "//depot/solvespace/": change = 1756]
2008-05-29 02:10:12 -08:00
Jonathan Westhues 010a65894d Now I can rename groups, using that same edit control in the text
window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1750]
2008-05-27 01:52:36 -08:00
Jonathan Westhues 4375c01c51 Add step and repeat translate, with multiple copies; that all works
nicely. And to do that, I've added the user interface to show an
edit control in the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1749]
2008-05-26 22:36:59 -08:00
Jonathan Westhues ecee90965e Change the workplanes a bit. Now the active workplane is per group,
so e.g. a new extrude starts in free space, which is likely what
you want. And default to an in-workplane group, and tweak the
display of workplanes.

[git-p4: depot-paths = "//depot/solvespace/": change = 1748]
2008-05-26 18:22:20 -08:00
Jonathan Westhues b484c26493 Many user interface additions. Now I report when the solver fails,
and in the case of a singular Jacobian, report which constraints
can be removed to fix it. Also a mechanism to hover and select
entities and constraints from the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1746]
2008-05-26 01:56:50 -08:00
Jonathan Westhues 248f74547e Add user interface to specify union/difference for extrudes, and
implement that. Also make solver work only between the first and
last visible group; earlier can just work from previous solve
result, and later don't matter.

There's some issues with the csg code; it will eventually produce
an open mesh, which is very bad. Not sure whether that's a logic
bug, or a numerical issue; still generating absurd triangles pretty
routinely.

[git-p4: depot-paths = "//depot/solvespace/": change = 1741]
2008-05-25 05:11:44 -08:00
Jonathan Westhues e80328279e Rip out the boundary rep csg stuff. I'll redo that with a triangle
mesh approach.

[git-p4: depot-paths = "//depot/solvespace/": change = 1732]
2008-05-20 19:58:14 -08:00
Jonathan Westhues c4e1270e25 Add constructive solid geometry ops. These work to some extent, but
not very well; I'm doing a b-rep, where the boundaries are complex
polygons, and there's too many special cases. I should probably
replace this with a triangle mesh solution.

[git-p4: depot-paths = "//depot/solvespace/": change = 1731]
2008-05-19 01:23:49 -08:00
Jonathan Westhues 30ad41f4a2 Fix a crash; it was possible to attempt to draw in a workplane
that's in a group that solves after the current group. This means
that the constraint/request gets deleted instantly, and stuff like
auto-constraints on the just-created entities blow up. I now check
that the active workplane comes from the active group or one solved
before it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1729]
2008-05-17 15:48:58 -08:00
Jonathan Westhues b480613763 Add angle constraints. I'm doing these differently from SketchFlat,
as a constraint on the direction cosine, rather than driving the
dot product against a rotated vector to zero. The drawing is the
ugly part; to do that for skew lines, I gave up.

Also add a function to clear non-existent items on the selection
after solving, since that could have caused an oops().

[git-p4: depot-paths = "//depot/solvespace/": change = 1727]
2008-05-17 03:15:14 -08:00
Jonathan Westhues 749e2a0149 Add double-sided extrudes, and user interface for that. Also put
the coordinate system (x, y, z normal vectors) in the bottom left
corner of the screen at all times, and hide group-created
workplanes except when that group is active, and activate that
workplane when the group is activated.

[git-p4: depot-paths = "//depot/solvespace/": change = 1726]
2008-05-17 00:02:39 -08:00
Jonathan Westhues 2ec23ffa3e Fix point-on-circle constraints to work with arcs too, and lock
extrudes normal to workplane if a workplane is active when the
extrusion is created.

[git-p4: depot-paths = "//depot/solvespace/": change = 1724]
2008-05-15 22:34:06 -08:00
Jonathan Westhues aa5c621d82 Add symmetry constraints without an explicit symmetry plane; these
use the horizontal or vertical axes of the active workplane. The
equations that we write from these are very fast (of the form u + v
= 0, or u - v = 0).

[git-p4: depot-paths = "//depot/solvespace/": change = 1720]
2008-05-13 02:38:21 -08:00
Jonathan Westhues 364938f332 Add an arc entity. That's not allowed to exist in free space (since
we need something to force the points into plane, and the workplane
supplies that), but otherwise straightforward. And add diameter and
equal radius constraints for the arc.

[git-p4: depot-paths = "//depot/solvespace/": change = 1718]
2008-05-12 02:01:44 -08:00
Jonathan Westhues e2263c69c8 Find a memory corruption! I was getting a pointer into the entity
list, and then adding a new entity to that list, and then looking
at that pointer again. Not okay; the add operation might have
forced a realloc. I have to watch for that.

And add a "distance ratio" constraint, plus a new kind of group
that comes with its own workplane. The workplane is not solved for;
it's generated explicitly in terms of elements that are already
solved.

[git-p4: depot-paths = "//depot/solvespace/": change = 1716]
2008-05-11 02:40:37 -08:00
Jonathan Westhues 6042fb3e0f Add transformed points and normals with a rotation (as well as a
translation; or equivalently, rotation about an arbitrary axis).
Those will be important for step and repeats, and for imported
parts.

Also fix a terrible memory corruption bug: I was freeing the remap
list after I loaded it from the file, but the code that put that
into the SS.group list made only a shallow copy.

[git-p4: depot-paths = "//depot/solvespace/": change = 1715]
2008-05-10 22:09:46 -08:00
Jonathan Westhues 10240cc1df Add parallel and same orientation constraints, that work on line
segments and normals.

[git-p4: depot-paths = "//depot/solvespace/": change = 1713]
2008-05-08 21:33:23 -08:00
Jonathan Westhues e11da119f0 Add point-line distance, point-plane distance, and point-on-circle
constraints. And generate the constraint equations for entities
(e.g., that our unit quaternions have magnitude one). Numerical
troubles there, but it sort of works. Also some stuff to draw
projection lines with projected constraints, and to auto-insert
more constraints as you draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1711]
2008-05-07 23:30:30 -08:00
Jonathan Westhues 328a946cc4 Add a diameter constraint, and add a `distance' entity that I can
remap when I copy circle entities, in order to make the radius
numerical somehow (analogy with the POINT_ and NORMAL_XFRMD) thing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1710]
2008-05-07 00:19:37 -08:00
Jonathan Westhues c05659753a Add the substitution solver. That speeds things up a bit, and
improves the quality of assumptions.

[git-p4: depot-paths = "//depot/solvespace/": change = 1709]
2008-05-06 23:10:20 -08:00
Jonathan Westhues 6b264a6ba6 Add a convenience command to draw a rectangle (as four line
segments), add the toggle construction command, and color the lines
differently depending on what group you're in.

Also change dynamic memory stuff to use a Win32 heap for everything
(no malloc), and validate that often. I think I've seen it crash,
though I can't reproduce it.

[git-p4: depot-paths = "//depot/solvespace/": change = 1708]
2008-05-06 20:17:29 -08:00
Jonathan Westhues c767d55c71 Now we can add new workplanes. So fix all the mistakes that I
hadn't previously noticed, because I didn't use to have workplanes
with non-zero offsets. And clean up the interface to normals a bit.

[git-p4: depot-paths = "//depot/solvespace/": change = 1707]
2008-05-05 03:17:00 -08:00
Jonathan Westhues d048946adc Fix some stupid bugs introduced with the new representation of
workplanes. And fix up our polygon normals, so that everything gets
shaded correctly (and so that later we can generate our STL files
with correct normals).

[git-p4: depot-paths = "//depot/solvespace/": change = 1706]
2008-05-05 01:47:23 -08:00
Jonathan Westhues 853c6cb59c A big change, to add a concept of normals. These are "oriented
vectors", represented by unit quaternions. This permits me to add
circles, where the normal defines the plane of the circle.

Still many things painful. The interface for editing normals is not
so intuitive, and it's not yet clear how I would e.g. export a
circle entity and recreate it properly, since that entity has a
param not associated with a normal or point.

And the transformed points/normals do not yet support rotations.
That will be necessary soon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1705]
2008-05-04 22:18:01 -08:00
Jonathan Westhues 30636a6f29 Make the extrude command do a bit more; now I generate all the
faces of the polyhedron. And shade the faces when I draw them, and
fix up our projection matrix so that the depth testing works
properly.

[git-p4: depot-paths = "//depot/solvespace/": change = 1703]
2008-05-02 02:54:22 -08:00
Jonathan Westhues 658b7df50f Make at-midpoint constraint also work to constrain midpoint of a
line segment on a plane. And simplify that code a bit, and improve
display.

[git-p4: depot-paths = "//depot/solvespace/": change = 1702]
2008-04-30 22:53:50 -08:00
Jonathan Westhues f1c5d07e39 Sort the parameters by sensitivity before solving, and always sort
the point that's being dragged first, to guarantee that that one
gets the max possible degrees of freedom. The sort code (sort a
list of integers, then apply the permutations by swaps) was more
painful than it should have been.

[git-p4: depot-paths = "//depot/solvespace/": change = 1700]
2008-04-30 22:25:38 -08:00
Jonathan Westhues 498ffd07ea Add symmetric and at midpoint constraints. The symmetry constraint
turned out straightforward, in great part because the planes are
workplanes (6 DOF, represented by a unit quaternion and a point),
and therefore make it easy to get a vector in the plane, as well as
a normal.

And on that subject, replace the previous hack for parallel vector
constraints with a better hack: pivot on the initial numerical
guess, to choose which components of the cross product to drive to
zero. Ugly, but I think that will be as robust as I can get.

[git-p4: depot-paths = "//depot/solvespace/": change = 1699]
2008-04-30 00:14:32 -08:00
Jonathan Westhues 70bf14530d Add point on line constraints, in 2d and 3d. The 3d equations do
not have much motivation behind them, but they seem to work. And
make sure that we don't solve multiple times without repainting in
between, and tweak the text window a bit more.

[git-p4: depot-paths = "//depot/solvespace/": change = 1696]
2008-04-28 01:40:02 -08:00
Jonathan Westhues 49ec1346d7 Add the first `derived' group, that generates entities based on
other entities. This requires a new point type, for a point that's
defined as a transformation of some other point. All works nicely,
I think. There's ugliness because entities are no longer guaranteed
to have a parent request.

Also speed up display of the text window, by caching brushes
instead of recreating for each character (!), and add a bit more
user interface in the text window.

[git-p4: depot-paths = "//depot/solvespace/": change = 1692]
2008-04-27 01:03:01 -08:00
Jonathan Westhues bfc7109e0c Standardize the behaviour of constraints, by assigning them a
workplane: a free constraint works in three-space (e.g. true
distance), and a constraint in a workplane works in that plane
(e.g. projected distance). And make the solver go automatically,
though solver itself has lots of pieces missing.

[git-p4: depot-paths = "//depot/solvespace/": change = 1691]
2008-04-26 21:00:12 -08:00
Jonathan Westhues 15476d4732 A great renaming. 2d coordinate systems are now called workplanes,
and the associated entities are now just points.

[git-p4: depot-paths = "//depot/solvespace/": change = 1690]
2008-04-26 19:26:27 -08:00
Jonathan Westhues 5bc3738ec4 Add cubics, and tweak mouse handling code.
[git-p4: depot-paths = "//depot/solvespace/": change = 1689]
2008-04-25 04:07:17 -08:00
Jonathan Westhues a7cec38656 Add code to assemble the piecewise linear segments in a group into
a polygon, and to fill that polygon.

[git-p4: depot-paths = "//depot/solvespace/": change = 1686]
2008-04-24 23:04:09 -08:00
Jonathan Westhues 1331457928 Rough file/save for SolveSpace; that's all done from a single
table, relatively small code size. No user interface for it,
though.

[git-p4: depot-paths = "//depot/solvespace/": change = 1685]
2008-04-23 22:22:16 -08:00
Jonathan Westhues a8001adf33 Add horizontal and vertical constraints. Those have their own 2d/3d
issues, when the points are not all in the same coordinate system.
All painful, of course. Also add continuous line drawing, and
auto-constraining of line segments as I draw.

[git-p4: depot-paths = "//depot/solvespace/": change = 1683]
2008-04-22 23:29:19 -08:00