2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-20 23:52:53 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-20 23:52:53 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Janne Karhu.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/physics/particle_boids.c
|
|
|
|
* \ingroup edphys
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_particle_types.h"
|
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "BKE_boids.h"
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_depsgraph.h"
|
2010-08-01 12:47:49 +00:00
|
|
|
#include "BKE_main.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
#include "BKE_particle.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
#include "physics_intern.h"
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/************************ add/del boid rule operators *********************/
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
static int rule_add_exec(bContext *C, wmOperator *op)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
int type= RNA_enum_get(op->ptr, "type");
|
|
|
|
|
|
|
|
BoidRule *rule;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
state = boid_get_current_state(part->boids);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (rule=state->rules.first; rule; rule=rule->next)
|
2009-07-20 23:52:53 +00:00
|
|
|
rule->flag &= ~BOIDRULE_CURRENT;
|
|
|
|
|
|
|
|
rule = boid_new_rule(type);
|
|
|
|
rule->flag |= BOIDRULE_CURRENT;
|
|
|
|
|
|
|
|
BLI_addtail(&state->rules, rule);
|
|
|
|
|
2010-12-05 18:59:23 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_rule_add(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Boid Rule";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Add a boid rule to the current boid state";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "BOID_OT_rule_add";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
ot->exec = rule_add_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2015-11-23 13:49:52 +11:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_boidrule_type_items, 0, "Type", "");
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2010-10-15 01:36:14 +00:00
|
|
|
static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidRule *rule;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
state = boid_get_current_state(part->boids);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (rule=state->rules.first; rule; rule=rule->next) {
|
|
|
|
if (rule->flag & BOIDRULE_CURRENT) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&state->rules, rule);
|
|
|
|
MEM_freeN(rule);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rule = state->rules.first;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rule)
|
2009-07-20 23:52:53 +00:00
|
|
|
rule->flag |= BOIDRULE_CURRENT;
|
|
|
|
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-07-25 12:07:19 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_rule_del(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Boid Rule";
|
|
|
|
ot->idname = "BOID_OT_rule_del";
|
2012-05-04 15:00:36 +00:00
|
|
|
ot->description = "Delete current boid rule";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = rule_del_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************ move up/down boid rule operators *********************/
|
2010-10-15 01:36:14 +00:00
|
|
|
static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidRule *rule;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
state = boid_get_current_state(part->boids);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (rule = state->rules.first; rule; rule=rule->next) {
|
|
|
|
if (rule->flag & BOIDRULE_CURRENT && rule->prev) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&state->rules, rule);
|
2013-02-22 14:12:55 +00:00
|
|
|
BLI_insertlinkbefore(&state->rules, rule->prev, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_rule_move_up(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Up Boid Rule";
|
|
|
|
ot->description = "Move boid rule up in the list";
|
|
|
|
ot->idname = "BOID_OT_rule_move_up";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = rule_move_up_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidRule *rule;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
state = boid_get_current_state(part->boids);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (rule = state->rules.first; rule; rule=rule->next) {
|
|
|
|
if (rule->flag & BOIDRULE_CURRENT && rule->next) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&state->rules, rule);
|
2013-02-22 14:12:55 +00:00
|
|
|
BLI_insertlinkafter(&state->rules, rule->next, rule);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_rule_move_down(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Down Boid Rule";
|
|
|
|
ot->description = "Move boid rule down in the list";
|
|
|
|
ot->idname = "BOID_OT_rule_move_down";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = rule_move_down_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************ add/del boid state operators *********************/
|
2010-10-15 01:36:14 +00:00
|
|
|
static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (state=part->boids->states.first; state; state=state->next)
|
2009-07-20 23:52:53 +00:00
|
|
|
state->flag &= ~BOIDSTATE_CURRENT;
|
|
|
|
|
|
|
|
state = boid_new_state(part->boids);
|
|
|
|
state->flag |= BOIDSTATE_CURRENT;
|
|
|
|
|
|
|
|
BLI_addtail(&part->boids->states, state);
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_state_add(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Boid State";
|
2010-02-10 21:15:44 +00:00
|
|
|
ot->description = "Add a boid state to the particle system";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "BOID_OT_state_add";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = state_add_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
2010-10-15 01:36:14 +00:00
|
|
|
static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (state=part->boids->states.first; state; state=state->next) {
|
|
|
|
if (state->flag & BOIDSTATE_CURRENT) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&part->boids->states, state);
|
|
|
|
MEM_freeN(state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* there must be at least one state */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!part->boids->states.first) {
|
2009-07-20 23:52:53 +00:00
|
|
|
state = boid_new_state(part->boids);
|
2012-10-21 05:46:41 +00:00
|
|
|
BLI_addtail(&part->boids->states, state);
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
state = part->boids->states.first;
|
|
|
|
|
|
|
|
state->flag |= BOIDSTATE_CURRENT;
|
|
|
|
|
2013-02-21 19:33:04 +00:00
|
|
|
DAG_relations_tag_update(bmain);
|
2012-07-25 12:07:19 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_state_del(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Boid State";
|
|
|
|
ot->idname = "BOID_OT_state_del";
|
2012-05-04 15:00:36 +00:00
|
|
|
ot->description = "Delete current boid state";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = state_del_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************ move up/down boid state operators *********************/
|
2010-10-15 01:36:14 +00:00
|
|
|
static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidSettings *boids;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
boids = part->boids;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (state = boids->states.first; state; state=state->next) {
|
|
|
|
if (state->flag & BOIDSTATE_CURRENT && state->prev) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&boids->states, state);
|
2013-02-22 14:12:55 +00:00
|
|
|
BLI_insertlinkbefore(&boids->states, state->prev, state);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_state_move_up(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Up Boid State";
|
|
|
|
ot->description = "Move boid state up in the list";
|
|
|
|
ot->idname = "BOID_OT_state_move_up";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = state_move_up_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-07-25 12:07:19 +00:00
|
|
|
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
|
|
|
|
ParticleSettings *part = ptr.data;
|
2009-07-20 23:52:53 +00:00
|
|
|
BoidSettings *boids;
|
|
|
|
BoidState *state;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
if (!part || part->phystype != PART_PHYS_BOIDS)
|
2009-07-20 23:52:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
2012-07-25 12:07:19 +00:00
|
|
|
boids = part->boids;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
for (state = boids->states.first; state; state=state->next) {
|
|
|
|
if (state->flag & BOIDSTATE_CURRENT && state->next) {
|
2009-07-20 23:52:53 +00:00
|
|
|
BLI_remlink(&boids->states, state);
|
2013-02-22 14:12:55 +00:00
|
|
|
BLI_insertlinkafter(&boids->states, state->next, state);
|
2012-07-25 12:07:19 +00:00
|
|
|
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
|
2009-07-20 23:52:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
void BOID_OT_state_move_down(wmOperatorType *ot)
|
2009-07-20 23:52:53 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Down Boid State";
|
|
|
|
ot->description = "Move boid state down in the list";
|
|
|
|
ot->idname = "BOID_OT_state_move_down";
|
2009-07-20 23:52:53 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->exec = state_move_down_exec;
|
2009-07-20 23:52:53 +00:00
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-20 23:52:53 +00:00
|
|
|
}
|
|
|
|
|