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
path: root/source
diff options
context:
space:
mode:
authorMichael Fox <mfoxdogg@gmail.com>2009-01-02 06:16:38 +0300
committerMichael Fox <mfoxdogg@gmail.com>2009-01-02 06:16:38 +0300
commitaf2304f3cb635f26e3421f72482a0604fba6b847 (patch)
tree1f18290921964606b9c747c4a45e7d056ad57df7 /source
parentada3868efdfb49bc24c4ee789aa53d66383d4658 (diff)
2.5
******** - added clear location/rotation/scale/origin - each action is a seperate operator - Drawing is delayed as the tag_region_redraw does not seem to have an effect perhaps a transformation notifier is needed - for the view to update just do some transformation, like press G - changed the shortcut key for area rip to alt-ctrl-r so it dosn't conflict with clear rotation
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/object/object_edit.c308
-rw-r--r--source/blender/editors/object/object_intern.h11
-rw-r--r--source/blender/editors/object/object_ops.c11
-rw-r--r--source/blender/editors/screen/screen_ops.c2
4 files changed, 221 insertions, 111 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 5e3daa843b6..a2f746a4ba1 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -126,6 +126,10 @@
#include "RNA_access.h"
#include "RNA_define.h"
+/* for menu/popup icons etc etc*/
+#include "UI_interface.h"
+#include "UI_resources.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -1200,6 +1204,7 @@ void OBJECT_OT_select_invert(wmOperatorType *ot)
static int object_de_select_all_exec(bContext *C, wmOperator *op)
{
+
int a=0, ok=0;
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
@@ -1276,137 +1281,229 @@ void OBJECT_OT_select_random(wmOperatorType *ot)
RNA_def_property_ui_text(prop, "Percent", "Max persentage that will be selected");
RNA_def_property_int_default(prop, 50);
}
-void clear_track(Scene *scene, View3D *v3d)
-{
- Base *base;
- int mode;
-
- if(G.obedit) return;
- if(scene->id.lib) return;
- mode= pupmenu("OK? %t|Clear Track %x1| Clear Track and Keep Transform %x2");
+/* ******** Clear object Translation *********** */
- if(mode<1) return;
+static int object_clear_location_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ int armature_clear= 0;
- for(base= FIRSTBASE; base; base= base->next) {
- if(TESTBASELIB(v3d, base)) {
- base->object->track= NULL;
- base->object->recalc |= OB_RECALC;
-
- if(mode==2) {
- apply_obmat(base->object);
- }
+ CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
+ if ((ob->flag & OB_POSEMODE)) {
+ /* only clear pose transforms if:
+ * - with a mesh in weightpaint mode, it's related armature needs to be cleared
+ * - with clearing transform of object being edited at the time
+ */
+ if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
+// XXX clear_armature(ob, mode);
+ armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
+ }
+ }
+ else if((G.f & G_WEIGHTPAINT)==0) {
+ if ((ob->protectflag & OB_LOCK_LOCX)==0)
+ ob->loc[0]= ob->dloc[0]= 0.0f;
+ if ((ob->protectflag & OB_LOCK_LOCY)==0)
+ ob->loc[1]= ob->dloc[1]= 0.0f;
+ if ((ob->protectflag & OB_LOCK_LOCZ)==0)
+ ob->loc[2]= ob->dloc[2]= 0.0f;
}
}
-
+ CTX_DATA_END;
+
DAG_scene_sort(scene);
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWOOPS, 0);
+ if(armature_clear==0) /* in this case flush was done */
+ ED_anim_dag_flush_update(C);
+ BIF_undo_push("Clear Location");
- BIF_undo_push("Clear Track");
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ return OPERATOR_FINISHED;
}
-void clear_object(Scene *scene, View3D *v3d, char mode)
+
+void OBJECT_OT_clear_location(wmOperatorType *ot)
{
- Base *base;
- Object *ob;
- float *v1, *v3, mat[3][3];
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name= "Clear Object Location";
+ ot->idname= "OBJECT_OT_clear_location";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= object_clear_location_exec;
+ ot->poll= ED_operator_object_active;
+}
+
+static int object_clear_rotation_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
int armature_clear= 0;
- char *str=NULL;
+
+ CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
+ if ((ob->flag & OB_POSEMODE)) {
+ /* only clear pose transforms if:
+ * - with a mesh in weightpaint mode, it's related armature needs to be cleared
+ * - with clearing transform of object being edited at the time
+ */
+ if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
+// XXX clear_armature(ob, mode);
+ armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
+ }
+ }
+ else if((G.f & G_WEIGHTPAINT)==0) {
+ /* eulers can only get cleared if they are not protected */
+ if ((ob->protectflag & OB_LOCK_ROTX)==0)
+ ob->rot[0]= ob->drot[0]= 0.0f;
+ if ((ob->protectflag & OB_LOCK_ROTY)==0)
+ ob->rot[1]= ob->drot[1]= 0.0f;
+ if ((ob->protectflag & OB_LOCK_ROTZ)==0)
+ ob->rot[2]= ob->drot[2]= 0.0f;
+ }
+ }
+ CTX_DATA_END;
- if(G.obedit) return;
- if(scene->id.lib) return;
+ DAG_scene_sort(scene);
+ if(armature_clear==0) /* in this case flush was done */
+ ED_anim_dag_flush_update(C);
+ BIF_undo_push("Clear Rotation");
- if(mode=='r') str= "Clear rotation";
- else if(mode=='g') str= "Clear location";
- else if(mode=='s') str= "Clear scale";
- else if(mode=='o') str= "Clear origin";
- else return;
+ ED_region_tag_redraw(CTX_wm_region(C));
- for(base= FIRSTBASE; base; base= base->next) {
- if(TESTBASELIB(v3d, base)) {
- ob= base->object;
-
- if ((ob->flag & OB_POSEMODE)) {
- /* only clear pose transforms if:
- * - with a mesh in weightpaint mode, it's related armature needs to be cleared
- * - with clearing transform of object being edited at the time
- */
- if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
-// XXX clear_armature(ob, mode);
- armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
- }
- }
- else if((G.f & G_WEIGHTPAINT)==0) {
- /* only clear transforms of 'normal' (not armature) object if:
- * - not in weightpaint mode or editmode
- * - if that object's transform locks are not enabled (this is done on a per-channel basis)
- */
- if (mode=='r') {
- /* eulers can only get cleared if they are not protected */
- if ((ob->protectflag & OB_LOCK_ROTX)==0)
- ob->rot[0]= ob->drot[0]= 0.0f;
- if ((ob->protectflag & OB_LOCK_ROTY)==0)
- ob->rot[1]= ob->drot[1]= 0.0f;
- if ((ob->protectflag & OB_LOCK_ROTZ)==0)
- ob->rot[2]= ob->drot[2]= 0.0f;
-
- /* quats here are not really used anymore anywhere, so it probably doesn't
- * matter to not clear them whether the euler-based rotation is used
- */
- /*QuatOne(ob->quat);
- QuatOne(ob->dquat);*/
-
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_clear_rotation(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name= "Clear Object Rotation";
+ ot->idname= "OBJECT_OT_clear_rotation";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= object_clear_rotation_exec;
+ ot->poll= ED_operator_object_active;
+}
+
+static int object_clear_scale_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ int armature_clear= 0;
+
+ CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
+ if ((ob->flag & OB_POSEMODE)) {
+ /* only clear pose transforms if:
+ * - with a mesh in weightpaint mode, it's related armature needs to be cleared
+ * - with clearing transform of object being edited at the time
+ */
+ if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
+// XXX clear_armature(ob, mode);
+ armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
+ }
+ }
+ else if((G.f & G_WEIGHTPAINT)==0) {
+ if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
+ ob->dsize[0]= 0.0f;
+ ob->size[0]= 1.0f;
}
- else if (mode=='g') {
- if ((ob->protectflag & OB_LOCK_LOCX)==0)
- ob->loc[0]= ob->dloc[0]= 0.0f;
- if ((ob->protectflag & OB_LOCK_LOCY)==0)
- ob->loc[1]= ob->dloc[1]= 0.0f;
- if ((ob->protectflag & OB_LOCK_LOCZ)==0)
- ob->loc[2]= ob->dloc[2]= 0.0f;
-
- }
- else if (mode=='s') {
- if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
- ob->dsize[0]= 0.0f;
- ob->size[0]= 1.0f;
- }
- if ((ob->protectflag & OB_LOCK_SCALEY)==0) {
- ob->dsize[1]= 0.0f;
- ob->size[1]= 1.0f;
- }
- if ((ob->protectflag & OB_LOCK_SCALEZ)==0) {
- ob->dsize[2]= 0.0f;
- ob->size[2]= 1.0f;
- }
+ if ((ob->protectflag & OB_LOCK_SCALEY)==0) {
+ ob->dsize[1]= 0.0f;
+ ob->size[1]= 1.0f;
}
- else if(mode=='o') {
- if(ob->parent) {
- v1= ob->loc;
- v3= ob->parentinv[3];
-
- Mat3CpyMat4(mat, ob->parentinv);
- VECCOPY(v3, v1);
- v3[0]= -v3[0];
- v3[1]= -v3[1];
- v3[2]= -v3[2];
- Mat3MulVecfl(mat, v3);
- }
+ if ((ob->protectflag & OB_LOCK_SCALEZ)==0) {
+ ob->dsize[2]= 0.0f;
+ ob->size[2]= 1.0f;
}
+ }
+ }
+ CTX_DATA_END;
+
+ DAG_scene_sort(scene);
+ if(armature_clear==0) /* in this case flush was done */
+ ED_anim_dag_flush_update(C);
+ BIF_undo_push("Clear Scale");
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_clear_scale(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name= "Clear Object Scale";
+ ot->idname= "OBJECT_OT_clear_scale";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= object_clear_scale_exec;
+ ot->poll= ED_operator_object_active;
+}
+
+static int object_clear_origin_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ float *v1, *v3, mat[3][3];
+ int armature_clear= 0;
+
+ CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
+ if ((ob->flag & OB_POSEMODE)) {
+ /* only clear pose transforms if:
+ * - with a mesh in weightpaint mode, it's related armature needs to be cleared
+ * - with clearing transform of object being edited at the time
+ */
+ if ((G.f & G_WEIGHTPAINT) || (ob==OBACT)) {
+// XXX clear_armature(ob, mode);
+ armature_clear= 1; /* silly system to prevent another dag update, so no action applied */
+ }
+ }
+ else if((G.f & G_WEIGHTPAINT)==0) {
+ if(ob->parent) {
+ v1= ob->loc;
+ v3= ob->parentinv[3];
- ob->recalc |= OB_RECALC_OB;
- }
+ Mat3CpyMat4(mat, ob->parentinv);
+ VECCOPY(v3, v1);
+ v3[0]= -v3[0];
+ v3[1]= -v3[1];
+ v3[2]= -v3[2];
+ Mat3MulVecfl(mat, v3);
+ }
}
}
+ CTX_DATA_END;
- allqueue(REDRAWVIEW3D, 0);
+
+ DAG_scene_sort(scene);
if(armature_clear==0) /* in this case flush was done */
ED_anim_dag_flush_update(C);
- BIF_undo_push(str);
+ BIF_undo_push("Clear origin");
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+
+ return OPERATOR_FINISHED;
}
+void OBJECT_OT_clear_origin(wmOperatorType *ot)
+{
+
+ /* identifiers */
+ ot->name= "Clear Object Origin";
+ ot->idname= "OBJECT_OT_clear_origin";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= object_clear_origin_exec;
+ ot->poll= ED_operator_object_active;
+}
+/* ******************** **************** */
+
void reset_slowparents(Scene *scene, View3D *v3d)
{
/* back to original locations */
@@ -1422,7 +1519,6 @@ void reset_slowparents(Scene *scene, View3D *v3d)
}
}
}
-
void set_slowparent(Scene *scene, View3D *v3d)
{
Base *base;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 794bba0791e..7cd8ec87294 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -29,7 +29,10 @@
#define ED_OBJECT_INTERN_H
/* internal exports only */
-
+#define CLEAR_OBJ_ROTATION 0
+#define CLEAR_OBJ_LOCATION 1
+#define CLEAR_OBJ_SCALE 2
+#define CLEAR_OBJ_ORIGIN 3
/* object_edit.c */
void OBJECT_OT_toggle_editmode(wmOperatorType *ot);
@@ -42,8 +45,10 @@ void OBJECT_OT_select_invert(wmOperatorType *ot);
void OBJECT_OT_select_random(wmOperatorType *ot);
void OBJECT_OT_select_by_type(wmOperatorType *ot);
void OBJECT_OT_select_by_layer(wmOperatorType *ot);
-
-
+void OBJECT_OT_clear_location(wmOperatorType *ot);
+void OBJECT_OT_clear_rotation(wmOperatorType *ot);
+void OBJECT_OT_clear_scale(wmOperatorType *ot);
+void OBJECT_OT_clear_origin(wmOperatorType *ot);
#endif /* ED_OBJECT_INTERN_H */
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index af8818e58fd..8150e748086 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -60,6 +60,7 @@
/* ************************** registration **********************************/
+
void ED_operatortypes_object(void)
{
WM_operatortype_append(OBJECT_OT_toggle_editmode);
@@ -72,7 +73,10 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_de_select_all);
WM_operatortype_append(OBJECT_OT_select_by_type);
WM_operatortype_append(OBJECT_OT_select_by_layer);
-
+ WM_operatortype_append(OBJECT_OT_clear_location);
+ WM_operatortype_append(OBJECT_OT_clear_rotation);
+ WM_operatortype_append(OBJECT_OT_clear_scale);
+ WM_operatortype_append(OBJECT_OT_clear_origin);
}
void ED_keymap_object(wmWindowManager *wm)
@@ -95,6 +99,11 @@ void ED_keymap_object(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "OBJECT_OT_make_track", TKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "OBJECT_OT_clear_track", TKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_clear_location", GKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_clear_rotation", RKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "OBJECT_OT_clear_origin", OKEY, KM_PRESS, KM_ALT, 0);
+
// RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 6c4ccad6a33..05a038bf236 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1550,7 +1550,7 @@ void ED_keymap_screen(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE, 0, 0, 0); /* action tria */
WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE, 0, 0, 0); /* action tria */
- WM_keymap_verify_item(keymap, "SCREEN_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "SCREEN_OT_area_rip", RKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);