[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12469] branches/particles/source/blender: hair now works again on non subsurfed mesh, painting onto subsurf now partly works.
Campbell Barton
cbarton at metavr.com
Sun Nov 4 16:23:27 CET 2007
Revision: 12469
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12469
Author: campbellbarton
Date: 2007-11-04 16:23:26 +0100 (Sun, 04 Nov 2007)
Log Message:
-----------
hair now works again on non subsurfed mesh, painting onto subsurf now partly works. some bugs fixed too.
Modified Paths:
--------------
branches/particles/source/blender/blenkernel/BKE_particle.h
branches/particles/source/blender/blenkernel/intern/modifier.c
branches/particles/source/blender/blenkernel/intern/particle.c
branches/particles/source/blender/blenkernel/intern/particle_system.c
branches/particles/source/blender/makesdna/DNA_particle_types.h
branches/particles/source/blender/render/intern/source/convertblender.c
branches/particles/source/blender/src/editparticle.c
Modified: branches/particles/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/particles/source/blender/blenkernel/BKE_particle.h 2007-11-04 05:31:20 UTC (rev 12468)
+++ branches/particles/source/blender/blenkernel/BKE_particle.h 2007-11-04 15:23:26 UTC (rev 12469)
@@ -251,7 +251,7 @@
/* particle_system.c */
void initialize_particle(struct ParticleData *pa, int p, 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 reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, int deform_only, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot);
int psys_particle_dm_face_lookup(struct DerivedMesh *dm, int index, float *fuv, struct LinkNode *node);
Modified: branches/particles/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/modifier.c 2007-11-04 05:31:20 UTC (rev 12468)
+++ branches/particles/source/blender/blenkernel/intern/modifier.c 2007-11-04 15:23:26 UTC (rev 12469)
@@ -5953,6 +5953,7 @@
int *facepa=emd->facepa, *vertpa=0;
int totdup=0,totvert=0,totface=0,totpart=0;
int i, j, v, mindex=0;
+ int deform_only = modifiers_isDeformedOnly(ob);
totface= dm->getNumFaces(dm);
totvert= dm->getNumVerts(dm);
@@ -6005,7 +6006,7 @@
for(i=0, pa=pars; i<=totpart; i++, pa++){
if(i!=totpart){
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,part->from,pa->num,-1,pa->fuv,loc0,nor,0,0);
+ psys_particle_on_emitter(deform_only, psmd,part->from,pa->num,-1,pa->fuv,loc0,nor,0,0);
Mat4MulVecfl(ob->obmat,loc0);
state.time=cfra;
Modified: branches/particles/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle.c 2007-11-04 05:31:20 UTC (rev 12468)
+++ branches/particles/source/blender/blenkernel/intern/particle.c 2007-11-04 15:23:26 UTC (rev 12469)
@@ -891,7 +891,7 @@
/* we need to modify the original fuv for its uv in relation to the derived mesh face)
* since the fuv is the position on the face on the original mesh */
- float fuv_mod[2];
+ float fuv_mod[3] = {0.0,0.0,0.0};
/* Not for quads, use for our abuse of LineIntersectsTriangleUV */
float p1[3], p2[3], v0[3], v1[3], v2[3], lambda;
@@ -922,7 +922,7 @@
i = index_dmcache;
}
- printf("Index DMCACHE %i\n", index_dmcache);
+ /*printf("Index DMCACHE %i\n", index_dmcache);*/
/* Any time this happens, and the face has not been removed,
* its a BUG watch out for this error! */
@@ -1495,13 +1495,13 @@
int p, totparent,totchild=psys->totchild;
float co[3], *orcos=0;
int from=PART_FROM_FACE;
-
+ int deform_only = modifiers_isDeformedOnly(ob);
totparent=(int)(totchild*part->parents*0.3);
tree=alloc_kdtree(totparent);
for(p=0,cpa=psys->child,cur=tree; p<totparent; p++,cpa++,cur++){
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,-1,cpa->fuv,cur->co,0,0,0);
+ psys_particle_on_emitter(deform_only, psmd,from,cpa->num,-1,cpa->fuv,cur->co,0,0,0);
cur->nbr=p;
@@ -1509,7 +1509,7 @@
}
for(; p<totchild; p++,cpa++){
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,from,cpa->num,-1,cpa->fuv,co,0,0,0);
+ psys_particle_on_emitter(deform_only, psmd,from,cpa->num,-1,cpa->fuv,co,0,0,0);
cpa->parent=find_nearest_in_kdtree(tree,co);
}
@@ -1637,7 +1637,7 @@
cpa_fuv = cpa->fuv;
cpa_from = PART_FROM_FACE;
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
+ psys_particle_on_emitter(deform_only, psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
VECCOPY(cpa_1st,orco);
@@ -2259,7 +2259,7 @@
MFace *mface;
int i;
//i = psys_particle_dm_face_lookup(dm, pa->num, pa->fuv, (LinkNode*)NULL, &pa->num_dmcache);
- i = pa->num_dmcache;
+ i = pa->num_dmcache==-1 ? pa->num : pa->num_dmcache;
if (i==-1) { vec[0] = vec[1] = 0; vec[2] = 1; return; }
mface=dm->getFaceData(dm,i,CD_MFACE);
@@ -2292,7 +2292,7 @@
/* replace with this */
MFace *mface;
int i; // = psys_particle_dm_face_lookup(dm, pa->num, pa->fuv, (LinkNode*)NULL);
- i = pa->num_dmcache;
+ i = pa->num_dmcache==-1 ? pa->num : pa->num_dmcache;
if (i==-1) { vec[0] = vec[1] = 0; vec[2] = 1; return; }
mface=dm->getFaceData(dm,i,CD_MFACE);
@@ -2318,7 +2318,7 @@
/* replace with this */
MFace *mface;
int i; // = psys_particle_dm_face_lookup(dm, pa->num, pa->fuv, (LinkNode*)NULL);
- i = pa->num_dmcache;
+ i = pa->num_dmcache==-1 ? pa->num : pa->num_dmcache;
if (i==-1) { Mat4One(mat); return; }
mface=dm->getFaceData(dm,i,CD_MFACE);
@@ -2762,6 +2762,7 @@
int totparent = 0;
int totpart = psys->totpart;
int totchild = psys->totchild;
+ int deform_only = modifiers_isDeformedOnly(ob);
short between = 0, edit = 0;
float *cpa_fuv; int cpa_num; short cpa_from;
@@ -2896,7 +2897,7 @@
cpa_fuv = cpa->fuv;
cpa_from = PART_FROM_FACE;
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
+ psys_particle_on_emitter(deform_only, psmd,cpa_from,cpa_num,-1,temp_fuv,orco,0,0,0);
/* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
VECCOPY(cpa_1st,orco);
Modified: branches/particles/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-11-04 05:31:20 UTC (rev 12468)
+++ branches/particles/source/blender/blenkernel/intern/particle_system.c 2007-11-04 15:23:26 UTC (rev 12469)
@@ -206,7 +206,17 @@
} else {
/* set the num_dmcache to an invalid value, just incase */
- /* TODO */
+ /* TODO PARTICLE, make the following line unnecessary, each function should know to use the num or num_dmcache */
+
+ /*
+ for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
+ pa->num_dmcache = pa->num;
+ }
+ */
+ for(p=0,pa=psys->particles; p<psys->totpart; p++,pa++) {
+ pa->num_dmcache = -1;
+ }
+
}
}
@@ -1158,7 +1168,7 @@
}
pa->loop=0;
- pa->num_dmcache = -1;
+ pa->num_dmcache = -1; /* assume we dont have a derived mesh face */
}
static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleSystemModifierData *psmd){
IpoCurve *icu=0;
@@ -1223,12 +1233,12 @@
}
/* sets particle to the emitter surface with initial velocity & rotation */
void reset_particle(ParticleData *pa, ParticleSystem *psys, ParticleSystemModifierData *psmd, Object *ob,
- float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot){
+ int deform_only, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot){
ParticleSettings *part;
ParticleTexture ptex;
ParticleKey state;
IpoCurve *icu=0;
- float fac, nor[3],loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],*q2=0;
+ float fac, nor[3]={0,0,0},loc[3],tloc[3],vel[3]={0.0,0.0,0.0},rot[4],*q2=0;
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};
@@ -1273,7 +1283,7 @@
where_is_object_time(ob,pa->time);
/* get birth location from object */
- psys_particle_on_emitter(modifiers_isDeformedOnly(ob), psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,loc,nor,utan,vtan);
+ psys_particle_on_emitter(deform_only, psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,loc,nor,utan,vtan);
/* save local coordinates for later */
VECCOPY(tloc,loc);
@@ -1447,13 +1457,13 @@
float *vg_vel=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_VEL);
float *vg_tan=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_TAN);
float *vg_rot=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_ROT);
- //int deform_only = modifiers_isDeformedOnly(ob); /* TODO PARTICLE - add later on */
+ int deform_only = modifiers_isDeformedOnly(ob);
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);
+ reset_particle(pa, psys, psmd, ob, deform_only, dtime, cfra, vg_vel, vg_tan, vg_rot);
if(vg_vel)
MEM_freeN(vg_vel);
@@ -2631,8 +2641,6 @@
int i, totface, intersect=0;
float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[4], min[3], max[3], p_min[3],p_max[3];
float cur_ipoint[3];
-
- int deform_only = modifiers_isDeformedOnly(ob); /* needed for psys_particle_on_dm */
if(dm==0){
psys_disable_all(ob);
@@ -3705,7 +3713,9 @@
/* frame & time changes */
float dfra, dtime, pa_dtime, pa_dfra=0.0;
float birthtime, dietime;
-
+
+ int deform_only = modifiers_isDeformedOnly(ob);
+
/* where have we gone in time since last time */
dfra= cfra - psys->cfra;
@@ -3740,7 +3750,7 @@
if(part->type==PART_REACTOR)
initialize_particle(pa,p,ob,psys,psmd);
- reset_particle(pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
+ reset_particle(pa,psys,psmd,ob,deform_only,dtime,cfra,vg_vel,vg_tan,vg_rot);
if(cfra>pa->time && part->flag & PART_LOOP && (part->flag & PART_LOOP_INSTANT)==0){
pa->loop=(short)((cfra-pa->time)/pa->lifetime)+1;
@@ -3813,7 +3823,7 @@
if(pa->alive==PARS_UNBORN || pa->alive==PARS_KILLED || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)){
/* allways reset particles to emitter before birth */
- reset_particle(pa,psys,psmd,ob,dtime,cfra,vg_vel,vg_tan,vg_rot);
+ reset_particle(pa,psys,psmd,ob,deform_only,dtime,cfra,vg_vel,vg_tan,vg_rot);
copy_particle_key(key,&pa->state,1);
}
@@ -3882,7 +3892,7 @@
pa->loop++;
if(part->flag & PART_LOOP_INSTANT){
- reset_particle(pa,psys,psmd,ob,0.0,cfra,vg_vel,vg_tan,vg_rot);
+ reset_particle(pa,psys,psmd,ob,deform_only,0.0,cfra,vg_vel,vg_tan,vg_rot);
pa->alive=PARS_ALIVE;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list