#include "BKE_material.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
+#include "BKE_multires.h"
#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "blendef.h"
#include "butspace.h"
-#include "multires.h"
#include "BIF_transform.h"
#include "BIF_poseobject.h"
if(ob->type==OB_MESH) {
me= get_mesh(ob);
if( me==0 ) return;
- if(me->pv) sculptmode_pmv_off(me);
+ if(me->pv) mesh_pmv_off(ob, me);
ok= 1;
G.obedit= ob;
make_editMesh();
return;
if(G.scene->selectmode & SCE_SELECT_POINT)
- nr= pupmenu("Specials%t|Rekey%x1|Subdivide%x2|Select First%x3|Select Last%x4");
+ nr= pupmenu("Specials%t|Rekey%x1|Subdivide%x2|Select First%x3|Select Last%x4|Remove Doubles%x5");
else
- nr= pupmenu("Specials%t|Rekey%x1");
+ nr= pupmenu("Specials%t|Rekey%x1|Remove Doubles%x5");
switch(nr) {
case 1:
case 4:
PE_select_tip();
break;
+ case 5:
+ PE_remove_doubles();
+ break;
}
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
BIF_undo_push("Create links");
}
-void apply_object()
+void apply_objects_locrot( void )
{
Base *base, *basact;
Object *ob;
+ bArmature *arm;
Mesh *me;
Curve *cu;
Nurb *nu;
BezTriple *bezt;
MVert *mvert;
float mat[3][3];
- int a;
-
- if(G.scene->id.lib) return;
- if(G.obedit) return;
- basact= BASACT;
+ int a, change = 0;
- if(G.qual & LR_SHIFTKEY) {
- ob= OBACT;
- if(ob==0) return;
-
- if(ob->transflag & OB_DUPLI) {
- make_duplilist_real();
- }
- else {
- if(okee("Apply deformation")) {
- object_apply_deform(ob);
- BIF_undo_push("Apply deformation");
- }
- }
- allqueue(REDRAWVIEW3D, 0);
-
- return;
- }
-
- if(okee("Apply scale and rotation")==0) return;
-
- base= FIRSTBASE;
- while(base) {
+ /* first check if we can execute */
+ for (base= FIRSTBASE; base; base= base->next) {
if TESTBASELIB(base) {
ob= base->object;
-
if(ob->type==OB_MESH) {
- object_to_mat3(ob, mat);
me= ob->data;
if(me->id.us>1) {
- error("Can't apply to a multi user mesh");
+ error("Can't apply to a multi user mesh, doing nothing.");
return;
}
if(me->key) {
- error("Can't apply to a mesh with vertex keys");
+ error("Can't apply to a mesh with vertex keys, doing nothing.");
return;
}
+ }
+ else if (ob->type==OB_ARMATURE) {
+ arm= ob->data;
+
+ if(arm->id.us>1) {
+ error("Can't apply to a multi user armature, doing nothing.");
+ return;
+ }
+ }
+ else if ELEM(ob->type, OB_CURVE, OB_SURF) {
+ cu= ob->data;
+
+ if(cu->id.us>1) {
+ error("Can't apply to a multi user curve, doing nothing.");
+ return;
+ }
+ if(cu->key) {
+ error("Can't apply to a curve with vertex keys, doing nothing.");
+ return;
+ }
+ }
+ }
+ }
+
+ /* now execute */
+ basact= BASACT;
+ base= FIRSTBASE;
+ for (base= FIRSTBASE; base; base= base->next) {
+ if TESTBASELIB(base) {
+ ob= base->object;
+
+ if(ob->type==OB_MESH) {
+ object_to_mat3(ob, mat);
+ me= ob->data;
+
+ /* see checks above */
mvert= me->mvert;
for(a=0; a<me->totvert; a++, mvert++) {
enter_editmode(EM_WAITCURSOR);
BIF_undo_push("Applied object"); /* editmode undo itself */
exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
- BASACT= basact;
+ BASACT= basact;
+ change = 1;
}
- else if (ob->type==OB_ARMATURE){
- bArmature *arm;
-
+ else if (ob->type==OB_ARMATURE) {
object_to_mat3(ob, mat);
arm= ob->data;
- if(arm->id.us>1) {
- error("Can't apply to a multi user armature");
- return;
- }
-
- apply_rot_armature (ob, mat);
+
+ /* see checks above */
+ apply_rot_armature(ob, mat);
+
/* Reset the object's transforms */
ob->size[0]= ob->size[1]= ob->size[2]= 1.0;
ob->rot[0]= ob->rot[1]= ob->rot[2]= 0.0;
QuatOne(ob->quat);
where_is_object(ob);
+
+ change = 1;
}
else if ELEM(ob->type, OB_CURVE, OB_SURF) {
float scale;
scale = Mat3ToScalef(mat);
cu= ob->data;
- if(cu->id.us>1) {
- error("Can't apply to a multi user curve");
- return;
- }
- if(cu->key) {
- error("Can't apply to a curve with vertex keys");
- return;
- }
+ /* see checks above */
nu= cu->nurb.first;
while(nu) {
BIF_undo_push("Applied object"); /* editmode undo itself */
exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */
BASACT= basact;
+
+ change = 1;
}
}
- base= base->next;
}
+ if (change) {
+ allqueue(REDRAWVIEW3D, 0);
+ BIF_undo_push("Apply Objects Scale & Rotation");
+ }
+}
+
+void apply_objects_visual_tx( void )
+{
+ Base *base;
+ Object *ob;
+ int change = 0;
- allqueue(REDRAWVIEW3D, 0);
- BIF_undo_push("Apply object");
+ for (base= FIRSTBASE; base; base= base->next) {
+ if TESTBASELIB(base) {
+ ob= base->object;
+ where_is_object(ob);
+ VECCOPY(ob->loc, ob->obmat[3]);
+ Mat4ToSize(ob->obmat, ob->size);
+ Mat4ToEul(ob->obmat, ob->rot);
+
+ where_is_object(ob);
+
+ change = 1;
+ }
+ }
+ if (change) {
+ allqueue(REDRAWVIEW3D, 0);
+ BIF_undo_push("Apply Objects Visual Transform");
+ }
+}
+
+void apply_object( void )
+{
+ Object *ob;
+ int evt;
+ if(G.scene->id.lib) return;
+ if(G.obedit) return;
+
+ if(G.qual & LR_SHIFTKEY) {
+ ob= OBACT;
+ if(ob==0) return;
+
+ if(ob->transflag & OB_DUPLI) {
+ make_duplilist_real();
+ }
+ else {
+ if(okee("Apply deformation")) {
+ object_apply_deform(ob);
+ BIF_undo_push("Apply deformation");
+ }
+ }
+ allqueue(REDRAWVIEW3D, 0);
+
+ } else {
+
+ evt = pupmenu("Apply Object%t|Scale and Rotation to ObData|Visual Transform to Objects Loc/Scale/Rot");
+ if (evt==-1) return;
+
+ if (evt==1) {
+ apply_objects_locrot();
+ } else if (evt==2) {
+ apply_objects_visual_tx();
+ }
+ }
}