Tiny addition to boids functionality: pitch value
authorJanne Karhu <jhkarh@gmail.com>
Thu, 16 Sep 2010 20:06:10 +0000 (20:06 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Thu, 16 Sep 2010 20:06:10 +0000 (20:06 +0000)
* Controls maximum rotation around side vector (as opposed to banking, which controls rotation around forward vector)

release/scripts/ui/properties_particle.py
source/blender/blenkernel/intern/boids.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_boid_types.h
source/blender/makesrna/intern/rna_boid.c

index c2bc761d39cbaadba585fcc475f2e9fe16203ba5..88e8f4d4a711df18898409ce110101f43955f809 100644 (file)
@@ -512,6 +512,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
             col = row.column()
             col.label(text="Misc:")
             col.prop(boids, "bank", slider=True)
+            col.prop(boids, "pitch", slider=True)
             col.prop(boids, "height", slider=True)
 
         if part.physics_type == 'KEYED' or part.physics_type == 'BOIDS' or part.physics_type == 'FLUID':
index 5bf228b2392ad56c6cf59296b37625e50ed9e7f5..e408f73e6c828f42b5f4f6765b29566eac925cc4 100644 (file)
@@ -1386,7 +1386,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa)
        /* save direction to state.ave unless the boid is falling */
        /* (boids can't effect their direction when falling) */
        if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) {
-               normalize_v3_v3(pa->state.ave, pa->state.vel);
+               copy_v3_v3(pa->state.ave, pa->state.vel);
+               pa->state.ave[2] *= bbd->part->boids->pitch;
+               normalize_v3(pa->state.ave);
        }
 
        /* apply damping */
@@ -1471,6 +1473,7 @@ void boid_default_settings(BoidSettings *boids)
 
        boids->landing_smoothness = 3.0f;
        boids->banking = 1.0f;
+       boids->pitch = 1.0f;
        boids->height = 1.0f;
 
        boids->health = 1.0f;
index d2b1b2d70101f845e3395945df6ccbe6a92b7226..25af3faa0698166aed7cee83af046eb8af70f05c 100644 (file)
@@ -11107,6 +11107,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
                
        }
+       {
+               ParticleSettings *part;
+               for(part = main->particle.first; part; part = part->id.next) {
+                       if(part->boids)
+                               part->boids->pitch = 1.0f;
+               }
+       }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
index 8584b5f99e9698c6ae34a9d2674b55559eac8e2b..c4324612affb1a5fa8209387b783a6cd9cc929bb 100644 (file)
@@ -187,8 +187,8 @@ typedef struct BoidState {
 typedef struct BoidSettings {
        int options, last_state_id;
 
-       float landing_smoothness, rt;
-       float banking, height;
+       float landing_smoothness, height;
+       float banking, pitch;
 
        float health, aggression;
        float strength, accuracy, range;
index 3afa135d079e3f0c7511aee9a6e2982c14933750..8cd6fcbeff9f36d4f095ccd78aa222029b2090c3 100644 (file)
@@ -480,6 +480,12 @@ static void rna_def_boid_settings(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Banking", "Amount of rotation around velocity vector on turns");
        RNA_def_property_update(prop, 0, "rna_Boids_reset");
 
+       prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "pitch");
+       RNA_def_property_range(prop, 0.0, 2.0);
+       RNA_def_property_ui_text(prop, "Pitch", "Amount of rotation around side vector");
+       RNA_def_property_update(prop, 0, "rna_Boids_reset");
+
        prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
        RNA_def_property_range(prop, 0.0, 2.0);
        RNA_def_property_ui_text(prop, "Height", "Boid height relative to particle size");