remove BM_ITER, BM_ITER_INDEX macros, use ELEM or MESH variants only (the maceros...
[blender-staging.git] / source / blender / editors / render / render_shading.c
index 83b4dfef6c67c8685e3537bb1f6c84105f7ced76..6722ac5e68669ce28be0832a9e1ae95c06b22fa4 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "MEM_guardedalloc.h"
 
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_mesh_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_material_types.h"
@@ -43,7 +44,6 @@
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
-#include "BLI_editVert.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_animsys.h"
 #include "BLI_utildefines.h"
 
 #include "BKE_animsys.h"
 
 #include "RE_pipeline.h"
 
 
 #include "RE_pipeline.h"
 
-#include "render_intern.h"     // own include
+#include "render_intern.h"  // own include
 
 /********************** material slot operators *********************/
 
 static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 
 /********************** material slot operators *********************/
 
 static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
 
 
-       if(!ob)
+       if (!ob)
                return OPERATOR_CANCELLED;
 
        object_add_material_slot(ob);
                return OPERATOR_CANCELLED;
 
        object_add_material_slot(ob);
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-       WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, ob);
+       WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+       WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -108,35 +108,35 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
 void OBJECT_OT_material_slot_add(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_add(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Add Material Slot";
-       ot->idname= "OBJECT_OT_material_slot_add";
-       ot->description="Add a new material slot";
+       ot->name = "Add Material Slot";
+       ot->idname = "OBJECT_OT_material_slot_add";
+       ot->description = "Add a new material slot";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= material_slot_add_exec;
-       ot->poll= ED_operator_object_active_editable;
+       ot->exec = material_slot_add_exec;
+       ot->poll = ED_operator_object_active_editable;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int material_slot_remove_exec(bContext *C, wmOperator *op)
 {
 }
 
 static int material_slot_remove_exec(bContext *C, wmOperator *op)
 {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
 
 
-       if(!ob)
+       if (!ob)
                return OPERATOR_CANCELLED;
 
        /* Removing material slots in edit mode screws things up, see bug #21822.*/
                return OPERATOR_CANCELLED;
 
        /* Removing material slots in edit mode screws things up, see bug #21822.*/
-       if(ob == CTX_data_edit_object(C)) {
+       if (ob == CTX_data_edit_object(C)) {
                BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
                return OPERATOR_CANCELLED;
        }
 
        object_remove_material_slot(ob);
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
                return OPERATOR_CANCELLED;
        }
 
        object_remove_material_slot(ob);
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-       WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, ob);
+       WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+       WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -144,61 +144,61 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
 void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Remove Material Slot";
-       ot->idname= "OBJECT_OT_material_slot_remove";
-       ot->description="Remove the selected material slot";
+       ot->name = "Remove Material Slot";
+       ot->idname = "OBJECT_OT_material_slot_remove";
+       ot->description = "Remove the selected material slot";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= material_slot_remove_exec;
-       ot->poll= ED_operator_object_active_editable;
+       ot->exec = material_slot_remove_exec;
+       ot->poll = ED_operator_object_active_editable;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
 
 
-       if(!ob)
+       if (!ob)
                return OPERATOR_CANCELLED;
 
                return OPERATOR_CANCELLED;
 
-       if(ob && ob->actcol>0) {
-               if(ob->type == OB_MESH) {
-                       BMEditMesh *em= ((Mesh*)ob->data)->edit_btmesh;
+       if (ob && ob->actcol > 0) {
+               if (ob->type == OB_MESH) {
+                       BMEditMesh *em = BMEdit_FromObject(ob);
                        BMFace *efa;
                        BMIter iter;
 
                        BMFace *efa;
                        BMIter iter;
 
-                       if(em) {
-                               BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
-                                       if(BM_elem_flag_test(efa, BM_ELEM_SELECT))
-                                               efa->mat_nr= ob->actcol-1;
+                       if (em) {
+                               BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+                                       if (BM_elem_flag_test(efa, BM_ELEM_SELECT))
+                                               efa->mat_nr = ob->actcol - 1;
                                }
                        }
                }
                                }
                        }
                }
-               else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+               else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
                        Nurb *nu;
                        Nurb *nu;
-                       ListBase *nurbs= curve_editnurbs((Curve*)ob->data);
+                       ListBase *nurbs = curve_editnurbs((Curve *)ob->data);
 
 
-                       if(nurbs) {
-                               for(nu= nurbs->first; nu; nu= nu->next)
-                                       if(isNurbsel(nu))
-                                               nu->mat_nr= nu->charidx= ob->actcol-1;
+                       if (nurbs) {
+                               for (nu = nurbs->first; nu; nu = nu->next)
+                                       if (isNurbsel(nu))
+                                               nu->mat_nr = nu->charidx = ob->actcol - 1;
                        }
                }
                        }
                }
-               else if(ob->type == OB_FONT) {
-                       EditFont *ef= ((Curve*)ob->data)->editfont;
+               else if (ob->type == OB_FONT) {
+                       EditFont *ef = ((Curve *)ob->data)->editfont;
                        int i, selstart, selend;
 
                        int i, selstart, selend;
 
-                       if(ef && BKE_font_getselection(ob, &selstart, &selend)) {
-                               for(i=selstart; i<=selend; i++)
+                       if (ef && BKE_font_getselection(ob, &selstart, &selend)) {
+                               for (i = selstart; i <= selend; i++)
                                        ef->textbufinfo[i].mat_nr = ob->actcol;
                        }
                }
        }
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                                        ef->textbufinfo[i].mat_nr = ob->actcol;
                        }
                }
        }
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
+       WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -206,48 +206,48 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
 void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Assign Material Slot";
-       ot->idname= "OBJECT_OT_material_slot_assign";
-       ot->description="Assign the material in the selected material slot to the selected vertices";
+       ot->name = "Assign Material Slot";
+       ot->idname = "OBJECT_OT_material_slot_assign";
+       ot->description = "Assign the material in the selected material slot to the selected vertices";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= material_slot_assign_exec;
-       ot->poll= ED_operator_object_active_editable;
+       ot->exec = material_slot_assign_exec;
+       ot->poll = ED_operator_object_active_editable;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int material_slot_de_select(bContext *C, int select)
 {
 }
 
 static int material_slot_de_select(bContext *C, int select)
 {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
 
 
-       if(!ob)
+       if (!ob)
                return OPERATOR_CANCELLED;
 
                return OPERATOR_CANCELLED;
 
-       if(ob->type == OB_MESH) {
-               BMEditMesh *em= ((Mesh*)ob->data)->edit_btmesh;
+       if (ob->type == OB_MESH) {
+               BMEditMesh *em = BMEdit_FromObject(ob);
 
 
-               if(em) {
-                       EDBM_deselect_by_material(em, ob->actcol-1, select);
+               if (em) {
+                       EDBM_deselect_by_material(em, ob->actcol - 1, select);
                }
        }
                }
        }
-       else if ELEM(ob->type, OB_CURVE, OB_SURF) {
-               ListBase *nurbs= curve_editnurbs((Curve*)ob->data);
+       else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+               ListBase *nurbs = curve_editnurbs((Curve *)ob->data);
                Nurb *nu;
                BPoint *bp;
                BezTriple *bezt;
                int a;
 
                Nurb *nu;
                BPoint *bp;
                BezTriple *bezt;
                int a;
 
-               if(nurbs) {
-                       for(nu= nurbs->first; nu; nu=nu->next) {
-                               if(nu->mat_nr==ob->actcol-1) {
-                                       if(nu->bezt) {
-                                               a= nu->pntsu;
-                                               bezt= nu->bezt;
-                                               while(a--) {
-                                                       if(bezt->hide==0) {
-                                                               if(select) {
+               if (nurbs) {
+                       for (nu = nurbs->first; nu; nu = nu->next) {
+                               if (nu->mat_nr == ob->actcol - 1) {
+                                       if (nu->bezt) {
+                                               a = nu->pntsu;
+                                               bezt = nu->bezt;
+                                               while (a--) {
+                                                       if (bezt->hide == 0) {
+                                                               if (select) {
                                                                        bezt->f1 |= SELECT;
                                                                        bezt->f2 |= SELECT;
                                                                        bezt->f3 |= SELECT;
                                                                        bezt->f1 |= SELECT;
                                                                        bezt->f2 |= SELECT;
                                                                        bezt->f3 |= SELECT;
@@ -261,12 +261,12 @@ static int material_slot_de_select(bContext *C, int select)
                                                        bezt++;
                                                }
                                        }
                                                        bezt++;
                                                }
                                        }
-                                       else if(nu->bp) {
-                                               a= nu->pntsu*nu->pntsv;
-                                               bp= nu->bp;
-                                               while(a--) {
-                                                       if(bp->hide==0) {
-                                                               if(select) bp->f1 |= SELECT;
+                                       else if (nu->bp) {
+                                               a = nu->pntsu * nu->pntsv;
+                                               bp = nu->bp;
+                                               while (a--) {
+                                                       if (bp->hide == 0) {
+                                                               if (select) bp->f1 |= SELECT;
                                                                else bp->f1 &= ~SELECT;
                                                        }
                                                        bp++;
                                                                else bp->f1 &= ~SELECT;
                                                        }
                                                        bp++;
@@ -277,7 +277,7 @@ static int material_slot_de_select(bContext *C, int select)
                }
        }
 
                }
        }
 
-       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
+       WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
 
        return OPERATOR_FINISHED;
 }
 
        return OPERATOR_FINISHED;
 }
@@ -290,15 +290,15 @@ static int material_slot_select_exec(bContext *C, wmOperator *UNUSED(op))
 void OBJECT_OT_material_slot_select(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_select(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Select Material Slot";
-       ot->idname= "OBJECT_OT_material_slot_select";
-       ot->description="Select vertices assigned to the selected material slot";
+       ot->name = "Select Material Slot";
+       ot->idname = "OBJECT_OT_material_slot_select";
+       ot->description = "Select vertices assigned to the selected material slot";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= material_slot_select_exec;
+       ot->exec = material_slot_select_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
 }
 
 static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
@@ -309,34 +309,34 @@ static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
 void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Deselect Material Slot";
-       ot->idname= "OBJECT_OT_material_slot_deselect";
-       ot->description="Deselect vertices assigned to the selected material slot";
+       ot->name = "Deselect Material Slot";
+       ot->idname = "OBJECT_OT_material_slot_deselect";
+       ot->description = "Deselect vertices assigned to the selected material slot";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= material_slot_deselect_exec;
+       ot->exec = material_slot_deselect_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 
 static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 
 static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Object *ob= ED_object_context(C);
+       Object *ob = ED_object_context(C);
        Material ***matar;
 
        Material ***matar;
 
-       if(!ob || !(matar= give_matarar(ob)))
+       if (!ob || !(matar = give_matarar(ob)))
                return OPERATOR_CANCELLED;
 
                return OPERATOR_CANCELLED;
 
-       CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
-               if(ob != ob_iter && give_matarar(ob_iter)) {
+       CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) {
+               if (ob != ob_iter && give_matarar(ob_iter)) {
                        if (ob->data != ob_iter->data)
                                assign_matarar(ob_iter, matar, ob->totcol);
                        
                        if (ob->data != ob_iter->data)
                                assign_matarar(ob_iter, matar, ob->totcol);
                        
-                       if(ob_iter->totcol==ob->totcol) {
-                               ob_iter->actcol= ob->actcol;
-                               WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
+                       if (ob_iter->totcol == ob->totcol) {
+                               ob_iter->actcol = ob->actcol;
+                               WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
                        }
                }
        }
                        }
                }
        }
@@ -349,43 +349,43 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
 void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
 {
        /* identifiers */
 void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Copy Material to Others";
-       ot->idname= "OBJECT_OT_material_slot_copy";
-       ot->description="Copies materials to other selected objects";
+       ot->name = "Copy Material to Others";
+       ot->idname = "OBJECT_OT_material_slot_copy";
+       ot->description = "Copies materials to other selected objects";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= material_slot_copy_exec;
+       ot->exec = material_slot_copy_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /********************** new material operator *********************/
 
 static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 /********************** new material operator *********************/
 
 static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Scene *scene= CTX_data_scene(C);
-       Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+       Scene *scene = CTX_data_scene(C);
+       Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy material */
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy material */
-       if(ma) {
-               ma= copy_material(ma);
+       if (ma) {
+               ma = copy_material(ma);
        }
        else {
        }
        else {
-               ma= add_material("Material");
+               ma = add_material("Material");
 
 
-               if(scene_use_new_shading_nodes(scene)) {
+               if (scene_use_new_shading_nodes(scene)) {
                        ED_node_shader_default(scene, &ma->id);
                        ED_node_shader_default(scene, &ma->id);
-                       ma->use_nodes= 1;
+                       ma->use_nodes = 1;
                }
        }
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
                }
        }
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
-       if(prop) {
+       if (prop) {
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                ma->id.us--;
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                ma->id.us--;
@@ -395,7 +395,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
                RNA_property_update(C, &ptr, prop);
        }
 
                RNA_property_update(C, &ptr, prop);
        }
 
-       WM_event_add_notifier(C, NC_MATERIAL|NA_ADDED, ma);
+       WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -403,35 +403,35 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
 void MATERIAL_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
 void MATERIAL_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "New Material";
-       ot->idname= "MATERIAL_OT_new";
-       ot->description="Add a new material";
+       ot->name = "New Material";
+       ot->idname = "MATERIAL_OT_new";
+       ot->description = "Add a new material";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= new_material_exec;
+       ot->exec = new_material_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /********************** new texture operator *********************/
 
 static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 /********************** new texture operator *********************/
 
 static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+       Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy texture */
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy texture */
-       if(tex)
-               tex= copy_texture(tex);
+       if (tex)
+               tex = copy_texture(tex);
        else
        else
-               tex= add_texture("Texture");
+               tex = add_texture("Texture");
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
-       if(prop) {
+       if (prop) {
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                tex->id.us--;
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                tex->id.us--;
@@ -441,7 +441,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
                RNA_property_update(C, &ptr, prop);
        }
 
                RNA_property_update(C, &ptr, prop);
        }
 
-       WM_event_add_notifier(C, NC_TEXTURE|NA_ADDED, tex);
+       WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -449,43 +449,43 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
 void TEXTURE_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
 void TEXTURE_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "New Texture";
-       ot->idname= "TEXTURE_OT_new";
-       ot->description="Add a new texture";
+       ot->name = "New Texture";
+       ot->idname = "TEXTURE_OT_new";
+       ot->description = "Add a new texture";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= new_texture_exec;
+       ot->exec = new_texture_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /********************** new world operator *********************/
 
 static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 /********************** new world operator *********************/
 
 static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Scene *scene= CTX_data_scene(C);
-       World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
+       Scene *scene = CTX_data_scene(C);
+       World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy world */
        PointerRNA ptr, idptr;
        PropertyRNA *prop;
 
        /* add or copy world */
-       if(wo) {
-               wo= copy_world(wo);
+       if (wo) {
+               wo = copy_world(wo);
        }
        else {
        }
        else {
-               wo= add_world("World");
+               wo = add_world("World");
 
 
-               if(scene_use_new_shading_nodes(scene)) {
+               if (scene_use_new_shading_nodes(scene)) {
                        ED_node_shader_default(scene, &wo->id);
                        ED_node_shader_default(scene, &wo->id);
-                       wo->use_nodes= 1;
+                       wo->use_nodes = 1;
                }
        }
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
                }
        }
 
        /* hook into UI */
        uiIDContextProperty(C, &ptr, &prop);
 
-       if(prop) {
+       if (prop) {
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                wo->id.us--;
                /* when creating new ID blocks, use is already 1, but RNA
                 * pointer se also increases user, so this compensates it */
                wo->id.us--;
@@ -495,7 +495,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
                RNA_property_update(C, &ptr, prop);
        }
 
                RNA_property_update(C, &ptr, prop);
        }
 
-       WM_event_add_notifier(C, NC_WORLD|NA_ADDED, wo);
+       WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -503,27 +503,27 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
 void WORLD_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
 void WORLD_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "New World";
-       ot->idname= "WORLD_OT_new";
-       ot->description= "Add a new world";
+       ot->name = "New World";
+       ot->idname = "WORLD_OT_new";
+       ot->description = "Add a new world";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= new_world_exec;
+       ot->exec = new_world_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /********************** render layer operators *********************/
 
 static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 /********************** render layer operators *********************/
 
 static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Scene *scene= CTX_data_scene(C);
+       Scene *scene = CTX_data_scene(C);
 
        scene_add_render_layer(scene, NULL);
 
        scene_add_render_layer(scene, NULL);
-       scene->r.actlay= BLI_countlist(&scene->r.layers) - 1;
+       scene->r.actlay = BLI_countlist(&scene->r.layers) - 1;
 
 
-       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -531,15 +531,15 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
 void SCENE_OT_render_layer_add(wmOperatorType *ot)
 {
        /* identifiers */
 void SCENE_OT_render_layer_add(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Add Render Layer";
-       ot->idname= "SCENE_OT_render_layer_add";
-       ot->description="Add a render layer";
+       ot->name = "Add Render Layer";
+       ot->idname = "SCENE_OT_render_layer_add";
+       ot->description = "Add a render layer";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= render_layer_add_exec;
+       ot->exec = render_layer_add_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
 }
 
 static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
@@ -547,10 +547,10 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
        Scene *scene = CTX_data_scene(C);
        SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay);
 
        Scene *scene = CTX_data_scene(C);
        SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay);
 
-       if(!scene_remove_render_layer(CTX_data_main(C), scene, rl))
+       if (!scene_remove_render_layer(CTX_data_main(C), scene, rl))
                return OPERATOR_CANCELLED;
 
                return OPERATOR_CANCELLED;
 
-       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -558,71 +558,71 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
 void SCENE_OT_render_layer_remove(wmOperatorType *ot)
 {
        /* identifiers */
 void SCENE_OT_render_layer_remove(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Remove Render Layer";
-       ot->idname= "SCENE_OT_render_layer_remove";
-       ot->description="Remove the selected render layer";
+       ot->name = "Remove Render Layer";
+       ot->idname = "SCENE_OT_render_layer_remove";
+       ot->description = "Remove the selected render layer";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= render_layer_remove_exec;
+       ot->exec = render_layer_remove_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int texture_slot_move(bContext *C, wmOperator *op)
 {
 }
 
 static int texture_slot_move(bContext *C, wmOperator *op)
 {
-       ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+       ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
 
 
-       if(id) {
+       if (id) {
                MTex **mtex_ar, *mtexswap;
                short act;
                MTex **mtex_ar, *mtexswap;
                short act;
-               int type= RNA_enum_get(op->ptr, "type");
-               struct AnimData *adt= BKE_animdata_from_id(id);
+               int type = RNA_enum_get(op->ptr, "type");
+               struct AnimData *adt = BKE_animdata_from_id(id);
 
                give_active_mtex(id, &mtex_ar, &act);
 
 
                give_active_mtex(id, &mtex_ar, &act);
 
-               if(type == -1) { /* Up */
-                       if(act > 0) {
+               if (type == -1) { /* Up */
+                       if (act > 0) {
                                mtexswap = mtex_ar[act];
                                mtexswap = mtex_ar[act];
-                               mtex_ar[act] = mtex_ar[act-1];
-                               mtex_ar[act-1] = mtexswap;
+                               mtex_ar[act] = mtex_ar[act - 1];
+                               mtex_ar[act - 1] = mtexswap;
                                
                                
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act-1, -1, 0);
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act-1, 0);
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, -1, act, 0);
-
-                               if(GS(id->name)==ID_MA) {
-                                       Material *ma= (Material *)id;
-                                       int mtexuse = ma->septex & (1<<act);
-                                       ma->septex &= ~(1<<act);
-                                       ma->septex |= (ma->septex & (1<<(act-1))) << 1;
-                                       ma->septex &= ~(1<<(act-1));
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
+
+                               if (GS(id->name) == ID_MA) {
+                                       Material *ma = (Material *)id;
+                                       int mtexuse = ma->septex & (1 << act);
+                                       ma->septex &= ~(1 << act);
+                                       ma->septex |= (ma->septex & (1 << (act - 1))) << 1;
+                                       ma->septex &= ~(1 << (act - 1));
                                        ma->septex |= mtexuse >> 1;
                                }
                                
                                        ma->septex |= mtexuse >> 1;
                                }
                                
-                               set_active_mtex(id, act-1);
+                               set_active_mtex(id, act - 1);
                        }
                }
                else { /* Down */
                        }
                }
                else { /* Down */
-                       if(act < MAX_MTEX-1) {
+                       if (act < MAX_MTEX - 1) {
                                mtexswap = mtex_ar[act];
                                mtexswap = mtex_ar[act];
-                               mtex_ar[act] = mtex_ar[act+1];
-                               mtex_ar[act+1] = mtexswap;
+                               mtex_ar[act] = mtex_ar[act + 1];
+                               mtex_ar[act + 1] = mtexswap;
                                
                                
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act+1, -1, 0);
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act+1, 0);
-                               BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, -1, act, 0);
-
-                               if(GS(id->name)==ID_MA) {
-                                       Material *ma= (Material *)id;
-                                       int mtexuse = ma->septex & (1<<act);
-                                       ma->septex &= ~(1<<act);
-                                       ma->septex |= (ma->septex & (1<<(act+1))) >> 1;
-                                       ma->septex &= ~(1<<(act+1));
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
+                               BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
+
+                               if (GS(id->name) == ID_MA) {
+                                       Material *ma = (Material *)id;
+                                       int mtexuse = ma->septex & (1 << act);
+                                       ma->septex &= ~(1 << act);
+                                       ma->septex |= (ma->septex & (1 << (act + 1))) >> 1;
+                                       ma->septex &= ~(1 << (act + 1));
                                        ma->septex |= mtexuse << 1;
                                }
                                
                                        ma->septex |= mtexuse << 1;
                                }
                                
-                               set_active_mtex(id, act+1);
+                               set_active_mtex(id, act + 1);
                        }
                }
 
                        }
                }
 
@@ -642,15 +642,15 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
        };
 
        /* identifiers */
        };
 
        /* identifiers */
-       ot->name= "Move Texture Slot";
-       ot->idname= "TEXTURE_OT_slot_move";
-       ot->description="Move texture slots up and down";
+       ot->name = "Move Texture Slot";
+       ot->idname = "TEXTURE_OT_slot_move";
+       ot->description = "Move texture slots up and down";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= texture_slot_move;
+       ot->exec = texture_slot_move;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
 }
 
        RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
 }
@@ -662,8 +662,8 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
 static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
 {
        float layout[12];
 static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
 {
        float layout[12];
-       if ( RNA_struct_find_property(op->ptr, "layout") )
-               RNA_float_get_array(op->ptr, "layout",layout);
+       if (RNA_struct_find_property(op->ptr, "layout") )
+               RNA_float_get_array(op->ptr, "layout", layout);
        else
                memcpy(layout, default_envmap_layout, sizeof(layout));
 
        else
                memcpy(layout, default_envmap_layout, sizeof(layout));
 
@@ -678,7 +678,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, co
 
 static int envmap_save_exec(bContext *C, wmOperator *op)
 {
 
 static int envmap_save_exec(bContext *C, wmOperator *op)
 {
-       Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+       Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
        Scene *scene = CTX_data_scene(C);
        //int imtype = RNA_enum_get(op->ptr, "file_type");
        char imtype = scene->r.im_format.imtype;
        Scene *scene = CTX_data_scene(C);
        //int imtype = RNA_enum_get(op->ptr, "file_type");
        char imtype = scene->r.im_format.imtype;
@@ -686,7 +686,7 @@ static int envmap_save_exec(bContext *C, wmOperator *op)
        
        RNA_string_get(op->ptr, "filepath", path);
        
        
        RNA_string_get(op->ptr, "filepath", path);
        
-       if(scene->r.scemode & R_EXTENSION)  {
+       if (scene->r.scemode & R_EXTENSION) {
                BKE_add_image_extension(path, imtype);
        }
        
                BKE_add_image_extension(path, imtype);
        }
        
@@ -705,7 +705,7 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
 {
        //Scene *scene= CTX_data_scene(C);
        
 {
        //Scene *scene= CTX_data_scene(C);
        
-       if(RNA_struct_property_is_set(op->ptr, "filepath"))
+       if (RNA_struct_property_is_set(op->ptr, "filepath"))
                return envmap_save_exec(C, op);
 
        //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype);
                return envmap_save_exec(C, op);
 
        //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype);
@@ -717,13 +717,13 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
 
 static int envmap_save_poll(bContext *C)
 {
 
 static int envmap_save_poll(bContext *C)
 {
-       Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+       Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
 
        if (!tex) 
                return 0;
        if (!tex->env || !tex->env->ok)
                return 0;
 
        if (!tex) 
                return 0;
        if (!tex->env || !tex->env->ok)
                return 0;
-       if (tex->env->cube[1]==NULL)
+       if (tex->env->cube[1] == NULL)
                return 0;
        
        return 1;
                return 0;
        
        return 1;
@@ -733,45 +733,45 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
 {
        PropertyRNA *prop;
        /* identifiers */
 {
        PropertyRNA *prop;
        /* identifiers */
-       ot->name= "Save Environment Map";
-       ot->idname= "TEXTURE_OT_envmap_save";
-       ot->description="Save the current generated Environment map to an image file";
+       ot->name = "Save Environment Map";
+       ot->idname = "TEXTURE_OT_envmap_save";
+       ot->description = "Save the current generated Environment map to an image file";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= envmap_save_exec;
-       ot->invoke= envmap_save_invoke;
-       ot->poll= envmap_save_poll;
+       ot->exec = envmap_save_exec;
+       ot->invoke = envmap_save_invoke;
+       ot->poll = envmap_save_poll;
        
        /* flags */
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */
+       ot->flag = OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */
        
        /* properties */
        
        /* properties */
-       prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
+       prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
        RNA_def_property_flag(prop, PROP_HIDDEN);
 
        RNA_def_property_flag(prop, PROP_HIDDEN);
 
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+       WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
 }
 
 static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+       Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
        
        BKE_free_envmapdata(tex->env);
        
        
        BKE_free_envmapdata(tex->env);
        
-       WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex);
+       WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
        
        return OPERATOR_FINISHED;
 }
 
 static int envmap_clear_poll(bContext *C)
 {
        
        return OPERATOR_FINISHED;
 }
 
 static int envmap_clear_poll(bContext *C)
 {
-       Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+       Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
        
        if (!tex) 
                return 0;
        if (!tex->env || !tex->env->ok)
                return 0;
        
        if (!tex) 
                return 0;
        if (!tex->env || !tex->env->ok)
                return 0;
-       if (tex->env->cube[1]==NULL)
+       if (tex->env->cube[1] == NULL)
                return 0;
        
        return 1;
                return 0;
        
        return 1;
@@ -780,16 +780,16 @@ static int envmap_clear_poll(bContext *C)
 void TEXTURE_OT_envmap_clear(wmOperatorType *ot)
 {
        /* identifiers */
 void TEXTURE_OT_envmap_clear(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Clear Environment Map";
-       ot->idname= "TEXTURE_OT_envmap_clear";
-       ot->description="Discard the environment map and free it from memory";
+       ot->name = "Clear Environment Map";
+       ot->idname = "TEXTURE_OT_envmap_clear";
+       ot->description = "Discard the environment map and free it from memory";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= envmap_clear_exec;
-       ot->poll= envmap_clear_poll;
+       ot->exec = envmap_clear_exec;
+       ot->poll = envmap_clear_poll;
        
        /* flags */
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
 }
 
 static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
@@ -797,11 +797,11 @@ static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
        Main *bmain = CTX_data_main(C);
        Tex *tex;
        
        Main *bmain = CTX_data_main(C);
        Tex *tex;
        
-       for (tex=bmain->tex.first; tex; tex=tex->id.next)
+       for (tex = bmain->tex.first; tex; tex = tex->id.next)
                if (tex->env)
                        BKE_free_envmapdata(tex->env);
        
                if (tex->env)
                        BKE_free_envmapdata(tex->env);
        
-       WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex);
+       WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
        
        return OPERATOR_FINISHED;
 }
        
        return OPERATOR_FINISHED;
 }
@@ -809,16 +809,16 @@ static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
 void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
 {
        /* identifiers */
 void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Clear All Environment Maps";
-       ot->idname= "TEXTURE_OT_envmap_clear_all";
-       ot->description="Discard all environment maps in the .blend file and free them from memory";
+       ot->name = "Clear All Environment Maps";
+       ot->idname = "TEXTURE_OT_envmap_clear_all";
+       ot->description = "Discard all environment maps in the .blend file and free them from memory";
        
        /* api callbacks */
        
        /* api callbacks */
-       ot->exec= envmap_clear_all_exec;
-       ot->poll= envmap_clear_poll;
+       ot->exec = envmap_clear_all_exec;
+       ot->poll = envmap_clear_poll;
        
        /* flags */
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /********************** material operators *********************/
 }
 
 /********************** material operators *********************/
@@ -826,9 +826,9 @@ void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
 /* material copy/paste */
 static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
 /* material copy/paste */
 static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+       Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
 
 
-       if(ma==NULL)
+       if (ma == NULL)
                return OPERATOR_CANCELLED;
 
        copy_matcopybuf(ma);
                return OPERATOR_CANCELLED;
 
        copy_matcopybuf(ma);
@@ -839,27 +839,27 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
 void MATERIAL_OT_copy(wmOperatorType *ot)
 {
        /* identifiers */
 void MATERIAL_OT_copy(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Copy Material";
-       ot->idname= "MATERIAL_OT_copy";
-       ot->description="Copy the material settings and nodes";
+       ot->name = "Copy Material";
+       ot->idname = "MATERIAL_OT_copy";
+       ot->description = "Copy the material settings and nodes";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= copy_material_exec;
+       ot->exec = copy_material_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER; /* no undo needed since no changes are made to the material */
+       ot->flag = OPTYPE_REGISTER; /* no undo needed since no changes are made to the material */
 }
 
 static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+       Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
 
 
-       if(ma==NULL)
+       if (ma == NULL)
                return OPERATOR_CANCELLED;
 
        paste_matcopybuf(ma);
 
                return OPERATOR_CANCELLED;
 
        paste_matcopybuf(ma);
 
-       WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, ma);
+       WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_DRAW, ma);
 
        return OPERATOR_FINISHED;
 }
 
        return OPERATOR_FINISHED;
 }
@@ -867,88 +867,88 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
 void MATERIAL_OT_paste(wmOperatorType *ot)
 {
        /* identifiers */
 void MATERIAL_OT_paste(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Paste Material";
-       ot->idname= "MATERIAL_OT_paste";
-       ot->description="Paste the material settings and nodes";
+       ot->name = "Paste Material";
+       ot->idname = "MATERIAL_OT_paste";
+       ot->description = "Paste the material settings and nodes";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= paste_material_exec;
+       ot->exec = paste_material_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 
 }
 
 
-static short mtexcopied=0; /* must be reset on file load */
+static short mtexcopied = 0; /* must be reset on file load */
 static MTex mtexcopybuf;
 
 void ED_render_clear_mtex_copybuf(void)
 static MTex mtexcopybuf;
 
 void ED_render_clear_mtex_copybuf(void)
-{      /* use for file reload */
-       mtexcopied= 0;
+{   /* use for file reload */
+       mtexcopied = 0;
 }
 
 static void copy_mtex_copybuf(ID *id)
 {
 }
 
 static void copy_mtex_copybuf(ID *id)
 {
-       MTex **mtex= NULL;
+       MTex **mtex = NULL;
        
        
-       switch(GS(id->name)) {
+       switch (GS(id->name)) {
                case ID_MA:
                case ID_MA:
-                       mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+                       mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
                        break;
                case ID_LA:
                        break;
                case ID_LA:
-                       mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+                       mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
                        // la->mtex[(int)la->texact] // TODO
                        break;
                case ID_WO:
                        // la->mtex[(int)la->texact] // TODO
                        break;
                case ID_WO:
-                       mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+                       mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
                        // mtex= wrld->mtex[(int)wrld->texact]; // TODO
                        break;
                case ID_PA:
                        // mtex= wrld->mtex[(int)wrld->texact]; // TODO
                        break;
                case ID_PA:
-                       mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+                       mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
                        break;
        }
        
                        break;
        }
        
-       if(mtex && *mtex) {
+       if (mtex && *mtex) {
                memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
                memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
-               mtexcopied= 1;
+               mtexcopied = 1;
        }
        else {
        }
        else {
-               mtexcopied= 0;
+               mtexcopied = 0;
        }
 }
 
 static void paste_mtex_copybuf(ID *id)
 {
        }
 }
 
 static void paste_mtex_copybuf(ID *id)
 {
-       MTex **mtex= NULL;
+       MTex **mtex = NULL;
        
        
-       if(mtexcopied == 0 || mtexcopybuf.tex==NULL)
+       if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
                return;
        
                return;
        
-       switch(GS(id->name)) {
+       switch (GS(id->name)) {
                case ID_MA:
                case ID_MA:
-                       mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+                       mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
                        break;
                case ID_LA:
                        break;
                case ID_LA:
-                       mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+                       mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
                        // la->mtex[(int)la->texact] // TODO
                        break;
                case ID_WO:
                        // la->mtex[(int)la->texact] // TODO
                        break;
                case ID_WO:
-                       mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+                       mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
                        // mtex= wrld->mtex[(int)wrld->texact]; // TODO
                        break;
                case ID_PA:
                        // mtex= wrld->mtex[(int)wrld->texact]; // TODO
                        break;
                case ID_PA:
-                       mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+                       mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
                        break;
                default:
                        BLI_assert("invalid id type");
                        return;
        }
        
                        break;
                default:
                        BLI_assert("invalid id type");
                        return;
        }
        
-       if(mtex) {
-               if(*mtex==NULL) {
-                       *mtex= MEM_mallocN(sizeof(MTex), "mtex copy");
+       if (mtex) {
+               if (*mtex == NULL) {
+                       *mtex = MEM_mallocN(sizeof(MTex), "mtex copy");
                }
                }
-               else if((*mtex)->tex) {
+               else if ((*mtex)->tex) {
                        (*mtex)->tex->id.us--;
                }
                
                        (*mtex)->tex->id.us--;
                }
                
@@ -961,9 +961,9 @@ static void paste_mtex_copybuf(ID *id)
 
 static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 {
 
 static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+       ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
 
 
-       if(id==NULL) {
+       if (id == NULL) {
                /* copying empty slot */
                ED_render_clear_mtex_copybuf();
                return OPERATOR_CANCELLED;
                /* copying empty slot */
                ED_render_clear_mtex_copybuf();
                return OPERATOR_CANCELLED;
@@ -976,7 +976,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 
 static int copy_mtex_poll(bContext *C)
 {
 
 static int copy_mtex_poll(bContext *C)
 {
-       ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+       ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
        
        return (id != NULL);
 }
        
        return (id != NULL);
 }
@@ -984,27 +984,27 @@ static int copy_mtex_poll(bContext *C)
 void TEXTURE_OT_slot_copy(wmOperatorType *ot)
 {
        /* identifiers */
 void TEXTURE_OT_slot_copy(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Copy Texture Slot Settings";
-       ot->idname= "TEXTURE_OT_slot_copy";
-       ot->description="Copy the material texture settings and nodes";
+       ot->name = "Copy Texture Slot Settings";
+       ot->idname = "TEXTURE_OT_slot_copy";
+       ot->description = "Copy the material texture settings and nodes";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= copy_mtex_exec;
-       ot->poll= copy_mtex_poll;
+       ot->exec = copy_mtex_exec;
+       ot->poll = copy_mtex_poll;
        
        /* flags */
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER; /* no undo needed since no changes are made to the mtex */
+       ot->flag = OPTYPE_REGISTER; /* no undo needed since no changes are made to the mtex */
 }
 
 static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 {
 }
 
 static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+       ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
 
 
-       if(id==NULL) {
-               Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
-               Lamp *la= CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
-               World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
-               ParticleSystem *psys= CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
+       if (id == NULL) {
+               Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+               Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
+               World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
+               ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
                
                if (ma)
                        id = &ma->id;
                
                if (ma)
                        id = &ma->id;
@@ -1015,13 +1015,13 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
                else if (psys)
                        id = &psys->part->id;
                
                else if (psys)
                        id = &psys->part->id;
                
-               if (id==NULL)
+               if (id == NULL)
                        return OPERATOR_CANCELLED;
        }
 
        paste_mtex_copybuf(id);
 
                        return OPERATOR_CANCELLED;
        }
 
        paste_mtex_copybuf(id);
 
-       WM_event_add_notifier(C, NC_TEXTURE|ND_SHADING_DRAW, NULL);
+       WM_event_add_notifier(C, NC_TEXTURE | ND_SHADING_DRAW, NULL);
 
        return OPERATOR_FINISHED;
 }
 
        return OPERATOR_FINISHED;
 }
@@ -1029,14 +1029,14 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
 void TEXTURE_OT_slot_paste(wmOperatorType *ot)
 {
        /* identifiers */
 void TEXTURE_OT_slot_paste(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Paste Texture Slot Settings";
-       ot->idname= "TEXTURE_OT_slot_paste";
-       ot->description="Copy the texture settings and nodes";
+       ot->name = "Paste Texture Slot Settings";
+       ot->idname = "TEXTURE_OT_slot_paste";
+       ot->description = "Copy the texture settings and nodes";
 
        /* api callbacks */
 
        /* api callbacks */
-       ot->exec= paste_mtex_exec;
+       ot->exec = paste_mtex_exec;
 
        /* flags */
 
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 }