Skip to content

Conversation

@phkahler
Copy link
Member

…for face dragging linked sketches, but don't enable that feature because existing sketches will crash when dragged. In mouse.cpp StartDraggingByEntity needs some face types uncommented to enable different face dragging options. All rotational movements are disabled because the points used for those faces are on-axis(I think), this needs to be changed for those to be more useful.

@phkahler
Copy link
Member Author

I'd like to merge this prior to 3.2 so people will start creating files with point handles in the face entities. That is a prerequisite for dragging linked objects by their faces - which works fine but is currently disabled to prevent crashes.

Oh, maybe we can check for a valid handle and only drag if one is present.

@phkahler
Copy link
Member Author

Looks like I need to update the files in 4 tests because they are no longer identicle. This adds a point handle to some faces.

@ruevs
Copy link
Member

ruevs commented Dec 28, 2025

@phkahler to summarize your work on dragging faces so far:

  1. https://github.com/phkahler/solvespace/tree/face-drag The previous attempt from Nov 30, 2025 with some debugging stuff from 2023 and the beginning of the story.)
  2. https://github.com/phkahler/solvespace/tree/drag-faces The one you already merged here e3f21de. It works and is non-intrusive - I like it. The branch should be deleted)
  3. https://github.com/phkahler/solvespace/tree/faces This PR

So back to this PR:

  • Adding the extra en.point[0] is a bit suspect to me. I need to think more.
  • You wrote in the first commit message "Add the necessary handles for face dragging linked sketches" - but linked 2d sketches are not draggable by their "face" - not surprising but the commit message is misleading.
  • Dragging linked 3d files created with "old" versions by the faces works with this version. Why?! (I did not debug)
  • Being able to drag by the faces is not important to me at all - in fact I keep the face selection disabled most of the time faces

Overall I think this is not ready.

@phkahler
Copy link
Member Author

phkahler commented Dec 28, 2025

@phkahler to summarize your work on dragging faces so far:

1. https://github.com/phkahler/solvespace/tree/face-drag The previous attempt from Nov 30, 2025 with some debugging stuff from 2023 and the beginning of the story.)

2. https://github.com/phkahler/solvespace/tree/drag-faces The one you already merged here [e3f21de](https://github.com/solvespace/solvespace/commit/e3f21de93d2d8a1dd254292c196f53eaae2ba4a5). It works and is non-intrusive - I like it. The branch should be deleted)

Branch deleted, thanks!

3. https://github.com/phkahler/solvespace/tree/faces This PR

So back to this PR:

* Adding the extra `en.point[0]` is a bit suspect to me. I need to think more.

When we drag a line, we add the end points to the drag list. It makes sense for dragging faces to add their point to the drag list. The problem is that when linking, all entites are copied with copy type N_ROT_TRANS, which creates a new entity using only numeric values (no free parameters). You can move them around because it's possible to get expressions for the points which are numeric values modified by the group parameters. Some face types just return the expressions for their underlying point which is probably what they all should do.

The problem: Some faces never set the entity handle for their point, which is clearly an oversite. This was never a problem because nothing ever tried to access that point by its handle - like adding it to the drag list.

* You wrote in the first commit message "Add the necessary handles for face dragging linked sketches" - but linked **2**d sketches are not draggable by their "face" - not surprising but the commit message is misleading.

2d sketches do not have a "face" entity. Faces are defined by a plane and can be selected by the corresponding triangles in the mesh - yes, every triangle has an entity handle!.

Fun fact. When I wrote the very first Helix code and posted this picture the upper surface would highlight with mouse-over, but it would crash if clicked because there was no actual face entity. The triangles were getting properly tagged because of some code I copied from somewhere. That was a big surprise to me because it's a twisted surface - not flat at all.

* Dragging linked 3d files created with "old" versions by the faces works with this version. Why?! (I did not debug)

My poor description. Trying to drag old linked files will not crash, it just fails to drag. This is because I added the check for a valid handle before using the face-associated point. It does not "work", it just doesn't crash.

* Being able to drag by the faces is not important to me at all - in fact I keep the face selection disabled most of the time ![faces](https://github.com/solvespace/solvespace/blob/master/res/icons/text-window/faces.png?raw=true)

Faces tend to light up often so it makes sense to turn them off. You are free to leave them turned off ;-) But when they are turned on it makes sense that they be useful and even draggable. I think this is really important for linked sketches where the main thing we do is position them relative to other parts in an assembly.

Overall I think this is not ready.

I think it is, but maybe I should update the commit message claiming linking old files work. Edit: Oh it's correct already.

@phkahler
Copy link
Member Author

@ruevs Ping!! And Happy New Year!!

src/group.cpp Outdated
en.param[2] = h.param(2);
en.numPoint = a;
// might use the original point, not the remapped one - but surface face uses TOP
// using the original point might allow face dragging the sides unconstrained extrusions
Copy link
Member

@ruevs ruevs Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that I found "suspect" as well. I do not understand the remapping well.
@jwesthues what do you think? (Happy New Year!).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy New Year! Looking at EntityBase::FaceGetPointExprs(), I see that FACE_NORMAL_PT and FACE_ROT_NORMAL_PT both simply return point[0], while the others calculate the point from numPoint. I think I did that to simplify the generation of the others. I believe suitable point entities do always exist in a real sketch, but I probably thought it would be simpler to repeat the transform calculation than to find that suitably transformed point.

This change seems to keep that behavior in FaceGetPointExprs(), but sometimes additionally set point[0] to a suitable point to drag. So point[0] provides both definition and dragging for FACE_NORMAL_PT and FACE_ROT_NORMAL_PT, but only dragging for others. That's inconsistent, though the use of those members is generally inconsistent between different entity types so that seems fine to me. It perhaps deserves a comment explicitly noting that inconsistent overloading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwesthues In the future we could also change the other face types to return the expressions from the points once the handles are included and drop the extra code in FaceGetPointExpers(). Would that make things more consistent? I'm not ready to do that on the eve of v3.2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phkahler I think you'd have to keep the old codepath to support linked files saved by earlier versions. So I definitely wouldn't change FaceGetPointXXX() now, and probably not ever.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that I found "suspect" as well. I do not understand the remapping well.

@ruevs I thought I finally understood remapping. Went to verify a few details, and now... It does what I thought, but im not sure how exactly. There's a step that seems to be missing, and the mechanism is IMHO rather broken. But it seems to work anyway. More on that later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruevs I thought I finally understood remapping. Went to verify a few details, and now... It does what I thought, but im not sure how exactly. There's a step that seems to be missing, and the mechanism is IMHO rather broken. But it seems to work anyway. More on that later.

I still don't understand it well enough because I have looked through this part of the code only a few times, superficially. An I've never tried to modify it or debug it to understand better. I should...

But the discussion between you and Jonathan above helped me a lot.

src/group.cpp Outdated
// might use the original point, not the remapped one - but surface face uses TOP
// using the original point might allow face dragging the sides unconstrained extrusions
en.point[0] = Remap(ep->point[0], REMAP_TOP);
// en.point[0] = ep->point[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At any rate we should decide what the right thing to do is, explain it in a comment and remove the other option.

}
en.numPoint = (ep->actPoint).ScaledBy(scale);
en.numNormal = (ep->actNormal).ScaledBy(scale);
en.point[0] = Remap(ep->point[0], remap);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Member

@ruevs ruevs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash 1d709cf and e4556fc together.

…for face dragging linked sketches. In mouse.cpp StartDraggingByEntity needs some face types uncommented to enable different face dragging options. All rotational face drags are disabled because the points used for those faces are on-axis(I think), this needs to be changed for those faces to be more useful.
@phkahler
Copy link
Member Author

phkahler commented Jan 1, 2026

@ruevs squashed. Some comments cleaned/removed. And I did opt to use the other point for extrusion sides - no idea why it won't drag a rectangle from a previous group by using that, but it will never do it with a remapped point.

@phkahler phkahler linked an issue Jan 2, 2026 that may be closed by this pull request
@phkahler phkahler merged commit 457aec9 into solvespace:master Jan 2, 2026
4 checks passed
@ruevs
Copy link
Member

ruevs commented Jan 2, 2026

@ruevs squashed.

But you still merged three commits ;-) At least 1cec22f and 457aec9 should have been squashed. Ideally also 2ee0cc6.

But it's OK... it's very unlikely someone will ever bisect is such a way that this is a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SketchUp-like moving by grab faces of solid

3 participants