397
403
void ED_object_enter_editmode(bContext *C, int flag)
399
Scene *scene= CTX_data_scene(C);
405
Scene *scene = CTX_data_scene(C);
402
ScrArea *sa= CTX_wm_area(C);
408
ScrArea *sa = CTX_wm_area(C);
406
412
if (scene->id.lib) return;
408
if (sa && sa->spacetype==SPACE_VIEW3D)
409
v3d= sa->spacedata.first;
411
if ((flag & EM_IGNORE_LAYER)==0) {
412
base= CTX_data_active_base(C); /* active layer checked here for view3d */
414
if (base==NULL) return;
415
else if (v3d && (base->lay & v3d->lay)==0) return;
416
else if (!v3d && (base->lay & scene->lay)==0) return;
414
if (sa && sa->spacetype == SPACE_VIEW3D)
415
v3d = sa->spacedata.first;
417
if ((flag & EM_IGNORE_LAYER) == 0) {
418
base = CTX_data_active_base(C); /* active layer checked here for view3d */
420
if (base == NULL) return;
421
else if (v3d && (base->lay & v3d->lay) == 0) return;
422
else if (!v3d && (base->lay & scene->lay) == 0) return;
425
base = scene->basact;
422
428
if (ELEM3(NULL, base, base->object, base->object->data)) return;
424
430
ob = base->object;
432
/* this checks actual object->data, for cases when other scenes have it in editmode context */
433
if ( BKE_object_is_in_editmode(ob) )
426
if (object_data_is_libdata(ob)) {
436
if (BKE_object_obdata_is_libdata(ob)) {
431
441
if (flag & EM_WAITCURSOR) waitcursor(1);
433
443
ob->restore_mode = ob->mode;
435
445
/* note, when switching scenes the object can have editmode data but
436
446
* not be scene->obedit: bug 22954, this avoids calling self eternally */
437
if ((ob->restore_mode & OB_MODE_EDIT)==0)
447
if ((ob->restore_mode & OB_MODE_EDIT) == 0)
438
448
ED_object_toggle_modes(C, ob->mode);
440
ob->mode= OB_MODE_EDIT;
442
if (ob->type==OB_MESH) {
450
ob->mode = OB_MODE_EDIT;
452
if (ob->type == OB_MESH) {
445
455
scene->obedit = ob; /* context sees this */
447
457
EDBM_mesh_make(CTX_data_tool_settings(C), scene, ob);
451
461
/* order doesn't matter */
452
462
EDBM_mesh_normals_update(em);
453
463
BMEdit_RecalcTessellation(em);
455
465
BM_mesh_select_mode_flush(em->bm);
458
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene);
468
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MESH, scene);
460
else if (ob->type==OB_ARMATURE) {
461
bArmature *arm= base->object->data;
470
else if (ob->type == OB_ARMATURE) {
471
bArmature *arm = base->object->data;
462
472
if (!arm) return;
464
* The function object_data_is_libdata make a problem here, the
474
* The function BKE_object_obdata_is_libdata make a problem here, the
465
475
* check for ob->proxy return 0 and let blender enter to edit mode
466
476
* this causes a crash when you try leave the edit mode.
467
477
* The problem is that i can't remove the ob->proxy check from
468
* object_data_is_libdata that prevent the bugfix #6614, so
478
* BKE_object_obdata_is_libdata that prevent the bugfix #6614, so
469
479
* i add this little hack here.
471
481
if (arm->id.lib) {
477
487
ED_armature_to_edit(ob);
478
488
/* to ensure all goes in restposition and without striding */
479
DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA?
489
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* XXX: should this be OB_RECALC_DATA? */
481
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene);
491
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene);
483
else if (ob->type==OB_FONT) {
484
scene->obedit= ob; // XXX for context
493
else if (ob->type == OB_FONT) {
494
scene->obedit = ob; /* XXX for context */
486
496
make_editText(ob);
488
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_TEXT, scene);
498
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene);
490
else if (ob->type==OB_MBALL) {
491
scene->obedit= ob; // XXX for context
500
else if (ob->type == OB_MBALL) {
501
scene->obedit = ob; /* XXX for context */
493
503
make_editMball(ob);
495
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MBALL, scene);
505
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene);
497
else if (ob->type==OB_LATTICE) {
498
scene->obedit= ob; // XXX for context
507
else if (ob->type == OB_LATTICE) {
508
scene->obedit = ob; /* XXX for context */
500
510
make_editLatt(ob);
502
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_LATTICE, scene);
512
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene);
504
else if (ob->type==OB_SURF || ob->type==OB_CURVE) {
506
scene->obedit= ob; // XXX for context
514
else if (ob->type == OB_SURF || ob->type == OB_CURVE) {
516
scene->obedit = ob; /* XXX for context */
507
517
make_editNurb(ob);
509
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_CURVE, scene);
519
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene);
513
523
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
516
scene->obedit= NULL; // XXX for context
526
scene->obedit = NULL; /* XXX for context */
517
527
ob->mode &= ~OB_MODE_EDIT;
518
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene);
528
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene);
521
531
if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
522
532
if (flag & EM_WAITCURSOR) waitcursor(0);
612
623
//XXX no longer used - to be removed - replaced by game_properties_copy_exec
618
prop= ob->prop.first;
629
prop = ob->prop.first;
624
str= MEM_callocN(50 + 33*tot, "copymenu prop");
635
str = MEM_callocN(50 + 33 * tot, "copymenu prop");
627
638
strcpy(str, "Copy Property %t|Replace All|Merge All|%l");
629
640
strcpy(str, "Copy Property %t|Clear All (no properties on active)");
632
prop= ob->prop.first;
643
prop = ob->prop.first;
635
646
strcat(str, "|");
636
647
strcat(str, prop->name);
642
if ( nr==1 || nr==2 ) {
643
for (base= FIRSTBASE; base; base= base->next) {
644
if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
645
if (nr==1) { /* replace */
646
copy_properties( &base->object->prop, &ob->prop );
653
if (nr == 1 || nr == 2) {
654
for (base = FIRSTBASE; base; base = base->next) {
655
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
656
if (nr == 1) { /* replace */
657
BKE_bproperty_copy_list(&base->object->prop, &ob->prop);
649
for (prop = ob->prop.first; prop; prop= prop->next ) {
650
set_ob_property(base->object, prop);
660
for (prop = ob->prop.first; prop; prop = prop->next) {
661
BKE_bproperty_object_set(base->object, prop);
657
prop = BLI_findlink(&ob->prop, nr-4); /* account for first 3 menu items & menu index starting at 1*/
668
prop = BLI_findlink(&ob->prop, nr - 4); /* account for first 3 menu items & menu index starting at 1*/
660
for (base= FIRSTBASE; base; base= base->next) {
661
if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
662
set_ob_property(base->object, prop);
671
for (base = FIRSTBASE; base; base = base->next) {
672
if ((base != BASACT) && (TESTBASELIB(v3d, base))) {
673
BKE_bproperty_object_set(base->object, prop);
706
717
/* both pointers should exist */
707
718
static void copy_texture_space(Object *to, Object *ob)
709
float *poin1= NULL, *poin2= NULL;
720
float *poin1 = NULL, *poin2 = NULL;
712
if (ob->type==OB_MESH) {
713
texflag= ((Mesh *)ob->data)->texflag;
714
poin2= ((Mesh *)ob->data)->loc;
723
if (ob->type == OB_MESH) {
724
texflag = ((Mesh *)ob->data)->texflag;
725
poin2 = ((Mesh *)ob->data)->loc;
716
727
else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
717
texflag= ((Curve *)ob->data)->texflag;
718
poin2= ((Curve *)ob->data)->loc;
728
texflag = ((Curve *)ob->data)->texflag;
729
poin2 = ((Curve *)ob->data)->loc;
720
else if (ob->type==OB_MBALL) {
721
texflag= ((MetaBall *)ob->data)->texflag;
722
poin2= ((MetaBall *)ob->data)->loc;
731
else if (ob->type == OB_MBALL) {
732
texflag = ((MetaBall *)ob->data)->texflag;
733
poin2 = ((MetaBall *)ob->data)->loc;
727
if (to->type==OB_MESH) {
728
((Mesh *)to->data)->texflag= texflag;
729
poin1= ((Mesh *)to->data)->loc;
738
if (to->type == OB_MESH) {
739
((Mesh *)to->data)->texflag = texflag;
740
poin1 = ((Mesh *)to->data)->loc;
731
742
else if (ELEM3(to->type, OB_CURVE, OB_SURF, OB_FONT)) {
732
((Curve *)to->data)->texflag= texflag;
733
poin1= ((Curve *)to->data)->loc;
743
((Curve *)to->data)->texflag = texflag;
744
poin1 = ((Curve *)to->data)->loc;
735
else if (to->type==OB_MBALL) {
736
((MetaBall *)to->data)->texflag= texflag;
737
poin1= ((MetaBall *)to->data)->loc;
746
else if (to->type == OB_MBALL) {
747
((MetaBall *)to->data)->texflag = texflag;
748
poin1 = ((MetaBall *)to->data)->loc;
742
memcpy(poin1, poin2, 9*sizeof(float)); /* this was noted in DNA_mesh, curve, mball */
753
memcpy(poin1, poin2, 9 * sizeof(float)); /* this was noted in DNA_mesh, curve, mball */
744
if (to->type==OB_MESH) {
755
if (to->type == OB_MESH) {
747
758
else if (to->type == OB_MBALL) {
759
BKE_mball_texspace_calc(to);
751
tex_space_curve(to->data);
762
BKE_curve_texspace_calc(to->data);
763
int do_scene_sort= 0;
774
int do_scene_sort = FALSE;
765
776
if (scene->id.lib) return;
767
if (!(ob=OBACT)) return;
778
if (!(ob = OBACT)) return;
769
780
if (scene->obedit) { // XXX get from context
770
781
/* obedit_copymenu(); */
774
785
copymenu_properties(scene, v3d, ob);
777
else if (event==10) {
788
else if (event == 10) {
778
789
copymenu_logicbricks(scene, v3d, ob);
781
else if (event==24) {
782
/* moved to object_link_modifiers */
792
else if (event == 24) {
793
/* moved to BKE_object_link_modifiers */
783
794
/* copymenu_modifiers(bmain, scene, v3d, ob); */
787
for (base= FIRSTBASE; base; base= base->next) {
798
for (base = FIRSTBASE; base; base = base->next) {
788
799
if (base != BASACT) {
789
800
if (TESTBASELIB(v3d, base)) {
790
801
base->object->recalc |= OB_RECALC_OB;
792
if (event==1) { /* loc */
803
if (event == 1) { /* loc */
793
804
copy_v3_v3(base->object->loc, ob->loc);
794
805
copy_v3_v3(base->object->dloc, ob->dloc);
796
else if (event==2) { /* rot */
807
else if (event == 2) { /* rot */
797
808
copy_v3_v3(base->object->rot, ob->rot);
798
809
copy_v3_v3(base->object->drot, ob->drot);
800
811
copy_qt_qt(base->object->quat, ob->quat);
801
812
copy_qt_qt(base->object->dquat, ob->dquat);
803
else if (event==3) { /* size */
814
else if (event == 3) { /* size */
804
815
copy_v3_v3(base->object->size, ob->size);
805
816
copy_v3_v3(base->object->dscale, ob->dscale);
807
else if (event==4) { /* drawtype */
808
base->object->dt= ob->dt;
809
base->object->dtx= ob->dtx;
810
base->object->empty_drawtype= ob->empty_drawtype;
811
base->object->empty_drawsize= ob->empty_drawsize;
813
else if (event==5) { /* time offs */
814
base->object->sf= ob->sf;
816
else if (event==6) { /* dupli */
817
base->object->dupon= ob->dupon;
818
base->object->dupoff= ob->dupoff;
819
base->object->dupsta= ob->dupsta;
820
base->object->dupend= ob->dupend;
818
else if (event == 4) { /* drawtype */
819
base->object->dt = ob->dt;
820
base->object->dtx = ob->dtx;
821
base->object->empty_drawtype = ob->empty_drawtype;
822
base->object->empty_drawsize = ob->empty_drawsize;
824
else if (event == 5) { /* time offs */
825
base->object->sf = ob->sf;
827
else if (event == 6) { /* dupli */
828
base->object->dupon = ob->dupon;
829
base->object->dupoff = ob->dupoff;
830
base->object->dupsta = ob->dupsta;
831
base->object->dupend = ob->dupend;
822
833
base->object->transflag &= ~OB_DUPLI;
823
834
base->object->transflag |= (ob->transflag & OB_DUPLI);
825
base->object->dup_group= ob->dup_group;
836
base->object->dup_group = ob->dup_group;
826
837
if (ob->dup_group)
827
838
id_lib_extern(&ob->dup_group->id);
829
else if (event==7) { /* mass */
830
base->object->mass= ob->mass;
832
else if (event==8) { /* damping */
833
base->object->damping= ob->damping;
834
base->object->rdamping= ob->rdamping;
836
else if (event==11) { /* all physical attributes */
840
else if (event == 7) { /* mass */
841
base->object->mass = ob->mass;
843
else if (event == 8) { /* damping */
844
base->object->damping = ob->damping;
845
base->object->rdamping = ob->rdamping;
847
else if (event == 11) { /* all physical attributes */
837
848
base->object->gameflag = ob->gameflag;
838
849
base->object->inertia = ob->inertia;
839
850
base->object->formfactor = ob->formfactor;
840
base->object->damping= ob->damping;
841
base->object->rdamping= ob->rdamping;
842
base->object->min_vel= ob->min_vel;
843
base->object->max_vel= ob->max_vel;
851
base->object->damping = ob->damping;
852
base->object->rdamping = ob->rdamping;
853
base->object->min_vel = ob->min_vel;
854
base->object->max_vel = ob->max_vel;
844
855
if (ob->gameflag & OB_BOUNDS) {
845
856
base->object->collision_boundtype = ob->collision_boundtype;
847
base->object->margin= ob->margin;
848
base->object->bsoft= copy_bulletsoftbody(ob->bsoft);
858
base->object->margin = ob->margin;
859
base->object->bsoft = copy_bulletsoftbody(ob->bsoft);
851
else if (event==17) { /* tex space */
862
else if (event == 17) { /* tex space */
852
863
copy_texture_space(base->object, ob);
854
else if (event==18) { /* font settings */
865
else if (event == 18) { /* font settings */
856
if (base->object->type==ob->type) {
858
cu1= base->object->data;
860
cu1->spacemode= cu->spacemode;
861
cu1->spacing= cu->spacing;
862
cu1->linedist= cu->linedist;
863
cu1->shear= cu->shear;
864
cu1->fsize= cu->fsize;
867
cu1->textoncurve= cu->textoncurve;
868
cu1->wordspace= cu->wordspace;
869
cu1->ulpos= cu->ulpos;
870
cu1->ulheight= cu->ulheight;
867
if (base->object->type == ob->type) {
869
cu1 = base->object->data;
871
cu1->spacemode = cu->spacemode;
872
cu1->spacing = cu->spacing;
873
cu1->linedist = cu->linedist;
874
cu1->shear = cu->shear;
875
cu1->fsize = cu->fsize;
878
cu1->textoncurve = cu->textoncurve;
879
cu1->wordspace = cu->wordspace;
880
cu1->ulpos = cu->ulpos;
881
cu1->ulheight = cu->ulheight;
871
882
if (cu1->vfont) cu1->vfont->id.us--;
872
cu1->vfont= cu->vfont;
883
cu1->vfont = cu->vfont;
873
884
id_us_plus((ID *)cu1->vfont);
874
885
if (cu1->vfontb) cu1->vfontb->id.us--;
875
cu1->vfontb= cu->vfontb;
886
cu1->vfontb = cu->vfontb;
876
887
id_us_plus((ID *)cu1->vfontb);
877
888
if (cu1->vfonti) cu1->vfonti->id.us--;
878
cu1->vfonti= cu->vfonti;
889
cu1->vfonti = cu->vfonti;
879
890
id_us_plus((ID *)cu1->vfonti);
880
891
if (cu1->vfontbi) cu1->vfontbi->id.us--;
881
cu1->vfontbi= cu->vfontbi;
882
id_us_plus((ID *)cu1->vfontbi);
892
cu1->vfontbi = cu->vfontbi;
893
id_us_plus((ID *)cu1->vfontbi);
884
BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */
895
BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */
887
898
BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family));
889
900
base->object->recalc |= OB_RECALC_DATA;
892
else if (event==19) { /* bevel settings */
903
else if (event == 19) { /* bevel settings */
894
905
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
896
cu1= base->object->data;
907
cu1 = base->object->data;
898
cu1->bevobj= cu->bevobj;
899
cu1->taperobj= cu->taperobj;
900
cu1->width= cu->width;
901
cu1->bevresol= cu->bevresol;
909
cu1->bevobj = cu->bevobj;
910
cu1->taperobj = cu->taperobj;
911
cu1->width = cu->width;
912
cu1->bevresol = cu->bevresol;
913
cu1->ext1 = cu->ext1;
914
cu1->ext2 = cu->ext2;
905
916
base->object->recalc |= OB_RECALC_DATA;
908
else if (event==25) { /* curve resolution */
919
else if (event == 25) { /* curve resolution */
910
921
if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
912
cu1= base->object->data;
914
cu1->resolu= cu->resolu;
915
cu1->resolu_ren= cu->resolu_ren;
923
cu1 = base->object->data;
925
cu1->resolu = cu->resolu;
926
cu1->resolu_ren = cu->resolu_ren;
928
nu = cu1->nurb.first;
920
nu->resolu= cu1->resolu;
931
nu->resolu = cu1->resolu;
924
935
base->object->recalc |= OB_RECALC_DATA;
927
else if (event==21) {
928
if (base->object->type==OB_MESH) {
938
else if (event == 21) {
939
if (base->object->type == OB_MESH) {
929
940
ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf);
944
else if (event==22) {
955
else if (event == 22) {
945
956
/* Copy the constraint channels over */
946
copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
957
BKE_copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
959
do_scene_sort = TRUE;
950
else if (event==23) {
951
base->object->softflag= ob->softflag;
961
else if (event == 23) {
962
base->object->softflag = ob->softflag;
952
963
if (base->object->soft) sbFree(base->object->soft);
954
base->object->soft= copy_softbody(ob->soft);
965
base->object->soft = copy_softbody(ob->soft, FALSE);
956
967
if (!modifiers_findByType(base->object, eModifierType_Softbody)) {
957
968
BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody));
960
else if (event==26) {
971
else if (event == 26) {
961
972
#if 0 // XXX old animation system
962
973
copy_nlastrips(&base->object->nlastrips, &ob->nlastrips);
963
974
#endif // XXX old animation system
965
else if (event==27) { /* autosmooth */
966
if (base->object->type==OB_MESH) {
968
Mesh *cme= base->object->data;
969
cme->smoothresh= me->smoothresh;
976
else if (event == 27) { /* autosmooth */
977
if (base->object->type == OB_MESH) {
979
Mesh *cme = base->object->data;
980
cme->smoothresh = me->smoothresh;
970
981
if (me->flag & ME_AUTOSMOOTH)
971
982
cme->flag |= ME_AUTOSMOOTH;
973
984
cme->flag &= ~ME_AUTOSMOOTH;
976
else if (event==28) { /* UV orco */
987
else if (event == 28) { /* UV orco */
977
988
if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
979
cu1= base->object->data;
990
cu1 = base->object->data;
981
992
if (cu->flag & CU_UV_ORCO)
982
993
cu1->flag |= CU_UV_ORCO;
984
995
cu1->flag &= ~CU_UV_ORCO;
987
else if (event==29) { /* protected bits */
988
base->object->protectflag= ob->protectflag;
990
else if (event==30) { /* index object */
991
base->object->index= ob->index;
993
else if (event==31) { /* object color */
998
else if (event == 29) { /* protected bits */
999
base->object->protectflag = ob->protectflag;
1001
else if (event == 30) { /* index object */
1002
base->object->index = ob->index;
1004
else if (event == 31) { /* object color */
994
1005
copy_v4_v4(base->object->col, ob->col);
1027
"Copy Attributes %t|Location%x1|Rotation%x2|Size%x3|Draw Options%x4|"
1028
"Time Offset%x5|Dupli%x6|Object Color%x31|%l|Mass%x7|Damping%x8|All Physical Attributes%x11|Properties%x9|"
1029
"Logic Bricks%x10|Protected Transform%x29|%l");
1031
strcat (str, "|Object Constraints%x22");
1032
strcat (str, "|NLA Strips%x26");
1034
// XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
1035
// strcat(str, "|Texture Space%x17");
1038
if (ob->type == OB_FONT) strcat(str, "|Font Settings%x18|Bevel Settings%x19");
1039
if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28");
1038
"Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|"
1039
"Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|"
1040
"Logic Bricks %x10|Protected Transform %x29|%l");
1042
strcat(str, "|Object Constraints %x22");
1043
strcat(str, "|NLA Strips %x26");
1045
/* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */
1046
/* strcat(str, "|Texture Space %x17"); */
1049
if (ob->type == OB_FONT) strcat(str, "|Font Settings %x18|Bevel Settings %x19");
1050
if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings %x19|UV Orco %x28");
1041
1052
if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
1042
strcat(str, "|Curve Resolution%x25");
1045
if (ob->type==OB_MESH) {
1046
strcat(str, "|Subsurf Settings%x21|AutoSmooth%x27");
1049
if (ob->soft) strcat(str, "|Soft Body Settings%x23");
1051
strcat(str, "|Pass Index%x30");
1053
if (ob->type==OB_MESH || ob->type==OB_CURVE || ob->type==OB_LATTICE || ob->type==OB_SURF) {
1054
strcat(str, "|Modifiers ...%x24");
1057
event= pupmenu(str);
1058
if (event<= 0) return;
1053
strcat(str, "|Curve Resolution %x25");
1056
if (ob->type == OB_MESH) {
1057
strcat(str, "|Subsurf Settings %x21|AutoSmooth %x27");
1060
if (ob->soft) strcat(str, "|Soft Body Settings %x23");
1062
strcat(str, "|Pass Index %x30");
1064
if (ob->type == OB_MESH || ob->type == OB_CURVE || ob->type == OB_LATTICE || ob->type == OB_SURF) {
1065
strcat(str, "|Modifiers ... %x24");
1068
event = pupmenu(str);
1069
if (event <= 0) return;
1060
1071
copy_attr(bmain, scene, v3d, event);
1186
1197
ot->poll = ED_operator_object_active_editable;
1189
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1200
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1191
1202
/* properties */
1192
1203
RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
1193
"First frame to calculate object paths on", MINFRAME, MAXFRAME/2.0);
1204
"First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
1194
1205
RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
1195
"Last frame to calculate object paths on", MINFRAME, MAXFRAME/2.0);
1200
/* for the object with pose/action: clear path curves for selected bones only */
1206
"Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
1211
static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
1213
Scene *scene = CTX_data_scene(C);
1216
return OPERATOR_CANCELLED;
1218
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
1219
ED_objects_recalculate_paths(C, scene);
1221
/* notifiers for updates */
1222
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
1224
return OPERATOR_FINISHED;
1227
void OBJECT_OT_paths_update(wmOperatorType *ot)
1230
ot->name = "Update Object Paths";
1231
ot->idname = "OBJECT_OT_paths_update";
1232
ot->description = "Recalculate paths for selected objects";
1235
ot->exec = object_update_paths_exec;
1236
ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */
1239
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1244
/* Clear motion paths for selected objects only */
1201
1245
void ED_objects_clear_paths(bContext *C)
1203
1247
/* loop over objects in scene */
1204
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
1248
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
1206
1250
if (ob->mpath) {
1207
1251
animviz_free_motionpath(ob->mpath);
1209
1253
ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
1249
int clear= (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0);
1252
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
1254
if (ob->type==OB_MESH) {
1255
mesh_set_smooth_flag(ob, !clear);
1293
int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0);
1296
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
1299
if (ob->type == OB_MESH) {
1300
BKE_mesh_smooth_flag_set(ob, !clear);
1257
1302
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
1258
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
1303
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
1262
1307
else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
1265
for (nu=cu->nurb.first; nu; nu=nu->next) {
1310
for (nu = cu->nurb.first; nu; nu = nu->next) {
1266
1311
if (!clear) nu->flag |= ME_SMOOTH;
1267
1312
else nu->flag &= ~ME_SMOOTH;
1270
1315
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
1271
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
1316
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
1278
return (done)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
1323
return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1281
1326
static int shade_poll(bContext *C)
1325
1370
float x, y, space;
1326
1371
int a, b, done;
1328
if (scene->obedit) return; // XXX get from context
1373
if (scene->obedit) return; // XXX get from context
1329
1374
if (scene->id.lib) return;
1331
for (base= FIRSTBASE; base; base= base->next) {
1376
for (base = FIRSTBASE; base; base = base->next) {
1332
1377
if (TESTBASELIB(v3d, base)) {
1336
for (a=1; a<=ob->totcol; a++) {
1337
ma= give_current_material(ob, a);
1381
for (a = 1; a <= ob->totcol; a++) {
1382
ma = give_current_material(ob, a);
1339
for (b=0; b<MAX_MTEX; b++) {
1384
for (b = 0; b < MAX_MTEX; b++) {
1340
1385
if (ma->mtex[b] && ma->mtex[b]->tex) {
1341
tex= ma->mtex[b]->tex;
1342
if (tex->type==TEX_IMAGE && tex->ima) {
1343
ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, NULL);
1386
tex = ma->mtex[b]->tex;
1387
if (tex->type == TEX_IMAGE && tex->ima) {
1388
ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL);
1345
1390
/* texturespace */
1347
if (ob->type==OB_MESH) {
1392
if (ob->type == OB_MESH) {
1349
mesh_get_texspace(ob->data, NULL, NULL, size);
1350
space= size[0]/size[1];
1394
BKE_mesh_texspace_get(ob->data, NULL, NULL, size);
1395
space = size[0] / size[1];
1352
1397
else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
1353
Curve *cu= ob->data;
1354
space= cu->size[0]/cu->size[1];
1398
Curve *cu = ob->data;
1399
space = cu->size[0] / cu->size[1];
1360
if (x>y) ob->size[0]= ob->size[1]*x/y;
1361
else ob->size[1]= ob->size[0]*y/x;
1364
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
1402
x = ibuf->x / space;
1405
if (x > y) ob->size[0] = ob->size[1] * x / y;
1406
else ob->size[1] = ob->size[0] * y / x;
1409
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
1411
BKE_image_release_ibuf(tex->ima, ibuf, NULL);
1367
1414
if (done) break;
1378
1425
static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
1380
1427
EnumPropertyItem *input = object_mode_items;
1381
EnumPropertyItem *item= NULL;
1428
EnumPropertyItem *item = NULL;
1385
1432
if (!C) /* needed for docs */
1386
1433
return object_mode_items;
1388
1437
ob = CTX_data_active_object(C);
1389
1438
while (ob && input->identifier) {
1390
if ((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) ||
1391
(ob->type == OB_CURVE) || (ob->type == OB_SURF) ||
1392
(ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) ||
1393
(input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
1394
(input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) ||
1395
((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT ||
1396
input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) ||
1397
(input->value == OB_MODE_OBJECT))
1439
if ((input->value == OB_MODE_EDIT && OB_TYPE_SUPPORT_EDITMODE(ob->type)) ||
1440
(input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
1441
(input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) ||
1442
((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT ||
1443
input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) ||
1444
(input->value == OB_MODE_OBJECT))
1398
1446
RNA_enum_item_add(&item, &totitem, input);
1402
1451
RNA_enum_item_end(&item, &totitem);
1611
1660
ot->poll = ED_operator_object_active_editable;
1614
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1663
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1616
1665
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to remove ", 0, INT_MAX);
1619
#define COPY_PROPERTIES_REPLACE 1
1620
#define COPY_PROPERTIES_MERGE 2
1621
#define COPY_PROPERTIES_COPY 3
1668
#define COPY_PROPERTIES_REPLACE 1
1669
#define COPY_PROPERTIES_MERGE 2
1670
#define COPY_PROPERTIES_COPY 3
1623
static EnumPropertyItem game_properties_copy_operations[] ={
1672
static EnumPropertyItem game_properties_copy_operations[] = {
1624
1673
{COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""},
1625
1674
{COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""},
1626
1675
{COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""},
1627
{0, NULL, 0, NULL, NULL}};
1629
static EnumPropertyItem gameprops_items[]= {
1630
{0, NULL, 0, NULL, NULL}};
1676
{0, NULL, 0, NULL, NULL}
1632
1679
static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
1634
Object *ob= ED_object_active_context(C);
1681
Object *ob = ED_object_active_context(C);
1635
1682
EnumPropertyItem tmp = {0, "", 0, "", ""};
1636
EnumPropertyItem *item= NULL;
1683
EnumPropertyItem *item = NULL;
1637
1684
bProperty *prop;
1641
return gameprops_items;
1688
return DummyRNA_NULL_items;
1643
for (a=1, prop= ob->prop.first; prop; prop=prop->next, a++) {
1645
tmp.identifier= prop->name;
1646
tmp.name= prop->name;
1690
for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) {
1692
tmp.identifier = prop->name;
1693
tmp.name = prop->name;
1647
1694
RNA_enum_item_add(&item, &totitem, &tmp);
1650
1697
RNA_enum_item_end(&item, &totitem);
1656
1703
static int game_property_copy_exec(bContext *C, wmOperator *op)
1658
Object *ob=ED_object_active_context(C);
1705
Object *ob = ED_object_active_context(C);
1659
1706
bProperty *prop;
1660
1707
int type = RNA_enum_get(op->ptr, "operation");
1661
int propid= RNA_enum_get(op->ptr, "property");
1708
int propid = RNA_enum_get(op->ptr, "property");
1663
1710
if (propid > 0) { /* copy */
1664
prop = BLI_findlink(&ob->prop, propid-1);
1711
prop = BLI_findlink(&ob->prop, propid - 1);
1667
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
1714
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
1668
1716
if (ob != ob_iter)
1669
set_ob_property(ob_iter, prop);
1717
BKE_bproperty_object_set(ob_iter, prop);
1670
1718
} CTX_DATA_END;
1675
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
1723
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
1676
1725
if (ob != ob_iter) {
1677
if (type == COPY_PROPERTIES_REPLACE)
1678
copy_properties(&ob_iter->prop, &ob->prop);
1680
/* merge - the default when calling with no argument */
1682
for (prop = ob->prop.first; prop; prop= prop->next)
1683
set_ob_property(ob_iter, prop);
1726
if (type == COPY_PROPERTIES_REPLACE) {
1727
BKE_bproperty_copy_list(&ob_iter->prop, &ob->prop);
1730
/* merge - the default when calling with no argument */
1731
for (prop = ob->prop.first; prop; prop = prop->next) {
1732
BKE_bproperty_object_set(ob_iter, prop);
1695
1746
/* identifiers */
1696
1747
ot->name = "Copy Game Property";
1697
1748
ot->idname = "OBJECT_OT_game_property_copy";
1749
ot->description = "Copy/merge/replace a game property from active object to all selected objects";
1699
1751
/* api callbacks */
1700
1752
ot->exec = game_property_copy_exec;
1701
1753
ot->poll = ED_operator_object_active_editable;
1704
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1756
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1706
1758
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
1707
prop=RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
1759
prop = RNA_def_enum(ot->srna, "property", DummyRNA_NULL_items, 0, "Property", "Properties to copy");
1760
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
1708
1761
RNA_def_enum_funcs(prop, gameprops_itemf);
1709
1762
ot->prop = prop;
1712
1765
static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
1714
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
1715
free_properties(&ob_iter->prop);
1767
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
1769
BKE_bproperty_free_list(&ob_iter->prop);
1722
1776
void OBJECT_OT_game_property_clear(wmOperatorType *ot)
1724
1778
/* identifiers */
1725
ot->name = "Clear Game Property";
1779
ot->name = "Clear Game Properties";
1726
1780
ot->idname = "OBJECT_OT_game_property_clear";
1781
ot->description = "Remove all game properties from all selected objects";
1728
1783
/* api callbacks */
1729
1784
ot->exec = game_property_clear_exec;
1730
1785
ot->poll = ED_operator_object_active_editable;
1733
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
1788
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
1736
1791
/************************ Copy Logic Bricks ***********************/
1738
1793
static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
1740
Object *ob=ED_object_active_context(C);
1795
Object *ob = ED_object_active_context(C);
1742
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
1797
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
1743
1799
if (ob != ob_iter) {
1744
1800
/* first: free all logic */
1745
free_sensors(&ob_iter->sensors);
1801
free_sensors(&ob_iter->sensors);
1746
1802
unlink_controllers(&ob_iter->controllers);
1747
1803
free_controllers(&ob_iter->controllers);
1748
1804
unlink_actuators(&ob_iter->actuators);