diff options
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r-- | source/blender/editors/object/object_add.c | 97 |
1 files changed, 75 insertions, 22 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index cd42661f320..4660d38a208 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -35,15 +35,18 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" +#include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" #include "DNA_object_fluidsim.h" #include "DNA_object_force.h" #include "DNA_scene_types.h" +#include "DNA_speaker_types.h" #include "DNA_vfont_types.h" #include "BLI_math.h" @@ -63,15 +66,18 @@ #include "BKE_group.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_key.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mball.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_nla.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_report.h" #include "BKE_sca.h" +#include "BKE_speaker.h" #include "BKE_texture.h" #include "RNA_access.h" @@ -764,6 +770,61 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } +static int object_speaker_add_exec(bContext *C, wmOperator *op) +{ + Object *ob; + int enter_editmode; + unsigned int layer; + float loc[3], rot[3]; + Scene *scene = CTX_data_scene(C); + + object_add_generic_invoke_options(C, op); + if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer)) + return OPERATOR_CANCELLED; + + ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer); + + /* to make it easier to start using this immediately in NLA, a default sound clip is created + * ready to be moved around to retime the sound and/or make new sound clips + */ + { + /* create new data for NLA hierarchy */ + AnimData *adt = BKE_id_add_animdata(&ob->id); + NlaTrack *nlt = add_nlatrack(adt, NULL); + NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data); + strip->start = CFRA; + strip->end += strip->start; + + /* hook them up */ + BKE_nlatrack_add_strip(nlt, strip); + + /* auto-name the strip, and give the track an interesting name */ + strcpy(nlt->name, "SoundTrack"); + BKE_nlastrip_validate_name(adt, strip); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + } + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_speaker_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Speaker"; + ot->description = "Add a speaker object to the scene"; + ot->idname= "OBJECT_OT_speaker_add"; + + /* api callbacks */ + ot->exec= object_speaker_add_exec; + ot->poll= ED_operator_objectmode; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ED_object_add_generic_props(ot, TRUE); +} + /* only used as menu */ void OBJECT_OT_group_instance_add(wmOperatorType *ot) { @@ -1437,28 +1498,6 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } /* duplicates using userflags */ -#if 0 // XXX old animation system - if(dupflag & USER_DUP_IPO) { - bConstraintChannel *chan; - id= (ID *)obn->ipo; - - if(id) { - ID_NEW_US( obn->ipo) - else obn->ipo= copy_ipo(obn->ipo); - id->us--; - } - /* Handle constraint ipos */ - for (chan=obn->constraintChannels.first; chan; chan=chan->next){ - id= (ID *)chan->ipo; - if(id) { - ID_NEW_US( chan->ipo) - else chan->ipo= copy_ipo(chan->ipo); - id->us--; - } - } - } -#endif // XXX old animation system - if(dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&obn->id); } @@ -1600,12 +1639,26 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id->us--; } break; + case OB_SPEAKER: + if(dupflag!=0) { + ID_NEW_US2(obn->data ) + else { + obn->data= copy_speaker(obn->data); + didit= 1; + } + id->us--; + } + break; + } /* check if obdata is copied */ if(didit) { + Key *key = ob_get_key(obn); + if(dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action((ID *)obn->data); + if(key) BKE_copy_animdata_id_action((ID*)key); } if(dupflag & USER_DUP_MAT) { |