Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-11 09:34:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-11 09:34:07 +0400
commit1649521abe637b5af74174eda0d8ca0b5f1c6ceb (patch)
treebd5ba469d738f4260be384d1b1a4f02079f8b9c5 /source/blender/blenkernel
parent11947f1a67ab6fb26cc36e8f9c421d7e464a70c9 (diff)
fix [#29203] Camera can still move even when transforms locked
added object_tfm_protected_backup, object_tfm_protected_restore so its easier to transform the object and respect protected channels (otherwise you need checks everywhere for each channel which is verbose).
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_object.h16
-rw-r--r--source/blender/blenkernel/intern/object.c65
2 files changed, 81 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 2ef942a2e09..ecc00901dd5 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -116,6 +116,22 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3
void *object_tfm_backup(struct Object *ob);
void object_tfm_restore(struct Object *ob, void *obtfm_pt);
+typedef struct ObjectTfmProtectedChannels {
+ float loc[3], dloc[3];
+ float size[3], dsize[3];
+ float rot[3], drot[3];
+ float quat[4], dquat[4];
+ float rotAxis[3], drotAxis[3];
+ float rotAngle, drotAngle;
+} ObjectTfmProtectedChannels;
+
+void object_tfm_protected_backup(const struct Object *ob,
+ ObjectTfmProtectedChannels *obtfm);
+
+void object_tfm_protected_restore(struct Object *ob,
+ const ObjectTfmProtectedChannels *obtfm,
+ const short protectflag);
+
void object_handle_update(struct Scene *scene, struct Object *ob);
void object_sculpt_modifiers_changed(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 45bd8f095a4..4e6bc4eee89 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1498,6 +1498,71 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
}
}
+void object_tfm_protected_backup(const Object *ob,
+ ObjectTfmProtectedChannels *obtfm)
+{
+
+#define TFMCPY( _v) (obtfm->_v = ob->_v)
+#define TFMCPY3D( _v) copy_v3_v3(obtfm->_v, ob->_v)
+#define TFMCPY4D( _v) copy_v4_v4(obtfm->_v, ob->_v)
+
+ TFMCPY3D(loc);
+ TFMCPY3D(dloc);
+ TFMCPY3D(size);
+ TFMCPY3D(dsize);
+ TFMCPY3D(rot);
+ TFMCPY3D(drot);
+ TFMCPY4D(quat);
+ TFMCPY4D(dquat);
+ TFMCPY3D(rotAxis);
+ TFMCPY3D(drotAxis);
+ TFMCPY(rotAngle);
+ TFMCPY(drotAngle);
+
+#undef TFMCPY
+#undef TFMCPY3D
+#undef TFMCPY4D
+
+}
+
+void object_tfm_protected_restore(Object *ob,
+ const ObjectTfmProtectedChannels *obtfm,
+ const short protectflag)
+{
+ unsigned int i;
+
+ for (i= 0; i < 3; i++) {
+ if (protectflag & (OB_LOCK_LOCX<<i)) {
+ ob->loc[i]= obtfm->loc[i];
+ ob->dloc[i]= obtfm->dloc[i];
+ }
+
+ if (protectflag & (OB_LOCK_SCALEX<<i)) {
+ ob->size[i]= obtfm->size[i];
+ ob->dsize[i]= obtfm->dsize[i];
+ }
+
+ if (protectflag & (OB_LOCK_ROTX<<i)) {
+ ob->rot[i]= obtfm->rot[i];
+ ob->drot[i]= obtfm->drot[i];
+
+ ob->quat[i + 1]= obtfm->quat[i + 1];
+ ob->dquat[i + 1]= obtfm->dquat[i + 1];
+
+ ob->rotAxis[i]= obtfm->rotAxis[i];
+ ob->drotAxis[i]= obtfm->drotAxis[i];
+ }
+ }
+
+ if ((protectflag & OB_LOCK_ROT4D) && (protectflag & OB_LOCK_ROTW)) {
+ ob->quat[0]= obtfm->quat[0];
+ ob->dquat[0]= obtfm->dquat[0];
+
+ ob->rotAngle= obtfm->rotAngle;
+ ob->drotAngle= obtfm->drotAngle;
+ }
+}
+
/* see pchan_apply_mat4() for the equivalent 'pchan' function */
void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent)
{