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