Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_data.h
- This file was added.
| /* | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| * | |||||
| * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | |||||
| * All rights reserved. | |||||
| */ | |||||
| /** \file | |||||
| * \ingroup edtransform | |||||
| */ | |||||
| #ifndef __TRANSFORM_DATA_H__ | |||||
| #define __TRANSFORM_DATA_H__ | |||||
| #include "BLI_utildefines.h" | |||||
| typedef struct TransDataExtension { | |||||
| /** Initial object drot. */ | |||||
| float drot[3]; | |||||
| // /* Initial object drotAngle, TODO: not yet implemented */ | |||||
| // float drotAngle; | |||||
| // /* Initial object drotAxis, TODO: not yet implemented */ | |||||
| // float drotAxis[3]; | |||||
| /** Initial object delta quat. */ | |||||
| float dquat[4]; | |||||
| /** Initial object delta scale. */ | |||||
| float dscale[3]; | |||||
| /** Rotation of the data to transform. */ | |||||
| float *rot; | |||||
| /** Initial rotation. */ | |||||
| float irot[3]; | |||||
| /** Rotation quaternion of the data to transform. */ | |||||
| float *quat; | |||||
| /** Initial rotation quaternion. */ | |||||
| float iquat[4]; | |||||
| /** Rotation angle of the data to transform. */ | |||||
| float *rotAngle; | |||||
| /** Initial rotation angle. */ | |||||
| float irotAngle; | |||||
| /** Rotation axis of the data to transform. */ | |||||
| float *rotAxis; | |||||
| /** Initial rotation axis. */ | |||||
| float irotAxis[4]; | |||||
| /** Size of the data to transform. */ | |||||
| float *size; | |||||
| /** Initial size. */ | |||||
| float isize[3]; | |||||
| /** Object matrix. */ | |||||
| float obmat[4][4]; | |||||
| /** Use instead of #TransData.smtx, | |||||
| * It is the same but without the #Bone.bone_mat, see #TD_PBONE_LOCAL_MTX_C. */ | |||||
| float l_smtx[3][3]; | |||||
| /** The rotscale matrix of pose bone, to allow using snap-align in translation mode, | |||||
| * when td->space[tdi].mtx is the loc pose bone matrix (and hence can't be used to apply | |||||
| * rotation in some cases, namely when a bone is in "NoLocal" or "Hinge" mode)... */ | |||||
| float r_mtx[3][3]; | |||||
| /** Inverse of previous one. */ | |||||
| float r_smtx[3][3]; | |||||
| /** Rotation mode, as defined in #eRotationModes (DNA_action_types.h). */ | |||||
| int rotOrder; | |||||
| /** Original object transformation used for rigid bodies. */ | |||||
| float oloc[3], orot[3], oquat[4], orotAxis[3], orotAngle; | |||||
| } TransDataExtension; | |||||
| /** Used to store 2 handles for each #TransData in case the other handle wasn't selected. | |||||
| * Also to unset temporary flags. */ | |||||
| typedef struct TransDataCurveHandleFlags { | |||||
| char ih1, ih2; | |||||
| char *h1, *h2; | |||||
| } TransDataCurveHandleFlags; | |||||
| typedef struct TransDataBasic { | |||||
| /** Various flags. */ | |||||
| int flag; | |||||
| /** Location of the data to transform. */ | |||||
| float *loc; | |||||
| /** Initial location. */ | |||||
| float iloc[3]; | |||||
| /** Extra data (mirrored element pointer, in editmode mesh to BMVert) | |||||
| * (editbone for roll fixing) (...). */ | |||||
| void *extra; | |||||
| } TransDataBasic; | |||||
| typedef struct TransDataProportional { | |||||
| /** Distance needed to affect element (for Proportionnal Editing). */ | |||||
| float dist; | |||||
| /** Distance to the nearest element (for Proportionnal Editing). */ | |||||
| float rdist; | |||||
| /** Factor of the transformation (for Proportionnal Editing). */ | |||||
| float factor; | |||||
| } TransDataProportional; | |||||
| typedef struct TransDataSpace { | |||||
| /** Transformation matrix from data space to global space. */ | |||||
| float mtx[3][3]; | |||||
| /** Transformation matrix from global space to data space. */ | |||||
| float smtx[3][3]; | |||||
| /** Axis orientation matrix of the data. */ | |||||
| float axismtx[3][3]; | |||||
| } TransDataSpace; | |||||
| typedef struct TransDataSpecial { | |||||
| /** Value pointer for special transforms. */ | |||||
| float *val; | |||||
| /** Old value. */ | |||||
| float ival; | |||||
| } TransDataSpecial; | |||||
| typedef struct TransDataObjectSpec { | |||||
| struct Object *ob; | |||||
| /** For objects/bones, the first constraint in its constraint stack. */ | |||||
| struct bConstraint *con; | |||||
| /** If set, copy of Object or PoseChannel protection. */ | |||||
| short protectflag; | |||||
| } TransDataObjectSpec; | |||||
| typedef struct TransDataIter { | |||||
| TransDataBasic basic; | |||||
| TransDataProportional prop; | |||||
| TransDataSpace space; | |||||
| TransDataSpecial special; | |||||
| TransDataObjectSpec object; | |||||
| TransDataExtension ext; | |||||
| struct { | |||||
| /** for curves, stores handle flags for modification/cancel. */ | |||||
| TransDataCurveHandleFlags *hdata; | |||||
| } curve; | |||||
| /** Individual data center. */ | |||||
| float center[3]; | |||||
| } TransDataIter; | |||||
| typedef struct TransData { | |||||
| TransDataBasic *basic; | |||||
| TransDataProportional *prop; | |||||
| TransDataSpace *space; | |||||
| TransDataSpecial *special; | |||||
| TransDataObjectSpec *object; | |||||
| TransDataExtension *ext; | |||||
| struct { | |||||
| /** for curves, stores handle flags for modification/cancel. */ | |||||
| TransDataCurveHandleFlags *hdata; | |||||
| } * curve; | |||||
| /** Individual data center. */ | |||||
| float (*center)[3]; | |||||
| uint elem_len; | |||||
| } TransData; | |||||
| /* Descriptor. */ | |||||
| typedef enum eTransDataDescr { | |||||
| TD_BASIC = (1 << 0), | |||||
| TD_PROP = (1 << 1), | |||||
| TD_SPACE = (1 << 2), | |||||
| TD_SPECIAL = (1 << 3), | |||||
| TD_OBJECT = (1 << 4), | |||||
| TD_EXT = (1 << 5), | |||||
| TD_CURVE = (1 << 6), | |||||
| TD_CENTER = (1 << 7), | |||||
| } eTransDataDescr; | |||||
| #define TD_BASIC_COMP \ | |||||
| (TD_BASIC | TD_PROP | TD_SPACE | TD_SPECIAL | TD_OBJECT | TD_CURVE | TD_CENTER) | |||||
| #define TD_ALL_COMP (TD_BASIC_COMP | TD_EXT) | |||||
| TransData *transform_data_alloc(const uint len, const eTransDataDescr descriptor); | |||||
| void transform_data_free(TransData *td); | |||||
| void transform_data_elem_update_all(const TransData *td, const int tdi, TransDataIter *td_iter); | |||||
| void transform_data_elem_read_all(const TransData *td, const int tdi, TransDataIter *r_td_iter); | |||||
| void transform_data_reorder(TransData *td, const int *indexes); | |||||
| #endif | |||||