* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/editors/physics/particle_edit.c
+ * \ingroup edphys
+ */
+
+
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "ED_physics.h"
#include "ED_mesh.h"
#include "ED_particle.h"
#include "ED_view3d.h"
static int point_is_selected(PTCacheEditPoint *point)
{
KEY_K;
- int sel;
if(point->flag & PEP_HIDE)
return 0;
- sel= 0;
-
LOOP_SELECTED_KEYS {
return 1;
}
if(!mpa) {
if(!edit->mirror_cache)
PE_update_mirror_cache(ob, psys);
+
+ if(!edit->mirror_cache)
+ return; /* something went wrong! */
mi= edit->mirror_cache[i];
if(mi == -1)
if(!edit->mirror_cache)
PE_update_mirror_cache(ob, psys);
+ if(!edit->mirror_cache)
+ return; /* something went wrong */
+
/* we delay settings the PARS_EDIT_RECALC for mirrored particles
* to avoid doing mirror twice */
LOOP_POINTS {
}
}
/* force set distances between neighbouring keys */
-void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
+static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
{
ParticleEditSettings *pset=PE_settings(scene);
{
DerivedMesh *dm=psys_get_modifier(ob,psys)->dm;
PTCacheEdit *edit= psys->edit;
- MFace *mface;
- MVert *mvert;
float *vec, *nor;
- int i, totface, totvert;
+ int i, totface /*, totvert*/;
if(!dm)
return;
BLI_kdtree_free(edit->emitter_field);
totface=dm->getNumFaces(dm);
- totvert=dm->getNumVerts(dm);
+ /*totvert=dm->getNumVerts(dm);*/ /*UNSUED*/
edit->emitter_cosnos=MEM_callocN(totface*6*sizeof(float),"emitter cosnos");
vec=edit->emitter_cosnos;
nor=vec+3;
- mvert=dm->getVertDataArray(dm,CD_MVERT);
for(i=0; i<totface; i++, vec+=6, nor+=6) {
- mface=dm->getFaceData(dm,i,CD_MFACE);
+ MFace *mface=dm->getFaceData(dm,i,CD_MFACE);
+ MVert *mvert;
mvert=dm->getVertData(dm,mface->v1,CD_MVERT);
VECCOPY(vec,mvert->co);
POINT_P;
PTCacheEditPoint *npoint=0, *new_points=0;
ParticleSystemModifierData *psmd;
- int i, totpart, new_totpart= psys->totpart, removed= 0;
+ int i, new_totpart= psys->totpart, removed= 0;
if(mirror) {
/* mirror tags */
psmd= psys_get_modifier(ob, psys);
- totpart= psys->totpart;
LOOP_TAGGED_POINTS {
PE_mirror_particle(ob, psmd->dm, psys, psys->particles + p, NULL);
if(new_totpart) {
npa= new_pars= MEM_callocN(new_totpart * sizeof(ParticleData), "ParticleData array");
npoint= new_points= MEM_callocN(new_totpart * sizeof(PTCacheEditPoint), "PTCacheEditKey array");
+
+ if(ELEM(NULL, new_pars, new_points)) {
+ /* allocation error! */
+ if(new_pars)
+ MEM_freeN(new_pars);
+ if(new_points)
+ MEM_freeN(new_points);
+ return 0;
+ }
}
pa= psys->particles;
ParticleKey key3[3];
KDTreeNearest ptn[3];
int w, maxw;
- float maxd, mind, dd, totw=0.0, weight[3];
+ float maxd, totw=0.0, weight[3];
psys_particle_on_dm(psmd->dm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,0,0);
maxw= BLI_kdtree_find_n_nearest(tree,3,co1,NULL,ptn);
maxd= ptn[maxw-1].dist;
- mind= ptn[0].dist;
- dd= maxd - mind;
for(w=0; w<maxw; w++) {
weight[w]= (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
LOOP_POINTS {
LOOP_KEYS {
- if((int)key->ftime == pm->frame) {
+ if((int)key->ftime == (int)pm->frame) {
key->co = pm->cur[BPHYS_DATA_LOCATION];
key->vel = pm->cur[BPHYS_DATA_VELOCITY];
key->rot = pm->cur[BPHYS_DATA_ROTATION];
if(cache && cache->flag & PTCACHE_DISK_CACHE)
return;
+ if(psys == NULL && cache->mem_cache.first == NULL)
+ return;
+
if(!edit) {
- totpoint = psys ? psys->totpart : ((PTCacheMem*)cache->mem_cache.first)->totpoint;
+ totpoint = psys ? psys->totpart : (int)((PTCacheMem*)cache->mem_cache.first)->totpoint;
edit= MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit");
edit->points=MEM_callocN(totpoint*sizeof(PTCacheEditPoint),"PTCacheEditPoints");