Blender V2.61 - r43446

BKE_effect.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BKE_EFFECT_H
00028 #define BKE_EFFECT_H
00029 
00035 #include "DNA_modifier_types.h"
00036 
00037 struct Object;
00038 struct Scene;
00039 struct Effect;
00040 struct ListBase;
00041 struct Particle;
00042 struct Group;
00043 struct RNG;
00044 struct ParticleSimulationData;
00045 struct ParticleData;
00046 struct ParticleKey;
00047 
00048 struct EffectorWeights *BKE_add_effector_weights(struct Group *group);
00049 struct PartDeflect *object_add_collision_fields(int type);
00050 
00051 /* Input to effector code */
00052 typedef struct EffectedPoint {
00053     float *loc;
00054     float *vel;
00055     float *ave; /* angular velocity for particles with dynamic rotation */
00056     float *rot; /* rotation quaternion for particles with dynamic rotation */
00057     float vel_to_frame;
00058     float vel_to_sec;
00059 
00060     /* only for particles */
00061     float size, charge;
00062 
00063     unsigned int flag;
00064     int index;
00065 
00066     struct ParticleSystem *psys;    /* particle system the point belongs to */
00067 } EffectedPoint;
00068 
00069 typedef struct GuideEffectorData {
00070     float vec_to_point[3];
00071     float strength;
00072 } GuideEffectorData;
00073 
00074 typedef struct EffectorData {
00075     /* Effector point */
00076     float loc[3];
00077     float nor[3];
00078     float vel[3];
00079 
00080     float vec_to_point[3];
00081     float distance, falloff;
00082 
00083     /* only for effector particles */
00084     float size, charge;
00085 
00086     /* only for vortex effector with surface falloff */
00087     float nor2[3], vec_to_point2[3];
00088 
00089     int *index; /* point index */
00090 } EffectorData;
00091 
00092 /* used for calculating the effector force */
00093 typedef struct EffectorCache {
00094     struct EffectorCache *next, *prev;
00095 
00096     struct Scene *scene;
00097     struct Object *ob;
00098     struct ParticleSystem *psys;
00099     struct SurfaceModifierData *surmd;
00100     
00101     struct PartDeflect *pd;
00102 
00103     /* precalculated for guides */
00104     struct GuideEffectorData *guide_data;
00105     float guide_loc[4], guide_dir[3], guide_radius;
00106     float velocity[3];
00107 
00108     float frame;
00109     int flag;
00110 } EffectorCache;
00111 
00112 struct Effect *copy_effect(struct Effect *eff);
00113 void copy_effects(struct ListBase *lbn, struct ListBase *lb);
00114 void deselectall_eff(struct Object *ob);
00115 
00116 void            free_partdeflect(struct PartDeflect *pd);
00117 struct ListBase *pdInitEffectors(struct Scene *scene, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights);
00118 void            pdEndEffectors(struct ListBase **effectors);
00119 void            pdDoEffectors(struct ListBase *effectors, struct ListBase *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *impulse);
00120 
00121 void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point);
00122 void pd_point_from_loc(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point);
00123 void pd_point_from_soft(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point);
00124 
00125 /* needed for boids */
00126 float effector_falloff(struct EffectorCache *eff, struct EffectorData *efd, struct EffectedPoint *point, struct EffectorWeights *weights);
00127 int closest_point_on_surface(SurfaceModifierData *surmd, const float co[3], float surface_co[3], float surface_nor[3], float surface_vel[3]);
00128 int get_effector_data(struct EffectorCache *eff, struct EffectorData *efd, struct EffectedPoint *point, int real_velocity);
00129 
00130 /* required for particle_system.c */
00131 //void do_physical_effector(struct EffectorData *eff, struct EffectorPoint *point, float *total_force);
00132 //float effector_falloff(struct EffectorData *eff, struct EffectorPoint *point, struct EffectorWeights *weights);
00133 
00134 /* EffectedPoint->flag */
00135 #define PE_WIND_AS_SPEED        1
00136 #define PE_DYNAMIC_ROTATION     2
00137 #define PE_USE_NORMAL_DATA      4
00138 
00139 /* EffectorData->flag */
00140 #define PE_VELOCITY_TO_IMPULSE  1
00141 
00142 
00143 #endif
00144