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"
|
2009-09-05 20:12:08 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_modifier_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"
|
|
|
|
|
|
2009-09-05 20:12:08 +00:00
|
|
|
#include "BKE_bvhutils.h"
|
|
|
|
|
#include "BKE_cdderivedmesh.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "BKE_context.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2009-09-05 20:12:08 +00:00
|
|
|
#include "BKE_DerivedMesh.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"
|
2009-09-10 22:32:33 +00:00
|
|
|
#include "BKE_modifier.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"
|
2009-09-05 20:12:08 +00:00
|
|
|
#include "BKE_pointcache.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-09-05 20:12:08 +00:00
|
|
|
#include "BLI_arithb.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-09-06 13:20:05 +00:00
|
|
|
#include "ED_particle.h"
|
2009-06-24 14:07:48 +00:00
|
|
|
|
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-07-28 18:51:06 +00:00
|
|
|
#include "UI_resources.h"
|
2009-07-23 20:40:51 +00:00
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "buttons_intern.h" // own include
|
|
|
|
|
|
2009-07-14 20:27:28 +00:00
|
|
|
|
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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a new material slot or duplicate the selected one.";
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Remove the selected material slot.";
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
|
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Assign Material Slot";
|
|
|
|
|
ot->idname= "OBJECT_OT_material_slot_assign";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Assign the material in the selected material slot to the selected vertices.";
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
/* 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++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Select vertices assigned to the selected material slot.";
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Deselect vertices assigned to the selected material slot.";
|
2009-06-24 14:07:48 +00:00
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a new material.";
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a new texture.";
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description= "Add a new world.";
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* 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-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a particle system.";
|
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-09-12 17:16:12 +00:00
|
|
|
ot->description="Remove the selected particle system.";
|
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 *********************/
|
|
|
|
|
|
2009-09-04 08:49:11 +00:00
|
|
|
static int psys_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
return (ptr.data != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-27 15:41:47 +00:00
|
|
|
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);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Add new particle settings.";
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= new_particle_settings_exec;
|
2009-09-04 08:49:11 +00:00
|
|
|
ot->poll= psys_poll;
|
2009-06-27 15:41:47 +00:00
|
|
|
|
|
|
|
|
/* 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);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
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-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a new particle 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);
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
2009-07-12 23:38:47 +00:00
|
|
|
|
|
|
|
|
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-09-12 17:16:12 +00:00
|
|
|
ot->description="Remove the selected particle 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
|
|
|
{
|
|
|
|
|
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
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
2009-07-12 23:38:47 +00:00
|
|
|
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->idname= "PARTICLE_OT_target_move_up";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description= "Move particle target up in the list.";
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
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
|
|
|
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
|
2009-07-12 23:38:47 +00:00
|
|
|
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->idname= "PARTICLE_OT_target_move_down";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description= "Move particle target down in the list.";
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-05 20:12:08 +00:00
|
|
|
/************************ connect/disconnect hair operators *********************/
|
|
|
|
|
|
|
|
|
|
static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys);
|
|
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
PTCacheEdit *edit = psys->edit;
|
|
|
|
|
PTCacheEditPoint *point = edit ? edit->points : NULL;
|
|
|
|
|
PTCacheEditKey *ekey = NULL;
|
|
|
|
|
HairKey *key;
|
|
|
|
|
int i, k;
|
|
|
|
|
float hairmat[4][4];
|
|
|
|
|
|
|
|
|
|
if(!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(!psys->part || psys->part->type != PART_HAIR)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for(i=0; i<psys->totpart; i++,pa++) {
|
|
|
|
|
if(point) {
|
|
|
|
|
ekey = point->keys;
|
|
|
|
|
point++;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-11 00:23:08 +00:00
|
|
|
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat);
|
2009-09-05 20:12:08 +00:00
|
|
|
|
|
|
|
|
for(k=0,key=pa->hair; k<pa->totkey; k++,key++) {
|
|
|
|
|
Mat4MulVecfl(hairmat,key->co);
|
|
|
|
|
|
|
|
|
|
if(ekey) {
|
|
|
|
|
ekey->flag &= ~PEK_USE_WCO;
|
|
|
|
|
ekey++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
psys_free_path_cache(psys, psys->edit);
|
|
|
|
|
|
|
|
|
|
psys->flag |= PSYS_GLOBAL_HAIR;
|
|
|
|
|
|
|
|
|
|
PE_update_object(scene, ob, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int disconnect_hair_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= NULL;
|
|
|
|
|
int all = RNA_boolean_get(op->ptr, "all");
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(all) {
|
|
|
|
|
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
|
|
|
|
disconnect_hair(scene, ob, psys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
psys = ptr.data;
|
|
|
|
|
disconnect_hair(scene, ob, psys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PARTICLE_OT_disconnect_hair(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
ot->name= "Disconnect Hair";
|
|
|
|
|
ot->description= "Disconnect hair from the emitter mesh.";
|
|
|
|
|
ot->idname= "PARTICLE_OT_disconnect_hair";
|
2009-09-12 17:16:12 +00:00
|
|
|
|
2009-09-05 20:12:08 +00:00
|
|
|
ot->exec= disconnect_hair_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys)
|
|
|
|
|
{
|
|
|
|
|
ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys);
|
|
|
|
|
ParticleData *pa = psys->particles;
|
|
|
|
|
PTCacheEdit *edit = psys->edit;
|
|
|
|
|
PTCacheEditPoint *point = edit ? edit->points : NULL;
|
|
|
|
|
PTCacheEditKey *ekey;
|
|
|
|
|
HairKey *key;
|
|
|
|
|
BVHTreeFromMesh bvhtree;
|
|
|
|
|
BVHTreeNearest nearest;
|
|
|
|
|
MFace *mface;
|
2009-09-10 22:32:33 +00:00
|
|
|
DerivedMesh *dm = NULL;
|
|
|
|
|
int numverts;
|
2009-09-05 20:12:08 +00:00
|
|
|
int i, k;
|
|
|
|
|
float hairmat[4][4], imat[4][4];
|
|
|
|
|
float v[4][3], vec[3];
|
|
|
|
|
|
|
|
|
|
if(!psys || !psys->part || psys->part->type != PART_HAIR)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
if(psmd->dm->deformedOnly)
|
|
|
|
|
dm= psmd->dm;
|
|
|
|
|
else
|
|
|
|
|
dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
|
|
|
|
|
|
|
|
|
|
numverts = dm->getNumVerts (dm);
|
|
|
|
|
|
2009-09-05 20:12:08 +00:00
|
|
|
memset( &bvhtree, 0, sizeof(bvhtree) );
|
|
|
|
|
|
|
|
|
|
/* convert to global coordinates */
|
|
|
|
|
for (i=0; i<numverts; i++)
|
|
|
|
|
Mat4MulVecfl (ob->obmat, CDDM_get_vert(dm, i)->co);
|
|
|
|
|
|
|
|
|
|
bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6);
|
|
|
|
|
|
|
|
|
|
for(i=0; i<psys->totpart; i++,pa++) {
|
|
|
|
|
key = pa->hair;
|
|
|
|
|
|
|
|
|
|
nearest.index = -1;
|
|
|
|
|
nearest.dist = FLT_MAX;
|
|
|
|
|
|
|
|
|
|
BLI_bvhtree_find_nearest(bvhtree.tree, key->co, &nearest, bvhtree.nearest_callback, &bvhtree);
|
|
|
|
|
|
|
|
|
|
if(nearest.index == -1) {
|
|
|
|
|
printf("No nearest point found for hair root!");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mface = CDDM_get_face(dm,nearest.index);
|
|
|
|
|
|
|
|
|
|
VecCopyf(v[0], CDDM_get_vert(dm,mface->v1)->co);
|
|
|
|
|
VecCopyf(v[1], CDDM_get_vert(dm,mface->v2)->co);
|
|
|
|
|
VecCopyf(v[2], CDDM_get_vert(dm,mface->v3)->co);
|
|
|
|
|
if(mface->v4) {
|
|
|
|
|
VecCopyf(v[3], CDDM_get_vert(dm,mface->v4)->co);
|
|
|
|
|
MeanValueWeights(v, 4, nearest.co, pa->fuv);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
MeanValueWeights(v, 3, nearest.co, pa->fuv);
|
|
|
|
|
|
|
|
|
|
pa->num = nearest.index;
|
|
|
|
|
pa->num_dmcache = psys_particle_dm_face_lookup(ob,psmd->dm,pa->num,pa->fuv,NULL);
|
|
|
|
|
|
|
|
|
|
psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat);
|
|
|
|
|
Mat4Invert(imat,hairmat);
|
|
|
|
|
|
|
|
|
|
VECSUB(vec, nearest.co, key->co);
|
|
|
|
|
|
|
|
|
|
if(point) {
|
|
|
|
|
ekey = point->keys;
|
|
|
|
|
point++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(k=0,key=pa->hair; k<pa->totkey; k++,key++) {
|
|
|
|
|
VECADD(key->co, key->co, vec);
|
|
|
|
|
Mat4MulVecfl(imat,key->co);
|
|
|
|
|
|
|
|
|
|
if(ekey) {
|
|
|
|
|
ekey->flag |= PEK_USE_WCO;
|
|
|
|
|
ekey++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free_bvhtree_from_mesh(&bvhtree);
|
2009-09-10 22:32:33 +00:00
|
|
|
if(!psmd->dm->deformedOnly)
|
|
|
|
|
dm->release(dm);
|
2009-09-05 20:12:08 +00:00
|
|
|
|
|
|
|
|
psys_free_path_cache(psys, psys->edit);
|
|
|
|
|
|
|
|
|
|
psys->flag &= ~PSYS_GLOBAL_HAIR;
|
|
|
|
|
|
|
|
|
|
PE_update_object(scene, ob, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int connect_hair_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
|
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
|
|
|
|
|
ParticleSystem *psys= NULL;
|
|
|
|
|
int all = RNA_boolean_get(op->ptr, "all");
|
|
|
|
|
|
|
|
|
|
if(!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
if(all) {
|
|
|
|
|
for(psys=ob->particlesystem.first; psys; psys=psys->next) {
|
|
|
|
|
connect_hair(scene, ob, psys);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
psys = ptr.data;
|
|
|
|
|
connect_hair(scene, ob, psys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PARTICLE_OT_connect_hair(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
ot->name= "Connect Hair";
|
|
|
|
|
ot->description= "Connect hair to the emitter mesh.";
|
|
|
|
|
ot->idname= "PARTICLE_OT_connect_hair";
|
2009-09-12 17:16:12 +00:00
|
|
|
|
2009-09-05 20:12:08 +00:00
|
|
|
ot->exec= connect_hair_exec;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "all", 0, "All hair", "Connect all hair systems to the emitter mesh");
|
|
|
|
|
}
|
|
|
|
|
|
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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Add a render layer.";
|
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
|
|
|
|
|
|
|
|
/* 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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Remove the selected render layer.";
|
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
|
|
|
|
|
|
|
|
/* 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);
|
2009-07-28 16:33:02 +00:00
|
|
|
SpaceButs *sbuts= CTX_wm_space_buts(C);
|
2009-07-23 20:40:51 +00:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
uiPopupMenu *pup;
|
|
|
|
|
uiLayout *layout;
|
|
|
|
|
|
2009-08-18 12:58:51 +00:00
|
|
|
RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr);
|
2009-07-23 20:40:51 +00:00
|
|
|
|
|
|
|
|
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";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Toolbar panel? DOC_BROKEN";
|
2009-07-23 20:40:51 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= toolbox_invoke;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-28 18:51:06 +00:00
|
|
|
/********************** filebrowse operator *********************/
|
|
|
|
|
|
|
|
|
|
typedef struct FileBrowseOp {
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
} FileBrowseOp;
|
|
|
|
|
|
|
|
|
|
static int file_browse_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
FileBrowseOp *fbo= op->customdata;
|
|
|
|
|
char *str;
|
|
|
|
|
|
2009-09-04 08:49:11 +00:00
|
|
|
if (RNA_property_is_set(op->ptr, "filename")==0 || fbo==NULL)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
2009-07-28 18:51:06 +00:00
|
|
|
str= RNA_string_get_alloc(op->ptr, "filename", 0, 0);
|
|
|
|
|
RNA_property_string_set(&fbo->ptr, fbo->prop, str);
|
|
|
|
|
RNA_property_update(C, &fbo->ptr, fbo->prop);
|
|
|
|
|
MEM_freeN(str);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int file_browse_cancel(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
|
op->customdata= NULL;
|
|
|
|
|
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
FileBrowseOp *fbo;
|
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
|
|
uiFileBrowseContextProperty(C, &ptr, &prop);
|
|
|
|
|
|
|
|
|
|
if(!prop)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
|
|
|
|
|
fbo->ptr= ptr;
|
|
|
|
|
fbo->prop= prop;
|
|
|
|
|
op->customdata= fbo;
|
|
|
|
|
|
|
|
|
|
str= RNA_property_string_get_alloc(&ptr, prop, 0, 0);
|
|
|
|
|
RNA_string_set(op->ptr, "filename", str);
|
|
|
|
|
MEM_freeN(str);
|
|
|
|
|
|
|
|
|
|
WM_event_add_fileselect(C, op);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BUTTONS_OT_file_browse(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "File Browse";
|
|
|
|
|
ot->idname= "BUTTONS_OT_file_browse";
|
2009-09-12 17:16:12 +00:00
|
|
|
ot->description="Open a file browser.";
|
2009-07-28 18:51:06 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= file_browse_invoke;
|
|
|
|
|
ot->exec= file_browse_exec;
|
|
|
|
|
ot->cancel= file_browse_cancel;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
WM_operator_properties_filesel(ot, 0);
|
|
|
|
|
}
|
|
|
|
|
|