EleotleCram / blender-cad-tools

a collection of Blender addons to make CAD design with Blender even more enjoyable
163 stars 7 forks source link

Can't transform in normal direction #1

Open 3DManuH opened 3 years ago

3DManuH commented 3 years ago

Can't transform in normal direction. Pivot is set to 3D cursor (works) - orientation to normal (doesn't worK) It scales as shown with red line but should work as shown with green lines on screenshot. 2020-12-13 00_42_47

3DManuH commented 3 years ago

2020-12-13_01-01-46

EleotleCram commented 3 years ago

Ah yes, this is currently a known limitation. Transforms are assumed to be in Cartesian directions (i.e. Global orientation). Figuring out the oriented bounding box is a known hard problem. Maybe we can take some shortcuts for orientations in the normal direction by calculating the sum of the normals of all selected elements. I assume at least that's how it works.

Has this ever worked for MeshTools btw ?

3DManuH commented 3 years ago

No, not working for MeshTools as well. Would be awesome to have this working for CAD Mesh Dimensions and MeshTools. Would use/need this feature all day long.

EleotleCram commented 3 years ago

I have something working. Needs some generalization though. And I don't know yet how it would be clear to the viewer/modeler which direction would be x, y or z. Look at the video, the gizmo changes orientation as I resize. Probably not what we want to happen in the Panel. cad_mesh_dim_normal_orientation

3DManuH commented 3 years ago

cool, that looks promising! hopefully you can remedy the gizmo orientation.

EleotleCram commented 3 years ago

I've pushed a new version that implements transform orientation 'NORMAL'.

A few notes:

Looking forward for some feedback.

3DManuH commented 3 years ago

sorry can't get it to work as expected. anything i am doing wrong?

https://user-images.githubusercontent.com/63927992/102715760-dbebd600-42d7-11eb-998d-e7cab5162d1c.mp4

EleotleCram commented 3 years ago

It looks like I screwed something up with matrices. It currently only works for objects which are at world origin (0,0,0) :rofl: I'll have another go at this... If you want a sneak preview, put your object at world center for now ;-)

3DManuH commented 3 years ago

ok, good to know. works really great so far besides the world origin limitation.

there is no local orientation right now. Is this something that could be added?

sorry, seems like i can not create a pull request. (Choose different branches or forks above to discuss and review changes. Learn about pull requests)

possible to add a shortcut for CAD Mesh Dimension? So you are not forced to use N-menu but can access the addon with shortcut?

EleotleCram commented 3 years ago

I'm afraid we hit a serious snag. I overlooked something in my approach. When custom orientations ('normal' is a special form of custom orientation) are involved, you cannot easily map the scale in the custom orientation to global and then expect this to work. There can be many bounding boxes in the custom orientation that map to a single bounding box in global orientation (vice versa).

This means, that we cannot use bpy.ops.transform.resize() (which is what cad_mesh_dimensions (and also MeshTools: edit_dimensions) is built around. I now understand why it wasn't included in the original addon either. It's hard. Add to this that we cannot access the Gizmo matrix easily. And that the Gizmo most of the time is not aligned properly anyway (See blue arrow in picture), basically you'd have to manipulate the mesh vertices directly and implement it for all the possible anchor points. This is way more than I bargained for when I set out to implement this feature request.

So unless we can come up with some clever trick, or I develop a need for this feature that overcomes my reluctance to dive into direct vertex manipulation, this issue is stuck.... Sorry. I gave it my best for now...

gizmo-not-aligned

3DManuH commented 3 years ago

sad to hear that. thank you for the hard work until now. hopefully you’ll find a workaround to get this fixed.

3DManuH commented 3 years ago

Hi Marcel, are there any plans to support normal (or 3d cursor) transformation?