diff options
author | Janne Karhu <jhkarh@gmail.com> | 2009-07-21 03:52:53 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2009-07-21 03:52:53 +0400 |
commit | b4353a84439085ac7d4bb7da2daed983637a75cc (patch) | |
tree | 01e560f80b4c190cddae071c7ca41cd5840fe1ec /source/blender/editors/space_buttons | |
parent | 01b787636b468a1d37a27bb7601de5b0dea9c4b0 (diff) |
Initial code for boids v2
Too many new features to list! But here are the biggies:
- Boids can move on air and/or land, or climb a goal object.
- Proper interaction with collision objects.
* Closest collision object in negative z direction is considered as ground.
* Other collision objects are obstacles and boids collide with them.
- Boid behavior rules are now added to a dynamic list.
* Many new rules and many still not implemented.
* Different rule evaluation modes (fuzzy, random, average).
- Only particle systems defined by per system "boid relations" are considered for simulation of that system.
* This is in addition to the boids own system of course.
* Relations define other systems as "neutral", "friend" or "enemy".
- All effectors now effect boid physics, not boid brains.
* This allows forcing boids somewhere.
* Exception to this is new "boid" effector, which defines boid predators (positive strength) and goals (negative strength).
Known issue:
- Boid health isn't yet stored in pointcache so simulations with "fight" rule are not be read from cache properly.
- Object/Group visualization object's animation is not played in "particle time". This is definately the wanted behavior, but isn't possible with the current state of dupliobject code.
Other new features:
- Particle systems can now be named separately from particle settings.
* Default name for particle settings is now "ParticleSettings" instead of "PSys"
- Per particle system list of particle effector weights.
* Enables different effection strengths for particles from different particle systems with without messing around with effector group setting.
Other code changes:
- KDTree now supports range search as it's needed for new boids.
- "Keyed particle targets" renamed as general "particle targets", as they're needed for boids too. (this might break some files saved with new keyed particles)
Bug fixes:
- Object & group visualizations didn't work.
- Interpolating pointcache didn't do rotation.
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_intern.h | 8 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 112 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 8 |
3 files changed, 66 insertions, 62 deletions
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 20db9fce8f2..adae52c1ce7 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -78,10 +78,10 @@ void OBJECT_OT_particle_system_add(struct wmOperatorType *ot); void OBJECT_OT_particle_system_remove(struct wmOperatorType *ot); void PARTICLE_OT_new(struct wmOperatorType *ot); -void PARTICLE_OT_new_keyed_target(struct wmOperatorType *ot); -void PARTICLE_OT_remove_keyed_target(struct wmOperatorType *ot); -void PARTICLE_OT_keyed_target_move_up(struct wmOperatorType *ot); -void PARTICLE_OT_keyed_target_move_down(struct wmOperatorType *ot); +void PARTICLE_OT_new_target(struct wmOperatorType *ot); +void PARTICLE_OT_remove_target(struct wmOperatorType *ot); +void PARTICLE_OT_target_move_up(struct wmOperatorType *ot); +void PARTICLE_OT_target_move_down(struct wmOperatorType *ot); void SCENE_OT_render_layer_add(struct wmOperatorType *ot); void SCENE_OT_render_layer_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 7dececd2679..8a9d2e9149b 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -30,6 +30,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_boid_types.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_object_types.h" @@ -57,6 +58,7 @@ #include "BLI_listbase.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -623,7 +625,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op) if(psys->part) part= psys_copy_settings(psys->part); else - part= psys_new_settings("PSys", bmain); + part= psys_new_settings("ParticleSettings", bmain); ob= ptr.id.data; @@ -632,6 +634,8 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op) psys->part = part; + psys_check_boid_data(psys); + DAG_scene_sort(scene); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -655,28 +659,28 @@ void PARTICLE_OT_new(wmOperatorType *ot) /********************** keyed particle target operators *********************/ -static int new_keyed_particle_target_exec(bContext *C, wmOperator *op) +static int new_particle_target_exec(bContext *C, wmOperator *op) { 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; - KeyedParticleTarget *kpt; + ParticleTarget *pt; if(!psys) return OPERATOR_CANCELLED; - kpt = psys->keyed_targets.first; - for(; kpt; kpt=kpt->next) - kpt->flag &= ~KEYED_TARGET_CURRENT; + pt = psys->targets.first; + for(; pt; pt=pt->next) + pt->flag &= ~PTARGET_CURRENT; - kpt = MEM_callocN(sizeof(KeyedParticleTarget), "keyed particle target"); + pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target"); - kpt->flag |= KEYED_TARGET_CURRENT; - kpt->psys = 1; + pt->flag |= PTARGET_CURRENT; + pt->psys = 1; - BLI_addtail(&psys->keyed_targets, kpt); + BLI_addtail(&psys->targets, pt); DAG_scene_sort(scene); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -686,44 +690,44 @@ static int new_keyed_particle_target_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_new_keyed_target(wmOperatorType *ot) +void PARTICLE_OT_new_target(wmOperatorType *ot) { /* identifiers */ - ot->name= "New Keyed Particle Target"; - ot->idname= "PARTICLE_OT_new_keyed_target"; + ot->name= "New Particle Target"; + ot->idname= "PARTICLE_OT_new_target"; /* api callbacks */ - ot->exec= new_keyed_particle_target_exec; + ot->exec= new_particle_target_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -static int remove_keyed_particle_target_exec(bContext *C, wmOperator *op) +static int remove_particle_target_exec(bContext *C, wmOperator *op) { 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; - KeyedParticleTarget *kpt; + ParticleTarget *pt; if(!psys) return OPERATOR_CANCELLED; - kpt = psys->keyed_targets.first; - for(; kpt; kpt=kpt->next) { - if(kpt->flag & KEYED_TARGET_CURRENT) { - BLI_remlink(&psys->keyed_targets, kpt); - MEM_freeN(kpt); + pt = psys->targets.first; + for(; pt; pt=pt->next) { + if(pt->flag & PTARGET_CURRENT) { + BLI_remlink(&psys->targets, pt); + MEM_freeN(pt); break; } } - kpt = psys->keyed_targets.last; + pt = psys->targets.last; - if(kpt) - kpt->flag |= KEYED_TARGET_CURRENT; + if(pt) + pt->flag |= PTARGET_CURRENT; DAG_scene_sort(scene); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); @@ -733,37 +737,37 @@ static int remove_keyed_particle_target_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_remove_keyed_target(wmOperatorType *ot) +void PARTICLE_OT_remove_target(wmOperatorType *ot) { /* identifiers */ - ot->name= "Remove Keyed Particle Target"; - ot->idname= "PARTICLE_OT_remove_keyed_target"; + ot->name= "Remove Particle Target"; + ot->idname= "PARTICLE_OT_remove_target"; /* api callbacks */ - ot->exec= remove_keyed_particle_target_exec; + ot->exec= remove_particle_target_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/************************ move up modifier operator *********************/ +/************************ move up particle target operator *********************/ -static int keyed_target_move_up_exec(bContext *C, wmOperator *op) +static int target_move_up_exec(bContext *C, wmOperator *op) { 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; - KeyedParticleTarget *kpt; + ParticleTarget *pt; if(!psys) return OPERATOR_CANCELLED; - kpt = psys->keyed_targets.first; - for(; kpt; kpt=kpt->next) { - if(kpt->flag & KEYED_TARGET_CURRENT && kpt->prev) { - BLI_remlink(&psys->keyed_targets, kpt); - BLI_insertlink(&psys->keyed_targets, kpt->prev->prev, kpt); + 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); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -774,35 +778,35 @@ static int keyed_target_move_up_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_keyed_target_move_up(wmOperatorType *ot) +void PARTICLE_OT_target_move_up(wmOperatorType *ot) { - ot->name= "Move Up Keyed Target"; - ot->description= "Move keyed particle target up in the list."; - ot->idname= "PARTICLE_OT_keyed_target_move_up"; + ot->name= "Move Up Target"; + ot->description= "Move particle target up in the list."; + ot->idname= "PARTICLE_OT_target_move_up"; - ot->exec= keyed_target_move_up_exec; + ot->exec= target_move_up_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/************************ move down modifier operator *********************/ +/************************ move down particle target operator *********************/ -static int keyed_target_move_down_exec(bContext *C, wmOperator *op) +static int target_move_down_exec(bContext *C, wmOperator *op) { 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; - KeyedParticleTarget *kpt; + ParticleTarget *pt; if(!psys) return OPERATOR_CANCELLED; - kpt = psys->keyed_targets.first; - for(; kpt; kpt=kpt->next) { - if(kpt->flag & KEYED_TARGET_CURRENT && kpt->next) { - BLI_remlink(&psys->keyed_targets, kpt); - BLI_insertlink(&psys->keyed_targets, kpt->next, kpt); + 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); DAG_object_flush_update(scene, ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -813,13 +817,13 @@ static int keyed_target_move_down_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_keyed_target_move_down(wmOperatorType *ot) +void PARTICLE_OT_target_move_down(wmOperatorType *ot) { - ot->name= "Move Down Keyed Target"; - ot->description= "Move keyed particle target down in the list."; - ot->idname= "PARTICLE_OT_keyed_target_move_down"; + ot->name= "Move Down Target"; + ot->description= "Move particle target down in the list."; + ot->idname= "PARTICLE_OT_target_move_down"; - ot->exec= keyed_target_move_down_exec; + ot->exec= target_move_down_exec; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 0c1f735451a..72c479b2877 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -198,10 +198,10 @@ void buttons_operatortypes(void) WM_operatortype_append(OBJECT_OT_particle_system_remove); WM_operatortype_append(PARTICLE_OT_new); - WM_operatortype_append(PARTICLE_OT_new_keyed_target); - WM_operatortype_append(PARTICLE_OT_remove_keyed_target); - WM_operatortype_append(PARTICLE_OT_keyed_target_move_up); - WM_operatortype_append(PARTICLE_OT_keyed_target_move_down); + WM_operatortype_append(PARTICLE_OT_new_target); + WM_operatortype_append(PARTICLE_OT_remove_target); + WM_operatortype_append(PARTICLE_OT_target_move_up); + WM_operatortype_append(PARTICLE_OT_target_move_down); WM_operatortype_append(SCENE_OT_render_layer_add); WM_operatortype_append(SCENE_OT_render_layer_remove); |