Cycles: svn merge -r41225:41232 ^/trunk/blender
[blender.git] / source / blender / editors / object / object_add.c
index 452e7e4..87af79d 100644 (file)
@@ -75,6 +75,7 @@
 #include "BKE_particle.h"
 #include "BKE_report.h"
 #include "BKE_sca.h"
+#include "BKE_scene.h"
 #include "BKE_speaker.h"
 #include "BKE_texture.h"
 
@@ -89,6 +90,7 @@
 #include "ED_curve.h"
 #include "ED_mball.h"
 #include "ED_mesh.h"
+#include "ED_node.h"
 #include "ED_object.h"
 #include "ED_render.h"
 #include "ED_screen.h"
@@ -319,6 +321,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int en
        /* more editor stuff */
        ED_object_base_init_transform(C, BASACT, loc, rot);
 
+       DAG_id_type_tag(bmain, ID_OB);
        DAG_scene_sort(bmain, scene);
        ED_render_id_flush_update(bmain, ob->data);
 
@@ -697,7 +700,9 @@ static const char *get_lamp_defname(int type)
 
 static int object_lamp_add_exec(bContext *C, wmOperator *op)
 {
+       Scene *scene= CTX_data_scene(C);
        Object *ob;
+       Lamp *la;
        int type= RNA_enum_get(op->ptr, "type");
        int enter_editmode;
        unsigned int layer;
@@ -708,9 +713,16 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
 
        ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer);
-       ((Lamp*)ob->data)->type= type;
-       rename_id((ID *)ob, get_lamp_defname(type));
-       rename_id((ID *)ob->data, get_lamp_defname(type));
+       la= (Lamp*)ob->data;
+
+       la->type= type;
+       rename_id(&ob->id, get_lamp_defname(type));
+       rename_id(&la->id, get_lamp_defname(type));
+
+       if(scene_use_new_shading_nodes(scene)) {
+               ED_node_shader_default(scene, &la->id);
+               la->use_nodes= 1;
+       }
        
        return OPERATOR_FINISHED;
 }
@@ -863,6 +875,7 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
 /* note: now unlinks constraints as well */
 void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base)
 {
+       DAG_id_type_tag(bmain, ID_OB);
        BLI_remlink(&scene->base, base);
        free_libblock_us(&bmain->object, base->object);
        if(scene->basact==base) scene->basact= NULL;