diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-15 22:01:18 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-15 22:01:18 +0400 |
commit | 816377cc02fe5dd4be945c0f3d415861114b4980 (patch) | |
tree | 306e9d1363aa66bc919e43b80b3380fab9f60ea9 /source/blender/blenkernel | |
parent | c8af263e5d8d9d41a757e8438cdcf3b64d57e0c0 (diff) | |
parent | ee768ada680ce0a8aa184c882005c0ef1c0140fb (diff) |
Undo revision 23130 which was a merge with 2.5, a messy one because I did something wrong (`svn status` output: http://www.pasteall.org/7887).soc-2009-kazanbas
The command: svn merge -r 23130:23129 https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-kazanbas
Diffstat (limited to 'source/blender/blenkernel')
72 files changed, 1892 insertions, 3016 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 4724ee19aaa..d35acb5447a 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -66,7 +66,7 @@ void free_action(struct bAction *act); void make_local_action(struct bAction *act); /* Some kind of bounding box operation on the action */ -void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers); +void calc_action_range(const struct bAction *act, float *start, float *end, int incl_hidden); /* Does action have any motion data at all? */ short action_has_motion(const struct bAction *act); diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index cc5b4dfdcaf..cabbaa7aa0f 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -55,9 +55,6 @@ void BKE_free_animdata(struct ID *id); /* Copy AnimData */ struct AnimData *BKE_copy_animdata(struct AnimData *adt); -/* Make Local */ -void BKE_animdata_make_local(struct AnimData *adt); - /* ************************************* */ /* KeyingSets API */ diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 1cbb2331782..0595134f5c9 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -74,6 +74,7 @@ struct bArmature *add_armature(char *name); struct bArmature *get_armature(struct Object *ob); void free_boneChildren(struct Bone *bone); void free_bones (struct bArmature *arm); +void unlink_armature(struct bArmature *arm); void free_armature(struct bArmature *arm); void make_local_armature(struct bArmature *arm); struct bArmature *copy_armature(struct bArmature *arm); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index d60737d62fe..42ee11587a7 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,7 +43,7 @@ struct bContext; struct ReportList; #define BLENDER_VERSION 250 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 2 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 4d24a2433b3..6ec988e111e 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -64,6 +64,7 @@ float brush_curve_strength(struct Brush *br, float p, const float len); /* sampling */ float brush_sample_falloff(struct Brush *brush, float dist); +float brush_sample_falloff_noalpha(struct Brush *brush, float dist); void brush_sample_tex(struct Brush *brush, float *xy, float *rgba); void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf); diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index a0061173438..6e69906b71d 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -49,7 +49,6 @@ typedef struct bConstraintOb { float startmat[4][4]; /* original matrix (before constraint solving) */ short type; /* type of owner */ - short rotOrder; /* rotation order for constraint owner (as defined in eEulerRotationOrders in BLI_arithb.h) */ } bConstraintOb; /* ---------------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index b9f3ee2dd6e..e5a8df1a932 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -47,7 +47,7 @@ struct BevList; #define SEGMENTSU(nu) ( ((nu)->flagu & CU_CYCLIC) ? (nu)->pntsu : (nu)->pntsu-1 ) #define SEGMENTSV(nu) ( ((nu)->flagv & CU_CYCLIC) ? (nu)->pntsv : (nu)->pntsv-1 ) -#define CU_DO_TILT(cu, nu) (((nu->flag & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1) +#define CU_DO_TILT(cu, nu) (((nu->type & CU_2D) && (cu->flag & CU_3D)==0) ? 0 : 1) #define CU_DO_RADIUS(cu, nu) ((CU_DO_TILT(cu, nu) || cu->bevobj || cu->ext1!=0.0 || cu->ext2!=0.0) ? 1:0) diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index e242ead3b87..70b6c1d13f4 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -32,8 +32,6 @@ #define DEPS_DEBUG */ -struct ID; -struct Main; struct Scene; struct DagNodeQueue; struct DagForest; @@ -105,9 +103,8 @@ void DAG_object_update_flags(struct Scene *sce, struct Object *ob, unsigned int /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(struct Scene *sce, unsigned int lay, int time); - /* flushes all recalc flags for this object down the dependency tree, - but not the DAG only supports objects and object data currently */ -void DAG_id_flush_update(struct ID *id, short flag); + /* flushes all recalc flags for this object down the dependency tree */ +void DAG_object_flush_update(struct Scene *sce, struct Object *ob, short flag); void DAG_pose_sort(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 5d0b89220d5..6323258ff43 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -119,6 +119,7 @@ typedef struct Global { #define G_GREASEPENCIL (1 << 17) /* #define G_AUTOMATKEYS (1 << 30) also removed */ +#define G_HIDDENHANDLES (1 << 31) /* used for curves only */ /* G.fileflags */ diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index b66ddf13527..35084aabadf 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -41,7 +41,6 @@ void free_group_object(struct GroupObject *go); void free_group(struct Group *group); void unlink_group(struct Group *group); struct Group *add_group(char *name); -struct Group *copy_group(struct Group *group); void add_to_group(struct Group *group, struct Object *ob); int rem_from_group(struct Group *group, struct Object *ob); struct Group *find_group(struct Object *ob, struct Group *group); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 54722dac910..4e7db115168 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -46,9 +46,6 @@ void *copy_libblock(void *rt); void id_lib_extern(struct ID *id); void id_us_plus(struct ID *id); void id_us_min(struct ID *id); -int id_make_local(struct ID *id, int test); -int id_copy(struct ID *id, struct ID **newid, int test); -int id_unlink(struct ID *id, int test); int check_for_dupid(struct ListBase *lb, struct ID *id, char *name); int new_id(struct ListBase *lb, struct ID *id, const char *name); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 27c75126026..b65d77751e2 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -90,10 +90,7 @@ typedef enum { eModifierTypeFlag_UsesPointCache = (1<<6), /* For physics modifiers, max one per type */ - eModifierTypeFlag_Single = (1<<7), - - /* Some modifier can't be added manually by user */ - eModifierTypeFlag_NoUserAdd = (1<<8) + eModifierTypeFlag_Single = (1<<7) } ModifierTypeFlag; typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin); diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index a331479cad1..6558212519f 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -35,12 +35,10 @@ struct Object; typedef struct MultiresSubsurf { struct MultiresModifierData *mmd; - struct Object *ob; - int local_mmd; + struct Mesh *me; } MultiresSubsurf; /* MultiresDM */ -struct Object *MultiresDM_get_object(struct DerivedMesh *dm); struct Mesh *MultiresDM_get_mesh(struct DerivedMesh *dm); struct DerivedMesh *MultiresDM_new(struct MultiresSubsurf *, struct DerivedMesh*, int, int, int); void *MultiresDM_get_vertnorm(struct DerivedMesh *); @@ -60,8 +58,8 @@ void multires_mark_as_modified(struct Object *ob); void multires_force_update(struct Object *ob); -struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*, - struct Object *, int, int); +struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, struct DerivedMesh*, + struct Mesh *, int, int); struct MultiresModifierData *find_multires_modifier(struct Object *ob); int multiresModifier_switch_level(struct Object *, const int); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index cbb37918d04..4ac95b61a5e 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -25,7 +25,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): Bob Holcomb. + * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** */ @@ -325,7 +325,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_NODE_COMBYUVA 234 #define CMP_NODE_DIFF_MATTE 235 #define CMP_NODE_COLOR_SPILL 236 -#define CMP_NODE_CHROMA_MATTE 237 +#define CMP_NODE_CHROMA 237 #define CMP_NODE_CHANNEL_MATTE 238 #define CMP_NODE_FLIP 239 #define CMP_NODE_SPLITVIEWER 240 @@ -345,9 +345,6 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); #define CMP_NODE_DBLUR 254 #define CMP_NODE_BILATERALBLUR 255 #define CMP_NODE_PREMULKEY 256 -#define CMP_NODE_DIST_MATTE 257 -#define CMP_NODE_VIEW_LEVELS 258 -#define CMP_NODE_COLOR_MATTE 259 #define CMP_NODE_GLARE 301 #define CMP_NODE_TONEMAP 302 @@ -424,9 +421,10 @@ extern struct ListBase node_all_textures; /* API */ int ntreeTexTagAnimated(struct bNodeTree *ntree); -void ntreeTexSetPreviewFlag(int); -void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, short thread, struct Tex *tex, short which_output, int cfra); +void ntreeTexUpdatePreviews( struct bNodeTree* nodetree ); +void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, char do_preview, short thread, struct Tex *tex, short which_output, int cfra); void ntreeTexCheckCyclics(struct bNodeTree *ntree); +void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node); char* ntreeTexOutputMenu(struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 1cb6efeb838..a57529ccf75 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -115,11 +115,6 @@ void object_handle_update(struct Scene *scene, struct Object *ob); float give_timeoffset(struct Object *ob); int give_obdata_texspace(struct Object *ob, int **texflag, float **loc, float **size, float **rot); - -int object_insert_ptcache(struct Object *ob); -// void object_delete_ptcache(struct Object *ob, int index); - - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 7dc9e4499c6..67b260b2348 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -29,20 +29,11 @@ #define BKE_PAINT_H struct Brush; -struct MFace; -struct MultireModifierData; -struct MVert; struct Object; struct Paint; struct Scene; -struct StrokeCache; -extern const char PAINT_CURSOR_SCULPT[3]; -extern const char PAINT_CURSOR_VERTEX_PAINT[3]; -extern const char PAINT_CURSOR_WEIGHT_PAINT[3]; -extern const char PAINT_CURSOR_TEXTURE_PAINT[3]; - -void paint_init(struct Paint *p, const char col[3]); +void paint_init(struct Paint *p, const char *brush_name); void free_paint(struct Paint *p); void copy_paint(struct Paint *orig, struct Paint *new); @@ -57,39 +48,4 @@ void paint_brush_slot_remove(struct Paint *p); * however hiding faces is useful */ int paint_facesel_test(struct Object *ob); -/* Session data (mode-specific) */ - -typedef struct SculptSession { - struct ProjVert *projverts; - - /* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */ - struct MultiresModifierData *multires; /* Special handling for multires meshes */ - struct MVert *mvert; - struct MFace *mface; - int totvert, totface; - float *face_normals; - - /* Mesh connectivity */ - struct ListBase *fmap; - struct IndexNode *fmap_mem; - int fmap_size; - - /* Used temporarily per-stroke */ - float *vertexcosnos; - ListBase damaged_rects; - ListBase damaged_verts; - - /* Used to cache the render of the active texture */ - unsigned int texcache_side, *texcache, texcache_actual; - - /* Layer brush persistence between strokes */ - float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */ - float *layer_disps; /* Displacements for each vertex */ - - struct SculptStroke *stroke; - struct StrokeCache *cache; -} SculptSession; - -void free_sculptsession(SculptSession **); - #endif diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 15896477a6a..cf02efc34ac 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -59,9 +59,6 @@ struct SurfaceModifierData; struct BVHTreeRay; struct BVHTreeRayHit; -#define PARTICLE_P ParticleData *pa; int p -#define LOOP_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) - typedef struct ParticleEffectorCache { struct ParticleEffectorCache *next, *prev; struct Object *ob; @@ -112,10 +109,46 @@ typedef struct ParticleCacheKey{ float vel[3]; float rot[4]; float col[3]; - float time; int steps; } ParticleCacheKey; +typedef struct ParticleEditKey{ + float *co; + float *vel; + float *rot; + float *time; + + float world_co[3]; + float length; + short flag; +} ParticleEditKey; + +typedef struct ParticleUndo { + struct ParticleUndo *next, *prev; + struct ParticleEditKey **keys; + struct KDTree *emitter_field; + struct ParticleData *particles; + float *emitter_cosnos; + int totpart, totkeys; + char name[64]; +} ParticleUndo; + +typedef struct ParticleEdit { + ListBase undo; + struct ParticleUndo *curundo; + + ParticleEditKey **keys; + int totkeys; + + int *mirror_cache; + + struct KDTree *emitter_field; + float *emitter_cosnos; + + char sel_col[3]; + char nosel_col[3]; +} ParticleEdit; + typedef struct ParticleThreadContext { /* shared */ struct Scene *scene; @@ -207,10 +240,9 @@ int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys); void psys_free_boid_rules(struct ListBase *list); void psys_free_settings(struct ParticleSettings *part); void free_child_path_cache(struct ParticleSystem *psys); -void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit); +void psys_free_path_cache(struct ParticleSystem *psys); void free_hair(struct ParticleSystem *psys, int softbody); void free_keyed_keys(struct ParticleSystem *psys); -void psys_free_particles(struct ParticleSystem *psys); void psys_free(struct Object * ob, struct ParticleSystem * psys); void psys_free_children(struct ParticleSystem *psys); @@ -239,9 +271,9 @@ void psys_reset(struct ParticleSystem *psys, int mode); void psys_find_parents(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys); -void psys_cache_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra); -void psys_cache_edit_paths(struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra); +void psys_cache_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate); void psys_cache_child_paths(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, float cfra, int editupdate); +void psys_update_world_cos(struct Object *ob, struct ParticleSystem *psys); int do_guide(struct Scene *scene, struct ParticleKey *state, int pa_num, float time, struct ListBase *lb); float psys_get_size(struct Object *ob, struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size); float psys_get_timestep(struct ParticleSettings *part); @@ -327,6 +359,12 @@ void reset_particle(struct Scene *scene, struct ParticleData *pa, struct Particl #define PSYS_EC_PARTICLE 4 #define PSYS_EC_REACTOR 8 +/* ParticleEditKey->flag */ +#define PEK_SELECT 1 +#define PEK_TO_SELECT 2 +#define PEK_TAG 4 +#define PEK_HIDE 8 + /* index_dmcache */ #define DMCACHE_NOTFOUND -1 #define DMCACHE_ISCHILD -2 diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 5ae10d736fd..5d9dddfe30d 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -60,8 +60,8 @@ #define PTCACHE_TYPE_SOFTBODY 0 #define PTCACHE_TYPE_PARTICLES 1 #define PTCACHE_TYPE_CLOTH 2 -#define PTCACHE_TYPE_SMOKE_DOMAIN 3 -#define PTCACHE_TYPE_SMOKE_HIGHRES 4 +#define PTCACHE_TYPE_SMOKE_DOMAIN_LOW 3 +#define PTCACHE_TYPE_SMOKE_DOMAIN_HIGH 4 /* PTCache read return code */ #define PTCACHE_READ_EXACT 1 @@ -101,8 +101,6 @@ typedef struct PTCacheFile { void *cur[BPHYS_TOT_DATA]; } PTCacheFile; -#define PTCACHE_VEL_PER_SEC 1 - typedef struct PTCacheID { struct PTCacheID *next, *prev; @@ -111,7 +109,6 @@ typedef struct PTCacheID { void *calldata; int type; int stack_index; - int flag; /* flags defined in DNA_object_force.h */ unsigned int data_types, info_types; @@ -154,76 +151,6 @@ typedef struct PTCacheBaker { void *progresscontext; } PTCacheBaker; -/* PTCacheEditKey->flag */ -#define PEK_SELECT 1 -#define PEK_TAG 2 -#define PEK_HIDE 4 -#define PEK_USE_WCO 8 - -typedef struct PTCacheEditKey{ - float *co; - float *vel; - float *rot; - float *time; - - float world_co[3]; - float ftime; - float length; - short flag; -} PTCacheEditKey; - -/* PTCacheEditPoint->flag */ -#define PEP_TAG 1 -#define PEP_EDIT_RECALC 2 -#define PEP_TRANSFORM 4 -#define PEP_HIDE 8 - -typedef struct PTCacheEditPoint { - struct PTCacheEditKey *keys; - int totkey; - short flag; -} PTCacheEditPoint; - -typedef struct PTCacheUndo { - struct PTCacheUndo *next, *prev; - struct PTCacheEditPoint *points; - - /* particles stuff */ - struct ParticleData *particles; - struct KDTree *emitter_field; - float *emitter_cosnos; - int psys_flag; - - /* cache stuff */ - struct ListBase mem_cache; - - int totpoint; - char name[64]; -} PTCacheUndo; - -typedef struct PTCacheEdit { - ListBase undo; - struct PTCacheUndo *curundo; - PTCacheEditPoint *points; - - struct PTCacheID pid; - - /* particles stuff */ - struct ParticleSystem *psys; - struct ParticleData *particles; - struct KDTree *emitter_field; - float *emitter_cosnos; - int *mirror_cache; - - struct ParticleCacheKey **pathcache; /* path cache (runtime) */ - ListBase pathcachebufs; - - int totpoint, totframes, totcached, edited; - - char sel_col[3]; - char nosel_col[3]; -} PTCacheEdit; - /* Particle functions */ void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time); @@ -231,8 +158,7 @@ void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **da void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb); void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys); void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd); -void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd); -void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd); +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num); void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob); @@ -253,10 +179,6 @@ void BKE_ptcache_update_info(PTCacheID *pid); /* Size of cache data type. */ int BKE_ptcache_data_size(int data_type); -/* Memory cache read/write helpers. */ -void BKE_ptcache_mem_init_pointers(struct PTCacheMem *pm); -void BKE_ptcache_mem_incr_pointers(struct PTCacheMem *pm); - /* Copy a specific data type from cache data to point data. */ void BKE_ptcache_data_get(void **data, int type, int index, void *to); @@ -275,7 +197,7 @@ int BKE_ptcache_get_continue_physics(void); /******************* Allocate & free ***************/ struct PointCache *BKE_ptcache_add(struct ListBase *ptcaches); -void BKE_ptcache_free_mem(struct ListBase *mem_cache); +void BKE_ptache_free_mem(struct PointCache *cache); void BKE_ptcache_free(struct PointCache *cache); void BKE_ptcache_free_list(struct ListBase *ptcaches); struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct ListBase *ptcaches_old); diff --git a/source/blender/blenkernel/BKE_sca.h b/source/blender/blenkernel/BKE_sca.h index 1b8e61f136f..22c4f39148a 100644 --- a/source/blender/blenkernel/BKE_sca.h +++ b/source/blender/blenkernel/BKE_sca.h @@ -47,6 +47,7 @@ void unlink_actuators(struct ListBase *lb); void free_actuator(struct bActuator *act); void free_actuators(struct ListBase *lb); +void free_text_controllers(struct Text *txt); void free_sensor(struct bSensor *sens); void free_sensors(struct ListBase *lb); struct bSensor *copy_sensor(struct bSensor *sens); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 686fc265de0..12a13a2b50c 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -84,5 +84,7 @@ int get_render_child_particle_number(struct RenderData *r, int num); int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); +void free_dome_warp_text(struct Text *txt); + #endif diff --git a/source/blender/blenkernel/BKE_sculpt.h b/source/blender/blenkernel/BKE_sculpt.h new file mode 100644 index 00000000000..9e5647a8775 --- /dev/null +++ b/source/blender/blenkernel/BKE_sculpt.h @@ -0,0 +1,72 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2007 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_SCULPT_H +#define BKE_SCULPT_H + +struct MFace; +struct MultireModifierData; +struct MVert; +struct Object; +struct StrokeCache; + +typedef struct SculptSession { + struct ProjVert *projverts; + + /* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */ + struct MultiresModifierData *multires; /* Special handling for multires meshes */ + struct MVert *mvert; + struct MFace *mface; + int totvert, totface; + float *face_normals; + + /* Mesh connectivity */ + struct ListBase *fmap; + struct IndexNode *fmap_mem; + int fmap_size; + + /* Used temporarily per-stroke */ + float *vertexcosnos; + ListBase damaged_rects; + ListBase damaged_verts; + + /* Used to cache the render of the active texture */ + unsigned int texcache_side, *texcache, texcache_actual; + + /* Layer brush persistence between strokes */ + float (*mesh_co_orig)[3]; /* Copy of the mesh vertices' locations */ + float *layer_disps; /* Displacements for each vertex */ + + struct SculptStroke *stroke; + struct StrokeCache *cache; +} SculptSession; + +void free_sculptsession(SculptSession **); + +#endif diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 5b413ae4e44..eb0e3c4ef00 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -115,9 +115,9 @@ typedef struct ShrinkwrapCalcData int vgroup; //Vertex group num struct DerivedMesh *target; //mesh we are shrinking to - SpaceTransform local2target; //transform to move between local and target space + SpaceTransform local2target; //transform to move bettwem local and target space - float keepDist; //Distance to keep above target surface (units are in local space) + float keepDist; //Distance to kept from target (units are in local space) } ShrinkwrapCalcData; diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index 0f8e9c5edf5..8dc38640e9a 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -32,15 +32,24 @@ #ifndef BKE_SMOKE_H_ #define BKE_SMOKE_H_ -typedef float (*bresenham_callback) (float *result, float *input, int res[3], int *pixel, float *tRay, float correct); - void smokeModifier_do(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, int useRenderParams, int isFinalCalc); void smokeModifier_free (struct SmokeModifierData *smd); void smokeModifier_reset(struct SmokeModifierData *smd); -void smokeModifier_reset_turbulence(struct SmokeModifierData *smd); void smokeModifier_createType(struct SmokeModifierData *smd); +void smoke_set_tray(struct SmokeModifierData *smd, size_t index, float transparency); +float smoke_get_tray(struct SmokeModifierData *smd, size_t index); +float smoke_get_tvox(struct SmokeModifierData *smd, size_t index); +void smoke_set_tvox(struct SmokeModifierData *smd, size_t index, float tvox); + +void smoke_set_bigtray(struct SmokeModifierData *smd, size_t index, float transparency); +float smoke_get_bigtray(struct SmokeModifierData *smd, size_t index); +float smoke_get_bigtvox(struct SmokeModifierData *smd, size_t index); +void smoke_set_bigtvox(struct SmokeModifierData *smd, size_t index, float tvox); + long long smoke_get_mem_req(int xres, int yres, int zres, int amplify); +void smoke_prepare_View(struct SmokeModifierData *smd, float *light); +void smoke_prepare_bigView(struct SmokeModifierData *smd, float *light); #endif /* BKE_SMOKE_H_ */ diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index e9f6eb21e36..1dd90b4dbda 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -54,9 +54,7 @@ void sound_delete(struct bContext *C, struct bSound* sound); void sound_cache(struct bSound* sound, int ignore); -void sound_delete_cache(struct bSound* sound); - -void sound_load(struct Main *main, struct bSound* sound); +void sound_load(struct bSound* sound); void sound_free(struct bSound* sound); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index bd14053d121..d288c0b6516 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -35,7 +35,6 @@ extern "C" { #endif -struct Main; struct Text; struct TextLine; struct SpaceText; @@ -47,7 +46,6 @@ struct Text* add_empty_text (char *name); int reopen_text (struct Text *text); struct Text* add_text (char *file, const char *relpath); struct Text* copy_text (struct Text *ta); -void unlink_text (struct Main *bmain, struct Text *text); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index a9862ba586b..a1600ce5473 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -40,8 +40,6 @@ struct ColorBand; struct HaloRen; struct TexMapping; struct EnvMap; -struct PointDensity; -struct VoxelData; /* in ColorBand struct */ #define MAXCOLORBAND 32 @@ -77,16 +75,6 @@ void BKE_free_envmap(struct EnvMap *env); struct EnvMap *BKE_add_envmap(void); struct EnvMap *BKE_copy_envmap(struct EnvMap *env); -void BKE_free_pointdensitydata(struct PointDensity *pd); -void BKE_free_pointdensity(struct PointDensity *pd); -struct PointDensity *BKE_add_pointdensity(void); -struct PointDensity *BKE_copy_pointdensity(struct PointDensity *pd); - -void BKE_free_voxeldatadata(struct VoxelData *vd); -void BKE_free_voxeldata(struct VoxelData *vd); -struct VoxelData *BKE_add_voxeldata(void); -struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd); - int BKE_texture_dependsOnTime(const struct Tex *texture); #endif diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 68aed2b0184..8d1df98c5b4 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -27,57 +27,55 @@ FILE(GLOB SRC intern/*.c) SET(INC - . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna - ../render/extern/include ../../../intern/decimation/extern - ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern - ../../../intern/iksolver/extern ../blenloader - ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern - ../../../intern/bsp/extern ../blenfont - ../../../intern/audaspace/intern - ../../../extern/lzo/minilzo - ../../../extern/lzma - ${ZLIB_INC} + . ../../../intern/guardedalloc ../../../intern/memutil ../editors/include ../blenlib ../makesdna + ../render/extern/include ../../../intern/decimation/extern + ../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern + ../../../intern/iksolver/extern ../blenloader + ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern + ../../../intern/bsp/extern ../blenfont + ../../../intern/audaspace/intern + ${ZLIB_INC} ) IF(WITH_BULLET) - SET(INC ${INC} ../../../extern/bullet2/src) - ADD_DEFINITIONS(-DUSE_BULLET) + SET(INC ${INC} ../../../extern/bullet2/src) + ADD_DEFINITIONS(-DUSE_BULLET) ENDIF(WITH_BULLET) IF(WITH_OPENEXR) - ADD_DEFINITIONS(-DWITH_OPENEXR) + ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) IF(WITH_OPENJPEG) - ADD_DEFINITIONS(-DWITH_OPENJPEG) + ADD_DEFINITIONS(-DWITH_OPENJPEG) ENDIF(WITH_OPENJPEG) IF(WITH_DDS) - ADD_DEFINITIONS(-DWITH_DDS) + ADD_DEFINITIONS(-DWITH_DDS) ENDIF(WITH_DDS) IF(WITH_QUICKTIME) - SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) - ADD_DEFINITIONS(-DWITH_QUICKTIME) + SET(INC ${INC} ../quicktime ${QUICKTIME_INC}) + ADD_DEFINITIONS(-DWITH_QUICKTIME) ENDIF(WITH_QUICKTIME) IF(WITH_FFMPEG) - SET(INC ${INC} ${FFMPEG_INC}) - ADD_DEFINITIONS(-DWITH_FFMPEG) + SET(INC ${INC} ${FFMPEG_INC}) + ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) IF(WITH_PYTHON) - SET(INC ${INC} ../python ${PYTHON_INC}) + SET(INC ${INC} ../python ${PYTHON_INC}) ELSE(WITH_PYTHON) - ADD_DEFINITIONS(-DDISABLE_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) ENDIF(WITH_PYTHON) IF(NOT WITH_ELBEEM) - ADD_DEFINITIONS(-DDISABLE_ELBEEM) + ADD_DEFINITIONS(-DDISABLE_ELBEEM) ENDIF(NOT WITH_ELBEEM) IF(WIN32) - SET(INC ${INC} ${PTHREADS_INC}) + SET(INC ${INC} ${PTHREADS_INC}) ENDIF(WIN32) BLENDERLIB(bf_blenkernel "${SRC}" "${INC}") diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index f14c624b40e..accaaef1e2f 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -11,8 +11,6 @@ incs += ' #/extern/bullet2/src' incs += ' #/intern/opennl/extern #/intern/bsp/extern' incs += ' ../gpu #/extern/glew/include' incs += ' #/intern/smoke/extern' -incs += ' #/extern/lzo/minilzo' -incs += ' #/extern/lzma' incs += ' #/intern/audaspace/intern' incs += ' ' + env['BF_OPENGL_INC'] @@ -62,10 +60,10 @@ if env['BF_NO_ELBEEM']: if env['WITH_BF_LCMS']: defs.append('WITH_LCMS') -# if env['BF_UNIT_TEST']: -# defs.append('UNIT_TEST') +if env['WITH_BF_UNIT_TEST']: + defs.append('WITH_UNIT_TEST') if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): incs += ' ' + env['BF_PTHREADS_INC'] -env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25] ) +env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core'], priority = [165] ) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 43b9a63a2c1..84cccd8b939 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2077,7 +2077,7 @@ static void clear_mesh_caches(Object *ob) static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; - int editing = paint_facesel_test(ob); + int editing = paint_facesel_test(ob)|(ob && ob->mode & OB_MODE_PARTICLE_EDIT); int needMapping = editing && (ob==obact); float min[3], max[3]; diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 6c2edc9e25f..d6d41d6579e 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -90,10 +90,6 @@ CPPFLAGS += -I$(NAN_BULLET2)/include CPPFLAGS += -I$(NAN_FREETYPE)/include CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2 -# lzo and lzma, for pointcache -CPPFLAGS += -I$(NAN_LZO)/minilzo -CPPFLAGS += -I$(NAN_LZMA) - ifeq ($(WITH_FFMPEG),true) CPPFLAGS += -DWITH_FFMPEG CPPFLAGS += $(NAN_FFMPEGCFLAGS) @@ -115,4 +111,3 @@ ifeq ($(WITH_QUICKTIME), true) CPPFLAGS += -I../../quicktime CPPFLAGS += -DWITH_QUICKTIME endif - diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 47de044ea25..f4d4eb1cc9c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -410,9 +410,8 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[]) bPoseChannel *get_pose_channel(const bPose *pose, const char *name) { bPoseChannel *chan; - - if (ELEM(NULL, pose, name) || (name[0] == 0)) - return NULL; + + if (pose==NULL) return NULL; for (chan=pose->chanbase.first; chan; chan=chan->next) { if (chan->name[0] == name[0]) { @@ -838,15 +837,14 @@ short action_has_motion(const bAction *act) } /* Calculate the extents of given action */ -void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers) +void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden) { FCurve *fcu; float min=999999999.0f, max=-999999999.0f; - short foundvert=0, foundmod=0; + short foundvert=0; if (act) { for (fcu= act->curves.first; fcu; fcu= fcu->next) { - /* if curve has keyframes, consider them first */ if (fcu->totvert) { float nmin, nmax; @@ -859,53 +857,10 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ foundvert= 1; } - - /* if incl_modifiers is enabled, need to consider modifiers too - * - only really care about the last modifier - */ - if ((incl_modifiers) && (fcu->modifiers.last)) { - FModifier *fcm= fcu->modifiers.last; - - /* only use the maximum sensible limits of the modifiers if they are more extreme */ - switch (fcm->type) { - case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */ - { - FMod_Limits *fmd= (FMod_Limits *)fcm->data; - - if (fmd->flag & FCM_LIMIT_XMIN) { - min= MIN2(min, fmd->rect.xmin); - } - if (fmd->flag & FCM_LIMIT_XMAX) { - max= MAX2(max, fmd->rect.xmax); - } - } - break; - - case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */ - { - FMod_Cycles *fmd= (FMod_Cycles *)fcm->data; - - if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) - min= MINAFRAMEF; - if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) - max= MAXFRAMEF; - } - break; - - // TODO: function modifier may need some special limits - - default: /* all other standard modifiers are on the infinite range... */ - min= MINAFRAMEF; - max= MAXFRAMEF; - break; - } - - foundmod= 1; - } } } - if (foundvert || foundmod) { + if (foundvert) { if(min==max) max+= 1.0f; *start= min; *end= max; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index eb74dc1fbfc..6c1b8eb9000 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -271,8 +271,8 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir) /* returns OK nu= cu->nurb.first; /* make sure that first and last frame are included in the vectors here */ - if(nu->type == CU_POLY) set_four_ipo(1.0f-fac, data, KEY_LINEAR); - else if(nu->type == CU_BEZIER) set_four_ipo(1.0f-fac, data, KEY_LINEAR); + if((nu->type & 7)==CU_POLY) set_four_ipo(1.0f-fac, data, KEY_LINEAR); + else if((nu->type & 7)==CU_BEZIER) set_four_ipo(1.0f-fac, data, KEY_LINEAR); else if(s0==s1 || p2==p3) set_four_ipo(1.0f-fac, data, KEY_CARDINAL); else set_four_ipo(1.0f-fac, data, KEY_BSPLINE); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 0e8450025da..5eaf2133515 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -204,35 +204,15 @@ AnimData *BKE_copy_animdata (AnimData *adt) return dadt; } -/* Make Local -------------------------------------------- */ - -static void make_local_strips(ListBase *strips) -{ - NlaStrip *strip; - - for(strip=strips->first; strip; strip=strip->next) { - if(strip->act) make_local_action(strip->act); - if(strip->remap && strip->remap->target) make_local_action(strip->remap->target); - - make_local_strips(&strip->strips); - } -} - -void BKE_animdata_make_local(AnimData *adt) -{ - NlaTrack *nlt; - - if(adt->action) make_local_action(adt->action); - if(adt->tmpact) make_local_action(adt->tmpact); - if(adt->remap && adt->remap->target) make_local_action(adt->remap->target); - - for(nlt=adt->nla_tracks.first; nlt; nlt=nlt->next) - make_local_strips(&nlt->strips); -} - /* *********************************** */ /* KeyingSet API */ +/* NOTES: + * It is very likely that there will be two copies of the api - one for internal use, + * and one 'operator' based wrapper of the internal API, which should allow for access + * from Python/scripts so that riggers can automate the creation of KeyingSets for their rigs. + */ + /* Finding Tools --------------------------- */ /* Find the first path that matches the given criteria */ @@ -265,7 +245,7 @@ KS_Path *BKE_keyingset_find_destination (KeyingSet *ks, ID *id, const char group if ((ksp->rna_path==0) || strcmp(rna_path, ksp->rna_path)) eq_path= 0; - /* index - need to compare whole-array setting too... */ + /* index */ if (ksp->array_index != array_index) eq_index= 0; @@ -319,25 +299,18 @@ void BKE_keyingset_add_destination (KeyingSet *ks, ID *id, const char group_name KS_Path *ksp; /* sanity checks */ - if ELEM(NULL, ks, rna_path) { - printf("ERROR: no Keying Set and/or RNA Path to add destination with \n"); + if ELEM(NULL, ks, rna_path) return; - } /* ID is optional for relative KeyingSets, but is necessary for absolute KeyingSets */ if (id == NULL) { - if (ks->flag & KEYINGSET_ABSOLUTE) { - printf("ERROR: No ID provided for absolute destination. \n"); + if (ks->flag & KEYINGSET_ABSOLUTE) return; - } } /* don't add if there is already a matching KS_Path in the KeyingSet */ - if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) { - if (G.f & G_DEBUG) - printf("ERROR: destination already exists in Keying Set \n"); + if (BKE_keyingset_find_destination(ks, id, group_name, rna_path, array_index, groupmode)) return; - } /* allocate a new KeyingSet Path */ ksp= MEM_callocN(sizeof(KS_Path), "KeyingSet Path"); @@ -467,19 +440,19 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_boolean_set(&new_ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_int_set_index(&new_ptr, prop, array_index, (int)value); else RNA_property_int_set(&new_ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(&new_ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_float_set_index(&new_ptr, prop, array_index, value); else RNA_property_float_set(&new_ptr, prop, value); @@ -1204,19 +1177,19 @@ void nladata_flush_channels (ListBase *channels) switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_boolean_set_index(ptr, prop, array_index, (int)value); else RNA_property_boolean_set(ptr, prop, (int)value); break; case PROP_INT: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_int_set_index(ptr, prop, array_index, (int)value); else RNA_property_int_set(ptr, prop, (int)value); break; case PROP_FLOAT: - if (RNA_property_array_length(ptr, prop)) + if (RNA_property_array_length(prop)) RNA_property_float_set_index(ptr, prop, array_index, value); else RNA_property_float_set(ptr, prop, value); @@ -1290,7 +1263,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) dummy_strip.act= adt->action; dummy_strip.remap= adt->remap; - /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ + // FIXME: what happens when we want to included F-Modifier access? calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); dummy_strip.start = dummy_strip.actstart; dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e568f1b2c0e..7b894d79b45 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -130,6 +130,7 @@ void free_bones (bArmature *arm) void free_armature(bArmature *arm) { if (arm) { + /* unlink_armature(arm);*/ free_bones(arm); /* free editmode data */ @@ -1987,9 +1988,9 @@ void chan_calc_mat(bPoseChannel *chan) SizeToMat3(chan->size, smat); /* rotations may either be quats or eulers (no rotation modes for now...) */ - if (chan->rotmode > 0) { + if (chan->rotmode) { /* euler rotations (will cause gimble lock... no rotation order to solve that yet) */ - EulOToMat3(chan->eul, chan->rotmode, rmat); + EulToMat3(chan->eul, rmat); } else { /* quats are normalised before use to eliminate scaling issues */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index f261b020717..746dc6c59cc 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -626,7 +626,8 @@ void BKE_write_undo(bContext *C, char *name) } } -/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ +/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation + * Note, ALWAYS call sound_initialize_sounds after BKE_undo_step() */ void BKE_undo_step(bContext *C, int step) { diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 18f065b59d9..d8926fc5753 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -74,15 +74,14 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, BoidSettings *boids = bbd->part->boids; ParticleEffectorCache *ec; Object *priority_ob = NULL; - BoidParticle *bpa = pa->boid; float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f}; float mul = (rule->type == eBoidRuleType_Avoid ? 1.0 : -1.0); - float priority = 0.0f, len = 0.0f; + float priority = 0.0f, len; int ret = 0; /* first find out goal/predator with highest priority */ /* if rule->ob specified use it */ - if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != bpa->ground)) { + if(gabr->ob && (rule->type != eBoidRuleType_Goal || gabr->ob != pa->stick_ob)) { PartDeflect *pd = gabr->ob->pd; float vec_to_part[3]; @@ -105,7 +104,7 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, PartDeflect *pd = eob->pd; /* skip current object */ - if(rule->type == eBoidRuleType_Goal && eob == bpa->ground) + if(rule->type == eBoidRuleType_Goal && eob == pa->stick_ob) continue; if(pd->forcefield == PFIELD_BOID && mul * pd->f_strength > 0.0f) { @@ -170,10 +169,10 @@ static int rule_goal_avoid(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, VECCOPY(bbd->goal_nor, nor); } } - else if(rule->type == eBoidRuleType_Avoid && bpa->data.mode == eBoidMode_Climbing && + else if(rule->type == eBoidRuleType_Avoid && pa->boid->mode == eBoidMode_Climbing && priority > 2.0f * gabr->fear_factor) { /* detach from surface and try to fly away from danger */ - VECCOPY(vec_to_part, bpa->gravity); + VECCOPY(vec_to_part, pa->r_ve); VecMulf(vec_to_part, -1.0f); } @@ -206,7 +205,6 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * KDTreeNearest *ptn = NULL; ParticleEffectorCache *ec; ParticleTarget *pt; - BoidParticle *bpa = pa->boid; float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f}; float co1[3], vel1[3], co2[3], vel2[3]; float len, t, inp, t_min = 2.0f; @@ -233,7 +231,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * Object *eob = ec->ob; /* don't check with current ground object */ - if(eob == bpa->ground) + if(eob == pa->stick_ob) continue; col.md = ( CollisionModifierData * ) ( modifiers_findByType ( eob, eModifierType_Collision ) ); @@ -560,19 +558,18 @@ static int rule_follow_leader(BoidRule *rule, BoidBrainData *bbd, BoidValues *va } static int rule_average_speed(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa) { - BoidParticle *bpa = pa->boid; BoidRuleAverageSpeed *asbr = (BoidRuleAverageSpeed*)rule; float vec[3] = {0.0f, 0.0f, 0.0f}; if(asbr->wander > 0.0f) { /* abuse pa->r_ave for wandering */ - bpa->wander[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); - bpa->wander[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); - bpa->wander[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); + pa->r_ave[0] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); + pa->r_ave[1] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); + pa->r_ave[2] += asbr->wander * (-1.0f + 2.0f * BLI_frand()); - Normalize(bpa->wander); + Normalize(pa->r_ave); - VECCOPY(vec, bpa->wander); + VECCOPY(vec, pa->r_ave); QuatMulVecf(pa->prev_state.rot, vec); @@ -617,8 +614,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti KDTreeNearest *ptn = NULL; ParticleTarget *pt; ParticleData *epars; - ParticleData *enemy_pa = NULL; - BoidParticle *bpa; + ParticleData *enemy_pa; /* friends & enemies */ float closest_enemy[3] = {0.0f,0.0f,0.0f}; float closest_dist = fbr->distance + 1.0f; @@ -628,10 +624,8 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti /* calculate own group strength */ int neighbors = BLI_kdtree_range_search(bbd->psys->tree, fbr->distance, pa->prev_state.co, NULL, &ptn); - for(n=0; n<neighbors; n++) { - bpa = bbd->psys->particles[ptn[n].index].boid; - health += bpa->data.health; - } + for(n=0; n<neighbors; n++) + health += bbd->psys->particles[ptn[n].index].boid->health; f_strength += bbd->part->boids->strength * health; @@ -648,8 +642,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti health = 0.0f; for(n=0; n<neighbors; n++) { - bpa = epars[ptn[n].index].boid; - health += bpa->data.health; + health += epars[ptn[n].index].boid->health; if(n==0 && pt->mode==PTARGET_MODE_ENEMY && ptn[n].dist < closest_dist) { VECCOPY(closest_enemy, ptn[n].co); @@ -681,8 +674,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti /* must face enemy to fight */ if(Inpf(pa->prev_state.ave, enemy_dir)>0.5f) { - bpa = enemy_pa->boid; - bpa->data.health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy); + enemy_pa->boid->health -= bbd->part->boids->strength * bbd->timestep * ((1.0f-bbd->part->boids->accuracy)*damage + bbd->part->boids->accuracy); } } else { @@ -691,8 +683,7 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti } /* check if boid doesn't want to fight */ - bpa = pa->boid; - if(bpa->data.health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) { + if(pa->boid->health/bbd->part->boids->health * bbd->part->boids->aggression < e_strength / f_strength) { /* decide to flee */ if(closest_dist < fbr->flee_distance * fbr->distance) { VecMulf(bbd->wanted_co, -1.0f); @@ -730,20 +721,18 @@ static boid_rule_cb boid_rules[] = { static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData *pa) { - BoidParticle *bpa = pa->boid; - - if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { - val->max_speed = boids->land_max_speed * bpa->data.health/boids->health; + if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)) { + val->max_speed = boids->land_max_speed * pa->boid->health/boids->health; val->max_acc = boids->land_max_acc * val->max_speed; - val->max_ave = boids->land_max_ave * M_PI * bpa->data.health/boids->health; + val->max_ave = boids->land_max_ave * M_PI * pa->boid->health/boids->health; val->min_speed = 0.0f; /* no minimum speed on land */ val->personal_space = boids->land_personal_space; - val->jump_speed = boids->land_jump_speed * bpa->data.health/boids->health; + val->jump_speed = boids->land_jump_speed * pa->boid->health/boids->health; } else { - val->max_speed = boids->air_max_speed * bpa->data.health/boids->health; + val->max_speed = boids->air_max_speed * pa->boid->health/boids->health; val->max_acc = boids->air_max_acc * val->max_speed; - val->max_ave = boids->air_max_ave * M_PI * bpa->data.health/boids->health; + val->max_ave = boids->air_max_ave * M_PI * pa->boid->health/boids->health; val->min_speed = boids->air_min_speed * boids->air_max_speed; val->personal_space = boids->air_personal_space; val->jump_speed = 0.0f; /* no jumping in air */ @@ -751,13 +740,11 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * } static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *ground_co, float *ground_nor) { - BoidParticle *bpa = pa->boid; - - if(bpa->data.mode == eBoidMode_Climbing) { + if(pa->boid->mode == eBoidMode_Climbing) { SurfaceModifierData *surmd = NULL; float x[3], v[3]; - surmd = (SurfaceModifierData *)modifiers_findByType ( bpa->ground, eModifierType_Surface ); + surmd = (SurfaceModifierData *)modifiers_findByType ( pa->stick_ob, eModifierType_Surface ); /* take surface velocity into account */ effector_find_co(bbd->scene, pa->state.co, surmd, NULL, NULL, x, NULL, v, NULL); @@ -766,7 +753,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro /* get actual position on surface */ effector_find_co(bbd->scene, x, surmd, NULL, NULL, ground_co, ground_nor, NULL, NULL); - return bpa->ground; + return pa->stick_ob; } else { float zvec[3] = {0.0f, 0.0f, 2000.0f}; @@ -816,15 +803,13 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro } static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule) { - BoidParticle *bpa = pa->boid; - if(rule==NULL) return 0; - if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND) + if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing) && rule->flag & BOIDRULE_ON_LAND) return 1; - if(bpa->data.mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR) + if(pa->boid->mode==eBoidMode_InAir && rule->flag & BOIDRULE_IN_AIR) return 1; return 0; @@ -850,13 +835,12 @@ void boids_precalc_rules(ParticleSettings *part, float cfra) } static void boid_climb(BoidSettings *boids, ParticleData *pa, float *surface_co, float *surface_nor) { - BoidParticle *bpa = pa->boid; float nor[3], vel[3]; VECCOPY(nor, surface_nor); - /* gather apparent gravity */ - VECADDFAC(bpa->gravity, bpa->gravity, surface_nor, -1.0); - Normalize(bpa->gravity); + /* gather apparent gravity to r_ve */ + VECADDFAC(pa->r_ve, pa->r_ve, surface_nor, -1.0); + Normalize(pa->r_ve); /* raise boid it's size from surface */ VecMulf(nor, pa->size * boids->height); @@ -893,17 +877,16 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, } static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) { BoidState *state = boids->states.first; - BoidParticle *bpa = pa->boid; for(; state; state=state->next) { - if(state->id==bpa->data.state_id) + if(state->id==pa->boid->state_id) return state; } /* for some reason particle isn't at a valid state */ state = boids->states.first; if(state) - bpa->data.state_id = state->id; + pa->boid->state_id = state->id; return state; } @@ -919,11 +902,9 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) BoidSettings *boids = bbd->part->boids; BoidValues val; BoidState *state = get_boid_state(boids, pa); - BoidParticle *bpa = pa->boid; - int rand; //BoidCondition *cond; - if(bpa->data.health <= 0.0f) { + if(pa->boid->health <= 0.0f) { pa->alive = PARS_DYING; return; } @@ -941,9 +922,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; /* create random seed for every particle & frame */ - BLI_srandom(bbd->psys->seed + p); - rand = BLI_rand(); - BLI_srandom((int)bbd->cfra + rand); + BLI_srandom(bbd->psys->seed + p + (int)bbd->cfra + (int)(1000*pa->r_rot[0])); set_boid_values(&val, bbd->part->boids, pa); @@ -960,7 +939,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) case eBoidRulesetType_Random: { /* use random rule for each particle (allways same for same particle though) */ - rule = BLI_findlink(&state->rules, rand % BLI_countlist(&state->rules)); + rule = BLI_findlink(&state->rules, (int)(1000.0f * pa->r_rot[1]) % BLI_countlist(&state->rules)); apply_boid_rule(bbd, rule, &val, pa, -1.0); } @@ -990,7 +969,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) } /* decide on jumping & liftoff */ - if(bpa->data.mode == eBoidMode_OnLand) { + if(pa->boid->mode == eBoidMode_OnLand) { /* fuzziness makes boids capable of misjudgement */ float mul = 1.0 + state->rule_fuzziness; @@ -1004,7 +983,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) Normalize2(cvel); if(Inp2f(cvel, dir) > 0.95 / mul) - bpa->data.mode = eBoidMode_Liftoff; + pa->boid->mode = eBoidMode_Liftoff; } else if(val.jump_speed > 0.0f) { float jump_v[3]; @@ -1057,7 +1036,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) if(jump) { VECCOPY(pa->prev_state.vel, jump_v); - bpa->data.mode = eBoidMode_Falling; + pa->boid->mode = eBoidMode_Falling; } } } @@ -1066,7 +1045,6 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) void boid_body(BoidBrainData *bbd, ParticleData *pa) { BoidSettings *boids = bbd->part->boids; - BoidParticle *bpa = pa->boid; BoidValues val; float acc[3] = {0.0f, 0.0f, 0.0f}, tan_acc[3], nor_acc[3]; float dvec[3], bvec[3]; @@ -1088,10 +1066,10 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) pa_mass*=pa->size; /* if boids can't fly they fall to the ground */ - if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && bbd->part->acc[2] != 0.0f) - bpa->data.mode = eBoidMode_Falling; + if((boids->options & BOID_ALLOW_FLIGHT)==0 && ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)==0 && bbd->part->acc[2] != 0.0f) + pa->boid->mode = eBoidMode_Falling; - if(bpa->data.mode == eBoidMode_Falling) { + if(pa->boid->mode == eBoidMode_Falling) { /* Falling boids are only effected by gravity. */ acc[2] = bbd->part->acc[2]; } @@ -1101,14 +1079,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) float level = landing_level + 1.0f; float new_vel[3]; - if(bpa->data.mode == eBoidMode_Liftoff) { - bpa->data.mode = eBoidMode_InAir; - bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); + if(pa->boid->mode == eBoidMode_Liftoff) { + pa->boid->mode = eBoidMode_InAir; + pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor); } - else if(bpa->data.mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) { + else if(pa->boid->mode == eBoidMode_InAir && boids->options & BOID_ALLOW_LAND) { /* auto-leveling & landing if close to ground */ - bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); + pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor); /* level = how many particle sizes above ground */ level = (pa->prev_state.co[2] - ground_co[2])/(2.0f * pa->size) - 0.5; @@ -1119,7 +1097,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) if(level < 1.0f) { bbd->wanted_co[0] = bbd->wanted_co[1] = bbd->wanted_co[2] = 0.0f; bbd->wanted_speed = 0.0f; - bpa->data.mode = eBoidMode_Falling; + pa->boid->mode = eBoidMode_Falling; } else if(level < landing_level) { bbd->wanted_speed *= (level - 1.0f)/landing_level; @@ -1210,7 +1188,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* account for effectors */ do_effectors(p, pa, &pa->state, bbd->scene, bbd->ob, bbd->psys, pa->state.co, force, tvel, bbd->dfra, bbd->cfra); - if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) { + if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)) { float length = Normalize(force); length = MAX2(0.0f, length - boids->land_stick_force); @@ -1221,8 +1199,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VecAddf(acc, acc, force); /* store smoothed acceleration for nice banking etc. */ - VECADDFAC(bpa->data.acc, bpa->data.acc, acc, dtime); - VecMulf(bpa->data.acc, 1.0f / (1.0f + dtime)); + VECADDFAC(pa->boid->acc, pa->boid->acc, acc, dtime); + VecMulf(pa->boid->acc, 1.0f / (1.0f + dtime)); /* integrate new location & velocity */ @@ -1240,32 +1218,32 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); - if(bpa->data.mode != eBoidMode_InAir) - bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); + if(pa->boid->mode != eBoidMode_InAir) + pa->stick_ob = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ - switch(bpa->data.mode) { + switch(pa->boid->mode) { case eBoidMode_InAir: { float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f}; /* don't take forward acceleration into account (better banking) */ - if(Inpf(bpa->data.acc, pa->state.vel) > 0.0f) { - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + if(Inpf(pa->boid->acc, pa->state.vel) > 0.0f) { + Projf(dvec, pa->boid->acc, pa->state.vel); + VecSubf(dvec, pa->boid->acc, dvec); } else { - VECCOPY(dvec, bpa->data.acc); + VECCOPY(dvec, pa->boid->acc); } - /* gather apparent gravity */ - VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + /* gather apparent gravity to r_ve */ + VECADDFAC(pa->r_ve, grav, dvec, -boids->banking); + Normalize(pa->r_ve); /* stick boid on goal when close enough */ if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) { - bpa->data.mode = eBoidMode_Climbing; - bpa->ground = bbd->goal_ob; + pa->boid->mode = eBoidMode_Climbing; + pa->stick_ob = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); boid_climb(boids, pa, ground_co, ground_nor); } @@ -1273,7 +1251,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) else if(boids->options & BOID_ALLOW_LAND && pa->state.co[2] <= ground_co[2] + pa->size * boids->height) { pa->state.co[2] = ground_co[2] + pa->size * boids->height; pa->state.vel[2] = 0.0f; - bpa->data.mode = eBoidMode_OnLand; + pa->boid->mode = eBoidMode_OnLand; } break; } @@ -1281,15 +1259,15 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) { float grav[3] = {0.0f, 0.0f, bbd->part->acc[2] < 0.0f ? -1.0f : 0.0f}; - /* gather apparent gravity */ - VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime); - Normalize(bpa->gravity); + /* gather apparent gravity to r_ve */ + VECADDFAC(pa->r_ve, pa->r_ve, grav, dtime); + Normalize(pa->r_ve); if(boids->options & BOID_ALLOW_LAND) { /* stick boid on goal when close enough */ if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) { - bpa->data.mode = eBoidMode_Climbing; - bpa->ground = bbd->goal_ob; + pa->boid->mode = eBoidMode_Climbing; + pa->stick_ob = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); boid_climb(boids, pa, ground_co, ground_nor); } @@ -1297,14 +1275,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) else if(pa->state.co[2] <= ground_co[2] + 1.01 * pa->size * boids->height){ pa->state.co[2] = ground_co[2] + pa->size * boids->height; pa->state.vel[2] = 0.0f; - bpa->data.mode = eBoidMode_OnLand; + pa->boid->mode = eBoidMode_OnLand; } /* if we're falling, can fly and want to go upwards lets fly */ else if(boids->options & BOID_ALLOW_FLIGHT && bbd->wanted_co[2] > 0.0f) - bpa->data.mode = eBoidMode_InAir; + pa->boid->mode = eBoidMode_InAir; } else - bpa->data.mode = eBoidMode_InAir; + pa->boid->mode = eBoidMode_InAir; break; } case eBoidMode_Climbing: @@ -1330,14 +1308,14 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) { /* stick boid on goal when close enough */ if(bbd->goal_ob && boid_goal_signed_dist(pa->state.co, bbd->goal_co, bbd->goal_nor) <= pa->size * boids->height) { - bpa->data.mode = eBoidMode_Climbing; - bpa->ground = bbd->goal_ob; + pa->boid->mode = eBoidMode_Climbing; + pa->stick_ob = bbd->goal_ob; boid_find_ground(bbd, pa, ground_co, ground_nor); boid_climb(boids, pa, ground_co, ground_nor); } /* ground is too far away so boid falls */ else if(pa->state.co[2]-ground_co[2] > 1.1 * pa->size * boids->height) - bpa->data.mode = eBoidMode_Falling; + pa->boid->mode = eBoidMode_Falling; else { /* constrain to surface */ pa->state.co[2] = ground_co[2] + pa->size * boids->height; @@ -1351,17 +1329,17 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECCOPY(grav, ground_nor); VecMulf(grav, -1.0f); - Projf(dvec, bpa->data.acc, pa->state.vel); - VecSubf(dvec, bpa->data.acc, dvec); + Projf(dvec, pa->boid->acc, pa->state.vel); + VecSubf(dvec, pa->boid->acc, dvec); - /* gather apparent gravity */ - VECADDFAC(bpa->gravity, grav, dvec, -boids->banking); - Normalize(bpa->gravity); + /* gather apparent gravity to r_ve */ + VECADDFAC(pa->r_ve, grav, dvec, -boids->banking); + Normalize(pa->r_ve); } else { - /* gather negative surface normal */ - VECADDFAC(bpa->gravity, bpa->gravity, ground_nor, -1.0f); - Normalize(bpa->gravity); + /* gather negative surface normal to r_ve */ + VECADDFAC(pa->r_ve, pa->r_ve, ground_nor, -1.0f); + Normalize(pa->r_ve); } break; } @@ -1369,29 +1347,29 @@ 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 && VecLength(pa->state.vel) > 0.1*pa->size) { + if(pa->boid->mode!=eBoidMode_Falling && VecLength(pa->state.vel) > 0.1*pa->size) { VECCOPY(pa->state.ave, pa->state.vel); Normalize(pa->state.ave); } /* apply damping */ - if(ELEM(bpa->data.mode, eBoidMode_OnLand, eBoidMode_Climbing)) + if(ELEM(pa->boid->mode, eBoidMode_OnLand, eBoidMode_Climbing)) VecMulf(pa->state.vel, 1.0f - 0.2f*bbd->part->dampfac); /* calculate rotation matrix based on forward & down vectors */ - if(bpa->data.mode == eBoidMode_InAir) { + if(pa->boid->mode == eBoidMode_InAir) { VECCOPY(mat[0], pa->state.ave); - Projf(dvec, bpa->gravity, pa->state.ave); - VecSubf(mat[2], bpa->gravity, dvec); + Projf(dvec, pa->r_ve, pa->state.ave); + VecSubf(mat[2], pa->r_ve, dvec); Normalize(mat[2]); } else { - Projf(dvec, pa->state.ave, bpa->gravity); + Projf(dvec, pa->state.ave, pa->r_ve); VecSubf(mat[0], pa->state.ave, dvec); Normalize(mat[0]); - VECCOPY(mat[2], bpa->gravity); + VECCOPY(mat[2], pa->r_ve); } VecMulf(mat[2], -1.0f); Crossf(mat[1], mat[2], mat[0]); diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 5f0697f06ce..eb3aefe7ee6 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -589,7 +589,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) MEM_freeN(mat); /* update dag */ - DAG_id_flush_update(&ob_new->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, ob_new, OB_RECALC_DATA); return 1; } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index bce4e1120be..a7b5a16d924 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -409,6 +409,23 @@ float brush_sample_falloff(Brush *brush, float dist) return 0.0f; } +float brush_sample_falloff_noalpha(Brush *brush, float dist) +{ + float outer, inner; + + outer = brush->size >> 1; + inner = outer*brush->innerradius; + + if (dist <= inner) { + return 1.0f; + } + else if ((dist < outer) && (inner < outer)) { + return 1.0f - sqrt((dist - inner)/(outer - inner)); + } + else + return 0.0f; +} + void brush_sample_tex(Brush *brush, float *xy, float *rgba) { MTex *mtex= brush->mtex[brush->texact]; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b20da0962a7..706eece108c 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1288,7 +1288,6 @@ typedef struct MultiresDM { CDDerivedMesh cddm; MultiresModifierData *mmd; - int local_mmd; int lvl, totlvl; float (*orco)[3]; @@ -1298,7 +1297,7 @@ typedef struct MultiresDM { IndexNode *vert_face_map_mem, *vert_edge_map_mem; int *face_offsets; - Object *ob; + Mesh *me; int modified; void (*update)(DerivedMesh*); @@ -1310,19 +1309,14 @@ static void MultiresDM_release(DerivedMesh *dm) int mvert_layer; /* Before freeing, need to update the displacement map */ - if(dm->needsFree && mrdm->modified) { - /* Check that mmd still exists */ - if(!mrdm->local_mmd && BLI_findindex(&mrdm->ob->modifiers, mrdm->mmd) < 0) - mrdm->mmd = NULL; - if(mrdm->mmd) - mrdm->update(dm); - } + if(dm->needsFree && mrdm->modified) + mrdm->update(dm); /* If the MVert data is being used as the sculpt undo store, don't free it */ mvert_layer = CustomData_get_layer_index(&dm->vertData, CD_MVERT); if(mvert_layer != -1) { CustomDataLayer *cd = &dm->vertData.layers[mvert_layer]; - if(mrdm->mmd && cd->data == mrdm->mmd->undo_verts) + if(cd->data == mrdm->mmd->undo_verts) cd->flag |= CD_FLAG_NOFREE; } @@ -1354,8 +1348,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts dm = &mrdm->cddm.dm; mrdm->mmd = ms->mmd; - mrdm->ob = ms->ob; - mrdm->local_mmd = ms->local_mmd; + mrdm->me = ms->me; if(dm) { MDisps *disps; @@ -1398,12 +1391,7 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts Mesh *MultiresDM_get_mesh(DerivedMesh *dm) { - return get_mesh(((MultiresDM*)dm)->ob); -} - -Object *MultiresDM_get_object(DerivedMesh *dm) -{ - return ((MultiresDM*)dm)->ob; + return ((MultiresDM*)dm)->me; } void *MultiresDM_get_orco(DerivedMesh *dm) @@ -1440,11 +1428,10 @@ void MultiresDM_set_update(DerivedMesh *dm, void (*update)(DerivedMesh*)) ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; - Mesh *me = mrdm->ob->data; if(!mrdm->vert_face_map) - create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, me->mface, - me->totvert, me->totface); + create_vert_face_map(&mrdm->vert_face_map, &mrdm->vert_face_map_mem, mrdm->me->mface, + mrdm->me->totvert, mrdm->me->totface); return mrdm->vert_face_map; } @@ -1452,11 +1439,10 @@ ListBase *MultiresDM_get_vert_face_map(DerivedMesh *dm) ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; - Mesh *me = mrdm->ob->data; if(!mrdm->vert_edge_map) - create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, me->medge, - me->totvert, me->totedge); + create_vert_edge_map(&mrdm->vert_edge_map, &mrdm->vert_edge_map_mem, mrdm->me->medge, + mrdm->me->totvert, mrdm->me->totedge); return mrdm->vert_edge_map; } @@ -1464,7 +1450,6 @@ ListBase *MultiresDM_get_vert_edge_map(DerivedMesh *dm) int *MultiresDM_get_face_offsets(DerivedMesh *dm) { MultiresDM *mrdm = (MultiresDM*)dm; - Mesh *me = mrdm->ob->data; int i, accum = 0; if(!mrdm->face_offsets) { @@ -1472,11 +1457,11 @@ int *MultiresDM_get_face_offsets(DerivedMesh *dm) int area = len * len; int t = 1 + len * 3 + area * 3, q = t + len + area; - mrdm->face_offsets = MEM_callocN(sizeof(int) * me->totface, "mrdm face offsets"); - for(i = 0; i < me->totface; ++i) { + mrdm->face_offsets = MEM_callocN(sizeof(int) * mrdm->me->totface, "mrdm face offsets"); + for(i = 0; i < mrdm->me->totface; ++i) { mrdm->face_offsets[i] = accum; - accum += (me->mface[i].v4 ? q : t); + accum += (mrdm->me->mface[i].v4 ? q : t); } } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 8be8df8e63b..3acaaecb1e8 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -347,7 +347,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) BKE_ptcache_id_from_cloth(&pid, ob, clmd); // don't do anything as long as we're in editmode! - if(pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT) + if(pid.cache->flag & PTCACHE_BAKE_EDIT_ACTIVE) return; BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr); @@ -496,30 +496,23 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, if(!do_init_cloth(ob, clmd, result, framenr)) return result; - if(framenr == startframe && cache->flag & PTCACHE_REDO_NEEDED) { - BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - cache->simframe= framenr; - cache->flag &= ~PTCACHE_REDO_NEEDED; - return result; - } - /* try to read from cache */ cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { - implicit_set_positions(clmd); - cloth_to_object (ob, clmd, result); - - cache->simframe= framenr; cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; - if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(&pid, framenr); + implicit_set_positions(clmd); + cloth_to_object (ob, clmd, result); return result; } else if(cache_result==PTCACHE_READ_OLD) { + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); + implicit_set_positions(clmd); + cache->flag |= PTCACHE_SIMULATION_VALID; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { @@ -531,10 +524,12 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } if(framenr == startframe) { - implicit_set_positions(clmd); - - cache->simframe= framenr; + if(cache->flag & PTCACHE_REDO_NEEDED) { + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); + do_init_cloth(ob, clmd, result, framenr); + } cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; /* don't write cache on first frame, but on second frame write * cache for frame 1 and 2 */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index dfbcc51a93c..88e73a00ba7 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -121,7 +121,6 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, if (ob) { cob->ob = ob; cob->type = datatype; - cob->rotOrder = EULER_ORDER_DEFAULT; // TODO: when objects have rotation order too, use that Mat4CpyMat4(cob->matrix, ob->obmat); } else @@ -138,15 +137,6 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, cob->pchan = (bPoseChannel *)subdata; cob->type = datatype; - if (cob->pchan->rotmode > 0) { - /* should be some type of Euler order */ - cob->rotOrder= cob->pchan->rotmode; - } - else { - /* Quats, so eulers should just use default order */ - cob->rotOrder= EULER_ORDER_DEFAULT; - } - /* matrix in world-space */ Mat4MulMat4(cob->matrix, cob->pchan->pose_mat, ob->obmat); } @@ -674,7 +664,6 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain * (Hopefully all compilers will be happy with the lines with just a space on them. Those are * really just to help this code easier to read) */ -// TODO: cope with getting rotation order... #define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \ { \ ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ @@ -698,7 +687,6 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain * (Hopefully all compilers will be happy with the lines with just a space on them. Those are * really just to help this code easier to read) */ -// TODO: cope with getting rotation order... #define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \ { \ ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ @@ -807,11 +795,11 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* extract components of both matrices */ VECCOPY(loc, ct->matrix[3]); - Mat4ToEulO(ct->matrix, eul, ct->rotOrder); + Mat4ToEul(ct->matrix, eul); Mat4ToSize(ct->matrix, size); VECCOPY(loco, invmat[3]); - Mat4ToEulO(invmat, eulo, cob->rotOrder); + Mat4ToEul(invmat, eulo); Mat4ToSize(invmat, sizo); /* disable channels not enabled */ @@ -826,8 +814,8 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; /* make new target mat and offset mat */ - LocEulOSizeToMat4(ct->matrix, loc, eul, size, ct->rotOrder); - LocEulOSizeToMat4(invmat, loco, eulo, sizo, cob->rotOrder); + LocEulSizeToMat4(ct->matrix, loc, eul, size); + LocEulSizeToMat4(invmat, loco, eulo, sizo); /* multiply target (parent matrix) by offset (parent inverse) to get * the effect of the parent that will be exherted on the owner @@ -1178,26 +1166,17 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr makeDispListCurveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { - if ((data->followflag & FOLLOWPATH_STATIC) == 0) { - /* animated position along curve depending on time */ - curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset; - - /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, - * but this will only work if it actually is animated... - * - * we firstly calculate the modulus of cu->ctime/cu->pathlen to clamp ctime within the 0.0 to 1.0 times pathlen - * range, then divide this (the modulus) by pathlen to get a value between 0.0 and 1.0 - */ - curvetime= fmod(cu->ctime, cu->pathlen) / cu->pathlen; + curvetime= bsystem_time(cob->scene, ct->tar, (float)ctime, 0.0) - data->offset; + +#if 0 // XXX old animation system + if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) { + curvetime /= cu->pathlen; CLAMP(curvetime, 0.0, 1.0); } - else { - /* fixed position along curve */ - curvetime= data->offset; // XXX might need a more sensible value - } +#endif // XXX old animation system if ( where_on_path(ct->tar, curvetime, vec, dir) ) { - if (data->followflag & FOLLOWPATH_FOLLOW) { + if (data->followflag) { vectoquat(dir, (short) data->trackflag, (short) data->upflag, quat); Normalize(dir); @@ -1325,7 +1304,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t VECCOPY(loc, cob->matrix[3]); Mat4ToSize(cob->matrix, size); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); + Mat4ToEul(cob->matrix, eul); /* eulers: radians to degrees! */ eul[0] = (float)(eul[0] / M_PI * 180); @@ -1360,7 +1339,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t eul[1] = (float)(eul[1] / 180 * M_PI); eul[2] = (float)(eul[2] / 180 * M_PI); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + LocEulSizeToMat4(cob->matrix, loc, eul, size); } static bConstraintTypeInfo CTI_ROTLIMIT = { @@ -1567,14 +1546,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta VECCOPY(loc, cob->matrix[3]); Mat4ToSize(cob->matrix, size); - Mat4ToEulO(ct->matrix, eul, ct->rotOrder); - Mat4ToEulO(cob->matrix, obeul, cob->rotOrder); + Mat4ToEul(ct->matrix, eul); + Mat4ToEul(cob->matrix, obeul); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[0], 'x', cob->rotOrder); + euler_rot(eul, obeul[0], 'x'); if (data->flag & ROTLIKE_X_INVERT) eul[0] *= -1; @@ -1584,7 +1563,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[1], 'y', cob->rotOrder); + euler_rot(eul, obeul[1], 'y'); if (data->flag & ROTLIKE_Y_INVERT) eul[1] *= -1; @@ -1594,14 +1573,14 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) - eulerO_rot(eul, obeul[2], 'z', cob->rotOrder); + euler_rot(eul, obeul[2], 'z'); if (data->flag & ROTLIKE_Z_INVERT) eul[2] *= -1; } compatible_eul(eul, obeul); - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + LocEulSizeToMat4(cob->matrix, loc, eul, size); } } @@ -3057,7 +3036,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * Mat4ToSize(ct->matrix, dvec); break; case 1: /* rotation (convert to degrees first) */ - Mat4ToEulO(ct->matrix, dvec, cob->rotOrder); + Mat4ToEul(ct->matrix, dvec); for (i=0; i<3; i++) dvec[i] = (float)(dvec[i] / M_PI * 180); break; @@ -3068,7 +3047,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* extract components of owner's matrix */ VECCOPY(loc, cob->matrix[3]); - Mat4ToEulO(cob->matrix, eul, cob->rotOrder); + Mat4ToEul(cob->matrix, eul); Mat4ToSize(cob->matrix, size); /* determine where in range current transforms lie */ @@ -3123,7 +3102,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } /* apply to matrix */ - LocEulOSizeToMat4(cob->matrix, loc, eul, size, cob->rotOrder); + LocEulSizeToMat4(cob->matrix, loc, eul, size); } } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 58ff601e7f7..7dd868278f4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -470,11 +470,8 @@ void test2DNurb(Nurb *nu) BezTriple *bezt; BPoint *bp; int a; - - if((nu->flag & CU_2D)==0) - return; - if(nu->type == CU_BEZIER) { + if( nu->type== CU_BEZIER+CU_2D ) { a= nu->pntsu; bezt= nu->bezt; while(a--) { @@ -484,7 +481,7 @@ void test2DNurb(Nurb *nu) bezt++; } } - else { + else if(nu->type & CU_2D) { a= nu->pntsu*nu->pntsv; bp= nu->bp; while(a--) { @@ -500,7 +497,7 @@ void minmaxNurb(Nurb *nu, float *min, float *max) BPoint *bp; int a; - if(nu->type == CU_BEZIER) { + if( (nu->type & 7)==CU_BEZIER ) { a= nu->pntsu; bezt= nu->bezt; while(a--) { @@ -597,7 +594,7 @@ static void makecyclicknots(float *knots, short pnts, short order) void makeknots(Nurb *nu, short uv) { - if(nu->type == CU_NURBS) { + if( (nu->type & 7)==CU_NURBS ) { if(uv == 1) { if(nu->knotsu) MEM_freeN(nu->knotsu); if(check_valid_nurb_u(nu)) { @@ -1553,7 +1550,7 @@ void makeBevelList(Object *ob) BPoint *bp; BevList *bl, *blnew, *blnext; BevPoint *bevp, *bevp2, *bevp1 = NULL, *bevp0; - float min, inp, x1, x2, y1, y2, vec[3], vec_prev[3], q[4], quat[4], quat_prev[4], cross[3]; + float min, inp, x1, x2, y1, y2, vec[3]; float *coord_array, *tilt_array=NULL, *radius_array=NULL, *coord_fp, *tilt_fp=NULL, *radius_fp=NULL; float *v1, *v2; struct bevelsort *sortdata, *sd, *sd1; @@ -1590,7 +1587,7 @@ void makeBevelList(Object *ob) else resolu= nu->resolu; - if(nu->type == CU_POLY) { + if((nu->type & 7)==CU_POLY) { len= nu->pntsu; bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList2"); BLI_addtail(&(cu->bev), bl); @@ -1613,7 +1610,7 @@ void makeBevelList(Object *ob) bp++; } } - else if(nu->type == CU_BEZIER) { + else if((nu->type & 7)==CU_BEZIER) { len= resolu*(nu->pntsu+ (nu->flagu & CU_CYCLIC) -1)+1; /* in case last point is not cyclic */ bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelBPoints"); @@ -1721,7 +1718,7 @@ void makeBevelList(Object *ob) bl->nr++; } } - else if(nu->type == CU_NURBS) { + else if((nu->type & 7)==CU_NURBS) { if(nu->pntsv==1) { len= (resolu*SEGMENTSU(nu)); @@ -1823,14 +1820,14 @@ void makeBevelList(Object *ob) bl= blnext; } - /* STEP 3: POLYS COUNT AND AUTOHOLE */ + /* STEP 3: COUNT POLYS TELLEN AND AUTOHOLE */ bl= cu->bev.first; poly= 0; while(bl) { if(bl->nr && bl->poly>=0) { poly++; bl->poly= poly; - bl->hole= 0; + bl->gat= 0; /* 'gat' is dutch for hole */ } bl= bl->next; } @@ -1882,7 +1879,7 @@ void makeBevelList(Object *ob) sd1= sortdata+ (a-1); for(b=a-1; b>=0; b--, sd1--) { /* all polys to the left */ if(bevelinside(sd1->bl, bl)) { - bl->hole= 1- sd1->bl->hole; + bl->gat= 1- sd1->bl->gat; break; } } @@ -1892,7 +1889,7 @@ void makeBevelList(Object *ob) if((cu->flag & CU_3D)==0) { sd= sortdata; for(a=0; a<poly; a++, sd++) { - if(sd->bl->hole==sd->dir) { + if(sd->bl->gat==sd->dir) { bl= sd->bl; bevp1= (BevPoint *)(bl+1); bevp2= bevp1+ (bl->nr-1); @@ -1912,10 +1909,7 @@ void makeBevelList(Object *ob) bl= cu->bev.first; while(bl) { - if(bl->nr < 2) { - /* do nothing */ - } - else if(bl->nr==2) { /* 2 pnt, treat separate */ + if(bl->nr==2) { /* 2 pnt, treat separate */ bevp2= (BevPoint *)(bl+1); bevp1= bevp2+1; @@ -1929,169 +1923,68 @@ void makeBevelList(Object *ob) if(cu->flag & CU_3D) { /* 3D */ float quat[4], q[4]; - VecSubf(vec, &bevp1->x, &bevp2->x); + vec[0]= bevp1->x - bevp2->x; + vec[1]= bevp1->y - bevp2->y; + vec[2]= bevp1->z - bevp2->z; vectoquat(vec, 5, 1, quat); - AxisAngleToQuat(q, vec, bevp1->alfa); + Normalize(vec); + q[0]= (float)cos(0.5*bevp1->alfa); + x1= (float)sin(0.5*bevp1->alfa); + q[1]= x1*vec[0]; + q[2]= x1*vec[1]; + q[3]= x1*vec[2]; QuatMul(quat, q, quat); QuatToMat3(quat, bevp1->mat); Mat3CpyMat3(bevp2->mat, bevp1->mat); } - } /* this has to be >2 points */ - else if(cu->flag & CU_NO_TWIST && cu->flag & CU_3D && bl->poly != -1) { - - /* Special case, cyclic curve with no twist. tricky... */ - - float quat[4], q[4], cross[3]; - - /* correcting a cyclic curve is more complicated, need to be corrected from both ends */ - float *quat_tmp1, *quat_tmp2; /* store a quat in the matrix temporarily */ - int iter_dir; - BevPoint *bevp_start= (BevPoint *)(bl+1); - - /* loop over the points twice, once up, once back, accumulate the quat rotations - * in both directions, then blend them in the 3rd loop and apply the tilt */ - for(iter_dir = 0; iter_dir < 2; iter_dir++) { - - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; - - nr= bl->nr; - while(nr--) { - - /* Normalizes */ - VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x); - - if(bl->nr==nr+1) { /* first time */ - vectoquat(vec, 5, 1, quat); - } - else { - float angle = NormalizedVecAngle2(vec_prev, vec); - - if(angle > 0.0f) { /* otherwise we can keep as is */ - Crossf(cross, vec_prev, vec); - AxisAngleToQuat(q, cross, angle); - QuatMul(quat, q, quat_prev); - } - else { - QUATCOPY(quat, quat_prev); - } - } - QUATCOPY(quat_prev, quat); /* quat_prev can't have the tilt applied */ - VECCOPY(vec_prev, vec); - - if(iter_dir==0) { /* up, first time */ - quat_tmp1= (float *)bevp1->mat; - - bevp0= bevp1; - bevp1= bevp2; - bevp2++; - } - else { /* down second time */ - quat_tmp1= ((float *)bevp1->mat)+4; - - bevp2= bevp1; - bevp1= bevp0; - bevp0--; - - /* wrap around */ - if (bevp0 < bevp_start) - bevp0= bevp_start+(bl->nr-1); - } - - QUATCOPY(quat_tmp1, quat); - } - } - - /* Now interpolate the 2 quats and apply tilt */ - - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; - - nr= bl->nr; - while(nr--) { - - VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x); - - quat_tmp1= (float *)bevp1->mat; - quat_tmp2= quat_tmp1+4; - - /* blend the 2 rotations gathered from both directions */ - QuatInterpol(quat, quat_tmp1, quat_tmp2, 1.0 - (((float)nr)/bl->nr)); - - AxisAngleToQuat(q, vec, bevp1->alfa); - QuatMul(quat, q, quat); - QuatToMat3(quat, bevp1->mat); - - /* generic */ - x1= bevp1->x- bevp0->x; - x2= bevp1->x- bevp2->x; - y1= bevp1->y- bevp0->y; - y2= bevp1->y- bevp2->y; - - calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa)); - - bevp0= bevp1; - bevp1= bevp2; - bevp2++; - } } - else { - /* Any curve with 3 or more points */ - + else if(bl->nr>2) { bevp2= (BevPoint *)(bl+1); bevp1= bevp2+(bl->nr-1); bevp0= bevp1-1; + nr= bl->nr; + while(nr--) { - + if(cu->flag & CU_3D) { /* 3D */ + float quat[4], q[4]; + + vec[0]= bevp2->x - bevp0->x; + vec[1]= bevp2->y - bevp0->y; + vec[2]= bevp2->z - bevp0->z; + + Normalize(vec); - /* Normalizes */ - VecBisect3(vec, &bevp0->x, &bevp1->x, &bevp2->x); - - if(bl->nr==nr+1 || !(cu->flag & CU_NO_TWIST)) { /* first time */ - vectoquat(vec, 5, 1, quat); - } - else { - float angle = NormalizedVecAngle2(vec_prev, vec); - - if(angle > 0.0f) { /* otherwise we can keep as is */ - Crossf(cross, vec_prev, vec); - AxisAngleToQuat(q, cross, angle); - QuatMul(quat, q, quat_prev); - } - else { - QUATCOPY(quat, quat_prev); - } - } - QUATCOPY(quat_prev, quat); /* quat_prev can't have the tilt applied */ - VECCOPY(vec_prev, vec); + vectoquat(vec, 5, 1, quat); - AxisAngleToQuat(q, vec, bevp1->alfa); + q[0]= (float)cos(0.5*bevp1->alfa); + x1= (float)sin(0.5*bevp1->alfa); + q[1]= x1*vec[0]; + q[2]= x1*vec[1]; + q[3]= x1*vec[2]; QuatMul(quat, q, quat); + QuatToMat3(quat, bevp1->mat); } - + x1= bevp1->x- bevp0->x; x2= bevp1->x- bevp2->x; y1= bevp1->y- bevp0->y; y2= bevp1->y- bevp2->y; - + calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa)); - - + + bevp0= bevp1; bevp1= bevp2; bevp2++; } - /* correct non-cyclic cases */ if(bl->poly== -1) { if(bl->nr>2) { @@ -2314,7 +2207,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ BezTriple *bezt, *prev, *next; short a; - if(nu->type != CU_BEZIER) return; + if((nu->type & 7)!=CU_BEZIER) return; if(nu->pntsu<2) return; a= nu->pntsu; @@ -2349,7 +2242,7 @@ void testhandlesNurb(Nurb *nu) BezTriple *bezt; short flag, a; - if(nu->type != CU_BEZIER) return; + if((nu->type & 7)!=CU_BEZIER) return; bezt= nu->bezt; a= nu->pntsu; @@ -2477,7 +2370,7 @@ void sethandlesNurb(ListBase *editnurb, short code) if(code==1 || code==2) { nu= editnurb->first; while(nu) { - if(nu->type == CU_BEZIER) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2507,7 +2400,7 @@ void sethandlesNurb(ListBase *editnurb, short code) } else { /* Toggle */ while(nu) { - if(nu->type == CU_BEZIER) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2524,7 +2417,7 @@ void sethandlesNurb(ListBase *editnurb, short code) } nu= editnurb->first; while(nu) { - if(nu->type == CU_BEZIER) { + if( (nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2572,7 +2465,7 @@ void switchdirectionNurb(Nurb *nu) if(nu->pntsu==1 && nu->pntsv==1) return; - if(nu->type == CU_BEZIER) { + if((nu->type & 7)==CU_BEZIER) { a= nu->pntsu; bezt1= nu->bezt; bezt2= bezt1+(a-1); @@ -2611,7 +2504,7 @@ void switchdirectionNurb(Nurb *nu) bp1++; bp2--; } - if(nu->type == CU_NURBS) { + if((nu->type & 7)==CU_NURBS) { /* inverse knots */ a= KNOTSU(nu); fp1= nu->knotsu; @@ -2674,7 +2567,7 @@ float (*curve_getVertexCos(Curve *cu, ListBase *lb, int *numVerts_r))[3] co = cos[0]; for (nu=lb->first; nu; nu=nu->next) { - if (nu->type == CU_BEZIER) { + if ((nu->type & 7)==CU_BEZIER) { BezTriple *bezt = nu->bezt; for (i=0; i<nu->pntsu; i++,bezt++) { @@ -2701,7 +2594,7 @@ void curve_applyVertexCos(Curve *cu, ListBase *lb, float (*vertexCos)[3]) int i; for (nu=lb->first; nu; nu=nu->next) { - if (nu->type == CU_BEZIER) { + if ((nu->type & 7)==CU_BEZIER) { BezTriple *bezt = nu->bezt; for (i=0; i<nu->pntsu; i++,bezt++) { @@ -2723,7 +2616,7 @@ int check_valid_nurb_u( struct Nurb *nu ) { if (nu==NULL) return 0; if (nu->pntsu <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + if ((nu->type & 7)!=CU_NURBS) return 1; /* not a nurb, lets assume its valid */ if (nu->pntsu < nu->orderu) return 0; if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagu>>1) & 2)) { /* Bezier U Endpoints */ @@ -2737,7 +2630,7 @@ int check_valid_nurb_v( struct Nurb *nu) { if (nu==NULL) return 0; if (nu->pntsv <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + if ((nu->type & 7)!=CU_NURBS) return 1; /* not a nurb, lets assume its valid */ if (nu->pntsv < nu->orderv) return 0; if (((nu->flag & CU_CYCLIC)==0) && ((nu->flagv>>1) & 2)) { /* Bezier V Endpoints */ diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 6a14762e0ed..6c765b02e5d 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -61,7 +61,6 @@ #include "DNA_space_types.h" #include "DNA_view2d_types.h" #include "DNA_view3d_types.h" -#include "DNA_windowmanager_types.h" #include "BLI_ghash.h" @@ -2142,77 +2141,39 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay) } -void DAG_id_flush_update(ID *id, short flag) -{ - Main *bmain= G.main; - wmWindowManager *wm; - wmWindow *win; - Scene *sce; - Object *obt, *ob= NULL; - short idtype; - - /* only one scene supported currently, making more scenes work - correctly requires changes beyond just the dependency graph */ - - if((wm= bmain->wm.first)) { - /* if we have a windowmanager, use sce from first window */ - for(win=wm->windows.first; win; win=win->next) { - sce= (win->screen)? win->screen->scene: NULL; - - if(sce) - break; - } - } - else - /* if not, use the first sce */ - sce= bmain->scene.first; - if(!id || !sce || !sce->theDag) - return; +/* flag this object and all its relations to recalc */ +/* if you need to do more objects, tag object yourself and + use DAG_scene_flush_update() in end */ +void DAG_object_flush_update(Scene *sce, Object *ob, short flag) +{ + + if(ob==NULL || sce->theDag==NULL) return; - /* set flags & pointcache for object */ - if(GS(id->name) == ID_OB) { - ob= (Object*)id; - ob->recalc |= flag; - BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); - - if(flag & OB_RECALC_DATA) { - /* all users of this ob->data should be checked */ - id= ob->data; - - /* no point in trying in this cases */ - if(!id || id->us <= 1) - id= NULL; - /* curves and surfaces only need to mark one object, since - otherwise cu->displist would be computed multiple times */ - else if(ob->type==OB_CURVE || ob->type==OB_SURF) - id= NULL; - /* also for locked shape keys we make an exception */ - else if(ob_get_key(ob) && (ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK))) - id= NULL; - } - } - - /* set flags & pointcache for object data */ - if(id) { - idtype= GS(id->name); - - if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) { - for(obt=bmain->object.first; obt; obt= obt->id.next) { - if(!(ob && obt == ob) && obt->data == id) { - obt->recalc |= OB_RECALC_DATA; - BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - - /* for these we only flag one object, otherwise cu->displist - would be computed multiple times */ - if(obt->type==OB_CURVE || obt->type==OB_SURF) - break; + ob->recalc |= flag; + BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); + + /* all users of this ob->data should be checked */ + /* BUT! displists for curves are still only on cu */ + if(flag & OB_RECALC_DATA) { + if(ob->type!=OB_CURVE && ob->type!=OB_SURF) { + ID *id= ob->data; + if(id && id->us>1) { + /* except when there's a key and shapes are locked */ + if(ob_get_key(ob) && (ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK))); + else { + Object *obt; + for (obt=G.main->object.first; obt; obt= obt->id.next) { + if (obt != ob && obt->data==ob->data) { + obt->recalc |= OB_RECALC_DATA; + BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); + } + } } } } } - - /* flush to other objects that depend on this one */ + // XXX if(G.curscreen) // DAG_scene_flush_update(sce, dag_screen_view3d_layers(), 0); // else diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index de85b0a33f6..069129c15da 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -834,7 +834,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) resolu= nu->resolu; if(!check_valid_nurb_u(nu)); - else if(nu->type == CU_BEZIER) { + else if((nu->type & 7)==CU_BEZIER) { /* count */ len= 0; @@ -902,7 +902,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) bezt++; } } - else if(nu->type == CU_NURBS) { + else if((nu->type & 7)==CU_NURBS) { len= (resolu*SEGMENTSU(nu)); dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); @@ -919,7 +919,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) else dl->type= DL_SEGM; makeNurbcurve(nu, data, NULL, NULL, resolu); } - else if(nu->type == CU_POLY) { + else if((nu->type & 7)==CU_POLY) { len= nu->pntsu; dl= MEM_callocN(sizeof(DispList), "makeDispListpoly"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 31f6e2c6067..90bf08059d7 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -698,19 +698,19 @@ float driver_get_target_value (ChannelDriver *driver, DriverTarget *dtar) if (RNA_path_resolve(&id_ptr, path, &ptr, &prop)) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_boolean_get_index(&ptr, prop, index); else value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= (float)RNA_property_int_get_index(&ptr, prop, index); else value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(&ptr, prop)) + if (RNA_property_array_length(prop)) value= RNA_property_float_get_index(&ptr, prop, index); else value= RNA_property_float_get(&ptr, prop); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5ce021e3931..70901778585 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -462,7 +462,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->resolu= cu->resolu; nu2->bezt = NULL; nu2->knotsu = nu2->knotsv = NULL; - nu2->flag= CU_2D; + nu2->flag= 0; nu2->charidx = charidx+1000; if (mat_nr > 0) nu2->mat_nr= mat_nr-1; nu2->pntsu = 4; @@ -495,6 +495,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->bp[3].vec[2] = 0; nu2->bp[3].vec[3] = 1.0; + nu2->type = CU_2D; BLI_addtail(&(cu->nurb), nu2); } diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 43c4137e73e..dd8f44c71d5 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -214,11 +214,6 @@ bGPdata *gpencil_data_addnew (char name[]) /* initial settings */ gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND); - /* for now, stick to view is also enabled by default - * since this is more useful... - */ - gpd->flag |= GP_DATA_VIEWALIGN; - return gpd; } @@ -313,7 +308,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) void gpencil_frame_delete_laststroke (bGPDlayer *gpl, bGPDframe *gpf) { bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; - int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */ + int cfra = 1; // XXX FIXME!!! /* error checking */ if (ELEM(NULL, gpf, gps)) diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 6bb47bc0f0f..6fffbd794ef 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -142,16 +142,6 @@ Group *add_group(char *name) return group; } -Group *copy_group(Group *group) -{ - Group *groupn; - - groupn= MEM_dupallocN(group); - BLI_duplicatelist(&groupn->gobject, &group->gobject); - - return groupn; -} - /* external */ void add_to_group(Group *group, Object *ob) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8b21ed89722..1af0d37d58f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -38,11 +38,6 @@ #include <time.h> -#ifdef _WIN32 -#define open _open -#define close _close -#endif - #include "MEM_guardedalloc.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 02d92a62b59..3c8bf9200f8 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -119,13 +119,6 @@ #define MAX_IDPUP 60 /* was 24 */ -/* GS reads the memory pointed at in a specific ordering. - only use this definition, makes little and big endian systems - work fine, in conjunction with MAKE_ID */ - -/* from blendef: */ -#define GS(a) (*((short *)(a))) - /* ************* general ************************ */ void id_lib_extern(ID *id) @@ -155,220 +148,6 @@ void id_us_min(ID *id) id->us--; } -int id_make_local(ID *id, int test) -{ - if(id->flag & LIB_INDIRECT) - return 0; - - switch(GS(id->name)) { - case ID_SCE: - return 0; /* not implemented */ - case ID_LI: - return 0; /* can't be linked */ - case ID_OB: - if(!test) make_local_object((Object*)id); - return 1; - case ID_ME: - if(!test) { - make_local_mesh((Mesh*)id); - make_local_key(((Mesh*)id)->key); - } - return 1; - case ID_CU: - if(!test) { - make_local_curve((Curve*)id); - make_local_key(((Curve*)id)->key); - } - return 1; - case ID_MB: - if(!test) make_local_mball((MetaBall*)id); - return 1; - case ID_MA: - if(!test) make_local_material((Material*)id); - return 1; - case ID_TE: - if(!test) make_local_texture((Tex*)id); - return 1; - case ID_IM: - return 0; /* not implemented */ - case ID_WV: - return 0; /* deprecated */ - case ID_LT: - if(!test) { - make_local_lattice((Lattice*)id); - make_local_key(((Lattice*)id)->key); - } - return 1; - case ID_LA: - if(!test) make_local_lamp((Lamp*)id); - return 1; - case ID_CA: - if(!test) make_local_camera((Camera*)id); - return 1; - case ID_IP: - return 0; /* deprecated */ - case ID_KE: - if(!test) make_local_key((Key*)id); - return 1; - case ID_WO: - if(!test) make_local_world((World*)id); - return 1; - case ID_SCR: - return 0; /* can't be linked */ - case ID_VF: - return 0; /* not implemented */ - case ID_TXT: - return 0; /* not implemented */ - case ID_SCRIPT: - return 0; /* deprecated */ - case ID_SO: - return 0; /* not implemented */ - case ID_GR: - return 0; /* not implemented */ - case ID_AR: - if(!test) make_local_armature((bArmature*)id); - return 1; - case ID_AC: - if(!test) make_local_action((bAction*)id); - return 1; - case ID_NT: - return 0; /* not implemented */ - case ID_BR: - if(!test) make_local_brush((Brush*)id); - return 1; - case ID_PA: - if(!test) make_local_particlesettings((ParticleSettings*)id); - return 1; - case ID_WM: - return 0; /* can't be linked */ - case ID_GD: - return 0; /* not implemented */ - } - - return 0; -} - -int id_copy(ID *id, ID **newid, int test) -{ - if(!test) *newid= NULL; - - /* conventions: - * - make shallow copy, only this ID block - * - id.us of the new ID is set to 1 */ - switch(GS(id->name)) { - case ID_SCE: - return 0; /* can't be copied from here */ - case ID_LI: - return 0; /* can't be copied from here */ - case ID_OB: - if(!test) *newid= (ID*)copy_object((Object*)id); - return 1; - case ID_ME: - if(!test) *newid= (ID*)copy_mesh((Mesh*)id); - return 1; - case ID_CU: - if(!test) *newid= (ID*)copy_curve((Curve*)id); - return 1; - case ID_MB: - if(!test) *newid= (ID*)copy_mball((MetaBall*)id); - return 1; - case ID_MA: - if(!test) *newid= (ID*)copy_material((Material*)id); - return 1; - case ID_TE: - if(!test) *newid= (ID*)copy_texture((Tex*)id); - return 1; - case ID_IM: - return 0; /* not implemented */ - case ID_WV: - return 0; /* deprecated */ - case ID_LT: - if(!test) *newid= (ID*)copy_lattice((Lattice*)id); - return 1; - case ID_LA: - if(!test) *newid= (ID*)copy_lamp((Lamp*)id); - return 1; - case ID_CA: - if(!test) *newid= (ID*)copy_camera((Camera*)id); - return 1; - case ID_IP: - return 0; /* deprecated */ - case ID_KE: - if(!test) *newid= (ID*)copy_key((Key*)id); - return 1; - case ID_WO: - if(!test) *newid= (ID*)copy_world((World*)id); - return 1; - case ID_SCR: - return 0; /* can't be copied from here */ - case ID_VF: - return 0; /* not implemented */ - case ID_TXT: - if(!test) *newid= (ID*)copy_text((Text*)id); - return 1; - case ID_SCRIPT: - return 0; /* deprecated */ - case ID_SO: - return 0; /* not implemented */ - case ID_GR: - if(!test) *newid= (ID*)copy_group((Group*)id); - return 1; - case ID_AR: - if(!test) *newid= (ID*)copy_armature((bArmature*)id); - return 1; - case ID_AC: - if(!test) *newid= (ID*)copy_action((bAction*)id); - return 1; - case ID_NT: - if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id, 0); - return 1; - case ID_BR: - if(!test) *newid= (ID*)copy_brush((Brush*)id); - return 1; - case ID_PA: - if(!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); - return 1; - case ID_WM: - return 0; /* can't be copied from here */ - case ID_GD: - return 0; /* not implemented */ - } - - return 0; -} - -int id_unlink(ID *id, int test) -{ - Main *mainlib= G.main; - ListBase *lb; - - switch(GS(id->name)) { - case ID_TXT: - if(test) return 1; - unlink_text(mainlib, (Text*)id); - break; - case ID_GR: - if(test) return 1; - unlink_group((Group*)id); - break; - case ID_OB: - if(test) return 1; - unlink_object(NULL, (Object*)id); - break; - } - - if(id->us == 0) { - if(test) return 1; - - lb= wich_libbase(mainlib, GS(id->name)); - free_libblock(lb, id); - - return 1; - } - - return 0; -} - ListBase *wich_libbase(Main *mainlib, short type) { switch( type ) { @@ -630,6 +409,13 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) return id; } +/* GS reads the memory pointed at in a specific ordering. + only use this definition, makes little and big endian systems + work fine, in conjunction with MAKE_ID */ + +/* from blendef: */ +#define GS(a) (*((short *)(a))) + /* by spec, animdata is first item after ID */ /* we still read ->adt itself, to ensure compiler warns when it doesnt exist */ static void id_copy_animdata(ID *id) diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e6f9ac2f404..50db2bfe706 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -170,22 +170,7 @@ void init_material(Material *ma) ma->sss_front= 1.0f; ma->sss_back= 1.0f; - ma->vol.density = 1.0f; - ma->vol.emission = 0.0f; - ma->vol.absorption = 1.0f; - ma->vol.scattering = 1.0f; - ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f; - ma->vol.absorption_col[0] = ma->vol.absorption_col[1] = ma->vol.absorption_col[2] = 0.0f; - ma->vol.density_scale = 1.0f; - ma->vol.depth_cutoff = 0.01f; - ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED; - ma->vol.stepsize = 0.2f; - ma->vol.shade_stepsize = 0.2f; - ma->vol.shade_type = MA_VOL_SHADE_SINGLE; - ma->vol.shadeflag |= MA_VOL_PRECACHESHADING; - ma->vol.precache_resolution = 50; - - ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP; + ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR; ma->preview = NULL; } @@ -1031,15 +1016,15 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } break; case MA_RAMP_DARK: - tmp=col[0]+((1-col[0])*facm); - if(tmp < *r) *r= tmp; - if(g) { - tmp=col[1]+((1-col[1])*facm); - if(tmp < *g) *g= tmp; - tmp=col[2]+((1-col[2])*facm); - if(tmp < *b) *b= tmp; - } - break; + tmp= fac*col[0]; + if(tmp < *r) *r= tmp; + if(g) { + tmp= fac*col[1]; + if(tmp < *g) *g= tmp; + tmp= fac*col[2]; + if(tmp < *b) *b= tmp; + } + break; case MA_RAMP_LIGHT: tmp= fac*col[0]; if(tmp > *r) *r= tmp; @@ -1169,37 +1154,8 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) } } break; - case MA_RAMP_SOFT: - if (g){ - float scr, scg, scb; - - /* first calculate non-fac based Screen mix */ - scr = 1.0 - ((1.0 - col[0])) * (1.0 - *r); - scg = 1.0 - ((1.0 - col[1])) * (1.0 - *g); - scb = 1.0 - ((1.0 - col[2])) * (1.0 - *b); - - *r = facm*(*r) + fac*(((1.0 - *r) * col[0] * (*r)) + (*r * scr)); - *g = facm*(*g) + fac*(((1.0 - *g) * col[1] * (*g)) + (*g * scg)); - *b = facm*(*b) + fac*(((1.0 - *b) * col[2] * (*b)) + (*b * scb)); - } - break; - case MA_RAMP_LINEAR: - if (col[0] > 0.5) - *r = *r + fac*(2*(col[0]-0.5)); - else - *r = *r + fac*(2*(col[0]) - 1); - if (g){ - if (col[1] > 0.5) - *g = *g + fac*(2*(col[1]-0.5)); - else - *g = *g + fac*(2*(col[1]) -1); - if (col[2] > 0.5) - *b = *b + fac*(2*(col[2]-0.5)); - else - *b = *b + fac*(2*(col[2]) - 1); - } - break; - } + } + } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index dcd8a746673..695bb6e3fa3 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -978,7 +978,7 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) } } -// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA); +// XXX do this in caller DAG_object_flush_update(scene, meshOb, OB_RECALC_DATA); } void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r) @@ -1266,7 +1266,7 @@ void mesh_pmv_revert(Object *ob, Mesh *me) MEM_freeN(me->pv->vert_map); me->pv->vert_map= NULL; -// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA); +// XXX do this in caller DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index f06173264ee..53d1baa5c9c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -73,12 +73,11 @@ #include "BLI_editVert.h" - - +#include "MTC_matrixops.h" +#include "MTC_vectorops.h" #include "BKE_main.h" #include "BKE_anim.h" -#include "BKE_action.h" #include "BKE_bmesh.h" // XXX #include "BKE_booleanops.h" #include "BKE_cloth.h" @@ -1190,7 +1189,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(amd->end_cap && amd->end_cap != ob) end_cap = mesh_get_derived_final(scene, amd->end_cap, CD_MASK_MESH); - Mat4One(offset); + MTC_Mat4One(offset); indexMap = MEM_callocN(sizeof(*indexMap) * dm->getNumVerts(dm), "indexmap"); @@ -1212,14 +1211,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float result_mat[4][4]; if(ob) - Mat4Invert(obinv, ob->obmat); + MTC_Mat4Invert(obinv, ob->obmat); else - Mat4One(obinv); + MTC_Mat4One(obinv); - Mat4MulSerie(result_mat, offset, + MTC_Mat4MulSerie(result_mat, offset, obinv, amd->offset_ob->obmat, NULL, NULL, NULL, NULL, NULL); - Mat4CpyMat4(offset, result_mat); + MTC_Mat4CpyMat4(offset, result_mat); } if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) { @@ -1244,7 +1243,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, prescribed length */ if(amd->fit_type == MOD_ARR_FITLENGTH || amd->fit_type == MOD_ARR_FITCURVE) { - float dist = sqrt(Inpf(offset[3], offset[3])); + float dist = sqrt(MTC_dot3Float(offset[3], offset[3])); if(dist > 1e-6f) /* this gives length = first copy start to last copy end @@ -1277,11 +1276,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); /* calculate the offset matrix of the final copy (for merging) */ - Mat4One(final_offset); + MTC_Mat4One(final_offset); for(j=0; j < count - 1; j++) { - Mat4MulMat4(tmp_mat, final_offset, offset); - Mat4CpyMat4(final_offset, tmp_mat); + MTC_Mat4MulMat4(tmp_mat, final_offset, offset); + MTC_Mat4CpyMat4(final_offset, tmp_mat); } numVerts = numEdges = numFaces = 0; @@ -1317,7 +1316,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { float tmp_co[3]; VECCOPY(tmp_co, mv->co); - Mat4MulVecfl(offset, tmp_co); + MTC_Mat4MulVecfl(offset, tmp_co); for(j = 0; j < maxVerts; j++) { /* if vertex already merged, don't use it */ @@ -1332,7 +1331,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if(amd->flags & MOD_ARR_MERGEFINAL) { VECCOPY(tmp_co, inMV->co); inMV = &src_mvert[i]; - Mat4MulVecfl(final_offset, tmp_co); + MTC_Mat4MulVecfl(final_offset, tmp_co); if(VecLenCompare(tmp_co, inMV->co, amd->merge_dist)) indexMap[i].merge_final = 1; } @@ -1350,7 +1349,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, *mv2 = *mv; numVerts++; - Mat4MulVecfl(offset, co); + MTC_Mat4MulVecfl(offset, co); VECCOPY(mv2->co, co); } } else if(indexMap[i].merge != i && indexMap[i].merge_final) { @@ -3182,7 +3181,7 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, /* we know the edge has 2 faces, so check the angle */ SmoothFace *face1 = edge->faces->link; SmoothFace *face2 = edge->faces->next->link; - float edge_angle_cos = Inpf(face1->normal, + float edge_angle_cos = MTC_dot3Float(face1->normal, face2->normal); if(edge_angle_cos < threshold) { @@ -4051,11 +4050,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* find the projector which the face points at most directly * (projector normal with largest dot product is best) */ - best_dot = Inpf(projectors[0].normal, face_no); + best_dot = MTC_dot3Float(projectors[0].normal, face_no); best_projector = &projectors[0]; for(j = 1; j < num_projectors; ++j) { - float tmp_dot = Inpf(projectors[j].normal, + float tmp_dot = MTC_dot3Float(projectors[j].normal, face_no); if(tmp_dot > best_dot) { best_dot = tmp_dot; @@ -5599,7 +5598,6 @@ static void hookModifier_copyData(ModifierData *md, ModifierData *target) thmd->indexar = MEM_dupallocN(hmd->indexar); memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv)); strncpy(thmd->name, hmd->name, 32); - strncpy(thmd->subtarget, hmd->subtarget, 32); } CustomDataMask hookModifier_requiredDataMask(Object *ob, ModifierData *md) @@ -5644,11 +5642,9 @@ static void hookModifier_updateDepgraph(ModifierData *md, DagForest *forest, Sce if (hmd->object) { DagNode *curNode = dag_get_node(forest, hmd->object); - - if (hmd->subtarget[0]) - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier"); - else - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier"); + + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, + "Hook Modifier"); } } @@ -5657,22 +5653,12 @@ static void hookModifier_deformVerts( float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { HookModifierData *hmd = (HookModifierData*) md; - bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); - float vec[3], mat[4][4], dmat[4][4]; + float vec[3], mat[4][4]; int i; DerivedMesh *dm = derivedData; - - /* get world-space matrix of target, corrected for the space the verts are in */ - if (hmd->subtarget[0] && pchan) { - /* bone target if there's a matching pose-channel */ - Mat4MulMat4(dmat, pchan->pose_mat, hmd->object->obmat); - } - else { - /* just object target */ - Mat4CpyMat4(dmat, hmd->object->obmat); - } + Mat4Invert(ob->imat, ob->obmat); - Mat4MulSerie(mat, ob->imat, dmat, hmd->parentinv, + Mat4MulSerie(mat, ob->imat, hmd->object->obmat, hmd->parentinv, NULL, NULL, NULL, NULL, NULL); /* vertex indices? */ @@ -5729,8 +5715,7 @@ static void hookModifier_deformVerts( } } } - } - else if(hmd->name[0]) { /* vertex group hook */ + } else { /* vertex group hook */ bDeformGroup *curdef; Mesh *me = ob->data; int index = 0; @@ -5816,6 +5801,26 @@ static void smokeModifier_initData(ModifierData *md) smd->coll = NULL; smd->type = 0; smd->time = -1; + + /* + smd->fluid = NULL; + smd->maxres = 48; + smd->amplify = 4; + smd->omega = 0.5; + smd->time = 0; + smd->flags = 0; + smd->noise = MOD_SMOKE_NOISEWAVE; + smd->visibility = 1; + + // init 3dview buffer + smd->tvox = NULL; + smd->tray = NULL; + smd->tvoxbig = NULL; + smd->traybig = NULL; + smd->viewsettings = 0; + smd->bind = NULL; + smd->max_textures = 0; + */ } static void smokeModifier_freeData(ModifierData *md) @@ -6696,8 +6701,10 @@ static DerivedMesh * particleInstanceModifier_applyModifier( if((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path){ float ran = 0.0f; if(pimd->random_position != 0.0f) { - BLI_srandom(psys->seed + (i/totvert)%totpart); - ran = pimd->random_position * BLI_frand(); + /* just use some static collection of random numbers */ + /* TODO: use something else that's unique to each instanced object */ + pa = psys->particles + (i/totvert)%totpart; + ran = pimd->random_position * 0.5 * (1.0f + pa->r_ave[0]); } if(pimd->flag & eParticleInstanceFlag_KeepShape) { @@ -8071,13 +8078,14 @@ static DerivedMesh *multiresModifier_applyModifier(ModifierData *md, Object *ob, int useRenderParams, int isFinalCalc) { MultiresModifierData *mmd = (MultiresModifierData*)md; + Mesh *me = get_mesh(ob); DerivedMesh *final; /* TODO: for now just skip a level1 mesh */ if(mmd->lvl == 1) return dm; - final = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams, isFinalCalc); + final = multires_dm_create_from_derived(mmd, dm, me, useRenderParams, isFinalCalc); if(mmd->undo_signal && mmd->undo_verts && mmd->undo_verts_tot == final->getNumVerts(final)) { int i; MVert *dst = CDDM_get_verts(final); @@ -8572,9 +8580,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->type = eModifierTypeType_OnlyDeform; mti->initData = smokeModifier_initData; mti->freeData = smokeModifier_freeData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single; + mti->flags = eModifierTypeFlag_AcceptsMesh; mti->deformVerts = smokeModifier_deformVerts; mti->dependsOnTime = smokeModifier_dependsOnTime; mti->updateDepgraph = smokeModifier_updateDepgraph; @@ -8605,7 +8611,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti = INIT_TYPE(Surface); mti->type = eModifierTypeType_OnlyDeform; mti->initData = surfaceModifier_initData; - mti->flags = eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_NoUserAdd; + mti->flags = eModifierTypeFlag_AcceptsMesh; mti->dependsOnTime = surfaceModifier_dependsOnTime; mti->freeData = surfaceModifier_freeData; mti->deformVerts = surfaceModifier_deformVerts; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 37e7e55050a..e91f318adad 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -83,7 +83,7 @@ int multiresModifier_switch_level(Object *ob, const int distance) mmd->lvl += distance; if(mmd->lvl < 1) mmd->lvl = 1; else if(mmd->lvl > mmd->totlvl) mmd->lvl = mmd->totlvl; - /* XXX: DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + /* XXX: DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); object_handle_update(ob);*/ return 1; } @@ -204,11 +204,10 @@ static void VecAddUf(float a[3], float b[3]) a[2] += b[2]; } -static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, int lvl, int totlvl, +static void multires_subdisp(DerivedMesh *orig, Mesh *me, DerivedMesh *final, int lvl, int totlvl, int totsubvert, int totsubedge, int totsubface, int addverts) { DerivedMesh *mrdm; - Mesh *me = ob->data; MultiresModifierData mmd_sub; MVert *mvs = CDDM_get_verts(final); MVert *mvd, *mvd_f1, *mvs_f1, *mvd_f3, *mvd_f4; @@ -223,7 +222,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = totlvl; - mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0); + mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); mvd = CDDM_get_verts(mrdm); /* Need to map from ccg to mrdm */ @@ -396,7 +395,7 @@ static void multires_subdisp(DerivedMesh *orig, Object *ob, DerivedMesh *final, } } - final->needsFree = 1; + final->needsFree = 1; final->release(final); mrdm->needsFree = 1; MultiresDM_mark_as_modified(mrdm); @@ -469,8 +468,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista orig = CDDM_from_mesh(me, NULL); memset(&mmd_sub, 0, sizeof(MultiresModifierData)); mmd_sub.lvl = mmd_sub.totlvl = mmd->lvl; - mmd_sub.simple = simple; - mrdm = multires_dm_create_from_derived(&mmd_sub, 1, orig, ob, 0, 0); + mrdm = multires_dm_create_from_derived(&mmd_sub, orig, me, 0, 0); totsubvert = mrdm->getNumVerts(mrdm); totsubedge = mrdm->getNumEdges(mrdm); totsubface = mrdm->getNumFaces(mrdm); @@ -499,7 +497,7 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int dista orig = CDDM_from_mesh(me, NULL); - multires_subdisp(orig, ob, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0); + multires_subdisp(orig, me, final, mmd->lvl, mmd->totlvl, totsubvert, totsubedge, totsubface, 0); orig->needsFree = 1; orig->release(orig); @@ -1168,11 +1166,9 @@ static void multiresModifier_disp_run(DerivedMesh *dm, MVert *subco, int invert) static void multiresModifier_update(DerivedMesh *dm) { - Object *ob; Mesh *me; MDisps *mdisps; - ob = MultiresDM_get_object(dm); me = MultiresDM_get_mesh(dm); mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); @@ -1193,7 +1189,7 @@ static void multiresModifier_update(DerivedMesh *dm) (includes older displacements but not new sculpts) */ mmd.totlvl = totlvl; mmd.lvl = lvl; - subco_dm = multires_dm_create_from_derived(&mmd, 1, orig, ob, 0, 0); + subco_dm = multires_dm_create_from_derived(&mmd, orig, me, 0, 0); cur_lvl_orig_verts = CDDM_get_verts(subco_dm); /* Subtract the original vertex cos from the new vertex cos */ @@ -1203,7 +1199,7 @@ static void multiresModifier_update(DerivedMesh *dm) final = multires_subdisp_pre(dm, totlvl - lvl, 0); - multires_subdisp(orig, ob, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm), + multires_subdisp(orig, me, final, lvl, totlvl, dm->getNumVerts(dm), dm->getNumEdges(dm), dm->getNumFaces(dm), 1); subco_dm->release(subco_dm); @@ -1230,7 +1226,7 @@ void multires_force_update(Object *ob) } } -struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob, +struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, DerivedMesh *dm, Mesh *me, int useRenderParams, int isFinalCalc) { SubsurfModifierData smd; @@ -1239,8 +1235,7 @@ struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, i int i; ms.mmd = mmd; - ms.ob = ob; - ms.local_mmd = local_mmd; + ms.me = me; memset(&smd, 0, sizeof(SubsurfModifierData)); smd.levels = smd.renderLevels = mmd->lvl - 1; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 480c79fbc1a..c41c4ae78e4 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -291,7 +291,7 @@ NlaStrip *add_nlastrip (bAction *act) /* determine initial range * - strip length cannot be 0... ever... */ - calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); + calc_action_range(strip->act, &strip->actstart, &strip->actend, 1); strip->start = strip->actstart; strip->end = (IS_EQ(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 90ea53d4364..bd6919dc115 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): Bob Holcomb. + * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** */ @@ -2597,7 +2597,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) if(outsocket_exists(lnode->new_node, lsock->new_sock)) { lsock->new_sock->ns.data= lsock->ns.data; lsock->ns.data= NULL; - lsock->new_sock= NULL; + lsock->new_sock= NULL; } } } @@ -2932,7 +2932,6 @@ static void registerCompositNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &cmp_node_viewer); nodeRegisterType(ntypelist, &cmp_node_splitviewer); nodeRegisterType(ntypelist, &cmp_node_output_file); - nodeRegisterType(ntypelist, &cmp_node_view_levels); nodeRegisterType(ntypelist, &cmp_node_curve_rgb); nodeRegisterType(ntypelist, &cmp_node_mix_rgb); @@ -2972,9 +2971,7 @@ static void registerCompositNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &cmp_node_premulkey); nodeRegisterType(ntypelist, &cmp_node_diff_matte); - nodeRegisterType(ntypelist, &cmp_node_distance_matte); - nodeRegisterType(ntypelist, &cmp_node_chroma_matte); - nodeRegisterType(ntypelist, &cmp_node_color_matte); + nodeRegisterType(ntypelist, &cmp_node_chroma); nodeRegisterType(ntypelist, &cmp_node_channel_matte); nodeRegisterType(ntypelist, &cmp_node_color_spill); nodeRegisterType(ntypelist, &cmp_node_luma_matte); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f10226f6f6b..0e45aedc3ed 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -101,13 +101,13 @@ #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" -#include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_property.h" #include "BKE_sca.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_sculpt.h" #include "BKE_softbody.h" #include "LBM_fluidsim.h" @@ -284,7 +284,6 @@ void free_object(Object *ob) if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; if(ob->dup_group) ob->dup_group->id.us--; - if(ob->gpd) ob->gpd->id.us--; if(ob->defbase.first) BLI_freelistN(&ob->defbase); if(ob->pose) @@ -308,8 +307,6 @@ void free_object(Object *ob) if(ob->gpulamp.first) GPU_lamp_free(ob); free_sculptsession(&ob->sculpt); - - if(ob->pc_ids.first) BLI_freelistN(&ob->pc_ids); } static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin) @@ -481,15 +478,15 @@ void unlink_object(Scene *scene, Object *ob) if(tpsys->part->dup_ob==ob) tpsys->part->dup_ob= NULL; - if(tpsys->part->phystype==PART_PHYS_BOIDS) { + if(tpsys->part->flag&PART_STICKY) { ParticleData *pa; - BoidParticle *bpa; int p; for(p=0,pa=tpsys->particles; p<tpsys->totpart; p++,pa++) { - bpa = pa->boid; - if(bpa->ground == ob) - bpa->ground = NULL; + if(pa->stick_ob==ob) { + pa->stick_ob= 0; + pa->flag &= ~PARS_STICKY; + } } } if(tpsys->part->boids) { @@ -1019,8 +1016,6 @@ Object *add_only_object(int type, char *name) ob->fluidsimFlag = 0; ob->fluidsimSettings = NULL; - ob->pc_ids.first = ob->pc_ids.last = NULL; - return ob; } @@ -1082,35 +1077,19 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) { ParticleSystem *psysn; ParticleData *pa; - int p; + int a; psysn= MEM_dupallocN(psys); psysn->particles= MEM_dupallocN(psys->particles); psysn->child= MEM_dupallocN(psys->child); + if(psysn->particles->keys) + psysn->particles->keys = MEM_dupallocN(psys->particles->keys); - if(psys->part->type == PART_HAIR) { - for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) - pa->hair = MEM_dupallocN(pa->hair); - } - - if(psysn->particles->keys || psysn->particles->boid) { - ParticleKey *key = psysn->particles->keys; - BoidParticle *boid = psysn->particles->boid; - - if(key) - key = MEM_dupallocN(key); - - if(boid) - boid = MEM_dupallocN(boid); - - for(p=0, pa=psysn->particles; p<psysn->totpart; p++, pa++) { - if(boid) - pa->boid = boid++; - if(key) { - pa->keys = key; - key += pa->totkey; - } - } + for(a=0, pa=psysn->particles; a<psysn->totpart; a++, pa++) { + if(pa->hair) + pa->hair= MEM_dupallocN(pa->hair); + if(a) + pa->keys= (pa-1)->keys + (pa-1)->totkey; } if(psys->soft) { @@ -1118,7 +1097,14 @@ ParticleSystem *copy_particlesystem(ParticleSystem *psys) psysn->soft->particles = psysn; } - BLI_duplicatelist(&psysn->targets, &psys->targets); + if(psys->particles->boid) { + psysn->particles->boid = MEM_dupallocN(psys->particles->boid); + for(a=1, pa=psysn->particles+1; a<psysn->totpart; a++, pa++) + pa->boid = (pa-1)->boid + 1; + } + + if(psys->targets.first) + BLI_duplicatelist(&psysn->targets, &psys->targets); psysn->pathcache= NULL; psysn->childcache= NULL; @@ -1282,8 +1268,7 @@ Object *copy_object(Object *ob) obn->derivedFinal = NULL; obn->gpulamp.first = obn->gpulamp.last = NULL; - obn->pc_ids.first = obn->pc_ids.last = NULL; - + return obn; } @@ -1807,7 +1792,7 @@ static void give_parvert(Object *par, int nr, float *vec) count= 0; while(nu && !found) { - if(nu->type == CU_BEZIER) { + if((nu->type & 7)==CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; while(a--) { @@ -2550,61 +2535,3 @@ int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3 return result; } - -static int pc_cmp(void *a, void *b) -{ - LinkData *ad = a, *bd = b; - if((int)ad->data > (int)bd->data) - return 1; - else return 0; -} - -int object_insert_ptcache(Object *ob) -{ - LinkData *link = NULL; - int i = 0; - - BLI_sortlist(&ob->pc_ids, pc_cmp); - - for(link=ob->pc_ids.first, i = 0; link; link=link->next, i++) - { - int index =(int)link->data; - - if(i < index) - break; - } - - link = MEM_callocN(sizeof(LinkData), "PCLink"); - link->data = (void *)i; - BLI_addtail(&ob->pc_ids, link); - - return i; -} - -#if 0 -static int pc_findindex(ListBase *listbase, int index) -{ - LinkData *link= NULL; - int number= 0; - - if (listbase == NULL) return -1; - - link= listbase->first; - while (link) { - if ((int)link->data == index) - return number; - - number++; - link= link->next; - } - - return -1; -} - -void object_delete_ptcache(Object *ob, int index) -{ - int list_index = pc_findindex(&ob->pc_ids, index); - LinkData *link = BLI_findlink(&ob->pc_ids, list_index); - BLI_freelinkN(&ob->pc_ids, link); -} -#endif diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index bd0b1a5e36e..8c77ed92aa1 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -63,14 +63,6 @@ #include "BKE_packedFile.h" #include "BKE_report.h" -#ifdef _WIN32 -#define open _open -#define close _close -#define read _read -#define write _write -#endif - - int seekPackedFile(PackedFile *pf, int offset, int whence) { int oldseek = -1, seek = 0; @@ -481,7 +473,7 @@ int unpackSound(ReportList *reports, bSound *sound, int how) freePackedFile(sound->packedfile); sound->packedfile = 0; - sound_load(NULL, sound); + sound_load(sound); ret_value = RET_OK; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 7c5b2b82b4b..80016f23d7c 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -39,11 +39,6 @@ #include <stdlib.h> #include <string.h> -const char PAINT_CURSOR_SCULPT[3] = {255, 100, 100}; -const char PAINT_CURSOR_VERTEX_PAINT[3] = {255, 255, 255}; -const char PAINT_CURSOR_WEIGHT_PAINT[3] = {200, 200, 255}; -const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255}; - Paint *paint_get_active(Scene *sce) { if(sce && sce->basact && sce->basact->object) { @@ -159,17 +154,14 @@ int paint_facesel_test(Object *ob) } -void paint_init(Paint *p, const char col[3]) +void paint_init(Paint *p, const char *name) { Brush *brush; /* If there's no brush, create one */ brush = paint_brush(p); - brush_check_exists(&brush, "Brush"); + brush_check_exists(&brush, name); paint_brush_set(p, brush); - - memcpy(p->paint_cursor_col, col, 3); - p->paint_cursor_col[3] = 128; } void free_paint(Paint *paint) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0ba2f357a1f..e1987d34a6c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -92,10 +92,10 @@ static void do_child_modifiers(Scene *scene, Object *ob, ParticleSystem *psys, P /* few helpers for countall etc. */ int count_particles(ParticleSystem *psys){ ParticleSettings *part=psys->part; - PARTICLE_P; - int tot=0; + ParticleData *pa; + int tot=0,p; - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++){ if(pa->alive == PARS_KILLED); else if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); @@ -106,10 +106,10 @@ int count_particles(ParticleSystem *psys){ } int count_particles_mod(ParticleSystem *psys, int totgr, int cur){ ParticleSettings *part=psys->part; - PARTICLE_P; - int tot=0; + ParticleData *pa; + int tot=0,p; - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++){ if(pa->alive == PARS_KILLED); else if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); @@ -120,10 +120,10 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur){ } int psys_count_keys(ParticleSystem *psys) { - PARTICLE_P; - int totkey=0; + ParticleData *pa; + int i, totpart=psys->totpart, totkey=0; - LOOP_PARTICLES + for(i=0, pa=psys->particles; i<totpart; i++, pa++) totkey += pa->totkey; return totkey; @@ -321,7 +321,7 @@ int psys_ob_has_hair(Object *ob) } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit)); + return ((scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && psys->edit); } int psys_check_enabled(Object *ob, ParticleSystem *psys) { @@ -368,16 +368,13 @@ void psys_free_settings(ParticleSettings *part) void free_hair(ParticleSystem *psys, int softbody) { - PARTICLE_P; - - if(psys->part->type != PART_HAIR) - return; + ParticleData *pa; + int i, totpart=psys->totpart; - LOOP_PARTICLES { + for(i=0, pa=psys->particles; i<totpart; i++, pa++) { if(pa->hair) MEM_freeN(pa->hair); pa->hair = NULL; - pa->totkey = 0; } psys->flag &= ~PSYS_HAIR_DONE; @@ -389,15 +386,13 @@ void free_hair(ParticleSystem *psys, int softbody) } void free_keyed_keys(ParticleSystem *psys) { - PARTICLE_P; - - if(psys->part->type == PART_HAIR) - return; + ParticleData *pa; + int i; if(psys->particles && psys->particles->keys) { MEM_freeN(psys->particles->keys); - LOOP_PARTICLES { + for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++) { if(pa->keys) { pa->keys= NULL; pa->totkey= 0; @@ -411,20 +406,13 @@ void free_child_path_cache(ParticleSystem *psys) psys->childcache = NULL; psys->totchildcache = 0; } -void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit) +void psys_free_path_cache(ParticleSystem *psys) { - if(edit) { - psys_free_path_cache_buffers(edit->pathcache, &edit->pathcachebufs); - edit->pathcache= NULL; - edit->totcached= 0; - } - if(psys) { - psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); - psys->pathcache= NULL; - psys->totcached= 0; + psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); + psys->pathcache= NULL; + psys->totcached= 0; - free_child_path_cache(psys); - } + free_child_path_cache(psys); } void psys_free_children(ParticleSystem *psys) { @@ -436,29 +424,6 @@ void psys_free_children(ParticleSystem *psys) free_child_path_cache(psys); } -void psys_free_particles(ParticleSystem *psys) -{ - PARTICLE_P; - - if(psys->particles) { - if(psys->part->type==PART_HAIR) { - LOOP_PARTICLES { - if(pa->hair) - MEM_freeN(pa->hair); - } - } - - if(psys->particles->keys) - MEM_freeN(psys->particles->keys); - - if(psys->particles->boid) - MEM_freeN(psys->particles->boid); - - MEM_freeN(psys->particles); - psys->particles= NULL; - psys->totpart= 0; - } -} /* free everything */ void psys_free(Object *ob, ParticleSystem * psys) { @@ -466,12 +431,23 @@ void psys_free(Object *ob, ParticleSystem * psys) int nr = 0; ParticleSystem * tpsys; - psys_free_path_cache(psys, NULL); + psys_free_path_cache(psys); + + free_hair(psys, 1); - psys_free_particles(psys); + free_keyed_keys(psys); if(psys->edit && psys->free_edit) - psys->free_edit(psys->edit); + psys->free_edit(psys); + + if(psys->particles){ + if(psys->particles->boid) + MEM_freeN(psys->particles->boid); + + MEM_freeN(psys->particles); + psys->particles = 0; + psys->totpart = 0; + } if(psys->child){ MEM_freeN(psys->child); @@ -502,11 +478,14 @@ void psys_free(Object *ob, ParticleSystem * psys) psys->part=0; } + if(psys->reactevents.first) + BLI_freelistN(&psys->reactevents); + BKE_ptcache_free_list(&psys->ptcaches); psys->pointcache = NULL; - BLI_freelistN(&psys->targets); - BLI_freelistN(&psys->reactevents); + if(psys->targets.first) + BLI_freelistN(&psys->targets); BLI_kdtree_free(psys->tree); @@ -666,7 +645,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) psmd->dm->release(psmd->dm); } - psys_free_path_cache(psys, NULL); + psys_free_path_cache(psys); if(psys->child){ MEM_freeN(psys->child); @@ -974,25 +953,17 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic typedef struct ParticleInterpolationData { - HairKey *hkey[2]; - - int keyed; ParticleKey *kkey[2]; - - SoftBody *soft; + HairKey *hkey[2]; BodyPoint *bp[2]; - - PointCache *cache; - - PTCacheEditPoint *epoint; - PTCacheEditKey *ekey[2]; - + SoftBody *soft; + int keyed, cached; float birthtime, dietime; - int bspline; } ParticleInterpolationData; /* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */ -static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int index, float t, ParticleKey *key1, ParticleKey *key2) +static void get_pointcache_keys_for_time(Object *ob, ParticleSystem *psys, int index, float t, ParticleKey *key1, ParticleKey *key2) { + PointCache *cache = psys->pointcache; static PTCacheMem *pm = NULL; /* not thread safe */ if(index < 0) { /* initialize */ @@ -1019,50 +990,35 @@ static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int inde static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind) { - if(pind->epoint) { - PTCacheEditPoint *point = pind->epoint; - - pind->ekey[0] = point->keys; - pind->ekey[1] = point->totkey > 1 ? point->keys + 1 : NULL; + if(pind->keyed) { + pind->kkey[0] = pa->keys; - pind->birthtime = *(point->keys->time); - pind->dietime = *((point->keys + point->totkey - 1)->time); - } - else if(pind->keyed) { - ParticleKey *key = pa->keys; - pind->kkey[0] = key; - pind->kkey[1] = pa->totkey > 1 ? key + 1 : NULL; + if(pa->totkey > 1) + pind->kkey[1] = pa->keys + 1; + else + pind->kkey[1] = NULL; - pind->birthtime = key->time; - pind->dietime = (key + pa->totkey - 1)->time; + pind->birthtime = pa->keys->time; + pind->dietime = (pa->keys + pa->totkey - 1)->time; } - else if(pind->cache) { - get_pointcache_keys_for_time(ob, pind->cache, -1, 0.0f, NULL, NULL); + else if(pind->cached) { + get_pointcache_keys_for_time(ob, psys, -1, 0.0f, NULL, NULL); - pind->birthtime = pa ? pa->time : pind->cache->startframe; - pind->dietime = pa ? pa->dietime : pind->cache->endframe; + pind->birthtime = pa->time; + pind->dietime = pa->dietime; } else { - HairKey *key = pa->hair; - pind->hkey[0] = key; - pind->hkey[1] = key + 1; + pind->hkey[0] = pa->hair; + pind->hkey[1] = pa->hair + 1; - pind->birthtime = key->time; - pind->dietime = (key + pa->totkey - 1)->time; + pind->birthtime = pa->hair->time; + pind->dietime = (pa->hair + pa->totkey - 1)->time; } - //if(pind->soft) { - // pind->bp[0] = pind->soft->bpoint + pa->bpi; - // pind->bp[1] = pind->soft->bpoint + pa->bpi + 1; - //} -} -static void edit_to_particle(ParticleKey *key, PTCacheEditKey *ekey) -{ - VECCOPY(key->co, ekey->co); - if(ekey->vel) { - VECCOPY(key->vel, ekey->vel); + if(pind->soft) { + pind->bp[0] = pind->soft->bpoint + pa->bpi; + pind->bp[1] = pind->soft->bpoint + pa->bpi + 1; } - key->time = *(ekey->time); } static void hair_to_particle(ParticleKey *key, HairKey *hkey) { @@ -1077,24 +1033,11 @@ static void bp_to_particle(ParticleKey *key, BodyPoint *bp, HairKey *hkey) static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData *pa, float t, float frs_sec, ParticleInterpolationData *pind, ParticleKey *result) { - PTCacheEditPoint *point = pind->epoint; ParticleKey keys[4]; - int point_vel = (point && point->keys->vel); float real_t, dfra, keytime; /* interpret timing and find keys */ - if(point) { - if(result->time < 0.0f) - real_t = -result->time; - else - real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey-1].time) - *(pind->ekey[0]->time)); - - while(*(pind->ekey[1]->time) < real_t) - pind->ekey[1]++; - - pind->ekey[0] = pind->ekey[1] - 1; - } - else if(pind->keyed) { + if(pind->keyed) { /* we have only one key, so let's use that */ if(pind->kkey[1]==NULL) { copy_particle_key(result, pind->kkey[0], 1); @@ -1131,7 +1074,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData pind->kkey[0] = pind->kkey[1] - 1; } - else if(pind->cache) { + else if(pind->cached) { if(result->time < 0.0f) /* flag for time in frames */ real_t = -result->time; else @@ -1152,11 +1095,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData } /* set actual interpolation keys */ - if(point) { - edit_to_particle(keys + 1, pind->ekey[0]); - edit_to_particle(keys + 2, pind->ekey[1]); - } - else if(pind->soft) { + if(pind->soft) { pind->bp[0] = pind->bp[1] - 1; bp_to_particle(keys + 1, pind->bp[0], pind->hkey[0]); bp_to_particle(keys + 2, pind->bp[1], pind->hkey[1]); @@ -1165,8 +1104,8 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData memcpy(keys + 1, pind->kkey[0], sizeof(ParticleKey)); memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey)); } - else if(pind->cache) { - get_pointcache_keys_for_time(NULL, pind->cache, p, real_t, keys+1, keys+2); + else if(pind->cached) { + get_pointcache_keys_for_time(NULL, psys, p, real_t, keys+1, keys+2); } else { hair_to_particle(keys + 1, pind->hkey[0]); @@ -1174,14 +1113,8 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData } /* set secondary interpolation keys for hair */ - if(!pind->keyed && !pind->cache && !point_vel) { - if(point) { - if(pind->ekey[0] != point->keys) - edit_to_particle(keys, pind->ekey[0] - 1); - else - edit_to_particle(keys, pind->ekey[0]); - } - else if(pind->soft) { + if(!pind->keyed && !pind->cached) { + if(pind->soft) { if(pind->hkey[0] != pa->hair) bp_to_particle(keys, pind->bp[0] - 1, pind->hkey[0] - 1); else @@ -1194,13 +1127,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData hair_to_particle(keys, pind->hkey[0]); } - if(point) { - if(pind->ekey[1] != point->keys + point->totkey - 1) - edit_to_particle(keys + 3, pind->ekey[1] + 1); - else - edit_to_particle(keys + 3, pind->ekey[1]); - } - else if(pind->soft) { + if(pind->soft) { if(pind->hkey[1] != pa->hair + pa->totkey - 1) bp_to_particle(keys + 3, pind->bp[1] + 1, pind->hkey[1] + 1); else @@ -1218,19 +1145,19 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData keytime = (real_t - keys[1].time) / dfra; /* convert velocity to timestep size */ - if(pind->keyed || pind->cache || point_vel){ + if(pind->keyed || pind->cached){ VecMulf(keys[1].vel, dfra / frs_sec); VecMulf(keys[2].vel, dfra / frs_sec); QuatInterpol(result->rot,keys[1].rot,keys[2].rot,keytime); } /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/ - psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ? -1 /* signal for cubic interpolation */ - : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL) + psys_interpolate_particle((pind->keyed || pind->cached) ? -1 /* signal for cubic interpolation */ + : ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL) ,keys, keytime, result, 1); /* the velocity needs to be converted back from cubic interpolation */ - if(pind->keyed || pind->cache || point_vel) + if(pind->keyed || pind->cached) VecMulf(result->vel, frs_sec / dfra); } /************************************************/ @@ -1683,7 +1610,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) } } } - return NULL; + return 0; } /************************************************/ /* Particles on a shape */ @@ -2202,7 +2129,7 @@ int psys_threads_init_path(ParticleThread *threads, Scene *scene, float cfra, in /*---start figuring out what is actually wanted---*/ if(psys_in_edit_mode(scene, psys)) - if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) + if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==0) totchild=0; if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ @@ -2318,7 +2245,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, needupdate= 0; w= 0; while(w<4 && cpa->pa[w]>=0) { - if(psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) { + if(psys->particles[cpa->pa[w]].flag & PARS_EDIT_RECALC) { needupdate= 1; break; } @@ -2361,7 +2288,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, } else{ if(ctx->editupdate && !(part->flag & PART_BRANCHING)) { - if(!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) + if(!(psys->particles[cpa->parent].flag & PARS_EDIT_RECALC)) return; memset(keys, 0, sizeof(*keys)*(ctx->steps+1)); @@ -2574,9 +2501,6 @@ void psys_cache_child_paths(Scene *scene, Object *ob, ParticleSystem *psys, floa ListBase threads; int i, totchild, totparent, totthread; - if(psys->flag & PSYS_GLOBAL_HAIR) - return; - pthreads= psys_threads_create(scene, ob, psys); if(!psys_threads_init_path(pthreads, scene, cfra, editupdate)) { @@ -2633,121 +2557,158 @@ void psys_cache_child_paths(Scene *scene, Object *ob, ParticleSystem *psys, floa /* -Usefull for making use of opengl vertex arrays for super fast strand drawing. */ /* -Makes child strands possible and creates them too into the cache. */ /* -Cached path data is also used to determine cut position for the editmode tool. */ -void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra) +void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra, int editupdate) { - ParticleCacheKey *ca, **cache= psys->pathcache; + ParticleCacheKey *ca, **cache=psys->pathcache; ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - ParticleSettings *part = psys->part; ParticleEditSettings *pset = &scene->toolsettings->particle; + ParticleSettings *part = psys->part; - ParticleData *pa = psys->particles; + ParticleData *pa; ParticleKey result; - SoftBody *soft = NULL; + ParticleEdit *edit = 0; + ParticleEditKey *ekey = 0; + + SoftBody *soft = 0; BodyPoint *bp[2] = {NULL, NULL}; Material *ma; + ParticleInterpolationData pind; float birthtime = 0.0, dietime = 0.0; - float t, time = 0.0, dfra = 1.0, frs_sec = scene->r.frs_sec; + float t, time = 0.0, keytime = 0.0, dfra = 1.0, frs_sec = scene->r.frs_sec; float col[4] = {0.5f, 0.5f, 0.5f, 1.0f}; float prev_tangent[3], hairmat[4][4]; float rotmat[3][3]; int k,i; - int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step)); + int steps = (int)pow(2.0, (double)psys->part->draw_step); int totpart = psys->totpart; + float sel_col[3]; + float nosel_col[3]; float length, vec[3]; float *vg_effector= NULL, effector=0.0f; float *vg_length= NULL, pa_length=1.0f; int keyed, baked; /* we don't have anything valid to create paths from so let's quit here */ - if(!(psys->flag & PSYS_HAIR_DONE) && !(psys->flag & PSYS_KEYED) && !(psys->pointcache->flag & PTCACHE_BAKED)) + if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0 && (psys->pointcache->flag & PTCACHE_BAKED)==0) return; - if(psys_in_edit_mode(scene, psys)) - if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) - return; - BLI_srandom(psys->seed); keyed = psys->flag & PSYS_KEYED; baked = psys->pointcache->flag & PTCACHE_BAKED; - /* clear out old and create new empty path cache */ - psys_free_path_cache(psys, psys->edit); - cache= psys->pathcache= psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps+1); + if(psys->renderdata) { + steps = (int)pow(2.0, (double)psys->part->ren_step); + } + else if(psys_in_edit_mode(scene, psys)) { + edit=psys->edit; + + //timed = edit->draw_timed; + + if(pset->brushtype == PE_BRUSH_WEIGHT) { + sel_col[0] = sel_col[1] = sel_col[2] = 1.0f; + nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f; + } + else{ + sel_col[0] = (float)edit->sel_col[0] / 255.0f; + sel_col[1] = (float)edit->sel_col[1] / 255.0f; + sel_col[2] = (float)edit->sel_col[2] / 255.0f; + nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; + nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; + nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; + } + } + + if(editupdate && psys->pathcache && totpart == psys->totcached) { + cache = psys->pathcache; + } + else { + /* clear out old and create new empty path cache */ + psys_free_path_cache(psys); + cache= psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps+1); + psys->pathcache= cache; + } - if(psys->soft && psys->softflag & OB_SB_ENABLE) { + if(edit==NULL && psys->soft && psys->softflag & OB_SB_ENABLE) { soft = psys->soft; if(!soft->bpoint) soft= NULL; } - + psys->lattice = psys_get_lattice(scene, ob, psys); ma= give_current_material(ob, psys->part->omat); if(ma && (psys->part->draw & PART_DRAW_MAT_COL)) VECCOPY(col, &ma->r) - + if(psys->part->from!=PART_FROM_PARTICLE) { if(!(psys->part->flag & PART_CHILD_EFFECT)) vg_effector = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_EFFECTOR); - if(!psys->totchild) + if(!edit && !psys->totchild) vg_length = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_LENGTH); } /*---first main loop: create all actual particles' paths---*/ - for(i=0; i<totpart; i++, pa++){ - if(pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) { + for(i=0,pa=psys->particles; i<totpart; i++, pa++){ + if(psys && edit==NULL && (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST)) { if(soft) bp[0] += pa->totkey; /* TODO use of initialized value? */ continue; } - if(!psys->totchild) { - BLI_srandom(psys->seed + i); - pa_length = 1.0f - part->randlength * BLI_frand(); + if(editupdate && !(pa->flag & PARS_EDIT_RECALC)) continue; + else memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); + + if(!edit && !psys->totchild) { + pa_length = 1.0f - part->randlength * 0.5 * (1.0f + pa->r_ave[0]); if(vg_length) pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length); } - pind.keyed = keyed; - pind.cache = baked ? psys->pointcache : NULL; - pind.soft = soft; - pind.epoint = NULL; - pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); - - memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); - cache[i]->steps = steps; + if(edit) + ekey = edit->keys[i]; + /*--get the first data points--*/ + pind.keyed = keyed; + pind.cached = baked; + pind.soft = soft; init_particle_interpolation(ob, psys, pa, &pind); + /* hairmat is needed for for non-hair particle too so we get proper rotations */ psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); VECCOPY(rotmat[0], hairmat[2]); VECCOPY(rotmat[1], hairmat[1]); VECCOPY(rotmat[2], hairmat[0]); - if(part->draw & PART_ABS_PATH_TIME) { - birthtime = MAX2(pind.birthtime, part->path_start); - dietime = MIN2(pind.dietime, part->path_end); - } - else { - float tb = pind.birthtime; - birthtime = tb + part->path_start * (pind.dietime - tb); - dietime = tb + part->path_end * (pind.dietime - tb); - } + if(!edit) { + if(part->draw & PART_ABS_PATH_TIME) { + birthtime = MAX2(pind.birthtime, part->path_start); + dietime = MIN2(pind.dietime, part->path_end); + } + else { + float tb = pind.birthtime; + birthtime = tb + part->path_start * (pind.dietime - tb); + dietime = tb + part->path_end * (pind.dietime - tb); + } - if(birthtime >= dietime) { - cache[i]->steps = -1; - continue; - } + if(birthtime >= dietime) { + cache[i]->steps = -1; + continue; + } - dietime = birthtime + pa_length * (dietime - birthtime); + dietime = birthtime + pa_length * (dietime - birthtime); + } + else + /* XXX brecht: don't know if this code from 2.4 is correct + * still, but makes hair appear again in particle mode */ + dietime= pind.hkey[0][pa->totkey-1].time; /*--interpolate actual path from data points--*/ for(k=0, ca=cache[i]; k<=steps; k++, ca++){ @@ -2760,13 +2721,45 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); /* keyed, baked and softbody are allready in global space */ - if(!keyed && !baked && !soft && !(psys->flag & PSYS_GLOBAL_HAIR)) { + if(!keyed && !baked && !soft) { Mat4MulVecfl(hairmat, result.co); } VECCOPY(ca->co, result.co); - VECCOPY(ca->col, col); + + /* selection coloring in edit mode */ + if(edit){ + if(pset->brushtype==PE_BRUSH_WEIGHT){ + if(k==steps) + VecLerpf(ca->col, nosel_col, sel_col, pind.hkey[0]->weight); + else + VecLerpf(ca->col, nosel_col, sel_col, + (1.0f - keytime) * pind.hkey[0]->weight + keytime * pind.hkey[1]->weight); + } + else{ + if((ekey + (pind.hkey[0] - pa->hair))->flag & PEK_SELECT){ + if((ekey + (pind.hkey[1] - pa->hair))->flag & PEK_SELECT){ + VECCOPY(ca->col, sel_col); + } + else{ + VecLerpf(ca->col, sel_col, nosel_col, keytime); + } + } + else{ + if((ekey + (pind.hkey[1] - pa->hair))->flag & PEK_SELECT){ + VecLerpf(ca->col, nosel_col, sel_col, keytime); + } + else{ + VECCOPY(ca->col, nosel_col); + } + } + } + } + else{ + VECCOPY(ca->col, col); + } } + /*--modify paths and calculate rotation & velocity--*/ @@ -2779,16 +2772,16 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra for(k=0, ca=cache[i]; k<=steps; k++, ca++) { /* apply effectors */ - if(!(psys->part->flag & PART_CHILD_EFFECT) && k) + if(!(psys->part->flag & PART_CHILD_EFFECT) && edit==0 && k) do_path_effectors(scene, ob, psys, i, ca, k, steps, cache[i]->co, effector, dfra, cfra, &length, vec); /* apply guide curves to path data */ - if(psys->effectors.first && (psys->part->flag & PART_CHILD_EFFECT)==0) + if(edit==0 && psys->effectors.first && (psys->part->flag & PART_CHILD_EFFECT)==0) /* ca is safe to cast, since only co and vel are used */ do_guide(scene, (ParticleKey*)ca, i, (float)k/(float)steps, &psys->effectors); /* apply lattice */ - if(psys->lattice) + if(psys->lattice && edit==0) calc_latt_deform(psys->lattice, ca->co, 1.0f); /* figure out rotation */ @@ -2817,8 +2810,8 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra cosangle= Inpf(tangent, prev_tangent); /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ + * angle, since floating point accuracy makes it give + * different results across platforms */ if(cosangle > 0.999999f) { QUATCOPY((ca - 1)->rot, (ca - 2)->rot); } @@ -2863,123 +2856,6 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra if(vg_length) MEM_freeN(vg_length); } -void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra) -{ - ParticleCacheKey *ca, **cache= edit->pathcache; - ParticleEditSettings *pset = &scene->toolsettings->particle; - - PTCacheEditPoint *point = edit->points; - PTCacheEditKey *ekey = NULL; - - ParticleSystem *psys = edit->psys; - ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - ParticleData *pa = psys ? psys->particles : NULL; - - ParticleInterpolationData pind; - ParticleKey result; - - float birthtime = 0.0, dietime = 0.0; - float t, time = 0.0, keytime = 0.0, frs_sec; - float hairmat[4][4]; - int k,i; - int steps = (int)pow(2.0, (double)pset->draw_step); - int totpart = edit->totpoint; - float sel_col[3]; - float nosel_col[3]; - - steps = MAX2(steps, 4); - - if(!cache || edit->totpoint != edit->totcached) { - /* clear out old and create new empty path cache */ - psys_free_path_cache(edit->psys, edit); - cache= edit->pathcache= psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps+1); - } - - frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; - - sel_col[0] = (float)edit->sel_col[0] / 255.0f; - sel_col[1] = (float)edit->sel_col[1] / 255.0f; - sel_col[2] = (float)edit->sel_col[2] / 255.0f; - nosel_col[0] = (float)edit->nosel_col[0] / 255.0f; - nosel_col[1] = (float)edit->nosel_col[1] / 255.0f; - nosel_col[2] = (float)edit->nosel_col[2] / 255.0f; - - /*---first main loop: create all actual particles' paths---*/ - for(i=0; i<totpart; i++, pa+=pa?1:0, point++){ - if(edit->totcached && !(point->flag & PEP_EDIT_RECALC)) - continue; - - ekey = point->keys; - - pind.keyed = 0; - pind.cache = NULL; - pind.soft = NULL; - pind.epoint = point; - pind.bspline = psys ? (psys->part->flag & PART_HAIR_BSPLINE) : 0; - - memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); - - cache[i]->steps = steps; - - /*--get the first data points--*/ - init_particle_interpolation(ob, psys, pa, &pind); - - if(psys) - psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - - birthtime = pind.birthtime; - dietime = pind.dietime; - - if(birthtime >= dietime) { - cache[i]->steps = -1; - continue; - } - - /*--interpolate actual path from data points--*/ - for(k=0, ca=cache[i]; k<=steps; k++, ca++){ - time = (float)k / (float)steps; - - t = birthtime + time * (dietime - birthtime); - - result.time = -t; - - do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); - - /* non-hair points are allready in global space */ - if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) - Mat4MulVecfl(hairmat, result.co); - - VECCOPY(ca->co, result.co); - - ca->vel[0] = ca->vel[1] = 0.0f; - ca->vel[1] = 1.0f; - - /* selection coloring in edit mode */ - if((ekey + (pind.ekey[0] - point->keys))->flag & PEK_SELECT){ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - VECCOPY(ca->col, sel_col); - } - else{ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, sel_col, nosel_col, keytime); - } - } - else{ - if((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT){ - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); - VecLerpf(ca->col, nosel_col, sel_col, keytime); - } - else{ - VECCOPY(ca->col, nosel_col); - } - } - - ca->time = t; - } - } - - edit->totcached = totpart; -} /************************************************/ /* Particle Key handling */ /************************************************/ @@ -3180,7 +3056,7 @@ void object_add_particle_system(Scene *scene, Object *ob) psys->cfra=bsystem_time(scene,ob,scene->r.cfra+1,0.0); DAG_scene_sort(scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } void object_remove_particle_system(Scene *scene, Object *ob) { @@ -3203,7 +3079,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT; DAG_scene_sort(scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } static void default_particle_settings(ParticleSettings *part) { @@ -3383,7 +3259,7 @@ void psys_flush_particle_settings(Scene *scene, ParticleSettings *part, int reca } } if(flush) - DAG_id_flush_update(&base->object->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, base->object, OB_RECALC_DATA); } } @@ -3415,7 +3291,7 @@ LinkNode *psys_using_settings(struct Scene *scene, ParticleSettings *part, int f } if(flush_update && found) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } return node; @@ -3594,8 +3470,6 @@ float psys_get_size(Object *ob, Material *ma, ParticleSystemModifierData *psmd, { ParticleTexture ptex; float size=1.0f; - - BLI_srandom(psys->seed + (pa - psys->particles) + 100); if(ma && part->from!=PART_FROM_PARTICLE){ ptex.size=size; @@ -3614,7 +3488,7 @@ float psys_get_size(Object *ob, Material *ma, ParticleSystemModifierData *psmd, size*=psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_size); if(part->randsize!=0.0) - size*= 1.0f - part->randsize * BLI_frand(); + size*= 1.0f - part->randsize*pa->sizemul; return size*part->size; } @@ -3781,10 +3655,16 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i if(p<totpart){ pa = psys->particles + p; + + if(pa->alive==PARS_DEAD && part->flag & PART_STICKY && pa->flag & PARS_STICKY && pa->stick_ob){ + copy_particle_key(state,&pa->state,0); + key_from_object(pa->stick_ob,state); + return; + } + pind.keyed = keyed; - pind.cache = cached ? psys->pointcache : NULL; + pind.cached = cached; pind.soft = NULL; - pind.epoint = NULL; init_particle_interpolation(ob, psys, pa, &pind); do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, state); @@ -3996,11 +3876,20 @@ int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psy return 0; /* currently not supported */ else if(psys->totchild && p>=psys->totpart){ ChildParticle *cpa=psys->child+p-psys->totpart; - ParticleKey *key1; + ParticleKey *key1, skey; float t = (cfra - pa->time + pa->loop * pa->lifetime) / pa->lifetime; pa = psys->particles + cpa->parent; - key1=&pa->state; + + if(pa->alive==PARS_DEAD && part->flag&PART_STICKY && pa->flag&PARS_STICKY && pa->stick_ob) { + key1 = &skey; + copy_particle_key(key1,&pa->state,0); + key_from_object(pa->stick_ob,key1); + } + else { + key1=&pa->state; + } + offset_child(cpa, key1, state, part->childflat, part->childrad); CLAMP(t,0.0,1.0); @@ -4057,6 +3946,10 @@ int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psy } } + if(pa->alive==PARS_DEAD && part->flag&PART_STICKY && pa->flag&PARS_STICKY && pa->stick_ob){ + key_from_object(pa->stick_ob,state); + } + if(psys->lattice) calc_latt_deform(psys->lattice, state->co,1.0f); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 1931b89af38..dcd3fcd2f89 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -123,11 +123,21 @@ static int get_current_display_percentage(ParticleSystem *psys) void psys_reset(ParticleSystem *psys, int mode) { ParticleSettings *part= psys->part; - PARTICLE_P; + ParticleData *pa; + int i; if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) { - if(mode == PSYS_RESET_ALL || !(part->type == PART_HAIR && (psys->edit && psys->edit->edited))) { - psys_free_particles(psys); + if(mode == PSYS_RESET_ALL || !(part->type == PART_HAIR && (psys->flag & PSYS_EDITED))) { + if(psys->particles) { + if(psys->particles->keys) + MEM_freeN(psys->particles->keys); + + for(i=0, pa=psys->particles; i<psys->totpart; i++, pa++) + if(pa->hair) MEM_freeN(pa->hair); + + MEM_freeN(psys->particles); + psys->particles= NULL; + } psys->totpart= 0; psys->totkeyed= 0; @@ -135,17 +145,14 @@ void psys_reset(ParticleSystem *psys, int mode) if(psys->reactevents.first) BLI_freelistN(&psys->reactevents); - - if(psys->edit && psys->free_edit) { - psys->free_edit(psys->edit); - psys->edit = NULL; - psys->free_edit = NULL; - } } } else if(mode == PSYS_RESET_CACHE_MISS) { /* set all particles to be skipped */ - LOOP_PARTICLES + ParticleData *pa = psys->particles; + int p=0; + + for(; p<psys->totpart; p++, pa++) pa->flag |= PARS_NO_DISP; } @@ -158,7 +165,7 @@ void psys_reset(ParticleSystem *psys, int mode) psys->totchild= 0; /* reset path cache */ - psys_free_path_cache(psys, psys->edit); + psys_free_path_cache(psys); /* reset point cache */ psys->pointcache->flag &= ~PTCACHE_SIMULATION_VALID; @@ -167,10 +174,9 @@ void psys_reset(ParticleSystem *psys, int mode) static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart) { - ParticleData *newpars = NULL; - BoidParticle *newboids = NULL; - PARTICLE_P; - int totpart, totsaved = 0; + ParticleData *newpars = 0, *pa; + BoidData *newboids = 0; + int i, totpart, totsaved = 0; if(new_totpart<0) { if(psys->part->distr==PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) { @@ -183,46 +189,47 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart) else totpart=new_totpart; - if(totpart && totpart != psys->totpart) { + if(totpart) { newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); - - if(psys->particles) { - totsaved=MIN2(psys->totpart,totpart); - /*save old pars*/ - if(totsaved) { - memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData)); - - if(psys->particles->boid) - memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidParticle)); - } - if(psys->particles->keys) - MEM_freeN(psys->particles->keys); + if(psys->part->phystype == PART_PHYS_BOIDS) + newboids = MEM_callocN(totpart*sizeof(BoidData), "Boid Data"); + } + if(psys->particles) { + totsaved=MIN2(psys->totpart,totpart); + /*save old pars*/ + if(totsaved) { + memcpy(newpars,psys->particles,totsaved*sizeof(ParticleData)); - if(psys->particles->boid) - MEM_freeN(psys->particles->boid); + if(newboids) + memcpy(newboids, psys->particles->boid, totsaved*sizeof(BoidData)); + } - for(p=0, pa=newpars; p<totsaved; p++, pa++) { - if(pa->keys) { - pa->keys= NULL; - pa->totkey= 0; - } - } + if(psys->particles->keys) + MEM_freeN(psys->particles->keys); - for(p=totsaved, pa=psys->particles+totsaved; p<psys->totpart; p++, pa++) - if(pa->hair) MEM_freeN(pa->hair); + if(psys->particles->boid) + MEM_freeN(psys->particles->boid); - MEM_freeN(psys->particles); + for(i=0, pa=newpars; i<totsaved; i++, pa++) { + if(pa->keys) { + pa->keys= NULL; + pa->totkey= 0; + } } - - psys->particles=newpars; - if(newboids) { - LOOP_PARTICLES - pa->boid = newboids++; - } - - psys->totpart=totpart; + for(i=totsaved, pa=psys->particles+totsaved; i<psys->totpart; i++, pa++) + if(pa->hair) MEM_freeN(pa->hair); + + MEM_freeN(psys->particles); + } + psys->particles=newpars; + + if(newboids) { + pa = psys->particles; + pa->boid = newboids; + for(i=1, pa++; i<totpart; i++,pa++) + pa->boid = (pa-1)->boid + 1; } if(psys->child) { @@ -230,6 +237,8 @@ static void realloc_particles(Object *ob, ParticleSystem *psys, int new_totpart) psys->child=0; psys->totchild=0; } + + psys->totpart=totpart; } static int get_psys_child_number(struct Scene *scene, ParticleSystem *psys) @@ -276,7 +285,8 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) each original elements can reference its derived elements */ Mesh *me= (Mesh*)ob->data; - PARTICLE_P; + ParticleData *pa= 0; + int p; /* CACHE LOCATIONS */ if(!dm->deformedOnly) { @@ -313,7 +323,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) } /* cache the verts/faces! */ - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) { if(psys->part->from == PART_FROM_VERT) { if(nodearray[pa->num]) pa->num_dmcache= GET_INT_FROM_POINTER(nodearray[pa->num]->link); @@ -333,7 +343,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) * should know to use the num or num_dmcache, set the num_dmcache to * an invalid value, just incase */ - LOOP_PARTICLES + for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) pa->num_dmcache = -1; } } @@ -1433,11 +1443,12 @@ static void distribute_particles_on_dm(DerivedMesh *finaldm, Scene *scene, Objec /* ready for future use, to emit particles without geometry */ static void distribute_particles_on_shape(Object *ob, ParticleSystem *psys, int from) { - PARTICLE_P; + ParticleData *pa; + int totpart=psys->totpart, p; fprintf(stderr,"Shape emission not yet possible!\n"); - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<totpart; p++,pa++){ pa->fuv[0]=pa->fuv[1]=pa->fuv[2]=pa->fuv[3]= 0.0; pa->foffset= 0.0f; pa->num= -1; @@ -1459,11 +1470,12 @@ static void distribute_particles(Scene *scene, Object *ob, ParticleSystem *psys, distribute_particles_on_shape(ob,psys,from); if(distr_error){ - PARTICLE_P; + ParticleData *pa; + int totpart=psys->totpart, p; fprintf(stderr,"Particle distribution error!\n"); - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<totpart; p++,pa++){ pa->fuv[0]=pa->fuv[1]=pa->fuv[2]=pa->fuv[3]= 0.0; pa->foffset= 0.0f; pa->num= -1; @@ -1558,7 +1570,7 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps Material *ma=0; //IpoCurve *icu=0; // XXX old animation system int totpart; - float rand; + float rand,length; part=psys->part; @@ -1613,8 +1625,40 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps pa->dietime= pa->time+pa->lifetime; + pa->sizemul= BLI_frand(); + + rand= BLI_frand(); + + /* while loops are to have a spherical distribution (avoid cubic distribution) */ + if(part->phystype != PART_PHYS_BOIDS) { + /* boids store gravity in r_ve, so skip here */ + length=2.0f; + while(length>1.0){ + pa->r_ve[0]=2.0f*(BLI_frand()-0.5f); + pa->r_ve[1]=2.0f*(BLI_frand()-0.5f); + pa->r_ve[2]=2.0f*(BLI_frand()-0.5f); + length=VecLength(pa->r_ve); + } + } + + length=2.0f; + while(length>1.0){ + pa->r_ave[0]=2.0f*(BLI_frand()-0.5f); + pa->r_ave[1]=2.0f*(BLI_frand()-0.5f); + pa->r_ave[2]=2.0f*(BLI_frand()-0.5f); + length=VecLength(pa->r_ave); + } + + pa->r_rot[0]=2.0f*(BLI_frand()-0.5f); + pa->r_rot[1]=2.0f*(BLI_frand()-0.5f); + pa->r_rot[2]=2.0f*(BLI_frand()-0.5f); + pa->r_rot[3]=2.0f*(BLI_frand()-0.5f); + + NormalQuat(pa->r_rot); + if(part->type!=PART_HAIR && part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){ - if(ptex.exist < BLI_frand()) + /* any unique random number will do (r_ave[0]) */ + if(ptex.exist < 0.5*(1.0+pa->r_ave[0])) pa->flag |= PARS_UNEXIST; else pa->flag &= ~PARS_UNEXIST; @@ -1628,9 +1672,10 @@ void initialize_particle(ParticleData *pa, int p, Object *ob, ParticleSystem *ps static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd) { //IpoCurve *icu=0; // XXX old animation system - PARTICLE_P; + ParticleData *pa; + int p, totpart=psys->totpart; - LOOP_PARTICLES + for(p=0, pa=psys->particles; p<totpart; p++, pa++) initialize_particle(pa,p,ob,psys,psmd); if(psys->part->type != PART_FLUID) { @@ -1698,39 +1743,10 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic float fac, phasefac, nor[3]={0,0,0},loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4]; float r_vel[3],r_ave[3],r_rot[4],p_vel[3]={0.0,0.0,0.0}; float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0}; - float q_phase[4], length, r_phase; + float q_phase[4]; part=psys->part; ptex.ivel=1.0; - - BLI_srandom(psys->seed + (pa - psys->particles)); - - /* we need to get every random even if they're not used so that they don't effect eachother */ - /* while loops are to have a spherical distribution (avoid cubic distribution) */ - length=2.0f; - while(length>1.0){ - r_vel[0]=2.0f*(BLI_frand()-0.5f); - r_vel[1]=2.0f*(BLI_frand()-0.5f); - r_vel[2]=2.0f*(BLI_frand()-0.5f); - length=VecLength(r_vel); - } - - length=2.0f; - while(length>1.0){ - r_ave[0]=2.0f*(BLI_frand()-0.5f); - r_ave[1]=2.0f*(BLI_frand()-0.5f); - r_ave[2]=2.0f*(BLI_frand()-0.5f); - length=VecLength(r_ave); - } - - r_rot[0]=2.0f*(BLI_frand()-0.5f); - r_rot[1]=2.0f*(BLI_frand()-0.5f); - r_rot[2]=2.0f*(BLI_frand()-0.5f); - r_rot[3]=2.0f*(BLI_frand()-0.5f); - - NormalQuat(r_rot); - - r_phase = BLI_frand(); if(part->from==PART_FROM_PARTICLE){ Object *tob; @@ -1741,26 +1757,29 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic if(tob==0) tob=ob; - tpsys=BLI_findlink(&tob->particlesystem, psys->target_psys-1); + tpsys=BLI_findlink(&tob->particlesystem,psys->target_psys-1); state.time = pa->time; if(pa->num == -1) memset(&state, 0, sizeof(state)); else psys_get_particle_state(scene, tob,tpsys,pa->num,&state,1); - psys_get_from_key(&state, loc, nor, rot, 0); + psys_get_from_key(&state,loc,nor,rot,0); - QuatMulVecf(rot, vtan); - QuatMulVecf(rot, utan); + QuatMulVecf(rot,vtan); + QuatMulVecf(rot,utan); + VECCOPY(r_vel,pa->r_ve); + VECCOPY(r_rot,pa->r_rot); + VECCOPY(r_ave,pa->r_ave); - VECCOPY(p_vel, state.vel); + VECCOPY(p_vel,state.vel); speed=Normalize(p_vel); - VecMulf(p_vel, Inpf(r_vel, p_vel)); - VECSUB(p_vel, r_vel, p_vel); + VecMulf(p_vel,Inpf(pa->r_ve,p_vel)); + VECSUB(p_vel,pa->r_ve,p_vel); Normalize(p_vel); - VecMulf(p_vel, speed); + VecMulf(p_vel,speed); - VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ + VECCOPY(pa->fuv,loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ } else{ /* get precise emitter matrix if particle is born */ @@ -1814,25 +1833,29 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic /* -velocity */ if(part->randfac!=0.0){ - Mat4Mul3Vecfl(ob->obmat,r_vel); + VECADD(r_vel,tloc,pa->r_ve); + Mat4MulVecfl(ob->obmat,r_vel); + VECSUB(r_vel,r_vel,loc); Normalize(r_vel); } /* -angular velocity */ if(part->avemode==PART_AVE_RAND){ - Mat4Mul3Vecfl(ob->obmat,r_ave); + VECADD(r_ave,tloc,pa->r_ave); + Mat4MulVecfl(ob->obmat,r_ave); + VECSUB(r_ave,r_ave,loc); Normalize(r_ave); } /* -rotation */ if(part->randrotfac != 0.0f){ + QUATCOPY(r_rot,pa->r_rot); Mat4ToQuat(ob->obmat,rot); QuatMul(r_rot,r_rot,rot); } } if(part->phystype==PART_PHYS_BOIDS) { - BoidParticle *bpa = pa->boid; float dvec[3], q[4], mat[3][3]; VECCOPY(pa->state.co,loc); @@ -1849,21 +1872,16 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic VECCOPY(pa->state.ave, nor); } /* and gravity in r_ve */ - bpa->gravity[0] = bpa->gravity[1] = 0.0f; - bpa->gravity[2] = -1.0f; + pa->r_ve[0] = pa->r_ve[1] = 0.0f; + pa->r_ve[2] = -1.0f; if(part->acc[2]!=0.0f) - bpa->gravity[2] = part->acc[2]; - - //pa->r_ve[0] = pa->r_ve[1] = 0.0f; - //pa->r_ve[2] = -1.0f; - //if(part->acc[2]!=0.0f) - // pa->r_ve[2] = part->acc[2]; + pa->r_ve[2] = part->acc[2]; /* calculate rotation matrix */ - Projf(dvec, r_vel, pa->state.ave); + Projf(dvec, pa->r_ve, pa->state.ave); VecSubf(mat[0], pa->state.ave, dvec); Normalize(mat[0]); - VECCOPY(mat[2], r_vel); + VECCOPY(mat[2], pa->r_ve); VecMulf(mat[2], -1.0f); Normalize(mat[2]); Crossf(mat[1], mat[2], mat[0]); @@ -1872,10 +1890,10 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic Mat3ToQuat_is_ok(mat, q); QuatCopy(pa->state.rot, q); - bpa->data.health = part->boids->health; - bpa->data.mode = eBoidMode_InAir; - bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; - bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + pa->boid->health = part->boids->health; + pa->boid->mode = eBoidMode_InAir; + pa->boid->state_id = ((BoidState*)part->boids->states.first)->id; + pa->boid->acc[0]=pa->boid->acc[1]=pa->boid->acc[2]=0.0f; } else { /* conversion done so now we apply new: */ @@ -1964,8 +1982,8 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic /* rotation phase */ phasefac = part->phasefac; - if(part->randphasefac != 0.0f) - phasefac += part->randphasefac * r_phase; + if(part->randphasefac != 0.0f) /* abuse r_ave[0] as a random number */ + phasefac += part->randphasefac * pa->r_ave[0]; VecRotToQuat(x_vec, phasefac*(float)M_PI, q_phase); /* combine base rotation & phase */ @@ -2003,7 +2021,8 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic pa->state.time = cfra; -// pa->flag &= ~PARS_STICKY; + pa->stick_ob = 0; + pa->flag &= ~PARS_STICKY; } static void reset_all_particles(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float dtime, float cfra, int from) { @@ -2069,9 +2088,8 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys) { ParticleSystem *kpsys = psys; ParticleTarget *pt; - PARTICLE_P; - ParticleKey *key; - int totpart = psys->totpart, k, totkeys = psys->totkeyed; + ParticleData *pa; + int totpart = psys->totpart, i, k, totkeys = psys->totkeyed; /* no proper targets so let's clear and bail out */ if(psys->totkeyed==0) { @@ -2083,12 +2101,12 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys) if(totpart && psys->particles->totkey != totkeys) { free_keyed_keys(psys); - key = MEM_callocN(totpart*totkeys*sizeof(ParticleKey), "Keyed keys"); + psys->particles->keys = MEM_callocN(totpart*totkeys*sizeof(ParticleKey), "Keyed keys"); + psys->particles->totkey = totkeys; - LOOP_PARTICLES { - pa->keys = key; + for(i=1, pa=psys->particles+1; i<totpart; i++,pa++){ + pa->keys = (pa-1)->keys + totkeys; pa->totkey = totkeys; - key += totkeys; } } @@ -2102,23 +2120,22 @@ static void set_keyed_keys(Scene *scene, Object *ob, ParticleSystem *psys) else kpsys = BLI_findlink(&ob->particlesystem, pt->psys - 1); - LOOP_PARTICLES { - key = pa->keys + k; - key->time = -1.0; /* use current time */ + for(i=0,pa=psys->particles; i<totpart; i++, pa++) { + (pa->keys + k)->time = -1.0; /* use current time */ - psys_get_particle_state(scene, pt->ob, kpsys, p%kpsys->totpart, key, 1); + psys_get_particle_state(scene, pt->ob, kpsys, i%kpsys->totpart, pa->keys + k, 1); if(psys->flag & PSYS_KEYED_TIMING){ - key->time = pa->time + pt->time; + (pa->keys+k)->time = pa->time + pt->time; if(pt->duration != 0.0f && k+1 < totkeys) { - copy_particle_key(key+1, key, 1); - (key+1)->time = pa->time + pt->time + pt->duration; + copy_particle_key(pa->keys+k+1, pa->keys+k, 1); + (pa->keys+k+1)->time = pa->time + pt->time + pt->duration; } } else if(totkeys > 1) - key->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime; + (pa->keys+k)->time = pa->time + (float)k / (float)(totkeys - 1) * pa->lifetime; else - key->time = pa->time; + pa->keys->time = pa->time; } if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f) @@ -2257,7 +2274,7 @@ void psys_clear_temp_pointcache(ParticleSystem *psys) if((psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) return; - BKE_ptcache_free_mem(&psys->pointcache->mem_cache); + BKE_ptache_free_mem(psys->pointcache); } void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra, int *efra) { @@ -2273,15 +2290,16 @@ void psys_get_pointcache_start_end(Scene *scene, ParticleSystem *psys, int *sfra static void update_particle_tree(ParticleSystem *psys) { if(psys) { - PARTICLE_P; + ParticleData *pa = psys->particles; + int p, totpart = psys->totpart; if(!psys->tree || psys->tree_frame != psys->cfra) { BLI_kdtree_free(psys->tree); - psys->tree = BLI_kdtree_new(psys->totpart); + psys->tree = BLI_kdtree_new(totpart); - LOOP_PARTICLES { + for(p=0, pa=psys->particles; p<totpart; p++,pa++){ if(pa->flag & (PARS_NO_DISP+PARS_UNEXIST) || pa->alive != PARS_ALIVE) continue; @@ -2524,9 +2542,9 @@ static void precalc_effectors(Scene *scene, Object *ob, ParticleSystem *psys, Pa ListBase *lb=&psys->effectors; ParticleEffectorCache *ec; ParticleSettings *part=psys->part; - PARTICLE_P; - int totpart; + ParticleData *pa; float vec2[3],loc[3],*co=0; + int p,totpart; for(ec= lb->first; ec; ec= ec->next) { PartDeflect *pd= ec->ob->pd; @@ -2550,7 +2568,7 @@ static void precalc_effectors(Scene *scene, Object *ob, ParticleSystem *psys, Pa ec->distances=MEM_callocN(totpart*sizeof(float),"particle distances"); ec->locations=MEM_callocN(totpart*3*sizeof(float),"particle locations"); - LOOP_PARTICLES { + for(p=0,pa=psys->particles; p<totpart; p++, pa++){ if(part->from == PART_FROM_PARTICLE) { VECCOPY(loc, pa->fuv); } @@ -3220,7 +3238,7 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa ParticleCollision col; BVHTreeRayHit hit; float ray_dir[3], zerovec[3]={0.0,0.0,0.0}; - float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z = 0.0f; + float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z; int deflections=0, max_deflections=10; VECCOPY(col.co1, pa->prev_state.co); @@ -3229,10 +3247,9 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa /* override for boids */ if(part->phystype == PART_PHYS_BOIDS) { - BoidParticle *bpa = pa->boid; radius = pa->size; boid_z = pa->state.co[2]; - skip_ob = bpa->ground; + skip_ob = pa->stick_ob; } /* 10 iterations to catch multiple deflections */ @@ -3302,7 +3319,12 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa deflections=max_deflections; /* store for reactors */ - copy_particle_key(&reaction_state, &pa->state, 0); + copy_particle_key(&reaction_state,&pa->state,0); + + if(part->flag & PART_STICKY){ + pa->stick_ob=ob; + pa->flag |= PARS_STICKY; + } } else { float nor_vec[3], tan_vec[3], tan_vel[3], vel[3]; @@ -3390,8 +3412,7 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); if(part->phystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) { - BoidParticle *bpa = pa->boid; - if(bpa->data.mode == eBoidMode_OnLand || co[2] <= boid_z) { + if(pa->boid->mode == eBoidMode_OnLand || co[2] <= boid_z) { co[2] = boid_z; vel[2] = 0.0f; } @@ -3433,9 +3454,10 @@ static void deflect_particle(Scene *scene, Object *pob, ParticleSystemModifierDa /* Hair */ /************************************************/ static void save_hair(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra){ - HairKey *key, *root; - PARTICLE_P; + ParticleData *pa; + HairKey *key; int totpart; + int i; Mat4Invert(ob->imat,ob->obmat); @@ -3446,22 +3468,21 @@ static void save_hair(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSy totpart=psys->totpart; /* save new keys for elements if needed */ - LOOP_PARTICLES { + for(i=0,pa=psys->particles; i<totpart; i++,pa++) { /* first time alloc */ if(pa->totkey==0 || pa->hair==NULL) { pa->hair = MEM_callocN((psys->part->hair_step + 1) * sizeof(HairKey), "HairKeys"); pa->totkey = 0; } - key = root = pa->hair; - key += pa->totkey; + key = pa->hair + pa->totkey; /* convert from global to geometry space */ VecCopyf(key->co, pa->state.co); Mat4MulVecfl(ob->imat, key->co); if(pa->totkey) { - VECSUB(key->co, key->co, root->co); + VECSUB(key->co, key->co, pa->hair->co); psys_vec_rot_to_face(psmd->dm, pa, key->co); } @@ -3473,7 +3494,7 @@ static void save_hair(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSy /* root is always in the origin of hair space so we set it to be so after the last key is saved*/ if(pa->totkey == psys->part->hair_step + 1) - root->co[0] = root->co[1] = root->co[2] = 0.0f; + pa->hair->co[0] = pa->hair->co[1] = pa->hair->co[2] = 0.0f; } } /************************************************/ @@ -3483,14 +3504,14 @@ static void save_hair(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSy static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra, float *vg_vel, float *vg_tan, float *vg_rot, float *vg_size) { + ParticleData *pa; ParticleSettings *part=psys->part; KDTree *tree=0; IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system Material *ma=give_current_material(ob,part->omat); BoidBrainData bbd; - PARTICLE_P; float timestep; - int totpart; + int p, totpart; /* current time */ float ctime, ipotime; // XXX old animation system /* frame & time changes */ @@ -3519,7 +3540,7 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic if(part->type==PART_REACTOR) vg_size=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_SIZE); - LOOP_PARTICLES { + for(p=0, pa=psys->particles; p<totpart; p++,pa++){ if(pa->flag & PARS_UNEXIST) continue; /* set correct ipo timing */ @@ -3588,7 +3609,7 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic } /* main loop: calculate physics for all particles */ - LOOP_PARTICLES { + for(p=0, pa=psys->particles; p<totpart; p++,pa++){ if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; copy_particle_key(&pa->prev_state,&pa->state,1); @@ -3676,6 +3697,9 @@ static void dynamics_step(Scene *scene, Object *ob, ParticleSystem *psys, Partic else{ pa->alive=PARS_DEAD; pa->state.time=pa->dietime; + + if(pa->flag&PARS_STICKY) + psys_key_to_object(pa->stick_ob,&pa->state,0); } } else @@ -3723,29 +3747,52 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED) && ( psys_in_edit_mode(scene, psys) || (part->type==PART_HAIR || (part->ren_as == PART_DRAW_PATH && (part->draw_as == PART_DRAW_REND || psys->renderdata))))){ - psys_cache_paths(scene, ob, psys, cfra); + psys_cache_paths(scene, ob, psys, cfra, 0); /* for render, child particle paths are computed on the fly */ if(part->childtype) { - if(((psys->totchild!=0)) || (psys_in_edit_mode(scene, psys) && (pset->flag&PE_DRAW_PART))) + if(((psys->totchild!=0)) || (psys_in_edit_mode(scene, psys) && (pset->flag&PE_SHOW_CHILD))) if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) psys_cache_child_paths(scene, ob, psys, cfra, 0); } } else if(psys->pathcache) - psys_free_path_cache(psys, NULL); + psys_free_path_cache(psys); +} + +/* calculate and store key locations in world coordinates */ +void psys_update_world_cos(Object *ob, ParticleSystem *psys) +{ + ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + ParticleData *pa; + ParticleEditKey *key; + int i, k, totpart; + float hairmat[4][4]; + + if(psys==0 || psys->edit==0) + return; + + totpart= psys->totpart; + + for(i=0, pa=psys->particles; i<totpart; i++, pa++) { + psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); + + for(k=0, key=psys->edit->keys[i]; k<pa->totkey; k++, key++) { + VECCOPY(key->world_co,key->co); + Mat4MulVecfl(hairmat, key->world_co); + } + } } static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra) { ParticleSettings *part = psys->part; - PARTICLE_P; - float disp = (float)get_current_display_percentage(psys)/100.0f; - - BLI_srandom(psys->seed); + ParticleData *pa; + int p; + float disp = (float)get_current_display_percentage(psys)/50.0f-1.0f; - LOOP_PARTICLES { - if(BLI_frand() > disp) + for(p=0, pa=psys->particles; p<psys->totpart; p++,pa++){ + if(pa->r_rot[0] > disp) pa->flag |= PARS_NO_DISP; else pa->flag &= ~PARS_NO_DISP; @@ -3761,6 +3808,9 @@ static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd psys_init_effectors(scene, ob, part->eff_group, psys); if(psys->effectors.first) precalc_effectors(scene, ob,psys,psmd,cfra); + + if(psys_in_edit_mode(scene, psys)) + psys_update_world_cos(ob, psys); psys_update_path_cache(scene, ob,psmd,psys,cfra); } @@ -3769,14 +3819,13 @@ static void hair_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *psmd, ParticleSystem *psys, float cfra) { ParticleSettings *part=psys->part; + ParticleData *pa; ParticleKey state; IpoCurve *icu_esize= NULL; //=find_ipocurve(part->ipo,PART_EMIT_SIZE); // XXX old animation system Material *ma=give_current_material(ob,part->omat); - PARTICLE_P; + int p; float disp, birthtime, dietime, *vg_size= NULL; // XXX ipotime=cfra - BLI_srandom(psys->seed); - if(part->from!=PART_FROM_PARTICLE) vg_size= psys_cache_vgroup(psmd->dm,psys,PSYS_VG_SIZE); @@ -3789,9 +3838,9 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps precalc_effectors(scene, ob,psys,psmd,cfra); //} - disp= (float)get_current_display_percentage(psys)/100.0f; + disp= (float)get_current_display_percentage(psys)/50.0f-1.0f; - LOOP_PARTICLES { + for(p=0, pa=psys->particles; p<psys->totpart; p++,pa++){ #if 0 // XXX old animation system if((part->flag&PART_ABS_TIME)==0 && part->ipo){ ipotime=100.0f*(cfra-pa->time)/pa->lifetime; @@ -3838,7 +3887,7 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps psys->lattice= NULL; } - if(BLI_frand() > disp) + if(pa->r_rot[0] > disp) pa->flag |= PARS_NO_DISP; else pa->flag &= ~PARS_NO_DISP; @@ -3891,8 +3940,8 @@ static void psys_changed_type(Object *ob, ParticleSystem *psys) else { free_hair(psys, 1); - CLAMP(part->path_start, 0.0f, MAX2(100.0f, part->end + part->lifetime)); - CLAMP(part->path_end, 0.0f, MAX2(100.0f, part->end + part->lifetime)); + CLAMP(part->path_start, part->sta, part->end + part->lifetime); + CLAMP(part->path_end, part->sta, part->end + part->lifetime); } psys->softflag= 0; @@ -3901,25 +3950,23 @@ static void psys_changed_type(Object *ob, ParticleSystem *psys) } void psys_check_boid_data(ParticleSystem *psys) { - BoidParticle *bpa; - PARTICLE_P; - - pa = psys->particles; + ParticleData *pa = psys->particles; + int p = 1; if(!pa) return; if(psys->part && psys->part->phystype==PART_PHYS_BOIDS) { if(!pa->boid) { - bpa = MEM_callocN(psys->totpart * sizeof(BoidParticle), "Boid Data"); + pa->boid = MEM_callocN(psys->totpart * sizeof(BoidData), "Boid Data"); - LOOP_PARTICLES - pa->boid = bpa++; + for(pa++; p<psys->totpart; p++, pa++) + pa->boid = (pa-1)->boid + 1; } } else if(pa->boid){ MEM_freeN(pa->boid); - LOOP_PARTICLES + for(; p<psys->totpart; p++, pa++) pa->boid = NULL; } } @@ -4067,10 +4114,10 @@ static void particles_fluid_step(Scene *scene, Object *ob, ParticleSystem *psys, static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd, float cfra) { ParticleSettings *part; + ParticleData *pa; PointCache *cache; PTCacheID pid; - PARTICLE_P; - int totpart, oldtotpart, totchild, oldtotchild; + int totpart, oldtotpart, totchild, oldtotchild, p; float disp, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; int init= 0, distr= 0, alloc= 0, usecache= 0, only_children_changed= 0; int framenr, framedelta, startframe, endframe; @@ -4213,7 +4260,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle } else if(result==PTCACHE_READ_OLD) { psys->cfra = (float)cache->simframe; - LOOP_PARTICLES { + for(p=0, pa=psys->particles; p<totpart; p++, pa++) { /* update alive status */ if(pa->time > psys->cfra) pa->alive = PARS_UNBORN; @@ -4252,11 +4299,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle } /* set particles to be not calculated TODO: can't work with pointcache */ - disp= (float)get_current_display_percentage(psys)/100.0f; + disp= (float)get_current_display_percentage(psys)/50.0f-1.0f; - BLI_srandom(psys->seed); - LOOP_PARTICLES { - if(BLI_frand() > disp) + for(p=0, pa=psys->particles; p<totpart; p++,pa++){ + if(pa->r_rot[0] > disp) pa->flag |= PARS_NO_DISP; else pa->flag &= ~PARS_NO_DISP; @@ -4293,7 +4339,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle psys_update_path_cache(scene, ob, psmd, psys,(int)cfra); } else if(psys->pathcache) - psys_free_path_cache(psys, NULL); + psys_free_path_cache(psys); /* cleanup */ if(vg_vel) MEM_freeN(vg_vel); @@ -4339,7 +4385,7 @@ static void psys_to_softbody(Scene *scene, Object *ob, ParticleSystem *psys) static int hair_needs_recalc(ParticleSystem *psys) { - if((!psys->edit || !psys->edit->edited) && + if((psys->flag & PSYS_EDITED)==0 && ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET)) { return 1; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 5a14277d63b..09170d92866 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -59,23 +59,28 @@ #include "BLI_blenlib.h" -/* both in intern */ #include "smoke_API.h" -#include "minilzo.h" - -#include "LzmaLib.h" - /* needed for directory lookup */ -/* untitled blend's need getpid for a unique name */ #ifndef WIN32 #include <dirent.h> -#include <unistd.h> #else -#include <process.h> #include "BLI_winstuff.h" #endif +/* untitled blend's need getpid for a unique name */ +#ifdef WIN32 +#include <process.h> +#else +#include <unistd.h> +#endif + +#ifdef _WIN32 +#ifndef snprintf +#define snprintf _snprintf +#endif +#endif + static void ptcache_data_to(void **data, int type, int index, void *to); static void ptcache_data_from(void **data, int type, void *from); @@ -171,7 +176,6 @@ static int ptcache_write_particle(int index, void *psys_v, void **data) { ParticleSystem *psys= psys_v; ParticleData *pa = psys->particles + index; - BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; float times[3] = {pa->time, pa->dietime, pa->lifetime}; if(data[BPHYS_DATA_INDEX]) { @@ -189,8 +193,8 @@ static int ptcache_write_particle(int index, void *psys_v, void **data) ptcache_data_from(data, BPHYS_DATA_SIZE, &pa->size); ptcache_data_from(data, BPHYS_DATA_TIMES, times); - if(boid) - ptcache_data_from(data, BPHYS_DATA_BOIDS, &boid->data); + if(pa->boid) + ptcache_data_from(data, BPHYS_DATA_TIMES, &pa->boid); return 1; } @@ -206,7 +210,6 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr { ParticleSystem *psys= psys_v; ParticleData *pa = psys->particles + index; - BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; if(cfra > pa->state.time) memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); @@ -230,8 +233,8 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr pa->lifetime = times[2]; } - if(boid) - ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &boid->data); + if(pa->boid) + ptcache_data_to(data, BPHYS_DATA_BOIDS, 0, &pa->boid); /* determine velocity from previous location */ if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { @@ -383,6 +386,8 @@ static int ptcache_totpoint_cloth(void *cloth_v) void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) { ParticleSystemModifierData *psmd; + ModifierData *md; + int a; memset(pid, 0, sizeof(PTCacheID)); @@ -408,26 +413,32 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) if(sb->particles) { psmd= psys_get_modifier(ob, sb->particles); - // pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); XXX TODO - get other index DG + pid->stack_index= modifiers_indexInObject(ob, (ModifierData*)psmd); + } + else { + for(a=0, md=ob->modifiers.first; md; md=md->next, a++) { + if(md->type == eModifierType_Softbody) { + pid->stack_index = a; + break; + } + } } - else - pid->stack_index = pid->cache->index; } void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) { + ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + memset(pid, 0, sizeof(PTCacheID)); pid->ob= ob; pid->calldata= psys; pid->type= PTCACHE_TYPE_PARTICLES; - pid->stack_index= psys->pointcache->index; + pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)psmd); pid->cache= psys->pointcache; pid->cache_ptr= &psys->pointcache; pid->ptcaches= &psys->ptcaches; - pid->flag |= PTCACHE_VEL_PER_SEC; - pid->write_elem= ptcache_write_particle; pid->write_stream = NULL; pid->read_stream = NULL; @@ -458,254 +469,76 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p pid->info_types= (1<<BPHYS_DATA_TIMES); } +#if 0 // XXX smoke pointcache stuff breaks compiling now /* Smoke functions */ static int ptcache_totpoint_smoke(void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; - if(sds->fluid) { + if(sds->fluid) + { return sds->res[0]*sds->res[1]*sds->res[2]; } else return 0; } -/* Smoke functions */ -static int ptcache_totpoint_smoke_turbulence(void *smoke_v) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - - if(sds->wt) { - return sds->res_wt[0]*sds->res_wt[1]*sds->res_wt[2]; - } - else - return 0; -} - // forward decleration static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); -static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) -{ - int r = 0; - unsigned char compressed; - LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS); - unsigned int out_len = LZO_OUT_LEN(in_len); - unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - size_t sizeOfIt = 5; - - if(mode == 1) { - r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); - if (!(r == LZO_E_OK) || (out_len >= in_len)) - compressed = 0; - else - compressed = 1; - } - else if(mode == 2) { - - r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1.... - props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); - - if(!(r == SZ_OK) || (out_len >= in_len)) - compressed = 0; - else - compressed = 2; - } - - ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); - if(compressed) { - ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int)); - ptcache_file_write(pf, out, out_len, sizeof(unsigned char)); - } - else - ptcache_file_write(pf, in, in_len, sizeof(unsigned char)); - - if(compressed == 2) - { - ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); - } - - MEM_freeN(props); - - return r; -} - static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) -{ +{ SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; - if(sds->fluid) { + if(sds->fluid) + { size_t res = sds->res[0]*sds->res[1]*sds->res[2]; - float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold; - unsigned char *obstacles; - unsigned int in_len = sizeof(float)*(unsigned int)res; - unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); - int mode = res >= 1000000 ? 2 : 1; - - smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); - - ptcache_compress_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)dens, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)densold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)heat, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)heatold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vx, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vy, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vz, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vxold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vyold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vzold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode); - ptcache_file_write(pf, &dt, 1, sizeof(float)); - ptcache_file_write(pf, &dx, 1, sizeof(float)); - - MEM_freeN(out); + float *dens, *densold, *heat, *heatold, *vx, *vy, *vz; - return 1; - } - return 0; -} - -static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - - if(sds->wt) { - unsigned int res_big_array[3]; - unsigned int res_big; - unsigned int res = sds->res[0]*sds->res[1]*sds->res[2]; - float *dens, *densold, *tcu, *tcv, *tcw; - unsigned int in_len = sizeof(float)*(unsigned int)res; - unsigned int in_len_big; - unsigned char *out; - int mode; - - smoke_turbulence_get_res(sds->wt, res_big_array); - res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; - mode = res_big >= 1000000 ? 2 : 1; - in_len_big = sizeof(float) * (unsigned int)res_big; - - smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); - - out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer"); - ptcache_compress_write(pf, (unsigned char *)dens, in_len_big, out, mode); - ptcache_compress_write(pf, (unsigned char *)densold, in_len_big, out, mode); - MEM_freeN(out); - - out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); - ptcache_compress_write(pf, (unsigned char *)tcu, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)tcv, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode); - MEM_freeN(out); + smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz); + + ptcache_file_write(pf, dens, res, sizeof(float)); + ptcache_file_write(pf, densold, res, sizeof(float)); + ptcache_file_write(pf, heat, res, sizeof(float)); + ptcache_file_write(pf, heatold, res, sizeof(float)); + ptcache_file_write(pf, vx, res, sizeof(float)); + ptcache_file_write(pf, vy, res, sizeof(float)); + ptcache_file_write(pf, vz, res, sizeof(float)); return 1; } + return 0; } // forward decleration static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); -static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len) -{ - int r = 0; - unsigned char compressed = 0; - unsigned int in_len; - unsigned int out_len = len; - unsigned char *in; - unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - size_t sizeOfIt = 5; - - ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); - if(compressed) { - ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); - in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); - ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); - - if(compressed == 1) - r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); - else if(compressed == 2) - { - size_t leni = in_len, leno = out_len; - ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); - r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); - } - - MEM_freeN(in); - } - else { - ptcache_file_read(pf, result, len, sizeof(unsigned char)); - } - - MEM_freeN(props); - - return r; -} - static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; - if(sds->fluid) { + if(sds->fluid) + { size_t res = sds->res[0]*sds->res[1]*sds->res[2]; - float dt, dx, *dens, *densold, *heat, *heatold, *vx, *vy, *vz, *vxold, *vyold, *vzold; - unsigned char *obstacles; - unsigned int out_len = (unsigned int)res * sizeof(float); + float *dens, *densold, *heat, *heatold, *vx, *vy, *vz; + + smoke_export(sds->fluid, &dens, &densold, &heat, &heatold, &vx, &vy, &vz); + + ptcache_file_read(pf, dens, res, sizeof(float)); + ptcache_file_read(pf, densold, res, sizeof(float)); + ptcache_file_read(pf, heat, res, sizeof(float)); + ptcache_file_read(pf, heatold, res, sizeof(float)); + ptcache_file_read(pf, vx, res, sizeof(float)); + ptcache_file_read(pf, vy, res, sizeof(float)); + ptcache_file_read(pf, vz, res, sizeof(float)); - smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); - - ptcache_compress_read(pf, (unsigned char *)sds->shadow, out_len); - ptcache_compress_read(pf, (unsigned char*)dens, out_len); - ptcache_compress_read(pf, (unsigned char*)densold, out_len); - ptcache_compress_read(pf, (unsigned char*)heat, out_len); - ptcache_compress_read(pf, (unsigned char*)heatold, out_len); - ptcache_compress_read(pf, (unsigned char*)vx, out_len); - ptcache_compress_read(pf, (unsigned char*)vy, out_len); - ptcache_compress_read(pf, (unsigned char*)vz, out_len); - ptcache_compress_read(pf, (unsigned char*)vxold, out_len); - ptcache_compress_read(pf, (unsigned char*)vyold, out_len); - ptcache_compress_read(pf, (unsigned char*)vzold, out_len); - ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res); - ptcache_file_read(pf, &dt, 1, sizeof(float)); - ptcache_file_read(pf, &dx, 1, sizeof(float)); - } -} - -static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - - if(sds->fluid) { - unsigned int res = sds->res[0]*sds->res[1]*sds->res[2]; - unsigned int res_big, res_big_array[3]; - float *dens, *densold, *tcu, *tcv, *tcw; - unsigned int out_len = sizeof(float)*(unsigned int)res; - unsigned int out_len_big; - - smoke_turbulence_get_res(sds->wt, res_big_array); - res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; - out_len_big = sizeof(float) * (unsigned int)res_big; - - smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); - - ptcache_compress_read(pf, (unsigned char*)dens, out_len_big); - ptcache_compress_read(pf, (unsigned char*)densold, out_len_big); - - ptcache_compress_read(pf, (unsigned char*)tcu, out_len); - ptcache_compress_read(pf, (unsigned char*)tcv, out_len); - ptcache_compress_read(pf, (unsigned char*)tcw, out_len); } } - -void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) +void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd, int num) { SmokeDomainSettings *sds = smd->domain; @@ -714,54 +547,24 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->ob= ob; pid->calldata= smd; - pid->type= PTCACHE_TYPE_SMOKE_DOMAIN; - pid->stack_index= sds->point_cache[0]->index; + // if(num == 0) + pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_LOW; + // else if(num == 1) + // pid->type= PTCACHE_TYPE_SMOKE_DOMAIN_HIGH; - pid->cache= sds->point_cache[0]; - pid->cache_ptr= &(sds->point_cache[0]); - pid->ptcaches= &(sds->ptcaches[0]); + pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)smd); + pid->cache= sds->point_cache; + pid->cache_ptr= &sds->point_cache; + pid->ptcaches= &sds->ptcaches; + + pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; pid->write_elem= NULL; pid->read_elem= NULL; - pid->read_stream = ptcache_read_smoke; pid->write_stream = ptcache_write_smoke; - - pid->interpolate_elem= NULL; - - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; - - pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values to make pointcache happy - pid->info_types= 0; -} - -void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) -{ - SmokeDomainSettings *sds = smd->domain; - - memset(pid, 0, sizeof(PTCacheID)); - - pid->ob= ob; - pid->calldata= smd; - - pid->type= PTCACHE_TYPE_SMOKE_HIGHRES; - pid->stack_index= sds->point_cache[1]->index; - - pid->cache= sds->point_cache[1]; - pid->cache_ptr= &sds->point_cache[1]; - pid->ptcaches= &sds->ptcaches[1]; - - pid->totpoint= pid->totwrite= ptcache_totpoint_smoke_turbulence; - - pid->write_elem= NULL; - pid->read_elem= NULL; - - pid->read_stream = ptcache_read_smoke_turbulence; - pid->write_stream = ptcache_write_smoke_turbulence; - pid->interpolate_elem= NULL; pid->write_header= ptcache_write_basic_header; @@ -770,6 +573,7 @@ void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, str pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy pid->info_types= 0; } +#endif // XXX smoke poitcache stuff breaks compiling void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd) { @@ -778,7 +582,7 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl pid->ob= ob; pid->calldata= clmd; pid->type= PTCACHE_TYPE_CLOTH; - pid->stack_index= clmd->point_cache->index; + pid->stack_index= modifiers_indexInObject(ob, (ModifierData *)clmd); pid->cache= clmd->point_cache; pid->cache_ptr= &clmd->point_cache; pid->ptcaches= &clmd->ptcaches; @@ -812,16 +616,14 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) } for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(psys->part) { + pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); + BKE_ptcache_id_from_particles(pid, ob, psys); + BLI_addtail(lb, pid); + + if(psys->soft) { pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); - BKE_ptcache_id_from_particles(pid, ob, psys); + BKE_ptcache_id_from_softbody(pid, ob, psys->soft); BLI_addtail(lb, pid); - - if(psys->soft) { - pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); - BKE_ptcache_id_from_softbody(pid, ob, psys->soft); - BLI_addtail(lb, pid); - } } } @@ -831,19 +633,18 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob) BKE_ptcache_id_from_cloth(pid, ob, (ClothModifierData*)md); BLI_addtail(lb, pid); } + /* + // enabled on next commit if(md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); - BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md); - BLI_addtail(lb, pid); - - pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); - BKE_ptcache_id_from_smoke_turbulence(pid, ob, (SmokeModifierData*)md); + BKE_ptcache_id_from_smoke(pid, ob, (SmokeModifierData*)md, 0); BLI_addtail(lb, pid); } } + */ } } @@ -927,10 +728,6 @@ static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, sho } if (do_ext) { - - if(pid->cache->index < 0) - pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob); - if(pid->cache->flag & PTCACHE_EXTERNAL) { if(pid->cache->index >= 0) snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02d"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ @@ -1105,7 +902,7 @@ static void ptcache_file_init_pointers(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<<BPHYS_DATA_BOIDS) ? &pf->data.boids : NULL; } -void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) +static void ptcache_mem_init_pointers(PTCacheMem *pm) { int data_types = pm->data_types; int i; @@ -1114,7 +911,7 @@ void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) pm->cur[i] = data_types & (1<<i) ? pm->data[i] : NULL; } -void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) +static void ptcache_mem_incr_pointers(PTCacheMem *pm) { int i; @@ -1180,7 +977,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) int cfra1 = 0, cfra2 = 0; int totpoint = 0, totpoint2 = 0; int *index = &i, *index2 = &i; - int use_old = 0, old_frame = 0; + int use_old = 0, old_frame; int ret = 0, error = 0; @@ -1267,12 +1064,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) return 0; if(pm) { - BKE_ptcache_mem_init_pointers(pm); + ptcache_mem_init_pointers(pm); totpoint = pm->totpoint; index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; } if(pm2) { - BKE_ptcache_mem_init_pointers(pm2); + ptcache_mem_init_pointers(pm2); totpoint2 = pm2->totpoint; index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; } @@ -1343,18 +1140,18 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(use_old) { if(pid->read_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize)) pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1); - else if(pid->read_elem) + else { error = 1; break; } } else { if(pid->read_elem && (pm || ptcache_file_read_data(pf))) pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL); - else if(pid->read_elem) + else { error = 1; break; } } if(pm) { - BKE_ptcache_mem_incr_pointers(pm); + ptcache_mem_incr_pointers(pm); index = pm->data_types & (1<<BPHYS_DATA_INDEX) ? pm->cur[BPHYS_DATA_INDEX] : &i; } } @@ -1388,7 +1185,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else { error = 1; break; } } - else if(pid->read_elem) + else { error = 1; break; } } else { @@ -1400,12 +1197,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else { error = 1; break; } } - else if(pid->read_elem) + else { error = 1; break; } } if(pm2) { - BKE_ptcache_mem_incr_pointers(pm2); + ptcache_mem_incr_pointers(pm2); index2 = pm2->data_types & (1<<BPHYS_DATA_INDEX) ? pm2->cur[BPHYS_DATA_INDEX] : &i; } } @@ -1577,11 +1374,11 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) pm->data_types = cfra ? pid->data_types : pid->info_types; ptcache_alloc_data(pm); - BKE_ptcache_mem_init_pointers(pm); + ptcache_mem_init_pointers(pm); for(i=0; i<totpoint; i++) { if(pid->write_elem && pid->write_elem(i, pid->calldata, pm->cur)) - BKE_ptcache_mem_incr_pointers(pm); + ptcache_mem_incr_pointers(pm); } //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); @@ -1682,8 +1479,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) PTCacheMem *pm= pid->cache->mem_cache.first; PTCacheMem *link= NULL; - pm= pid->cache->mem_cache.first; - if(mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = 0; for(; pm; pm=pm->next) @@ -1844,10 +1639,8 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) sbFreeSimulation(pid->calldata); else if(pid->type == PTCACHE_TYPE_PARTICLES) psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH); - else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN_LOW) smokeModifier_reset(pid->calldata); - else if(pid->type == PTCACHE_TYPE_SMOKE_HIGHRES) - smokeModifier_reset_turbulence(pid->calldata); } if(clear) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); @@ -1885,7 +1678,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) skip = 1; - if(skip == 0 && psys->part) { + if(skip == 0) { BKE_ptcache_id_from_particles(&pid, ob, psys); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } @@ -1896,17 +1689,17 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) BKE_ptcache_id_from_cloth(&pid, ob, (ClothModifierData*)md); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } + /* + // enabled on next commit if(md->type == eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData *)md; if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { - BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md); - reset |= BKE_ptcache_id_reset(scene, &pid, mode); - - BKE_ptcache_id_from_smoke_turbulence(&pid, ob, (SmokeModifierData*)md); + BKE_ptcache_id_from_smoke(&pid, ob, (SmokeModifierData*)md, 0); reset |= BKE_ptcache_id_reset(scene, &pid, mode); } } + */ } return reset; @@ -1966,7 +1759,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, int enable) if(CONTINUE_PHYSICS == 0) { for(ob=G.main->object.first; ob; ob=ob->id.next) if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED)) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); } } } @@ -1986,16 +1779,15 @@ PointCache *BKE_ptcache_add(ListBase *ptcaches) cache->startframe= 1; cache->endframe= 250; cache->step= 10; - cache->index = -1; BLI_addtail(ptcaches, cache); return cache; } -void BKE_ptcache_free_mem(ListBase *mem_cache) +void BKE_ptache_free_mem(PointCache *cache) { - PTCacheMem *pm = mem_cache->first; + PTCacheMem *pm = cache->mem_cache.first; if(pm) { for(; pm; pm=pm->next) { @@ -2004,25 +1796,22 @@ void BKE_ptcache_free_mem(ListBase *mem_cache) MEM_freeN(pm->index_array); } - BLI_freelistN(mem_cache); + BLI_freelistN(&cache->mem_cache); } } void BKE_ptcache_free(PointCache *cache) { - BKE_ptcache_free_mem(&cache->mem_cache); - if(cache->edit && cache->free_edit) - cache->free_edit(cache->edit); + BKE_ptache_free_mem(cache); MEM_freeN(cache); } void BKE_ptcache_free_list(ListBase *ptcaches) { PointCache *cache = ptcaches->first; - while(cache) { - BLI_remlink(ptcaches, cache); - BKE_ptcache_free(cache); - cache = ptcaches->first; - } + for(; cache; cache=cache->next) + BKE_ptache_free_mem(cache); + + BLI_freelistN(ptcaches); } static PointCache *ptcache_copy(PointCache *cache) @@ -2112,7 +1901,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) Base *base; ListBase pidlist; PTCacheID *pid = baker->pid; - PointCache *cache = NULL; + PointCache *cache; float frameleno = scene->r.framelen; int cfrao = CFRA; int startframe = MAXFRAME; @@ -2286,7 +2075,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) pm->frame = cfra; ptcache_alloc_data(pm); - BKE_ptcache_mem_init_pointers(pm); + ptcache_mem_init_pointers(pm); ptcache_file_init_pointers(pf); for(i=0; i<pm->totpoint; i++) { @@ -2302,7 +2091,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) return; } ptcache_copy_data(pf->cur, pm->cur); - BKE_ptcache_mem_incr_pointers(pm); + ptcache_mem_incr_pointers(pm); } //ptcache_make_index_array(pm, pid->totpoint(pid->calldata)); @@ -2333,7 +2122,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) pf->totpoint = pm->totpoint; pf->type = pid->type; - BKE_ptcache_mem_init_pointers(pm); + ptcache_mem_init_pointers(pm); ptcache_file_init_pointers(pf); if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { @@ -2353,7 +2142,7 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) ptcache_file_close(pf); return; } - BKE_ptcache_mem_incr_pointers(pm); + ptcache_mem_incr_pointers(pm); } ptcache_file_close(pf); diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index de2118af202..139895bbdaf 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -52,6 +52,30 @@ #include "BKE_blender.h" #include "BKE_sca.h" +//#include "wm_event_types.h" + +void free_text_controllers(Text *txt) +{ + Object *ob; + bController *cont; + + ob= G.main->object.first; + while(ob) { + cont= ob->controllers.first; + while(cont) { + if(cont->type==CONT_PYTHON) { + bPythonCont *pc; + + pc= cont->data; + if(pc->text==txt) pc->text= NULL; + } + cont= cont->next; + } + ob= ob->id.next; + } +} + + /* ******************* SENSORS ************************ */ void free_sensor(bSensor *sens) @@ -394,10 +418,12 @@ void init_actuator(bActuator *act) act->data= 0; switch(act->type) { +#ifdef __NLA case ACT_ACTION: case ACT_SHAPEACTION: act->data= MEM_callocN(sizeof(bActionActuator), "actionact"); break; +#endif case ACT_SOUND: sa = act->data= MEM_callocN(sizeof(bSoundActuator), "soundact"); sa->volume = 1.0f; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6f9ed3e0978..2a8fd765386 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -155,7 +155,6 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) scen->theDag= NULL; scen->obedit= NULL; scen->toolsettings= MEM_dupallocN(sce->toolsettings); - scen->stats= NULL; ts= scen->toolsettings; if(ts) { @@ -245,11 +244,6 @@ void free_scene(Scene *sce) base= base->next; } /* do not free objects! */ - - if(sce->gpd) { - sce->gpd->id.us--; - sce->gpd= NULL; - } BLI_freelistN(&sce->base); seq_free_editing(sce); @@ -305,9 +299,6 @@ void free_scene(Scene *sce) ntreeFreeTree(sce->nodetree); MEM_freeN(sce->nodetree); } - - if(sce->stats) - MEM_freeN(sce->stats); } Scene *add_scene(char *name) @@ -404,13 +395,11 @@ Scene *add_scene(char *name) sce->unit.scale_length = 1.0f; pset= &sce->toolsettings->particle; - pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER|PE_AUTO_VELOCITY; + pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; pset->totrekey= 5; pset->totaddkey= 5; pset->brushtype= PE_BRUSH_NONE; - pset->draw_step= 2; - pset->fade_frames= 2; for(a=0; a<PE_TOT_BRUSH; a++) { pset->brush[a].strength= 50; pset->brush[a].size= 50; @@ -860,3 +849,14 @@ float get_render_aosss_error(RenderData *r, float error) return error; } +void free_dome_warp_text(struct Text *txt) +{ + Scene *scene; + + scene = G.main->scene.first; + while(scene) { + if (scene->r.dometext == txt) + scene->r.dometext = NULL; + scene = scene->id.next; + } +} diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 078258092f7..2ee95ed928e 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2792,10 +2792,6 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force) if (!(force || seq->len != v->length || !v->frameMap)) { return; } - if (!seq->seq1) { /* make coverity happy and check for (CID 598) - input strip ... */ - return; - } if (!v->frameMap || v->length != seq->len) { if (v->frameMap) MEM_freeN(v->frameMap); @@ -2811,7 +2807,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force) /* if there is no IPO, try to make retiming easy by stretching the strip */ // XXX old animation system - seq - if (/*!seq->ipo &&*/ seq->seq1->enddisp != seq->seq1->start + if (/*!seq->ipo &&*/ seq->seq1 && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) { fallback_fac = (float) seq->seq1->len / (float) (seq->seq1->enddisp - seq->seq1->start); diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index c6b714c3125..159a60ad3af 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -570,7 +570,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq) } seq->strip->len = seq->len; } else if (seq->type == SEQ_SOUND) { - seq->len = AUD_getInfo(seq->sound->handle).length * FPS; + seq->len = AUD_getInfo(seq->sound->snd_sound).length * FPS; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index efb7db04029..27357d92aae 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -574,7 +574,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object } } - //Just to make sure we are not leaving any memory behind + //Just to make sure we are not letting any memory behind assert(ssmd.emCache == NULL); assert(ssmd.mCache == NULL); } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index fe5541211ce..22ea41276ff 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -54,13 +54,10 @@ #include "BKE_DerivedMesh.h" #include "BKE_modifier.h" #include "BKE_particle.h" -#include "BKE_pointcache.h" -#include "BKE_smoke.h" #include "BKE_utildefines.h" #include "DNA_customdata_types.h" #include "DNA_group_types.h" -#include "DNA_lamp_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" @@ -123,7 +120,8 @@ struct DerivedMesh; struct SmokeModifierData; // forward declerations -static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); +static void get_cell(struct SmokeModifierData *smd, float *pos, int *cell, int correct); +static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, int correct); void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); #define TRI_UVOFFSET (1./4.) @@ -165,11 +163,6 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // calc other res with max_res provided VECSUB(size, max, min); - - // prevent crash when initializing a plane as domain - if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON)) - return 0; - if(size[0] > size[1]) { if(size[0] > size[1]) @@ -212,31 +205,18 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // TODO: put in failsafe if res<=0 - dg // printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); + // dt max is 0.1 smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0, 0.1); + smd->domain->wt = smoke_turbulence_init(smd->domain->res, (smd->domain->flags & MOD_SMOKE_HIGHRES) ? (smd->domain->amplify + 1) : 0, smd->domain->noise); smd->time = scene->r.cfra; - - if(smd->domain->flags & MOD_SMOKE_HIGHRES) - { - smd->domain->wt = smoke_turbulence_init(smd->domain->res, smd->domain->amplify + 1, smd->domain->noise); - smd->domain->res_wt[0] = smd->domain->res[0] * (smd->domain->amplify + 1); - smd->domain->res_wt[1] = smd->domain->res[1] * (smd->domain->amplify + 1); - smd->domain->res_wt[2] = smd->domain->res[2] * (smd->domain->amplify + 1); - smd->domain->dx_wt = smd->domain->dx / (smd->domain->amplify + 1); - printf("smd->domain->amplify: %d\n", smd->domain->amplify); - printf("(smd->domain->flags & MOD_SMOKE_HIGHRES)\n"); - } - - if(!smd->domain->shadow) - smd->domain->shadow = MEM_callocN(sizeof(float) * smd->domain->res[0] * smd->domain->res[1] * smd->domain->res[2], "SmokeDomainShadow"); - + smd->domain->firstframe = smd->time; + smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta)); - if(smd->domain->wt) - { + if(smd->domain->wt) smoke_initWaveletBlenderRNA(smd->domain->wt, &(smd->domain->strength)); - printf("smoke_initWaveletBlenderRNA\n"); - } + return 1; } else if((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) @@ -276,11 +256,12 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive SmokeCollSettings *scs = smd->coll; MVert *mvert = dm->getVertArray(dm); MFace *mface = dm->getFaceArray(dm); - int i = 0, divs = 0; + size_t i = 0, divs = 0; int *tridivs = NULL; float cell_len = 1.0 / 50.0; // for res = 50 - int newdivs = 0; - int quads = 0, facecounter = 0; + size_t newdivs = 0; + //size_t max_points = 0; + size_t quads = 0, facecounter = 0; // copy obmat Mat4CpyMat4(scs->mat, ob->obmat); @@ -318,7 +299,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive int again = 0; do { - int j, k; + size_t j, k; int divs1 = tridivs[3 * facecounter + 0]; int divs2 = tridivs[3 * facecounter + 1]; //int divs3 = tridivs[3 * facecounter + 2]; @@ -415,10 +396,10 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive { smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 ); } - return 1; + } - return 1; + return 0; } /*! init triangle divisions */ @@ -525,9 +506,22 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) { if(smd->domain) { - if(smd->domain->shadow) - MEM_freeN(smd->domain->shadow); - smd->domain->shadow = NULL; + // free visualisation buffers + if(smd->domain->bind) + { + glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); + MEM_freeN(smd->domain->bind); + } + smd->domain->max_textures = 0; // unnecessary but let's be sure + + if(smd->domain->tray) + MEM_freeN(smd->domain->tray); + if(smd->domain->tvox) + MEM_freeN(smd->domain->tvox); + if(smd->domain->traybig) + MEM_freeN(smd->domain->traybig); + if(smd->domain->tvoxbig) + MEM_freeN(smd->domain->tvoxbig); if(smd->domain->fluid) smoke_free(smd->domain->fluid); @@ -535,11 +529,6 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) if(smd->domain->wt) smoke_turbulence_free(smd->domain->wt); - BKE_ptcache_free_list(&(smd->domain->ptcaches[0])); - smd->domain->point_cache[0] = NULL; - BKE_ptcache_free_list(&(smd->domain->ptcaches[1])); - smd->domain->point_cache[1] = NULL; - MEM_freeN(smd->domain); smd->domain = NULL; } @@ -587,46 +576,50 @@ void smokeModifier_freeCollision(SmokeModifierData *smd) } } -void smokeModifier_reset_turbulence(struct SmokeModifierData *smd) -{ - if(smd && smd->domain && smd->domain->wt) - { - smoke_turbulence_free(smd->domain->wt); - smd->domain->wt = NULL; - } - - smd->domain->point_cache[1]->flag &= ~PTCACHE_SIMULATION_VALID; - smd->domain->point_cache[1]->flag |= PTCACHE_OUTDATED; - smd->domain->point_cache[1]->simframe= 0; - smd->domain->point_cache[1]->last_exact= 0; -} - void smokeModifier_reset(struct SmokeModifierData *smd) { if(smd) { if(smd->domain) { - if(smd->domain->shadow) - MEM_freeN(smd->domain->shadow); - smd->domain->shadow = NULL; + // free visualisation buffers + if(smd->domain->bind) + { + glDeleteTextures(smd->domain->max_textures, (GLuint *)smd->domain->bind); + MEM_freeN(smd->domain->bind); + smd->domain->bind = NULL; + } + smd->domain->max_textures = 0; + if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG) + smd->domain->viewsettings = 0; + else + smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG; + + if(smd->domain->tray) + MEM_freeN(smd->domain->tray); + if(smd->domain->tvox) + MEM_freeN(smd->domain->tvox); + if(smd->domain->traybig) + MEM_freeN(smd->domain->traybig); + if(smd->domain->tvoxbig) + MEM_freeN(smd->domain->tvoxbig); + + smd->domain->tvox = NULL; + smd->domain->tray = NULL; + smd->domain->tvoxbig = NULL; + smd->domain->traybig = NULL; if(smd->domain->fluid) { smoke_free(smd->domain->fluid); smd->domain->fluid = NULL; } - - smd->domain->point_cache[0]->flag &= ~PTCACHE_SIMULATION_VALID; - smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; - smd->domain->point_cache[0]->simframe= 0; - smd->domain->point_cache[0]->last_exact= 0; - - smokeModifier_reset_turbulence(smd); - - smd->time = -1; - - // printf("reset domain end\n"); + + if(smd->domain->wt) + { + smoke_turbulence_free(smd->domain->wt); + smd->domain->wt = NULL; + } } else if(smd->flow) { @@ -684,31 +677,31 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->smd = smd; - smd->domain->point_cache[0] = BKE_ptcache_add(&(smd->domain->ptcaches[0])); - smd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE; - smd->domain->point_cache[0]->step = 1; - - smd->domain->point_cache[1] = BKE_ptcache_add(&(smd->domain->ptcaches[1])); - smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE; - smd->domain->point_cache[1]->step = 1; - /* set some standard values */ smd->domain->fluid = NULL; - smd->domain->wt = NULL; + smd->domain->wt = NULL; smd->domain->eff_group = NULL; smd->domain->fluid_group = NULL; smd->domain->coll_group = NULL; smd->domain->maxres = 32; - smd->domain->amplify = 1; - smd->domain->omega = 1.0; + smd->domain->amplify = 1; + smd->domain->omega = 1.0; smd->domain->alpha = -0.001; smd->domain->beta = 0.1; smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG; smd->domain->strength = 2.0; smd->domain->noise = MOD_SMOKE_NOISEWAVE; + smd->domain->visibility = 1; smd->domain->diss_speed = 5; + // init 3dview buffer + smd->domain->tvox = NULL; + smd->domain->tray = NULL; + smd->domain->tvoxbig = NULL; + smd->domain->traybig = NULL; smd->domain->viewsettings = 0; + smd->domain->bind = NULL; + smd->domain->max_textures = 0; } else if(smd->type & MOD_SMOKE_TYPE_FLOW) { @@ -742,321 +735,16 @@ void smokeModifier_createType(struct SmokeModifierData *smd) } } -// forward decleration -void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct); -static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct); -static int get_lamp(Scene *scene, float *light) -{ - Base *base_tmp = NULL; - for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) - { - if(base_tmp->object->type == OB_LAMP) - { - Lamp *la = (Lamp *)base_tmp->object->data; - - if(la->type == LA_LOCAL) - { - VECCOPY(light, base_tmp->object->obmat[3]); - return 1; - } - } - } - return 0; -} - -static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) -{ - SmokeDomainSettings *sds = smd->domain; - GroupObject *go = NULL; - Base *base = NULL; - - // do flows and fluids - if(1) - { - Object *otherobj = NULL; - ModifierData *md = NULL; - if(sds->fluid_group) // we use groups since we have 2 domains - go = sds->fluid_group->gobject.first; - else - base = scene->base.first; - while(base || go) - { - otherobj = NULL; - if(sds->fluid_group) - { - if(go->ob) - otherobj = go->ob; - } - else - otherobj = base->object; - if(!otherobj) - { - if(sds->fluid_group) - go = go->next; - else - base= base->next; - - continue; - } - - md = modifiers_findByType(otherobj, eModifierType_Smoke); - - // check for active smoke modifier - if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { - SmokeModifierData *smd2 = (SmokeModifierData *)md; - - // check for initialized smoke object - if((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) - { - // we got nice flow object - SmokeFlowSettings *sfs = smd2->flow; - - if(sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected - { - ParticleSystem *psys = sfs->psys; - ParticleSettings *part=psys->part; - ParticleData *pa = NULL; - int p = 0; - float *density = smoke_get_density(sds->fluid); - float *bigdensity = smoke_turbulence_get_density(sds->wt); - float *heat = smoke_get_heat(sds->fluid); - float *velocity_x = smoke_get_velocity_x(sds->fluid); - float *velocity_y = smoke_get_velocity_y(sds->fluid); - float *velocity_z = smoke_get_velocity_z(sds->fluid); - unsigned char *obstacle = smoke_get_obstacle(sds->fluid); - int bigres[3]; - - // mostly copied from particle code - for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) - { - int cell[3]; - size_t i = 0; - size_t index = 0; - int badcell = 0; - if(pa->alive == PARS_KILLED) continue; - else if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; - else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; - else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; - // VECCOPY(pos, pa->state.co); - // Mat4MulVecfl (ob->imat, pos); - // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0); - // check if cell is valid (in the domain boundary) - for(i = 0; i < 3; i++) - { - if((cell[i] > sds->res[i] - 1) || (cell[i] < 0)) - { - badcell = 1; - break; - } - } - if(badcell) - continue; - // 2. set cell values (heat, density and velocity) - index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow - { - // heat[index] += sfs->temp * 0.1; - // density[index] += sfs->density * 0.1; - heat[index] = sfs->temp; - density[index] = sfs->density; - - /* - velocity_x[index] = pa->state.vel[0]; - velocity_y[index] = pa->state.vel[1]; - velocity_z[index] = pa->state.vel[2]; - */ - - // obstacle[index] |= 2; - // we need different handling for the high-res feature - if(bigdensity) - { - // init all surrounding cells according to amplification, too - int i, j, k; - - smoke_turbulence_get_res(smd->domain->wt, bigres); - - for(i = 0; i < smd->domain->amplify + 1; i++) - for(j = 0; j < smd->domain->amplify + 1; j++) - for(k = 0; k < smd->domain->amplify + 1; k++) - { - index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); - bigdensity[index] = sfs->density; - } - } - } - else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow - { - heat[index] = 0.f; - density[index] = 0.f; - velocity_x[index] = 0.f; - velocity_y[index] = 0.f; - velocity_z[index] = 0.f; - // we need different handling for the high-res feature - if(bigdensity) - { - // init all surrounding cells according to amplification, too - int i, j, k; - smoke_turbulence_get_res(smd->domain->wt, bigres); - - for(i = 0; i < smd->domain->amplify + 1; i++) - for(j = 0; j < smd->domain->amplify + 1; j++) - for(k = 0; k < smd->domain->amplify + 1; k++) - { - index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); - bigdensity[index] = 0.f; - } - } - } // particles loop - } - } - else - { - /* - for() - { - // no psys - BVHTreeNearest nearest; - nearest.index = -1; - nearest.dist = FLT_MAX; - - BLI_bvhtree_find_nearest(sfs->bvh->tree, pco, &nearest, sfs->bvh->nearest_callback, sfs->bvh); - }*/ - } - } - } - if(sds->fluid_group) - go = go->next; - else - base= base->next; - } - } +// forward declaration +void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big); - // do effectors - /* - if(sds->eff_group) - { - for(go = sds->eff_group->gobject.first; go; go = go->next) - { - if(go->ob) - { - if(ob->pd) - { - - } - } - } - } - */ - - // do collisions - if(1) - { - Object *otherobj = NULL; - ModifierData *md = NULL; - - if(sds->coll_group) // we use groups since we have 2 domains - go = sds->coll_group->gobject.first; - else - base = scene->base.first; - - while(base || go) - { - otherobj = NULL; - if(sds->coll_group) - { - if(go->ob) - otherobj = go->ob; - } - else - otherobj = base->object; - if(!otherobj) - { - if(sds->coll_group) - go = go->next; - else - base= base->next; - continue; - } - md = modifiers_findByType(otherobj, eModifierType_Smoke); - - // check for active smoke modifier - if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { - SmokeModifierData *smd2 = (SmokeModifierData *)md; - - if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) - { - // we got nice collision object - SmokeCollSettings *scs = smd2->coll; - size_t i, j; - unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); - - for(i = 0; i < scs->numpoints; i++) - { - int badcell = 0; - size_t index = 0; - int cell[3]; - - // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0); - - // check if cell is valid (in the domain boundary) - for(j = 0; j < 3; j++) - if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) - { - badcell = 1; - break; - } - - if(badcell) - continue; - // 2. set cell values (heat, density and velocity) - index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - - // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); - // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); - obstacles[index] = 1; - // for moving gobstacles - /* - const LbmFloat maxVelVal = 0.1666; - const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; - - LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); - { - const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; - USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); - if(usqr>maxusqr) { - // cutoff at maxVelVal - for(int jj=0; jj<3; jj++) { - if(objvel[jj]>0.) objvel[jj] = maxVelVal; - if(objvel[jj]<0.) objvel[jj] = -maxVelVal; - } - } - } - const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); - const LbmVec oldov=objvel; // debug - objvel = vec2L((*pNormals)[n]) *dp; - */ - } - } - } - - if(sds->coll_group) - go = go->next; - else - base= base->next; - } - } -} void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) { + if(scene->r.cfra >= smd->time) + smokeModifier_init(smd, ob, scene, dm); + if((smd->type & MOD_SMOKE_TYPE_FLOW)) { - if(scene->r.cfra >= smd->time) - smokeModifier_init(smd, ob, scene, dm); - if(scene->r.cfra > smd->time) { // XXX TODO @@ -1076,9 +764,6 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } else if(smd->type & MOD_SMOKE_TYPE_COLL) { - if(scene->r.cfra >= smd->time) - smokeModifier_init(smd, ob, scene, dm); - if(scene->r.cfra > smd->time) { // XXX TODO @@ -1101,231 +786,459 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } else if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { - PointCache *cache = NULL; - PTCacheID pid; - PointCache *cache_wt = NULL; - PTCacheID pid_wt; - float timescale; - int cache_result = 0, cache_result_wt = 0; - int startframe, endframe, framenr, badloading = 0; SmokeDomainSettings *sds = smd->domain; - float light[3]; - - framenr = scene->r.cfra; - - cache = sds->point_cache[0]; - - BKE_ptcache_id_from_smoke(&pid, ob, smd); - BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); - - cache_wt = sds->point_cache[1]; - BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd); - - /* handle continuous simulation with the play button */ - if(BKE_ptcache_get_continue_physics()) - { - // TODO - return; - } - - if(framenr < startframe) + + if(scene->r.cfra > smd->time) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; - - cache_wt->flag &= ~PTCACHE_SIMULATION_VALID; - cache_wt->simframe= 0; - cache_wt->last_exact= 0; + GroupObject *go = NULL; + Base *base = NULL; + + tstart(); + + if(sds->flags & MOD_SMOKE_DISSOLVE) + { + smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); + + if(sds->wt) + smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); + } - // we got back in time, reset smoke in this case (TODO: use cache later) - // smd->time = scene->r.cfra; - // smokeModifier_reset(smd); + /* reset view for new frame */ + if(sds->viewsettings < MOD_SMOKE_VIEW_USEBIG) + sds->viewsettings = 0; + else + sds->viewsettings = MOD_SMOKE_VIEW_USEBIG; - return; - } - else if(framenr > endframe) - { - framenr = endframe; + // do flows and fluids + if(1) + { + Object *otherobj = NULL; + ModifierData *md = NULL; - // we load last valid frame here - // and don't update the smd->time variable later - badloading = 1; - } + if(sds->fluid_group) // we use groups since we have 2 domains + go = sds->fluid_group->gobject.first; + else + base = scene->base.first; - if(!(cache->flag & PTCACHE_SIMULATION_VALID)) - { - BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - } - if(sds->wt && !(cache_wt->flag & PTCACHE_SIMULATION_VALID)) - { - BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_OUTDATED); - } + while(base || go) + { + otherobj = NULL; - if(smd->time == -1 && framenr!= startframe) - return; + if(sds->fluid_group) + { + if(go->ob) + otherobj = go->ob; + } + else + otherobj = base->object; - if(!smokeModifier_init(smd, ob, scene, dm)) - return; + if(!otherobj) + { + if(sds->fluid_group) + go = go->next; + else + base= base->next; - if(!smd->domain->fluid) - return; + continue; + } - /* try to read from cache */ - cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); - // printf("cache_result: %d\n", cache_result); + md = modifiers_findByType(otherobj, eModifierType_Smoke); + + // check for active smoke modifier + if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) + { + SmokeModifierData *smd2 = (SmokeModifierData *)md; + + // check for initialized smoke object + if((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) + { + // we got nice flow object + SmokeFlowSettings *sfs = smd2->flow; + + if(sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected + { + ParticleSystem *psys = sfs->psys; + ParticleSettings *part=psys->part; + ParticleData *pa = NULL; + int p = 0; + float *density = smoke_get_density(sds->fluid); + float *bigdensity = smoke_turbulence_get_density(sds->wt); + float *heat = smoke_get_heat(sds->fluid); + float *velocity_x = smoke_get_velocity_x(sds->fluid); + float *velocity_y = smoke_get_velocity_y(sds->fluid); + float *velocity_z = smoke_get_velocity_z(sds->fluid); + unsigned char *obstacle = smoke_get_obstacle(sds->fluid); + int bigres[3]; + + printf("found flow psys\n"); + + // mostly copied from particle code + for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) + { + int cell[3]; + size_t i = 0; + size_t index = 0; + int badcell = 0; + + if(pa->alive == PARS_KILLED) continue; + else if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; + else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; + else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; + + // VECCOPY(pos, pa->state.co); + // Mat4MulVecfl (ob->imat, pos); + + // 1. get corresponding cell + get_cell(smd, pa->state.co, cell, 0); + + // check if cell is valid (in the domain boundary) + for(i = 0; i < 3; i++) + { + if((cell[i] > sds->res[i] - 1) || (cell[i] < 0)) + { + badcell = 1; + break; + } + } + + if(badcell) + continue; + + // 2. set cell values (heat, density and velocity) + index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); + + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow + { + // heat[index] += sfs->temp * 0.1; + // density[index] += sfs->density * 0.1; + + heat[index] = sfs->temp; + density[index] = sfs->density; + + /* + velocity_x[index] = pa->state.vel[0]; + velocity_y[index] = pa->state.vel[1]; + velocity_z[index] = pa->state.vel[2]; + */ + obstacle[index] |= 2; + + // we need different handling for the high-res feature + if(bigdensity) + { + // init all surrounding cells according to amplification, too + int i, j, k; + + smoke_turbulence_get_res(smd->domain->wt, bigres); + + for(i = 0; i < smd->domain->amplify + 1; i++) + for(j = 0; j < smd->domain->amplify + 1; j++) + for(k = 0; k < smd->domain->amplify + 1; k++) + { + index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); + bigdensity[index] = sfs->density; + } + } + } + else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow + { + heat[index] = 0.f; + density[index] = 0.f; + velocity_x[index] = 0.f; + velocity_y[index] = 0.f; + velocity_z[index] = 0.f; + + // we need different handling for the high-res feature + if(bigdensity) + { + // init all surrounding cells according to amplification, too + int i, j, k; + + smoke_turbulence_get_res(smd->domain->wt, bigres); + + for(i = 0; i < smd->domain->amplify + 1; i++) + for(j = 0; j < smd->domain->amplify + 1; j++) + for(k = 0; k < smd->domain->amplify + 1; k++) + { + index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); + bigdensity[index] = 0.f; + } + } + } + } + } + else + { + /* + for() + { + // no psys + BVHTreeNearest nearest; - if(cache_result == PTCACHE_READ_EXACT) - { - SmokeDomainSettings *sds = smd->domain; + nearest.index = -1; + nearest.dist = FLT_MAX; - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= framenr; - sds->v3dnum = framenr; + BLI_bvhtree_find_nearest(sfs->bvh->tree, pco, &nearest, sfs->bvh->nearest_callback, sfs->bvh); + }*/ + } + } + } - if(!badloading) - smd->time = scene->r.cfra; + if(sds->fluid_group) + go = go->next; + else + base= base->next; + } + } - // check for wt cache - if(sds->wt) + // do effectors + /* + if(sds->eff_group) { - cache_result_wt = BKE_ptcache_read_cache(&pid_wt, (float)framenr, scene->r.frs_sec); - // printf("cache_result_wt: %d\n", cache_result_wt); - - // error handling - if(cache_result_wt == PTCACHE_READ_EXACT) - { - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - cache_wt->simframe= framenr; - } - else if(cache_result_wt==PTCACHE_READ_OLD) + for(go = sds->eff_group->gobject.first; go; go = go->next) { - BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_FREE); - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - } - else if(ob->id.lib || (cache_wt->flag & PTCACHE_BAKED)) - { - // if baked and nothing in cache, do nothing - cache_wt->flag &= ~PTCACHE_SIMULATION_VALID; - cache_wt->simframe= 0; - cache_wt->last_exact= 0; + if(go->ob) + { + if(ob->pd) + { + + } + } } } + */ - // printf("PTCACHE_READ_EXACT\n"); - return; - } - else if(cache_result==PTCACHE_READ_OLD) - { - BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); - cache->flag |= PTCACHE_SIMULATION_VALID; + // do collisions + if(1) + { + Object *otherobj = NULL; + ModifierData *md = NULL; - BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_FREE); - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - } - else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) - { - // if baked and nothing in cache, do nothing - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; - - cache_wt->flag &= ~PTCACHE_SIMULATION_VALID; - cache_wt->simframe= 0; - cache_wt->last_exact= 0; - - // printf("PTCACHE_BAKED\n"); - return; - } - /* - else if((cache_result==0) && ((startframe!=framenr) && !(cache->flag & PTCACHE_SIMULATION_VALID || (framenr == smd->time)))) - { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe= 0; - cache->last_exact= 0; + if(sds->coll_group) // we use groups since we have 2 domains + go = sds->coll_group->gobject.first; + else + base = scene->base.first; - return; - }*/ + while(base || go) + { + otherobj = NULL; - // printf("framenr: %d, time: %f\n", framenr, smd->time); + if(sds->coll_group) + { + if(go->ob) + otherobj = go->ob; + } + else + otherobj = base->object; - /* do simulation */ + if(!otherobj) + { + if(sds->coll_group) + go = go->next; + else + base= base->next; - // low res - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe= framenr; + continue; + } + + md = modifiers_findByType(otherobj, eModifierType_Smoke); + + // check for active smoke modifier + if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) + { + SmokeModifierData *smd2 = (SmokeModifierData *)md; - if(sds->wt) - { - cache_wt->flag |= PTCACHE_SIMULATION_VALID; - cache_wt->simframe= framenr; - } - - tstart(); + if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) + { + // we got nice collision object + SmokeCollSettings *scs = smd2->coll; + size_t i, j; + unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); - if(sds->flags & MOD_SMOKE_DISSOLVE) - { - smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); - } + for(i = 0; i < scs->numpoints; i++) + { + int badcell = 0; + size_t index = 0; + int cell[3]; - smoke_calc_domain(scene, ob, smd); - - // set new time - smd->time = scene->r.cfra; + // 1. get corresponding cell + get_cell(smd, &scs->points[3 * i], cell, 0); + + // check if cell is valid (in the domain boundary) + for(j = 0; j < 3; j++) + if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) + { + badcell = 1; + break; + } + + if(badcell) + continue; + + // 2. set cell values (heat, density and velocity) + index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); + + // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); + // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); + + obstacles[index] = 1; - // frame 1 is start, don't simulate anything - if(smd->time == 1) - { + // for moving gobstacles + /* + const LbmFloat maxVelVal = 0.1666; + const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; + + LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); { + const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; + USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); + if(usqr>maxusqr) { + // cutoff at maxVelVal + for(int jj=0; jj<3; jj++) { + if(objvel[jj]>0.) objvel[jj] = maxVelVal; + if(objvel[jj]<0.) objvel[jj] = -maxVelVal; + } + } } + + const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); + const LbmVec oldov=objvel; // debug + objvel = vec2L((*pNormals)[n]) *dp; + */ + } + } + } + + if(sds->coll_group) + go = go->next; + else + base= base->next; + } + } + // set new time smd->time = scene->r.cfra; - BKE_ptcache_write_cache(&pid, framenr); + // simulate the actual smoke (c++ code in intern/smoke) + smoke_step(sds->fluid, smd->time); if(sds->wt) - BKE_ptcache_write_cache(&pid_wt, framenr); - - if(get_lamp(scene, light)) - smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx); + smoke_turbulence_step(sds->wt, sds->fluid); - // printf("smd->time: %f\n", smd->time); - return; + tend(); + printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); } + else if(scene->r.cfra < smd->time) + { + // we got back in time, reset smoke in this case (TODO: use cache later) + smd->time = scene->r.cfra; + smokeModifier_reset(smd); + } + } +} - // simulate the actual smoke (c++ code in intern/smoke) - smoke_step(sds->fluid, smd->time); - BKE_ptcache_write_cache(&pid, framenr); +// update necessary information for 3dview +void smoke_prepare_View(SmokeModifierData *smd, float *light) +{ + float *density = NULL; + int x, y, z; - if(sds->wt) - { + if(!smd->domain->tray) + { + // TRay is for self shadowing + smd->domain->tray = MEM_callocN(sizeof(float)*smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2], "Smoke_tRay"); + } + if(!smd->domain->tvox) + { + // TVox is for tranaparency + smd->domain->tvox = MEM_callocN(sizeof(float)*smd->domain->res[0]*smd->domain->res[1]*smd->domain->res[2], "Smoke_tVox"); + } - if(sds->flags & MOD_SMOKE_DISSOLVE) - smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); + // update 3dview + density = smoke_get_density(smd->domain->fluid); + for(x = 0; x < smd->domain->res[0]; x++) + for(y = 0; y < smd->domain->res[1]; y++) + for(z = 0; z < smd->domain->res[2]; z++) + { + size_t index; + + index = smoke_get_index(x, smd->domain->res[0], y, smd->domain->res[1], z); + // Transparency computation + // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 + // T_vox = exp(-C_ext * h) + // C_ext/sigma_t = density * C_ext + smoke_set_tvox(smd, index, exp(-density[index] * 7.0 * smd->domain->dx)); + } + smoke_calc_transparency(smd, light, 0); +} - smoke_turbulence_step(sds->wt, sds->fluid); - BKE_ptcache_write_cache(&pid_wt, framenr); - } +// update necessary information for 3dview ("high res" option) +void smoke_prepare_bigView(SmokeModifierData *smd, float *light) +{ + float *density = NULL; + size_t i = 0; + int bigres[3]; + + smoke_turbulence_get_res(smd->domain->wt, bigres); - if(get_lamp(scene, light)) - smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx); + if(!smd->domain->traybig) + { + // TRay is for self shadowing + smd->domain->traybig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tRayBig"); + } + if(!smd->domain->tvoxbig) + { + // TVox is for tranaparency + smd->domain->tvoxbig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tVoxBig"); + } - tend(); - // printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); + density = smoke_turbulence_get_density(smd->domain->wt); + for (i = 0; i < bigres[0] * bigres[1] * bigres[2]; i++) + { + // Transparency computation + // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4 + // T_vox = exp(-C_ext * h) + // C_ext/sigma_t = density * C_ext + smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / (smd->domain->amplify + 1)) ); } + smoke_calc_transparency(smd, light, 1); } -static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct) + +float smoke_get_tvox(SmokeModifierData *smd, size_t index) { - const size_t index = smoke_get_index(pixel[0], res[0], pixel[1], res[1], pixel[2]); + return smd->domain->tvox[index]; +} - // T_ray *= T_vox - *tRay *= exp(input[index]*correct); - - if(result[index] < 0.0f) - { -#pragma omp critical - result[index] = *tRay; - } +void smoke_set_tvox(SmokeModifierData *smd, size_t index, float tvox) +{ + smd->domain->tvox[index] = tvox; +} + +float smoke_get_tray(SmokeModifierData *smd, size_t index) +{ + return smd->domain->tray[index]; +} + +void smoke_set_tray(SmokeModifierData *smd, size_t index, float transparency) +{ + smd->domain->tray[index] = transparency; +} - return *tRay; +float smoke_get_bigtvox(SmokeModifierData *smd, size_t index) +{ + return smd->domain->tvoxbig[index]; +} + +void smoke_set_bigtvox(SmokeModifierData *smd, size_t index, float tvox) +{ + smd->domain->tvoxbig[index] = tvox; +} + +float smoke_get_bigtray(SmokeModifierData *smd, size_t index) +{ + return smd->domain->traybig[index]; +} + +void smoke_set_bigtray(SmokeModifierData *smd, size_t index, float transparency) +{ + smd->domain->traybig[index] = transparency; } long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) @@ -1346,7 +1259,34 @@ long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) return totalMB; } -static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, bresenham_callback cb, float *result, float *input, int res[3], float correct) + +static void calc_voxel_transp(SmokeModifierData *smd, int *pixel, float *tRay) +{ + // printf("Pixel(%d, %d, %d)\n", pixel[0], pixel[1], pixel[2]); + const size_t index = smoke_get_index(pixel[0], smd->domain->res[0], pixel[1], smd->domain->res[1], pixel[2]); + + // T_ray *= T_vox + *tRay *= smoke_get_tvox(smd, index); +} + +static void calc_voxel_transp_big(SmokeModifierData *smd, int *pixel, float *tRay) +{ + int bigres[3]; + size_t index; + + smoke_turbulence_get_res(smd->domain->wt, bigres); + index = smoke_get_index(pixel[0], bigres[0], pixel[1], bigres[1], pixel[2]); + + /* + if(index > bigres[0]*bigres[1]*bigres[2]) + printf("pixel[0]: %d, [1]: %d, [2]: %d\n", pixel[0], pixel[1], pixel[2]); + */ + + // T_ray *= T_vox + *tRay *= smoke_get_bigtvox(smd, index); +} + +static void bresenham_linie_3D(SmokeModifierData *smd, int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, int big) { int dx, dy, dz, i, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2; int pixel[3]; @@ -1373,8 +1313,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f err_1 = dy2 - l; err_2 = dz2 - l; for (i = 0; i < l; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; + if(!big) + calc_voxel_transp(smd, pixel, tRay); + else + calc_voxel_transp_big(smd, pixel, tRay); + if(*tRay < 0.0f) + return; if (err_1 > 0) { pixel[1] += y_inc; err_1 -= dx2; @@ -1391,8 +1335,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f err_1 = dx2 - m; err_2 = dz2 - m; for (i = 0; i < m; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; + if(!big) + calc_voxel_transp(smd, pixel, tRay); + else + calc_voxel_transp_big(smd, pixel, tRay); + if(*tRay < 0.0f) + return; if (err_1 > 0) { pixel[0] += x_inc; err_1 -= dy2; @@ -1409,8 +1357,12 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f err_1 = dy2 - n; err_2 = dx2 - n; for (i = 0; i < n; i++) { - if(cb(result, input, res, pixel, tRay, correct) <= FLT_EPSILON) - break; + if(!big) + calc_voxel_transp(smd, pixel, tRay); + else + calc_voxel_transp_big(smd, pixel, tRay); + if(*tRay < 0.0f) + return; if (err_1 > 0) { pixel[1] += y_inc; err_1 -= dz2; @@ -1424,15 +1376,41 @@ static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, f pixel[2] += z_inc; } } - cb(result, input, res, pixel, tRay, correct); + if(!big) + calc_voxel_transp(smd, pixel, tRay); + else + calc_voxel_transp_big(smd, pixel, tRay); } -static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct) +static void get_cell(struct SmokeModifierData *smd, float *pos, int *cell, int correct) { float tmp[3]; - VECSUB(tmp, pos, p0); - VecMulf(tmp, 1.0 / dx); + VECSUB(tmp, pos, smd->domain->p0); + VecMulf(tmp, 1.0 / smd->domain->dx); + + if(correct) + { + cell[0] = MIN2(smd->domain->res[0] - 1, MAX2(0, (int)floor(tmp[0]))); + cell[1] = MIN2(smd->domain->res[1] - 1, MAX2(0, (int)floor(tmp[1]))); + cell[2] = MIN2(smd->domain->res[2] - 1, MAX2(0, (int)floor(tmp[2]))); + } + else + { + cell[0] = (int)floor(tmp[0]); + cell[1] = (int)floor(tmp[1]); + cell[2] = (int)floor(tmp[2]); + } +} +static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, int correct) +{ + float tmp[3]; + int res[3]; + smoke_turbulence_get_res(smd->domain->wt, res); + + VECSUB(tmp, pos, smd->domain->p0); + + VecMulf(tmp, (smd->domain->amplify + 1)/ smd->domain->dx ); if(correct) { @@ -1448,22 +1426,43 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int } } -void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct) + +void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int big) { int x, y, z; float bv[6]; + int res[3]; + float bigfactor = 1.0; - memset(result, -1, sizeof(float)*res[0]*res[1]*res[2]); // x - bv[0] = p0[0]; - bv[1] = p1[0]; + // x + bv[0] = smd->domain->p0[0]; + bv[1] = smd->domain->p1[0]; // y - bv[2] = p0[1]; - bv[3] = p1[1]; + bv[2] = smd->domain->p0[1]; + bv[3] = smd->domain->p1[1]; // z - bv[4] = p0[2]; - bv[5] = p1[2]; + bv[4] = smd->domain->p0[2]; + bv[5] = smd->domain->p1[2]; +/* + printf("bv[0]: %f, [1]: %f, [2]: %f, [3]: %f, [4]: %f, [5]: %f\n", bv[0], bv[1], bv[2], bv[3], bv[4], bv[5]); + + printf("p0[0]: %f, p0[1]: %f, p0[2]: %f\n", smd->domain->p0[0], smd->domain->p0[1], smd->domain->p0[2]); + printf("p1[0]: %f, p1[1]: %f, p1[2]: %f\n", smd->domain->p1[0], smd->domain->p1[1], smd->domain->p1[2]); + printf("dx: %f, amp: %d\n", smd->domain->dx, smd->domain->amplify); +*/ + if(!big) + { + res[0] = smd->domain->res[0]; + res[1] = smd->domain->res[1]; + res[2] = smd->domain->res[2]; + } + else + { + smoke_turbulence_get_res(smd->domain->wt, res); + bigfactor = 1.0 / (smd->domain->amplify + 1); + } -#pragma omp parallel for schedule(static) private(y, z) +#pragma omp parallel for schedule(static) private(y, z) shared(big, smd, light, res, bigfactor) for(x = 0; x < res[0]; x++) for(y = 0; y < res[1]; y++) for(z = 0; z < res[2]; z++) @@ -1476,29 +1475,41 @@ void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, index = smoke_get_index(x, res[0], y, res[1], z); - if(result[index] >= 0.0f) - continue; - voxelCenter[0] = p0[0] + dx * x + dx * 0.5; - voxelCenter[1] = p0[1] + dx * y + dx * 0.5; - voxelCenter[2] = p0[2] + dx * z + dx * 0.5; + // voxelCenter = m_voxelarray[i].GetCenter(); + voxelCenter[0] = smd->domain->p0[0] + smd->domain->dx * bigfactor * x + smd->domain->dx * bigfactor * 0.5; + voxelCenter[1] = smd->domain->p0[1] + smd->domain->dx * bigfactor * y + smd->domain->dx * bigfactor * 0.5; + voxelCenter[2] = smd->domain->p0[2] + smd->domain->dx * bigfactor * z + smd->domain->dx * bigfactor * 0.5; + + // printf("vc[0]: %f, vc[1]: %f, vc[2]: %f\n", voxelCenter[0], voxelCenter[1], voxelCenter[2]); + // printf("light[0]: %f, light[1]: %f, light[2]: %f\n", light[0], light[1], light[2]); // get starting position (in voxel coords) if(BLI_bvhtree_bb_raycast(bv, light, voxelCenter, pos) > FLT_EPSILON) { // we're ouside - get_cell(p0, res, dx, pos, cell, 1); + // printf("out: pos[0]: %f, pos[1]: %f, pos[2]: %f\n", pos[0], pos[1], pos[2]); + if(!big) + get_cell(smd, pos, cell, 1); + else + get_bigcell(smd, pos, cell, 1); } else { + // printf("in: pos[0]: %f, pos[1]: %f, pos[2]: %f\n", light[0], light[1], light[2]); // we're inside - get_cell(p0, res, dx, light, cell, 1); + if(!big) + get_cell(smd, light, cell, 1); + else + get_bigcell(smd, light, cell, 1); } - bresenham_linie_3D(cell[0], cell[1], cell[2], x, y, z, &tRay, cb, result, input, res, correct); + // printf("cell - [0]: %d, [1]: %d, [2]: %d\n", cell[0], cell[1], cell[2]); + bresenham_linie_3D(smd, cell[0], cell[1], cell[2], x, y, z, &tRay, big); - // convention -> from a RGBA float array, use G value for tRay -// #pragma omp critical - result[index] = tRay; + if(!big) + smoke_set_tray(smd, index, tRay); + else + smoke_set_bigtray(smd, index, tRay); } } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index fdbfe154fae..68f918b0c68 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -866,8 +866,7 @@ static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring bp->frozen = 1.0f; bp->colball = 0.0f; bp->flag = 0; - bp->springweight = 1.0f; - bp->mass = sb->nodemass; + } } } @@ -3623,9 +3622,9 @@ static void particles_to_softbody(Scene *scene, Object *ob) /* find first BodyPoint index for each particle */ if(psys->totpart > 0) { -// psys->particles->bpi = 0; -// for(a=1, pa=psys->particles+1; a<psys->totpart; a++, pa++) -// pa->bpi = (pa-1)->bpi + (pa-1)->totkey; + psys->particles->bpi = 0; + for(a=1, pa=psys->particles+1; a<psys->totpart; a++, pa++) + pa->bpi = (pa-1)->bpi + (pa-1)->totkey; } /* we always make body points */ @@ -4079,7 +4078,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(framenr < startframe) { cache->flag &= ~PTCACHE_SIMULATION_VALID; cache->simframe= 0; - //cache->last_exact= 0; + cache->last_exact= 0; return; } @@ -4141,29 +4140,20 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i pa= sb->particles->particles; } - if(framenr == startframe && cache->flag & PTCACHE_REDO_NEEDED) { - BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - cache->simframe= framenr; - cache->flag &= ~PTCACHE_REDO_NEEDED; - return; - } - /* try to read from cache */ cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { - if(sb->particles==0) - softbody_to_object(ob, vertexCos, numVerts, sb->local); - - cache->simframe= framenr; cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; - if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(&pid, framenr); + if(sb->particles==0) + softbody_to_object(ob, vertexCos, numVerts, sb->local); return; } else if(cache_result==PTCACHE_READ_OLD) { + BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE); cache->flag |= PTCACHE_SIMULATION_VALID; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { @@ -4175,11 +4165,16 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } if(framenr == startframe) { + if(cache->flag & PTCACHE_REDO_NEEDED) { + softbody_update_positions(ob, sb, vertexCos, numVerts); + softbody_reset(ob, sb, vertexCos, numVerts); + cache->flag &= ~PTCACHE_REDO_NEEDED; + } /* first frame, no simulation to do, just set the positions */ softbody_update_positions(ob, sb, vertexCos, numVerts); - cache->simframe= framenr; cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; /* don't write cache on first frame, but on second frame write * cache for frame 1 and 2 */ @@ -4191,6 +4186,10 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i softbody_update_positions(ob, sb, vertexCos, numVerts); + /* do simulation */ + cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe= framenr; + /* checking time: */ dtime = framedelta*timescale; @@ -4199,10 +4198,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i if(sb->particles==0) softbody_to_object(ob, vertexCos, numVerts, 0); - /* do simulation */ - cache->simframe= framenr; - cache->flag |= PTCACHE_SIMULATION_VALID; - BKE_ptcache_write_cache(&pid, framenr); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 2d5d8dad7a8..a3275792a85 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -34,7 +34,7 @@ void sound_init() { AUD_Specs specs; - int device, buffersize; + int device, buffersize, success; device = U.audiodevice; buffersize = U.mixbufsize; @@ -54,8 +54,15 @@ void sound_init() if(specs.channels <= AUD_CHANNELS_INVALID) specs.channels = AUD_CHANNELS_STEREO; - if(!AUD_init(device, specs, buffersize)) - AUD_init(AUD_NULL_DEVICE, specs, buffersize); + if(!AUD_init(device, specs, buffersize)) { + if(device == AUD_SDL_DEVICE) + success= AUD_init(AUD_OPENAL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); + else + success= AUD_init(AUD_SDL_DEVICE, specs, AUD_DEFAULT_BUFFER_SIZE*4); + + if(!success) + AUD_init(AUD_NULL_DEVICE, specs, buffersize); + } } void sound_exit() @@ -71,7 +78,7 @@ struct bSound* sound_new_file(struct Main *main, char* filename) int len; strcpy(str, filename); - BLI_convertstringcode(str, main->name); + BLI_convertstringcode(str, G.sce); len = strlen(filename); while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') @@ -79,11 +86,11 @@ struct bSound* sound_new_file(struct Main *main, char* filename) sound = alloc_libblock(&main->sound, ID_SO, filename+len); strcpy(sound->name, filename); -// XXX unused currently sound->type = SOUND_TYPE_FILE; + sound->type = SOUND_TYPE_FILE; - sound_load(main, sound); + sound_load(sound); - if(!sound->handle) + if(!sound->snd_sound) { free_libblock(&main->sound, sound); sound = NULL; @@ -107,9 +114,9 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) sound->child_sound = source; sound->type = SOUND_TYPE_BUFFER; - sound_load(CTX_data_main(C), sound); + sound_load(sound); - if(!sound->handle) + if(!sound->snd_sound) { free_libblock(&CTX_data_main(C)->sound, sound); sound = NULL; @@ -133,9 +140,9 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa sound->end = end; sound->type = SOUND_TYPE_LIMITER; - sound_load(CTX_data_main(C), sound); + sound_load(sound); - if(!sound->handle) + if(!sound->snd_sound) { free_libblock(&CTX_data_main(C)->sound, sound); sound = NULL; @@ -162,35 +169,22 @@ void sound_cache(struct bSound* sound, int ignore) if(sound->cache && !ignore) AUD_unload(sound->cache); - sound->cache = AUD_bufferSound(sound->handle); - sound->changed++; + sound->cache = AUD_bufferSound(sound->snd_sound); } -void sound_delete_cache(struct bSound* sound) -{ - if(sound->cache) - { - AUD_unload(sound->cache); - sound->cache = NULL; - } -} - -void sound_load(struct Main *main, struct bSound* sound) +void sound_load(struct bSound* sound) { if(sound) { - if(sound->handle) + if(sound->snd_sound) { - AUD_unload(sound->handle); - sound->handle = NULL; + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; } -// XXX unused currently -#if 0 switch(sound->type) { case SOUND_TYPE_FILE: -#endif { char fullpath[FILE_MAX]; char *path; @@ -204,32 +198,32 @@ void sound_load(struct Main *main, struct bSound* sound) if(sound->id.lib) path = sound->id.lib->filename; else - path = main ? main->name : G.sce; + path = G.sce; BLI_convertstringcode(fullpath, path); /* but we need a packed file then */ if (pf) - sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + sound->snd_sound = AUD_loadBuffer((unsigned char*) pf->data, pf->size); /* or else load it from disk */ else - sound->handle = AUD_load(fullpath); - } // XXX -// XXX unused currently -#if 0 + sound->snd_sound = AUD_load(fullpath); break; } case SOUND_TYPE_BUFFER: - if(sound->child_sound && sound->child_sound->handle) - sound->handle = AUD_bufferSound(sound->child_sound->handle); + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_bufferSound(sound->child_sound->snd_sound); break; case SOUND_TYPE_LIMITER: - if(sound->child_sound && sound->child_sound->handle) - sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end); + if(sound->child_sound && sound->child_sound->snd_sound) + sound->snd_sound = AUD_limitSound(sound->child_sound, sound->start, sound->end); break; } -#endif - sound->changed++; + + if(sound->cache) + { + + } } } @@ -241,36 +235,33 @@ void sound_free(struct bSound* sound) sound->packedfile = NULL; } - if(sound->handle) + if(sound->snd_sound) { - AUD_unload(sound->handle); - sound->handle = NULL; + AUD_unload(sound->snd_sound); + sound->snd_sound = NULL; } } void sound_unlink(struct bContext *C, struct bSound* sound) { + bSound *snd; Scene *scene; SoundHandle *handle; -// XXX unused currently -#if 0 - bSound *snd; for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next) { if(snd->child_sound == sound) { snd->child_sound = NULL; - if(snd->handle) + if(snd->snd_sound) { - AUD_unload(sound->handle); - snd->handle = NULL; + AUD_unload(sound->snd_sound); + snd->snd_sound = NULL; } sound_unlink(C, snd); } } -#endif for(scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) { @@ -328,6 +319,8 @@ void sound_stop_all(struct bContext *C) } } +#define SOUND_PLAYBACK_LAMBDA 1.0 + void sound_update_playing(struct bContext *C) { SoundHandle *handle; @@ -373,10 +366,12 @@ void sound_update_playing(struct bContext *C) action = 3; else { - float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe; + float diff = AUD_getPosition(handle->handle) - (cfra - handle->startframe) / fps; +// AUD_XXX float diff = AUD_getPosition(handle->handle) * fps - cfra + handle->startframe if(diff < 0.0) diff = -diff; - if(diff > FPS/2.0) + if(diff > SOUND_PLAYBACK_LAMBDA) +// AUD_XXX if(diff > 5.0f) { action = 2; } @@ -388,9 +383,9 @@ void sound_update_playing(struct bContext *C) { if(handle->state == AUD_STATUS_INVALID) { - if(handle->source && handle->source->handle) + if(handle->source && handle->source->snd_sound) { - AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, handle->frameskip / fps, (handle->frameskip + handle->endframe - handle->startframe)/fps); handle->handle = AUD_play(limiter, 1); AUD_unload(limiter); if(handle->handle) @@ -429,10 +424,10 @@ void sound_scrub(struct bContext *C) { if(cfra >= handle->startframe && cfra < handle->endframe && !handle->mute) { - if(handle->source && handle->source->handle) + if(handle->source && handle->source->snd_sound) { int frameskip = handle->frameskip + cfra - handle->startframe; - AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->handle, frameskip / fps, (frameskip + 1)/fps); + AUD_Sound* limiter = AUD_limitSound(handle->source->cache ? handle->source->cache : handle->source->snd_sound, frameskip / fps, (frameskip + 1)/fps); AUD_play(limiter, 0); AUD_unload(limiter); } @@ -455,7 +450,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e for(handle = scene->sound_handles.first; handle; handle = handle->next) { - if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle) + if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->snd_sound) { frameskip = handle->frameskip; s = handle->startframe - start; @@ -467,7 +462,7 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e s = 0; } - limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps); + limiter = AUD_limitSound(handle->source->snd_sound, frameskip / fps, e / fps); delayer = AUD_delaySound(limiter, s / fps); AUD_playDevice(mixdown, delayer); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index dac426de4eb..8e3d59bbc58 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -37,22 +37,14 @@ #include "BLI_blenlib.h" -#include "DNA_action_types.h" -#include "DNA_armature_types.h" -#include "DNA_constraint_types.h" -#include "DNA_controller_types.h" #include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" #include "DNA_text_types.h" -#include "BKE_depsgraph.h" -#include "BKE_global.h" +#include "BKE_utildefines.h" +#include "BKE_text.h" #include "BKE_library.h" +#include "BKE_global.h" #include "BKE_main.h" -#include "BKE_node.h" -#include "BKE_text.h" -#include "BKE_utildefines.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" @@ -459,85 +451,6 @@ Text *copy_text(Text *ta) return tan; } -void unlink_text(Main *bmain, Text *text) -{ - bScreen *scr; - ScrArea *area; - SpaceLink *sl; - Scene *scene; - Object *ob; - bController *cont; - bConstraint *con; - short update; - - /* dome */ - for(scene=bmain->scene.first; scene; scene=scene->id.next) - if(scene->r.dometext == text) - scene->r.dometext = NULL; - - for(ob=bmain->object.first; ob; ob=ob->id.next) { - /* game controllers */ - for(cont=ob->controllers.first; cont; cont=cont->next) { - if(cont->type==CONT_PYTHON) { - bPythonCont *pc; - - pc= cont->data; - if(pc->text==text) pc->text= NULL; - } - } - - /* pyconstraints */ - update = 0; - - if(ob->type==OB_ARMATURE && ob->pose) { - bPoseChannel *pchan; - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for(con = pchan->constraints.first; con; con=con->next) { - if(con->type==CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = con->data; - if (data->text==text) data->text = NULL; - update = 1; - - } - } - } - } - - for(con = ob->constraints.first; con; con=con->next) { - if(con->type==CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = con->data; - if (data->text==text) data->text = NULL; - update = 1; - } - } - - if(update) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - } - - /* pynodes */ - // XXX nodeDynamicUnlinkText(&text->id); - - /* text space */ - for(scr= bmain->screen.first; scr; scr= scr->id.next) { - for(area= scr->areabase.first; area; area= area->next) { - for(sl= area->spacedata.first; sl; sl= sl->next) { - if(sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - - if(st->text==text) { - st->text= NULL; - st->top= 0; - } - } - } - } - } - - text->id.us= 0; -} - - /*****************************/ /* Editing utility functions */ /*****************************/ diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index fe8b97db606..eeffbfe5ef6 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -38,12 +38,11 @@ #include "PIL_dynlib.h" - +#include "MTC_matrixops.h" #include "BLI_blenlib.h" #include "BLI_arithb.h" #include "BLI_rand.h" -#include "BLI_kdopbvh.h" #include "DNA_texture_types.h" #include "DNA_key_types.h" @@ -418,8 +417,6 @@ void free_texture(Tex *tex) free_plugin_tex(tex->plugin); if(tex->coba) MEM_freeN(tex->coba); if(tex->env) BKE_free_envmap(tex->env); - if(tex->pd) BKE_free_pointdensity(tex->pd); - if(tex->vd) BKE_free_voxeldata(tex->vd); BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; @@ -489,16 +486,6 @@ void default_tex(Tex *tex) tex->env->depth=0; } - if (tex->pd) { - tex->pd->radius = 0.3f; - tex->pd->falloff_type = TEX_PD_FALLOFF_STD; - } - - if (tex->vd) { - tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0; - tex->vd->interp_type=TEX_VD_LINEAR; - tex->vd->file_format=TEX_VD_SMOKE; - } pit = tex->plugin; if (pit) { varstr= pit->varstr; @@ -750,9 +737,9 @@ void make_local_texture(Tex *tex) void autotexname(Tex *tex) { - char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", + char texstr[20][12]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", "Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave", - "Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""}; + "Voronoi", "DistNoise", "", "", "", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; @@ -901,106 +888,6 @@ void BKE_free_envmap(EnvMap *env) } /* ------------------------------------------------------------------------- */ - -PointDensity *BKE_add_pointdensity(void) -{ - PointDensity *pd; - - pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); - pd->flag = 0; - pd->radius = 0.3f; - pd->falloff_type = TEX_PD_FALLOFF_STD; - pd->falloff_softness = 2.0; - pd->source = TEX_PD_PSYS; - pd->point_tree = NULL; - pd->point_data = NULL; - pd->noise_size = 0.5f; - pd->noise_depth = 1; - pd->noise_fac = 1.0f; - pd->noise_influence = TEX_PD_NOISE_STATIC; - pd->coba = add_colorband(1); - pd->speed_scale = 1.0f; - pd->totpoints = 0; - pd->coba = add_colorband(1); - pd->object = NULL; - pd->psys = NULL; - return pd; -} - -PointDensity *BKE_copy_pointdensity(PointDensity *pd) -{ - PointDensity *pdn; - - pdn= MEM_dupallocN(pd); - pdn->point_tree = NULL; - pdn->point_data = NULL; - if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); - - return pdn; -} - -void BKE_free_pointdensitydata(PointDensity *pd) -{ - if (pd->point_tree) { - BLI_bvhtree_free(pd->point_tree); - pd->point_tree = NULL; - } - if (pd->point_data) { - MEM_freeN(pd->point_data); - pd->point_data = NULL; - } - if(pd->coba) MEM_freeN(pd->coba); -} - -void BKE_free_pointdensity(PointDensity *pd) -{ - BKE_free_pointdensitydata(pd); - MEM_freeN(pd); -} - - -void BKE_free_voxeldatadata(struct VoxelData *vd) -{ - if (vd->dataset) { - MEM_freeN(vd->dataset); - vd->dataset = NULL; - } - -} - -void BKE_free_voxeldata(struct VoxelData *vd) -{ - BKE_free_voxeldatadata(vd); - MEM_freeN(vd); -} - -struct VoxelData *BKE_add_voxeldata(void) -{ - VoxelData *vd; - - vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); - vd->dataset = NULL; - vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; - vd->interp_type= TEX_VD_LINEAR; - vd->file_format= TEX_VD_SMOKE; - vd->int_multiplier = 1.0; - vd->object = NULL; - - return vd; - } - -struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) -{ - VoxelData *vdn; - - vdn= MEM_dupallocN(vd); - vdn->dataset = NULL; - - return vdn; -} - - -/* ------------------------------------------------------------------------- */ int BKE_texture_dependsOnTime(const struct Tex *texture) { if(texture->plugin) { |