This commit is contained in:
2007-12-18 17:29:35 +00:00
83 changed files with 5300 additions and 4342 deletions

View File

@@ -91,8 +91,9 @@ extern struct ListBase editNurb;
void mainqenter (unsigned short event, short val);
void waitcursor(int);
void allqueue(unsigned short event, short val);
#define REDRAWVIEW3D 0x4010
#define REDRAWBUTSEDIT 0x4019
#define REDRAWVIEW3D 0x4010
#define REDRAWBUTSOBJECT 0x4018
#define REDRAWBUTSEDIT 0x4019
struct Material;
extern struct Material defmaterial;

View File

@@ -294,6 +294,7 @@ struct Object *modifiers_isDeformedByArmature(struct Object *ob);
struct Object *modifiers_isDeformedByLattice(struct Object *ob);
int modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
int modifiers_isDeformed(struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
int modifiers_indexInObject(struct Object *ob, struct ModifierData *md);

View File

@@ -169,6 +169,8 @@ typedef struct ParticleThreadContext {
int from, cfrom, distr;
struct ParticleData *tpars;
/* path caching */
int editupdate, between, steps;
int totchild, totparent;
@@ -203,15 +205,18 @@ void psys_disable_all(struct Object *ob);
void psys_enable_all(struct Object *ob);
int psys_ob_has_hair(struct Object *ob);
int psys_in_edit_mode(struct ParticleSystem *psys);
int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys);
void psys_free_settings(struct ParticleSettings *part);
void free_child_path_cache(struct ParticleSystem *psys);
void psys_free_path_cache(struct ParticleSystem *psys);
void psys_free_render_memory(struct Object *ob, struct ParticleSystem *psys);
void free_hair(struct ParticleSystem *psys);
void free_keyed_keys(struct ParticleSystem *psys);
void psys_free(struct Object * ob, struct ParticleSystem * psys);
void psys_particles_to_render_backup(struct Object *ob, struct ParticleSystem *psys);
void psys_render_backup_to_particles(struct Object *ob, struct ParticleSystem *psys);
void clear_particles_from_cache(struct Object *ob, struct ParticleSystem *psys, int cfra);
//void psys_remove_from_particle_list(struct Object *ob, short nbr, struct ParticleSystem *psys);
@@ -280,6 +285,7 @@ void psys_particle_on_dm(struct Object *ob, struct DerivedMesh *dm, int from, in
void initialize_particle(struct ParticleData *pa, int p, struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd);
void reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot);
void psys_calc_dmfaces(struct Object *ob, struct DerivedMesh *dm, struct ParticleSystem *psys);
int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fw, struct LinkNode *node);
/* ParticleEffectorCache->type */

View File

@@ -1877,7 +1877,7 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
int needMapping, CustomDataMask dataMask)
{
Mesh *me = ob->data;
ModifierData *md = modifiers_getVirtualModifierList(ob);
ModifierData *firstmd, *md;
LinkNode *datamasks, *curr;
CustomDataMask mask;
float (*deformedVerts)[3] = NULL;
@@ -1886,6 +1886,8 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
int fluidsimMeshUsed = 0;
int required_mode;
md = firstmd = modifiers_getVirtualModifierList(ob);
modifiers_clearErrors(ob);
/* we always want to keep original indices */
@@ -2097,6 +2099,9 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
}
}
for(md=firstmd; md; md=md->next)
modifier_freeTemporaryData(md);
/* Yay, we are done. If we have a DerivedMesh and deformed vertices
* need to apply these back onto the DerivedMesh. If we have no
* DerivedMesh then we need to build one.

View File

@@ -292,14 +292,6 @@ static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], i
dob->index= index;
ob->lay= lay;
/* allowing duplicators for particle systems... a bit silly still */
{
PartEff *paf= give_parteff(ob);
if(paf) {
Mat4Invert(ob->imat, ob->obmat);
Mat4CpyMat4(paf->imat, ob->imat);
}
}
return dob;
}
@@ -809,7 +801,7 @@ ListBase *object_duplilist(Scene *sce, Object *ob)
group_duplilist(duplilist, ob, 0); /* now recursive */
/* make copy already, because in group dupli's deform displists can be makde, requiring parent matrices */
/* make copy already, because in group dupli's deform displists can be made, requiring parent matrices */
for(dob= duplilist->first; dob; dob= dob->next)
Mat4CpyMat4(dob->ob->obmat, dob->mat);
}

View File

@@ -1480,7 +1480,7 @@ void makeBevelList(Object *ob)
while(nu) {
if(nu->pntsu<=1) {
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList");
BLI_addtail(&(cu->bev), bl);
bl->nr= 0;
} else {
@@ -1490,8 +1490,7 @@ void makeBevelList(Object *ob)
resolu= nu->resolu;
if((nu->type & 7)==CU_POLY) {
len= nu->pntsu;
bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList");
BLI_addtail(&(cu->bev), bl);
@@ -1544,7 +1543,7 @@ void makeBevelList(Object *ob)
bevp->z= prevbezt->vec[1][2];
bevp->alfa= prevbezt->alfa;
bevp->f1= SELECT;
bevp->f2= SELECT;
bevp->f2= 0;
bevp++;
bl->nr++;
bl->flag= 1;

View File

@@ -1900,7 +1900,7 @@ static void dag_object_time_update_flags(Object *ob)
ParticleSystem *psys= ob->particlesystem.first;
for(; psys; psys=psys->next) {
if(psys->flag & PSYS_ENABLED) {
if(psys_check_enabled(ob, psys)) {
ob->recalc |= OB_RECALC_DATA;
break;
}

View File

@@ -5358,7 +5358,7 @@ static void particleSystemModifier_deformVerts(
else
return;
if((psys->flag&PSYS_ENABLED)==0)
if(!psys_check_enabled(ob, psys))
return;
if(dm==0){
@@ -7513,3 +7513,14 @@ int modifiers_usesPointCache(Object *ob)
return 0;
}
void modifier_freeTemporaryData(ModifierData *md)
{
if(md->type == eModifierType_Armature) {
ArmatureModifierData *amd= (ArmatureModifierData*)md;
if(amd->prevCos)
MEM_freeN(amd->prevCos);
}
}

View File

@@ -2201,7 +2201,7 @@ void object_handle_update(Object *ob)
psys= ob->particlesystem.first;
while(psys) {
if(psys->flag & PSYS_ENABLED) {
if(psys_check_enabled(ob, psys)) {
particle_system_update(ob, psys);
psys= psys->next;
}

View File

@@ -77,6 +77,7 @@
#include "BKE_bad_level_calls.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_cdderivedmesh.h"
#include "blendef.h"
#include "RE_render_ext.h"
@@ -248,6 +249,23 @@ int psys_in_edit_mode(ParticleSystem *psys)
{
return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current(OBACT) && psys->edit);
}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd;
if(!(psys->flag & PSYS_ENABLED))
return 0;
psmd= psys_get_modifier(ob, psys);
if(G.rendering) {
if(!psys->renderdata || !(psmd->modifier.mode & eModifierMode_Render))
return 0;
}
else if(!(psmd->modifier.mode & eModifierMode_Realtime))
return 0;
return 1;
}
/************************************************/
/* Freeing stuff */
@@ -301,27 +319,6 @@ void psys_free_path_cache(ParticleSystem *psys)
}
free_child_path_cache(psys);
}
void psys_free_render_memory(Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd;
/* this is a bad function, but saves a lot of memory rendering.
* particles should really be generated on the fly with render
* settings! */
psys_free_path_cache(psys);
if(psys->child){
MEM_freeN(psys->child);
psys->child=0;
psys->totchild=0;
}
psmd= psys_get_modifier(ob, psys);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
psys->recalc |= PSYS_ALLOC|PSYS_DISTR;
//DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
}
/* free everything */
void psys_free(Object *ob, ParticleSystem * psys)
{
@@ -366,6 +363,92 @@ void psys_free(Object *ob, ParticleSystem * psys)
}
}
/* these two functions move away particle data and bring it back after
* rendering, to make different render settings possible without
* removing the previous data. this should be solved properly once */
typedef struct ParticleRenderDataup {
ChildParticle *child;
ParticleCacheKey **pathcache;
ParticleCacheKey **childcache;
int totchild, totcached, totchildcache;
DerivedMesh *dm;
int totdmvert, totdmedge, totdmface;
} ParticleRenderDataup;
void psys_particles_to_render_backup(Object *ob, ParticleSystem *psys)
{
ParticleRenderDataup *data;
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
if(!G.rendering)
return;
data= MEM_callocN(sizeof(ParticleRenderDataup), "ParticleRenderDataup");
data->child= psys->child;
data->totchild= psys->totchild;
data->pathcache= psys->pathcache;
data->totcached= psys->totcached;
data->childcache= psys->childcache;
data->totchildcache= psys->totchildcache;
if(psmd->dm)
data->dm= CDDM_copy(psmd->dm);
data->totdmvert= psmd->totdmvert;
data->totdmedge= psmd->totdmedge;
data->totdmface= psmd->totdmface;
psys->child= NULL;
psys->pathcache= NULL;
psys->childcache= NULL;
psys->totchild= psys->totcached= psys->totchildcache= 0;
psys->renderdata= data;
}
void psys_render_backup_to_particles(Object *ob, ParticleSystem *psys)
{
ParticleRenderDataup *data;
ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
data= psys->renderdata;
if(!data)
return;
if(psmd->dm) {
psmd->dm->needsFree= 1;
psmd->dm->release(psmd->dm);
}
psys_free_path_cache(psys);
if(psys->child){
MEM_freeN(psys->child);
psys->child= 0;
psys->totchild= 0;
}
psys->child= data->child;
psys->totchild= data->totchild;
psys->pathcache= data->pathcache;
psys->totcached= data->totcached;
psys->childcache= data->childcache;
psys->totchildcache= data->totchildcache;
psmd->dm= data->dm;
psmd->totdmvert= data->totdmvert;
psmd->totdmedge= data->totdmedge;
psmd->totdmface= data->totdmface;
psmd->flag &= ~eParticleSystemFlag_psys_updated;
if(psys->part->from==PART_FROM_FACE && psmd->dm)
psys_calc_dmfaces(ob, psmd->dm, psys);
MEM_freeN(data);
psys->renderdata= NULL;
}
/************************************************/
/* Interpolated Particles */
/************************************************/
@@ -691,12 +774,13 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float *
#define PARTICLE_ERROR(_nor, _vec) _vec[0]=_vec[1]=_vec[2]=0.0; if(_nor){ _nor[0]=_nor[1]=0.0; _nor[2]=1.0; }
void psys_particle_on_dm(Object *ob, DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor)
{
float (*orcodata)[3] = dm->getVertDataArray(dm, CD_ORCO);
float (*orcodata)[3];
if(index < 0){ /* 'no dm' error has happened! */
PARTICLE_ERROR(nor, vec);
return;
}
orcodata= dm->getVertDataArray(dm, CD_ORCO);
if (dm->deformedOnly || index_dmcache == DMCACHE_ISCHILD) {
/* this works for meshes with deform verts only - constructive modifiers wont work properly*/
@@ -1406,7 +1490,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
/*---start figuring out what is actually wanted---*/
if(psys_in_edit_mode(psys))
if(G.rendering==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==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){
@@ -1415,7 +1499,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
between=1;
}
if(G.rendering)
if(psys->renderdata)
steps=(int)pow(2.0,(double)part->ren_step);
else{
totchild=(int)((float)totchild*(float)part->disp/100.0f);
@@ -1870,7 +1954,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0)
return;
if(G.rendering)
if(psys->renderdata)
steps = (int)pow(2.0, (double)psys->part->ren_step);
else if(psys_in_edit_mode(psys)){
edit=psys->edit;
@@ -2290,7 +2374,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData
psys_particle_on_dm(ob, dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, vec, 0, 0, 0, orco, 0);
/* see psys_face_mat for why this function is called */
transform_mesh_orco_verts(ob->data, orco, 1, 1);
transform_mesh_orco_verts(ob->data, &orco, 1, 1);
VECCOPY(hairmat[3],orco);
}

View File

@@ -92,7 +92,7 @@ static int get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
if(G.rendering || (part->child_nbr && part->childtype))
if(psys->renderdata || (part->child_nbr && part->childtype))
return 100;
if(part->phystype==PART_PHYS_KEYED){
@@ -136,7 +136,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
}
psys->particles=newpars;
child_nbr= (G.rendering)? psys->part->ren_child_nbr: psys->part->child_nbr;
child_nbr= (psys->renderdata)? psys->part->ren_child_nbr: psys->part->child_nbr;
if(child_nbr && psys->part->childtype){
if(psys->child)
MEM_freeN(psys->child);
@@ -155,7 +155,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
}
/* only run this if from == PART_FROM_FACE */
static void psys_calc_dmfaces(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
void psys_calc_dmfaces(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
{
/* use for building derived mesh face-origin info,
node - the allocated links - total derived mesh face count
@@ -472,7 +472,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
ParticleThreadContext *ctx= thread->ctx;
Object *ob= ctx->ob;
DerivedMesh *dm= ctx->dm;
ParticleData *tpars=0, *tpa;
ParticleData *tpa;
ParticleSettings *part= ctx->psys->part;
float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3], ornor1[3];
float cur_d, min_d;
@@ -494,6 +494,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
int w, maxw;
psys_particle_on_dm(ctx->ob,ctx->dm,from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co1,0,0,0,orco1,0);
transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_n_nearest(ctx->tree,3,orco1,NULL,ptn);
for(w=0; w<maxw; w++){
@@ -586,7 +587,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
//pa->verts[1]=0;
//pa->verts[2]=0;
tpa=tpars+ctx->index[p];
tpa=ctx->tpars+ctx->index[p];
pa->num=ctx->index[p];
pa->fuv[0]=tpa->fuv[0];
pa->fuv[1]=tpa->fuv[1];
@@ -633,6 +634,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
do_seams= (part->flag&PART_CHILD_SEAMS && ctx->seams);
psys_particle_on_dm(ob,dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,0,0,orco1,ornor1);
transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1);
maxw = BLI_kdtree_find_n_nearest(ctx->tree,(do_seams)?10:4,orco1,ornor1,ptn);
maxd=ptn[maxw-1].dist;
@@ -778,7 +780,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
Object *ob= ctx->ob;
ParticleSystem *psys= ctx->psys;
Object *tob;
ParticleData *pa=0, *tpars;
ParticleData *pa=0, *tpars= 0;
ParticleSettings *part;
ParticleSystem *tpsys;
ParticleSeam *seams= 0;
@@ -820,6 +822,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
for(p=0,pa=psys->particles; p<totpart; p++,pa++){
psys_particle_on_dm(ob,dm,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,ornor);
transform_mesh_orco_verts((Mesh*)ob->data, &orco, 1, 1);
BLI_kdtree_insert(tree, p, orco, ornor);
}
@@ -874,7 +877,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
}
else{
/* no need to figure out distribution */
int child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
int child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
for(i=0; i<child_nbr; i++){
for(p=0; p<psys->totpart; p++,cpa++){
@@ -923,8 +926,10 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
tree=BLI_kdtree_new(totvert);
for(p=0; p<totvert; p++){
if(orcodata)
if(orcodata) {
VECCOPY(co,orcodata[p])
transform_mesh_orco_verts((Mesh*)ob->data, &co, 1, 1);
}
else
VECCOPY(co,mv[p].co)
BLI_kdtree_insert(tree,p,co,NULL);
@@ -990,7 +995,8 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
/* 2.1 */
if((part->flag&PART_EDISTR || children) && ELEM(from,PART_FROM_PARTICLE,PART_FROM_VERT)==0){
float totarea=0.0, *co1, *co2, *co3, *co4;
MVert *v1, *v2, *v3, *v4;
float totarea=0.0, co1[3], co2[3], co3[3], co4[3];
float (*orcodata)[3];
orcodata= dm->getVertDataArray(dm, CD_ORCO);
@@ -999,21 +1005,31 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
MFace *mf=dm->getFaceData(dm,i,CD_MFACE);
if(orcodata) {
co1= orcodata[mf->v1];
co2= orcodata[mf->v2];
co3= orcodata[mf->v3];
VECCOPY(co1, orcodata[mf->v1]);
VECCOPY(co2, orcodata[mf->v2]);
VECCOPY(co3, orcodata[mf->v3]);
transform_mesh_orco_verts((Mesh*)ob->data, &co1, 1, 1);
transform_mesh_orco_verts((Mesh*)ob->data, &co2, 1, 1);
transform_mesh_orco_verts((Mesh*)ob->data, &co3, 1, 1);
}
else {
co1= ((MVert*)dm->getVertData(dm,mf->v1,CD_MVERT))->co;
co2= ((MVert*)dm->getVertData(dm,mf->v2,CD_MVERT))->co;
co3= ((MVert*)dm->getVertData(dm,mf->v3,CD_MVERT))->co;
v1= (MVert*)dm->getVertData(dm,mf->v1,CD_MVERT);
v2= (MVert*)dm->getVertData(dm,mf->v2,CD_MVERT);
v3= (MVert*)dm->getVertData(dm,mf->v3,CD_MVERT);
VECCOPY(co1, v1->co);
VECCOPY(co2, v2->co);
VECCOPY(co3, v3->co);
}
if (mf->v4){
if(orcodata)
co4= orcodata[mf->v4];
else
co4= ((MVert*)dm->getVertData(dm,mf->v4,CD_MVERT))->co;
if(orcodata) {
VECCOPY(co4, orcodata[mf->v4]);
transform_mesh_orco_verts((Mesh*)ob->data, &co4, 1, 1);
}
else {
v4= (MVert*)dm->getVertData(dm,mf->v4,CD_MVERT);
VECCOPY(co4, v4->co);
}
cur= AreaQ3Dfl(co1, co2, co3, co4);
}
else
@@ -1096,9 +1112,9 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
}
}
else {
float step, pos;
double step, pos;
step= (totpart <= 1)? 0.5f: 1.0f/(totpart-1);
step= (totpart <= 1)? 0.5: 1.0/(totpart-1);
pos= 0.0f;
i= 0;
@@ -1157,6 +1173,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
ctx->cfrom= cfrom;
ctx->distr= distr;
ctx->dm= dm;
ctx->tpars= tpars;
seed= 31415926 + ctx->psys->seed;
@@ -1434,9 +1451,6 @@ static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleS
initialize_particle(pa,p,ob,psys,psmd);
/* store the derived mesh face index for each particle */
//if(psys->part->from==PART_FROM_FACE)
// psys_calc_dmfaces(ob, psmd->dm, psys);
icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ);
if(icu){
float time=psys->part->sta, end=psys->part->end;
@@ -1715,9 +1729,6 @@ static void reset_all_particles(Object *ob, ParticleSystem *psys, ParticleSystem
float *vg_tan=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_TAN);
float *vg_rot=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_ROT);
//if (psys->part->from == PART_FROM_FACE)
// psys_calc_dmfaces(ob, psmd->dm, psys);
for(p=from, pa=psys->particles+from; p<totpart; p++, pa++)
reset_particle(pa, psys, psmd, ob, dtime, cfra, vg_vel, vg_tan, vg_rot);
@@ -4167,7 +4178,7 @@ static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd,
ParticleSettings *part=psys->part;
ParticleEditSettings *pset=&G.scene->toolsettings->particle;
int distr=0,alloc=0;
int child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
int child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
if((psys->part->childtype && psys->totchild != psys->totpart*child_nbr) || psys->recalc&PSYS_ALLOC)
alloc=1;
@@ -4205,11 +4216,10 @@ static void hair_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSyst
{
ParticleSettings *part = psys->part;
if(psys->recalc & PSYS_DISTR) {
if(psys->recalc & PSYS_DISTR)
/* need this for changing subsurf levels */
psys_calc_dmfaces(ob, psmd->dm, psys);
}
if(psys->effectors.first)
psys_end_effectors(psys);
@@ -4377,6 +4387,10 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
psys->recalc &= ~PSYS_TYPE;
alloc = 1;
/* this is a bad level call, but currently type change
* can happen after redraw, so force redraw from here */
allqueue(REDRAWBUTSOBJECT, 0);
}
else
oldtotpart = psys->totpart;
@@ -4386,7 +4400,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
else
totpart = psys->part->totpart;
child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
if(oldtotpart != totpart || psys->recalc&PSYS_ALLOC || (psys->part->childtype && psys->totchild != psys->totpart*child_nbr))
alloc = 1;
@@ -4428,7 +4442,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
/* set particles to be not calculated */
disp= (float)get_current_display_percentage(psys)/50.0f-1.0f;
if(disp<1.0f) for(p=0, pa=psys->particles; p<totpart; p++,pa++){
for(p=0, pa=psys->particles; p<totpart; p++,pa++){
if(pa->r_rot[0] > disp)
pa->flag |= PARS_NO_DISP;
else
@@ -4436,12 +4450,9 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
}
/* ok now we're all set so let's go */
if(psys->totpart) {
//if(psys->part->from==PART_FROM_FACE) {
// psys_calc_dmfaces(ob, psmd->dm, psys);
//}
if(psys->totpart)
dynamics_step(ob,psys,psmd,cfra,vg_vel,vg_tan,vg_rot,vg_size);
}
psys->recalc = 0;
psys->cfra=cfra;
@@ -4513,21 +4524,24 @@ void particle_system_update(Object *ob, ParticleSystem *psys){
ParticleSystemModifierData *psmd=0;
float cfra;
if((psys->flag & PSYS_ENABLED)==0) return;
psmd=psys_get_modifier(ob,psys);
if(!psys_check_enabled(ob, psys))
return;
cfra=bsystem_time(ob,(float)CFRA,0.0);
psmd= psys_get_modifier(ob, psys);
/* system was already updated from modifier stack */
if(psmd->flag&eParticleSystemFlag_psys_updated){
if(psmd->flag&eParticleSystemFlag_psys_updated) {
psmd->flag &= ~eParticleSystemFlag_psys_updated;
/* make sure it really was updated to cfra */
if(psys->cfra==cfra)
return;
}
if(!psmd->dm)
return;
/* baked path softbody */
if(psys->part->type==PART_HAIR && psys->soft)
psys_to_softbody(ob, psys, 0);
@@ -4561,6 +4575,6 @@ void particle_system_update(Object *ob, ParticleSystem *psys){
system_step(ob,psys,psmd,cfra);
Mat4CpyMat4(psys->imat, ob->imat); /* used for duplicators */
Mat4Invert(psys->imat, ob->obmat); /* used for duplicators */
}