Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-07-25 16:07:19 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-07-25 16:07:19 +0400
commit7eaef1068dbec8dda48aadbed8c0e86e1245ad63 (patch)
tree2561066f3ef6e44bc55835b0a8b631471b904a4d /source/blender/editors/physics
parent1bb491348b039eff2cc4e56267efcb43d24fccae (diff)
Fix #31419, Changing Boid-Properties impossible with pinned Particle Menu.
Boid operators now retrieve the particle settings from the context directly, instead of always using the particle system (which is only needed to get to the settings anyway). When particle settings are pinned there is no particle system in the context, causing the operators to fail.
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r--source/blender/editors/physics/particle_boids.c98
1 files changed, 34 insertions, 64 deletions
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index 23ce4776b73..aff66b272fe 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -56,23 +56,18 @@
/************************ add/del boid rule operators *********************/
static int rule_add_exec(bContext *C, wmOperator *op)
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
- Object *ob= ptr.id.data;
- ParticleSettings *part;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
int type= RNA_enum_get(op->ptr, "type");
BoidRule *rule;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- part = psys->part;
-
state = boid_get_current_state(part->boids);
-
for (rule=state->rules.first; rule; rule=rule->next)
rule->flag &= ~BOIDRULE_CURRENT;
@@ -82,7 +77,6 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BLI_addtail(&state->rules, rule);
DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
}
@@ -107,25 +101,22 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
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;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidRule *rule;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- state = boid_get_current_state(psys->part->boids);
+ state = boid_get_current_state(part->boids);
-
for (rule=state->rules.first; rule; rule=rule->next) {
if (rule->flag & BOIDRULE_CURRENT) {
BLI_remlink(&state->rules, rule);
MEM_freeN(rule);
break;
}
-
}
rule = state->rules.first;
@@ -133,10 +124,8 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
rule->flag |= BOIDRULE_CURRENT;
DAG_scene_sort(bmain, scene);
- DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
+ DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-
return OPERATOR_FINISHED;
}
@@ -157,23 +146,21 @@ void BOID_OT_rule_del(wmOperatorType *ot)
/************************ move up/down boid rule operators *********************/
static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
- Object *ob = ptr.id.data;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidRule *rule;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- state = boid_get_current_state(psys->part->boids);
+ state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule=rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->prev) {
BLI_remlink(&state->rules, rule);
BLI_insertlink(&state->rules, rule->prev->prev, rule);
- DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
break;
}
}
@@ -195,23 +182,21 @@ void BOID_OT_rule_move_up(wmOperatorType *ot)
static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
- Object *ob = ptr.id.data;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidRule *rule;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- state = boid_get_current_state(psys->part->boids);
+ state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule=rule->next) {
if (rule->flag & BOIDRULE_CURRENT && rule->next) {
BLI_remlink(&state->rules, rule);
BLI_insertlink(&state->rules, rule->next, rule);
- DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
break;
}
}
@@ -235,17 +220,13 @@ void BOID_OT_rule_move_down(wmOperatorType *ot)
/************************ add/del boid state operators *********************/
static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
- Object *ob= ptr.id.data;
- ParticleSettings *part;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- part = psys->part;
-
for (state=part->boids->states.first; state; state=state->next)
state->flag &= ~BOIDSTATE_CURRENT;
@@ -254,8 +235,6 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
BLI_addtail(&part->boids->states, state);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-
return OPERATOR_FINISHED;
}
@@ -276,24 +255,19 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
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;
- ParticleSettings *part;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- part = psys->part;
-
for (state=part->boids->states.first; state; state=state->next) {
if (state->flag & BOIDSTATE_CURRENT) {
BLI_remlink(&part->boids->states, state);
MEM_freeN(state);
break;
}
-
}
/* there must be at least one state */
@@ -307,9 +281,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
state->flag |= BOIDSTATE_CURRENT;
DAG_scene_sort(bmain, scene);
- DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
-
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
return OPERATOR_FINISHED;
}
@@ -331,22 +303,20 @@ void BOID_OT_state_del(wmOperatorType *ot)
/************************ move up/down boid state operators *********************/
static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
- Object *ob = ptr.id.data;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidSettings *boids;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- boids = psys->part->boids;
+ boids = part->boids;
for (state = boids->states.first; state; state=state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->prev) {
BLI_remlink(&boids->states, state);
BLI_insertlink(&boids->states, state->prev->prev, state);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
break;
}
}
@@ -368,21 +338,21 @@ void BOID_OT_state_move_up(wmOperatorType *ot)
static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
- ParticleSystem *psys= ptr.data;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings);
+ ParticleSettings *part = ptr.data;
BoidSettings *boids;
BoidState *state;
- if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS)
return OPERATOR_CANCELLED;
- boids = psys->part->boids;
+ boids = part->boids;
for (state = boids->states.first; state; state=state->next) {
if (state->flag & BOIDSTATE_CURRENT && state->next) {
BLI_remlink(&boids->states, state);
BLI_insertlink(&boids->states, state->next, state);
- DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
+ DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
break;
}
}