Add docs for how object's stored transforms work #23
@ -133,3 +133,58 @@ be more or less complex. Steps in **bold** are rather mandatory.
|
||||
6. **recalcData** : Flush updates to Blender data when needed
|
||||
7. **headerPrint** : Send text to the header
|
||||
8. **viewRedrawForce** : Send redraw events to the proper screen area
|
||||
|
||||
## Stored Transforms
|
||||
|
||||
Each object has a set of source-of-truth (i.e. not derived or cached) transforms
|
||||
stored directly in its DNA, in the `Object` struct in *DNA_object_types.h*.
|
||||
These specify the aspects of an object's transforms that are independent of
|
||||
other objects in the scene, and which do not result from constraints, etc.
|
||||
|
||||
### Loc/Rot/Scale
|
||||
|
||||
The simplest of these are the `loc`, `rot`, and `scale` properties, which form
|
||||
the base transform of an object. These are the familiar properties that users
|
||||
use to set and animate an object's position in 3D space.
|
||||
|
||||
`rot` also has counterparts for quaternion and axis-angle rotations: `quat` for
|
||||
quaternions and `rotAxis` + `rotAngle` for axis-angle. These are used for the
|
||||
object's rotation when `rotmode` is set to the corresponding rotation mode.
|
||||
|
||||
### Delta Transforms
|
||||
|
||||
After the base transform, there are the delta transforms, stored in the `dloc`,
|
||||
`drot`, and `dscale` properties. These can also be set by the user, and
|
||||
effectively define a "rest position" for the object.
|
||||
|
||||
`loc`/`dloc`, `rot`/`drot`, and `scale`/`dscale` are first combined as pairs
|
||||
(e.g. `loc` with `dloc`), and then assembled together into a transform matrix
|
||||
afterward.
|
||||
|
||||
> NOTE: Quaternion and axis-angle rotation modes also have corresponding `d*`
|
||||
> properties for delta transforms, for when the object is in those respective
|
||||
> rotation modes. They are applied the same way as `drot`.
|
||||
|
||||
The relevant code for this is in *blenkernel/intern/object.cc* in the functions
|
||||
`BKE_object_scale_to_mat3`, `BKE_object_rot_to_mat3`, `BKE_object_to_mat3`, and
|
||||
`BKE_object_to_mat4`.
|
||||
|
||||
### Parent-Inverse Matrix
|
||||
|
||||
Finally, there is one additional transform step that is internal to an object:
|
||||
the parent-inverse matrix.
|
||||
|
||||
The parent-inverse matrix is a 4x4 matrix stored in the property `parentinv`.
|
||||
Importantly, it is *not* the transform (inverse or otherwise) of the object's
|
||||
parent. Rather, it's an arbitrary 4x4 matrix that gets applied to an object's
|
||||
transforms if and only if it has a parent.
|
||||
|
||||
Its intended purpose (and the source of its name) is to keep a child object
|
||||
where it is visually when a parent-child relationship is created, without
|
||||
changing the child's loc/rot/scale values. To accomplish this, the matrix is
|
||||
automatically set to the inverse of the parent's transform *at the time the
|
||||
parent-child relationship is created*. It is specifically *not* updated to
|
||||
continuously match the parent's inverse.
|
||||
|
||||
The relevant code for applying this transform is in
|
||||
*blenkernel/intern/object.cc* in the function `BKE_object_apply_mat4_ex`.
|
||||
|
Loading…
Reference in New Issue
Block a user