Page MenuHome

Array Modifier: Added rotation functionality
Needs ReviewPublic

Authored by Paul Le Henaff (mightyboat) on Aug 30 2018, 5:14 PM.

Details

Summary

Currently, when using the array modifier, you can't apply any rotation to the instances. This quickly becomes very limiting because when creating meshes that make use of repeating patterns , the only way to do that is to use an empty object, and that quickly makes the model much more complicated than it needs to be. You always need to keep track of that empty and make sure it moves with the mesh.

This update simply adds a rotation input, which allows you to achieve rotation without using an empty object.

It's not meant to replace the empty object functionality (because it's extremely useful in some cases), but simply add an extra dimension to the default array functionality to allow more complex array modifier uses without having to use empty objects all the time.

Later, more could be added, like adding a way to define the axis of rotation, adding scaling etc.

I've added screenshots to show the usage:

Before:

After:

Example use case:

Edit:
Drastically simplified the code by using the existing functions available in the codebase.

Diff Detail

Event Timeline

@Campbell Barton (campbellbarton) @Bastien Montagne (mont29)
Hello, this diff adds a rotation functionality to the Array Modifier. Would you be able to review it? I'm a new developer so I don't know if there's already been discussion about this, and I don't yet know the proper development process, or the communication channels, for adding new stuff, so feel free to remove this if there are already plans. Thanks.

Habib Gahbiche (zazizizou) added inline comments.
source/blender/modifiers/intern/MOD_array.c
456

I think here you could use copy_m3_m4(offset, B)

source/blender/modifiers/intern/MOD_array.c
456

That function looks promising. However, it's first argument is a 3x3 matrix, but the offset matrix should be 4x4. The code compiles, and rotation works, but translation data is lost because it messes up the 4th column of the offset matrix (translation is done in the 4th column of that matrix).
I've looked at other functions in the same file, and none seem to do what we need here (maybe I overlooked one?).

The closest seems to be copy_m4_m3 (If I change all the vectors to 3x3), however looking at the code it clears the 4th row and column to zeroes.

Maybe a new method could be added in math_matrix, but it should probably be done a separate commit since that file is generic and used in many places, right?

I wrote a function that works, so I could submit it if people think its worth doing.