![]() |
|
To Micheus about Ivla Vert|Perpendicular Connect idea - Printable Version +- Wings 3D Development Forum (https://www.wings3d.com/forum) +-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1) +--- Forum: Design & Development (https://www.wings3d.com/forum/forumdisplay.php?fid=6) +--- Thread: To Micheus about Ivla Vert|Perpendicular Connect idea (/showthread.php?tid=3232) |
To Micheus about Ivla Vert|Perpendicular Connect idea - Luiz Fonte Boa - 12-01-2026 The idea of user "Ivla" remained on my mind, Micheus. So... ------------------- Hello Micheus! First of all, thank you for all the continuous hard work and dedication maintaining and improving Wings3D. In these times of artificial intelligence—and considering the idea of using it as an ally—this whole suggestion actually started while I was just playing around with Google's Gemini AI. To be completely honest, I am just copying and pasting what it gave me here! Haha! So I would love to know from you, dear Micheus, if the structure of these instructions makes any sense at all—because for me, as you know, this is all Greek! Following up on the original idea brought up by user **IVLA** in the thread https://wings3d.com/forum/showthread.php?tid=3218&action=lastpost, I would like to respectfully suggest a small feature for future consideration: a Vertex | Perpendicular Connect command, which would allow connecting a selected vertex directly to an opposite edge at an exact 90-degree angle. Just as a starting point or conceptual reference, here is one possible way this could be structured within `src/wings_vertex_cmd.erl`: ### 1. Context Menu Entry (`menu/1`) Adding the command alongside the existing `Connect` options in Vertex mode: ```erlang menu(St) -> [ ... {?__(10,"Connect"),connect, ?__(11,"Create a new edge by connecting selected vertices")}, {?__(12,"Perpendicular Connect"), perp_connect, ?__(13,"Connect selected vertex perpendicularly (90 deg) to a target edge")}, ... ]. ``` ### 2. Command Routing (`command/2`) Mapping the `perp_connect` atom to prompt the user for the target edge: ```erlang command(connect, St) -> ?SLOW(connect(St)); command(perp_connect, St) -> ask_perp_connect(St); ``` ### 3. Orthogonal Projection Logic Using vector dot product to find the exact 90-degree intersection point on the target edge before splitting and connecting: ```erlang %%% %%% Perpendicular Connect (90 degrees) %%% ask_perp_connect(St) -> wings:ask({[{edge, ?__(14,"Select target edge for 90-degree connection")}], []}, St, fun do_perp_connect/2). do_perp_connect({TargetEdge, _}, #st{sel=[{Id, SelVertices}]} = St) -> case gb_sets:to_list(SelVertices) of [VertP] -> wings_sel:map( fun(_, #we{id=WeId}=We) when WeId =:= Id -> apply_perp_cut(VertP, TargetEdge, We); (_, We) -> We end, St); _ -> wings_u:error_msg(?__(15,"Select exactly ONE source vertex first.")) end; do_perp_connect(_, _) -> wings_u:error_msg(?__(16,"Select one vertex in a single object.")). apply_perp_cut(VertP, Edge, #we{vp=Vtab, es=Etab}=We0) -> #edge{vs=VertA, ve=VertB} = array:get(Edge, Etab), PosP = array:get(VertP, Vtab), PosA = array:get(VertA, Vtab), PosB = array:get(VertB, Vtab), AB = e3d_vec ub(PosB, PosA),AP = e3d_vec ub(PosP, PosA),LenSq = e3d_vec:dot(AB, AB), case LenSq > 1.0e-12 of true -> T = e3d_vec:dot(AP, AB) / LenSq, if T > 0.0001 andalso T < 0.9999 -> PosQ = e3d_vec:add(PosA, e3d_vec:mul(AB, T)), {We1, VertQ} = wings_edge:fast_cut(Edge, PosQ, We0), {We2, _NewSel} = wings_vertex:connect(VertP, [VertQ], We1), We2; true -> wings_u:error_msg(?__(17,"Perpendicular point falls outside the edge segment.")) end; false -> wings_u:error_msg(?__(18,"Target edge has zero length.")) end. ``` *(Note: I also realize there are three tricky edge cases to keep in mind: ensuring both the vertex and target edge actually share the same face, handling non-planar faces where a 90° cut might create an unexpected crease, and obtuse angles where the perpendicular projection falls outside the edge segment).* Of course, you know the internal architecture and edge-case conventions of Wings3D far better than I do, so please feel free to adapt or disregard this snippet as you see fit. Thank you again for your time and for keeping Wings3D such a great tool! RE: To Micheus about Ivla Vert|Perpendicular Connect idea - Luiz Fonte Boa - 12-01-2026 Alternatively, instead of creating a separate command in the Vertex menu, another very natural approach would be integrating this as a 90-degree perpendicular snap directly inside the interactive Tools | Connect tool (for example, triggered by holding a modifier key like Ctrl or Shift while dragging along the target edge). Conceptually, this could be structured within plugins_src/commands/wpc_connect.erl as follows: 1. Updating the Help / Information Line Adding a hint in the bottom status bar when the user is dragging a connection from an existing vertex to an edge: Code: %% Inside the interactive drag loop help string:2. Intercepting the Drag Event (Modifier Key Check) During the mouse motion event when the previous point was a vertex (PosP) and the cursor is currently sliding over an edge (VertA to VertB): Code: handle_motion(Event, #cstate{prev_pos=PosP, curr_edge={VertA, VertB}}=State) ->3. Orthogonal Projection Helper Function Using vector dot product to override the slide percentage T with the exact 90-degree projection point: Code: calc_perpendicular_t(PosP, PosA, PosB, FallbackT) ->(Note: Integrating this into Tools | Connect actually handles face-sharing validation naturally since the interactive tool already restricts connections to valid adjacent topology. However, two edge cases still apply: non-planar faces where a 90° cut might create an unexpected crease, and obtuse angles where the perpendicular projection falls outside the edge segment—handled above by smoothly falling back to standard mouse sliding). PS: To avoid any conflict with Wings3D's standard camera navigation or selection modifiers (Ctrl, Shift, Alt), this perpendicular snap could be toggled using a clean, non-conflicting hotkey while dragging—such as pressing [1] (or whatever available key fits Wings3D's input conventions best). RE: To Micheus about Ivla Vert|Perpendicular Connect idea - micheus - 12-01-2026 I liked the second approach. I would avoid to create a command just for this. Currently, Connect Tool already uses the key [1], so we would need to use [2] for that. Also, in this mode we probably will need to "disable" the vertices highlight since it's like an snap - moving the mouse pointer on the edge and we getting near to its vertex the "selection" just jumps to the vertex. Thanks for the pseud-code. AI really can help with insights and some small code, but we need to be sure it is nothing inflating it. I also have been doing some tests with it.
RE: To Micheus about Ivla Vert|Perpendicular Connect idea - micheus - 12-01-2026 Fonte Boa, Since you cannot test on v1.5.4 I recorded this gif. Take a look and see if is there something unexpected. I didn't filter the cut crossing edges although it's not a big deal. In case someone else wants to check it, here is the patch (for v2.4.1): wpc_connect_tool.beam
|