2009-06-07 13:36:12 +00:00
|
|
|
/**
|
|
|
|
|
* $Id:
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "DNA_boid_types.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "DNA_curve_types.h"
|
2009-07-14 20:27:28 +00:00
|
|
|
#include "DNA_group_types.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
2009-07-23 20:40:51 +00:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-07-14 20:27:28 +00:00
|
|
|
#include "BKE_group.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "BKE_font.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "BKE_library.h"
|
2009-07-02 19:41:31 +00:00
|
|
|
#include "BKE_main.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "BKE_material.h"
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
#include "BKE_node.h"
|
2009-06-27 15:41:47 +00:00
|
|
|
#include "BKE_particle.h"
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
#include "BKE_scene.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "BKE_texture.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "BKE_utildefines.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "BKE_world.h"
|
|
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "BLI_editVert.h"
|
2009-07-12 23:38:47 +00:00
|
|
|
#include "BLI_listbase.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "RNA_access.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "ED_curve.h"
|
|
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
|
2009-07-14 20:27:28 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2009-07-23 20:40:51 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "buttons_intern.h" // own include
|
|
|
|
|
|
2009-07-14 20:27:28 +00:00
|
|
|
|
|
|
|
|
/********************** group operators *********************/
|
|
|
|
|
|
|
|
|
|
static int group_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Base *base;
|
|
|
|
|
Group *group;
|
|
|
|
|
int value= RNA_enum_get(op->ptr, "group");
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
base= object_in_scene(ob, scene);
|
|
|
|
|
if(!base)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(value == -1)
|
|
|
|
|
group= add_group( "Group" );
|
|
|
|
|
else
|
|
|
|
|
group= BLI_findlink(&bmain->group, value);
|
|
|
|
|
|
|
|
|
|
if(group) {
|
|
|
|
|
add_to_group(group, ob);
|
|
|
|
|
ob->flag |= OB_FROMGROUP;
|
|
|
|
|
base->flag |= OB_FROMGROUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem group_items[]= {
|
|
|
|
|
{-1, "ADD_NEW", 0, "Add New Group", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free)
|
|
|
|
|
{
|
|
|
|
|
EnumPropertyItem tmp = {0, "", 0, "", ""};
|
|
|
|
|
EnumPropertyItem *item= NULL;
|
|
|
|
|
Main *bmain;
|
|
|
|
|
Group *group;
|
|
|
|
|
int a, totitem= 0;
|
|
|
|
|
|
|
|
|
|
if(!C) /* needed for docs */
|
|
|
|
|
return group_items;
|
|
|
|
|
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, group_items, -1);
|
|
|
|
|
|
|
|
|
|
bmain= CTX_data_main(C);
|
|
|
|
|
if(bmain->group.first)
|
|
|
|
|
RNA_enum_item_add_separator(&item, &totitem);
|
|
|
|
|
|
|
|
|
|
for(a=0, group=bmain->group.first; group; group=group->id.next, a++) {
|
|
|
|
|
tmp.value= a;
|
|
|
|
|
tmp.identifier= group->id.name+2;
|
|
|
|
|
tmp.name= group->id.name+2;
|
|
|
|
|
RNA_enum_item_add(&item, &totitem, &tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
|
|
|
|
|
|
|
|
|
*free= 1;
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_group_add(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_group_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= group_add_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
prop= RNA_def_enum(ot->srna, "group", group_items, -1, "Group", "Group to add object to.");
|
|
|
|
|
RNA_def_enum_funcs(prop, group_itemf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int group_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
|
|
|
|
|
Base *base;
|
|
|
|
|
|
|
|
|
|
if(!ob || !group)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
base= object_in_scene(ob, scene);
|
|
|
|
|
if(!base)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
rem_from_group(group, ob);
|
|
|
|
|
|
|
|
|
|
if(find_group(ob, NULL) == NULL) {
|
|
|
|
|
ob->flag &= ~OB_FROMGROUP;
|
|
|
|
|
base->flag &= ~OB_FROMGROUP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_group_remove(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Group";
|
|
|
|
|
ot->idname= "OBJECT_OT_group_remove";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= group_remove_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
/********************** material slot operators *********************/
|
|
|
|
|
|
|
|
|
|
static int material_slot_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
object_add_material_slot(ob);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_add(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= material_slot_add_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int material_slot_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
object_remove_material_slot(ob);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_remove";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= material_slot_remove_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int material_slot_assign_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(ob && ob->actcol>0) {
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
EditMesh *em= ((Mesh*)ob->data)->edit_mesh;
|
|
|
|
|
EditFace *efa;
|
|
|
|
|
|
|
|
|
|
if(em) {
|
|
|
|
|
for(efa= em->faces.first; efa; efa=efa->next)
|
|
|
|
|
if(efa->f & SELECT)
|
|
|
|
|
efa->mat_nr= ob->actcol-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
|
|
|
|
ListBase *editnurb= ((Curve*)ob->data)->editnurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
|
|
|
|
|
if(editnurb) {
|
|
|
|
|
for(nu= editnurb->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;
|
|
|
|
|
int i, selstart, selend;
|
|
|
|
|
|
|
|
|
|
if(ef && BKE_font_getselection(ob, &selstart, &selend)) {
|
|
|
|
|
for(i=selstart; i<=selend; i++)
|
|
|
|
|
ef->textbufinfo[i].mat_nr = ob->actcol-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Assign Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_assign";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= material_slot_assign_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int material_slot_de_select(bContext *C, int select)
|
|
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(ob->type == OB_MESH) {
|
|
|
|
|
EditMesh *em= ((Mesh*)ob->data)->edit_mesh;
|
|
|
|
|
|
|
|
|
|
if(em) {
|
|
|
|
|
if(select)
|
|
|
|
|
EM_select_by_material(em, ob->actcol-1);
|
|
|
|
|
else
|
|
|
|
|
EM_deselect_by_material(em, ob->actcol-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ELEM(ob->type, OB_CURVE, OB_SURF) {
|
|
|
|
|
ListBase *editnurb= ((Curve*)ob->data)->editnurb;
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
BezTriple *bezt;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
for(nu= editnurb->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;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bezt->f1 &= ~SELECT;
|
|
|
|
|
bezt->f2 &= ~SELECT;
|
|
|
|
|
bezt->f3 &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 bp->f1 &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
bp++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int material_slot_select_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
return material_slot_de_select(C, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_select(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Select Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_select";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= material_slot_select_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int material_slot_deselect_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
return material_slot_de_select(C, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Deselect Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_deselect";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= material_slot_deselect_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
/********************** new material operator *********************/
|
|
|
|
|
|
|
|
|
|
static int new_material_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2009-06-24 14:07:48 +00:00
|
|
|
Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
2009-06-07 13:36:12 +00:00
|
|
|
Object *ob;
|
2009-06-24 14:07:48 +00:00
|
|
|
PointerRNA ptr;
|
2009-06-07 13:36:12 +00:00
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
/* add or copy material */
|
|
|
|
|
if(ma)
|
|
|
|
|
ma= copy_material(ma);
|
|
|
|
|
else
|
|
|
|
|
ma= add_material("Material");
|
|
|
|
|
|
|
|
|
|
ma->id.us--; /* compensating for us++ in assign_material */
|
|
|
|
|
|
|
|
|
|
/* attempt to assign to material slot */
|
2009-06-24 14:07:48 +00:00
|
|
|
ptr= CTX_data_pointer_get_type(C, "material_slot", &RNA_MaterialSlot);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
if(ptr.data) {
|
2009-06-07 13:36:12 +00:00
|
|
|
ob= ptr.id.data;
|
|
|
|
|
index= (Material**)ptr.data - ob->mat;
|
|
|
|
|
|
|
|
|
|
assign_material(ob, ma, index+1);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
}
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_MATERIAL|NA_ADDED, ma);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MATERIAL_OT_new(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "New Material";
|
|
|
|
|
ot->idname= "MATERIAL_OT_new";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= new_material_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** new texture operator *********************/
|
|
|
|
|
|
|
|
|
|
static int new_texture_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2009-06-24 14:07:48 +00:00
|
|
|
Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
|
2009-06-07 13:36:12 +00:00
|
|
|
ID *id;
|
|
|
|
|
MTex *mtex;
|
2009-06-24 14:07:48 +00:00
|
|
|
PointerRNA ptr;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* add or copy texture */
|
|
|
|
|
if(tex)
|
|
|
|
|
tex= copy_texture(tex);
|
|
|
|
|
else
|
|
|
|
|
tex= add_texture("Texture");
|
|
|
|
|
|
|
|
|
|
id_us_min(&tex->id);
|
|
|
|
|
|
|
|
|
|
/* attempt to assign to texture slot */
|
2009-06-24 14:07:48 +00:00
|
|
|
ptr= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
if(ptr.data) {
|
2009-06-07 13:36:12 +00:00
|
|
|
id= ptr.id.data;
|
|
|
|
|
mtex= ptr.data;
|
|
|
|
|
|
|
|
|
|
if(mtex) {
|
|
|
|
|
if(mtex->tex)
|
|
|
|
|
id_us_min(&mtex->tex->id);
|
|
|
|
|
mtex->tex= tex;
|
|
|
|
|
id_us_plus(&tex->id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX nodes, notifier .. */
|
|
|
|
|
}
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_TEXTURE|NA_ADDED, tex);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TEXTURE_OT_new(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "New Texture";
|
|
|
|
|
ot->idname= "TEXTURE_OT_new";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= new_texture_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** new world operator *********************/
|
|
|
|
|
|
|
|
|
|
static int new_world_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2009-06-24 14:07:48 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* add or copy world */
|
|
|
|
|
if(wo)
|
|
|
|
|
wo= copy_world(wo);
|
|
|
|
|
else
|
|
|
|
|
wo= add_world("World");
|
|
|
|
|
|
|
|
|
|
/* assign to scene */
|
|
|
|
|
if(scene->world)
|
|
|
|
|
id_us_min(&scene->world->id);
|
|
|
|
|
scene->world= wo;
|
|
|
|
|
|
2009-06-24 14:07:48 +00:00
|
|
|
WM_event_add_notifier(C, NC_WORLD|NA_ADDED, wo);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WORLD_OT_new(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "New World";
|
|
|
|
|
ot->idname= "WORLD_OT_new";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= new_world_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/********************** particle system slot operators *********************/
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
static int particle_system_add_exec(bContext *C, wmOperator *op)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
|
|
if(!scene || !ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
object_add_particle_system(scene, ob);
|
2009-06-27 15:41:47 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
void OBJECT_OT_particle_system_add(wmOperatorType *ot)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Particle System Slot";
|
2009-06-30 19:20:45 +00:00
|
|
|
ot->idname= "OBJECT_OT_particle_system_add";
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-06-30 19:20:45 +00:00
|
|
|
ot->exec= particle_system_add_exec;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
static int particle_system_remove_exec(bContext *C, wmOperator *op)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
|
|
if(!scene || !ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
object_remove_particle_system(scene, ob);
|
2009-06-27 15:41:47 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-30 19:20:45 +00:00
|
|
|
void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
|
2009-06-27 15:41:47 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Particle System Slot";
|
2009-06-30 19:20:45 +00:00
|
|
|
ot->idname= "OBJECT_OT_particle_system_remove";
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-06-30 19:20:45 +00:00
|
|
|
ot->exec= particle_system_remove_exec;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** new particle settings operator *********************/
|
|
|
|
|
|
|
|
|
|
static int new_particle_settings_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2009-07-02 19:41:31 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2009-07-12 23:38:47 +00:00
|
|
|
ParticleSystem *psys;
|
|
|
|
|
ParticleSettings *part = NULL;
|
2009-06-27 15:41:47 +00:00
|
|
|
Object *ob;
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
|
|
|
|
|
psys = ptr.data;
|
|
|
|
|
|
2009-06-27 15:41:47 +00:00
|
|
|
/* add or copy particle setting */
|
2009-07-12 23:38:47 +00:00
|
|
|
if(psys->part)
|
|
|
|
|
part= psys_copy_settings(psys->part);
|
2009-06-27 15:41:47 +00:00
|
|
|
else
|
2009-07-20 23:52:53 +00:00
|
|
|
part= psys_new_settings("ParticleSettings", bmain);
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
ob= ptr.id.data;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
if(psys->part)
|
|
|
|
|
psys->part->id.us--;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
psys->part = part;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
psys_check_boid_data(psys);
|
|
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
DAG_scene_sort(scene);
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
2009-06-27 15:41:47 +00:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PARTICLE_OT_new(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "New Particle Settings";
|
|
|
|
|
ot->idname= "PARTICLE_OT_new";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= new_particle_settings_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
2009-07-09 19:45:27 +00:00
|
|
|
|
2009-07-12 23:38:47 +00:00
|
|
|
/********************** keyed particle target operators *********************/
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
static int new_particle_target_exec(bContext *C, wmOperator *op)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
if(!psys)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
|
|
|
|
for(; pt; pt=pt->next)
|
|
|
|
|
pt->flag &= ~PTARGET_CURRENT;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target");
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt->flag |= PTARGET_CURRENT;
|
|
|
|
|
pt->psys = 1;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_addtail(&psys->targets, pt);
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
DAG_scene_sort(scene);
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
void PARTICLE_OT_new_target(wmOperatorType *ot)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->name= "New Particle Target";
|
|
|
|
|
ot->idname= "PARTICLE_OT_new_target";
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->exec= new_particle_target_exec;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
static int remove_particle_target_exec(bContext *C, wmOperator *op)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
if(!psys)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
|
|
|
|
for(; pt; pt=pt->next) {
|
|
|
|
|
if(pt->flag & PTARGET_CURRENT) {
|
|
|
|
|
BLI_remlink(&psys->targets, pt);
|
|
|
|
|
MEM_freeN(pt);
|
2009-07-12 23:38:47 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.last;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
if(pt)
|
|
|
|
|
pt->flag |= PTARGET_CURRENT;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
DAG_scene_sort(scene);
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
void PARTICLE_OT_remove_target(wmOperatorType *ot)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->name= "Remove Particle Target";
|
|
|
|
|
ot->idname= "PARTICLE_OT_remove_target";
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->exec= remove_particle_target_exec;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/************************ move up particle target operator *********************/
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
static int target_move_up_exec(bContext *C, wmOperator *op)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
if(!psys)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
|
|
|
|
for(; pt; pt=pt->next) {
|
|
|
|
|
if(pt->flag & PTARGET_CURRENT && pt->prev) {
|
|
|
|
|
BLI_remlink(&psys->targets, pt);
|
|
|
|
|
BLI_insertlink(&psys->targets, pt->prev->prev, pt);
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
void PARTICLE_OT_target_move_up(wmOperatorType *ot)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->name= "Move Up Target";
|
|
|
|
|
ot->description= "Move particle target up in the list.";
|
|
|
|
|
ot->idname= "PARTICLE_OT_target_move_up";
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->exec= target_move_up_exec;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
/************************ move down particle target operator *********************/
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
static int target_move_down_exec(bContext *C, wmOperator *op)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
ParticleTarget *pt;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
if(!psys)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
2009-07-20 23:52:53 +00:00
|
|
|
pt = psys->targets.first;
|
|
|
|
|
for(; pt; pt=pt->next) {
|
|
|
|
|
if(pt->flag & PTARGET_CURRENT && pt->next) {
|
|
|
|
|
BLI_remlink(&psys->targets, pt);
|
|
|
|
|
BLI_insertlink(&psys->targets, pt->next, pt);
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
void PARTICLE_OT_target_move_down(wmOperatorType *ot)
|
2009-07-12 23:38:47 +00:00
|
|
|
{
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->name= "Move Down Target";
|
|
|
|
|
ot->description= "Move particle target down in the list.";
|
|
|
|
|
ot->idname= "PARTICLE_OT_target_move_down";
|
2009-07-12 23:38:47 +00:00
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
ot->exec= target_move_down_exec;
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Render
* UI layout for scene buttons has quite some changes, I tried to
better organize things according to the pipeline, and also showing
important properties by default, and collapsing less important ones.
Some changes compared to 2.4x:
* Panorama is now a Camera property.
* Sequence and Compositing are now enabled by default, but will only
do something when there is a node tree using nodes, or a strip in the
sequence editor.
* Enabling Full Sample now automatically enables Save Buffers too.
* Stamp option to include info in file is removed, it now simply always
does this if one of the stamp infos is enabled.
* Xvid, H.264 and Ogg Theora are now directly in the file format menu,
but still using FFMPEG. Unfortunately Ogg is broken at the moment
(also in 2.4x), so that's disabled. And Xvid crashes on 64bit linux,
maybe solvable by upgrading extern/xvidcore/, using ubuntu libs makes
it work.
* Organized file format menu by image/movie types.
Added:
* Render layers RNA wrapped, operatorized, layouted.
* FFMPEG format/codec options are now working.
Defaults changed:
* Compositing & Sequencer enabled.
* Tiles set to 8x8.
* Time/Date/Frame/Scene/Camera/Filename enabled for stamp.
2009-07-13 19:09:13 +00:00
|
|
|
/********************** render layer operators *********************/
|
|
|
|
|
|
|
|
|
|
static int render_layer_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
|
|
|
|
|
scene_add_render_layer(scene);
|
|
|
|
|
scene->r.actlay= BLI_countlist(&scene->r.layers) - 1;
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCENE_OT_render_layer_add(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Add Render Layer";
|
|
|
|
|
ot->idname= "SCENE_OT_render_layer_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= render_layer_add_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int render_layer_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
SceneRenderLayer *rl;
|
|
|
|
|
int act= scene->r.actlay;
|
|
|
|
|
|
|
|
|
|
if(BLI_countlist(&scene->r.layers) <= 1)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
rl= BLI_findlink(&scene->r.layers, scene->r.actlay);
|
|
|
|
|
BLI_remlink(&scene->r.layers, rl);
|
|
|
|
|
MEM_freeN(rl);
|
|
|
|
|
|
|
|
|
|
scene->r.actlay= 0;
|
|
|
|
|
|
|
|
|
|
if(scene->nodetree) {
|
|
|
|
|
bNode *node;
|
|
|
|
|
for(node= scene->nodetree->nodes.first; node; node= node->next) {
|
|
|
|
|
if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) {
|
|
|
|
|
if(node->custom1==act)
|
|
|
|
|
node->custom1= 0;
|
|
|
|
|
else if(node->custom1>act)
|
|
|
|
|
node->custom1--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCENE_OT_render_layer_remove(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Remove Render Layer";
|
|
|
|
|
ot->idname= "SCENE_OT_render_layer_remove";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= render_layer_remove_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
}
|
2009-07-21 00:36:07 +00:00
|
|
|
|
2009-07-23 20:40:51 +00:00
|
|
|
/********************** toolbox operator *********************/
|
|
|
|
|
|
|
|
|
|
static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
bScreen *sc= CTX_wm_screen(C);
|
|
|
|
|
SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
|
uiLayout *layout;
|
|
|
|
|
|
|
|
|
|
RNA_pointer_create(&sc->id, &RNA_SpaceButtonsWindow, sbuts, &ptr);
|
|
|
|
|
|
|
|
|
|
pup= uiPupMenuBegin(C, "Align", 0);
|
|
|
|
|
layout= uiPupMenuLayout(pup);
|
|
|
|
|
uiItemsEnumR(layout, &ptr, "align");
|
|
|
|
|
uiPupMenuEnd(C, pup);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BUTTONS_OT_toolbox(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Toolbox";
|
|
|
|
|
ot->idname= "BUTTONS_OT_toolbox";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= toolbox_invoke;
|
|
|
|
|
}
|
|
|
|
|
|