Particles
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 27 Nov 2007 11:17:52 +0000 (11:17 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 27 Nov 2007 11:17:52 +0000 (11:17 +0000)
=========

- Fix for bug #7840: adding particle system to nurbs, curves crashes.
  Now simply doesn't allow to add a particle system to a non-mesh
  object, the current code does not support it.
- Fix for bug #7834: deleting vertices of an object with a particle
  system crashes. Fixed by disabling particle display for objects in
  editmode.
- Fix for the particle add brush on subsurfed objects.

source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/src/buttons_object.c
source/blender/src/drawobject.c
source/blender/src/editparticle.c

index 9336dde01510fb256397c7725ee09486f24ca238..25dded40352465a86fa06e455252909e29787599 100644 (file)
@@ -5164,8 +5164,6 @@ static void particleSystemModifier_deformVerts(
                if(psmd->flag & eParticleSystemFlag_Loaded)
                        psmd->flag &= ~eParticleSystemFlag_Loaded;
                else{
-                       /* TODO PARTICLE - Added this so changing subsurf under hair updates it
-                       should it be done elsewhere? - Campbell */
                        psys->recalc |= PSYS_RECALC_HAIR;
                        psys->recalc |= PSYS_DISTR;
                        psmd->flag |= eParticleSystemFlag_DM_changed;
@@ -5179,6 +5177,9 @@ static void particleSystemModifier_deformVerts(
        }
 }
 
+/* disabled particles in editmode for now, until support for proper derivedmesh
+ * updates is coded */
+#if 0
 static void particleSystemModifier_deformVertsEM(
                 ModifierData *md, Object *ob, EditMesh *editData,
                 DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
@@ -5191,6 +5192,7 @@ static void particleSystemModifier_deformVertsEM(
 
        if(!derivedData) dm->release(dm);
 }
+#endif
 
 /* Particle Instance */
 static void particleInstanceModifier_initData(ModifierData *md) 
@@ -6757,14 +6759,18 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
 
                mti = INIT_TYPE(ParticleSystem);
                mti->type = eModifierTypeType_OnlyDeform;
-               mti->flags = eModifierTypeFlag_AcceptsMesh
+               mti->flags = eModifierTypeFlag_AcceptsMesh;
+#if 0
                                        |eModifierTypeFlag_SupportsEditmode
                                        |eModifierTypeFlag_EnableInEditmode;
+#endif
                mti->initData = particleSystemModifier_initData;
                mti->freeData = particleSystemModifier_freeData;
                mti->copyData = particleSystemModifier_copyData;
                mti->deformVerts = particleSystemModifier_deformVerts;
+#if 0
                mti->deformVertsEM = particleSystemModifier_deformVertsEM;
+#endif
                mti->requiredDataMask = particleSystemModifier_requiredDataMask;
 
                mti = INIT_TYPE(ParticleInstance);
index c0de1901f69206ba691aad99ec50d957ae4a2930..4db6adce6f272d7d9844c5cd13f6447d4d3cac11 100644 (file)
@@ -583,7 +583,7 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float *
        if(osface==NULL || origindex==NULL) {
                /* Assume we dont need osface data */
                if (index <totface) {
-                       printf("\tNO CD_ORIGSPACE, assuming not needed\n");
+                       //printf("\tNO CD_ORIGSPACE, assuming not needed\n");
                        return index;
                } else {
                        printf("\tNO CD_ORIGSPACE, error out of range\n");
@@ -645,7 +645,7 @@ void psys_particle_on_dm(Object *ob, DerivedMesh *dm, int from, int index, int i
                /* this works for meshes with deform verts only - constructive modifiers wont work properly*/
                float temp1[3];
 
-               if(index_dmcache == DMCACHE_ISCHILD && index >= dm->getNumFaces(dm)) {
+               if(index >= dm->getNumFaces(dm)) {
                        PARTICLE_ERROR(nor, vec);
                        return;
                }
index b0c75ea6ab06e24e6f61d0bc45d3679a23544e56..5d3a4332b5da96194783bd50fde1e280b595b669 100644 (file)
@@ -4006,7 +4006,7 @@ 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);
        }
index 455b41d3f0ec5d50687a254fbef041cf15e3172d..3a3d653fdf2fcfb86713c2af138248ab5dc37d46 100644 (file)
@@ -4656,7 +4656,7 @@ void particle_panels()
 
        ob=OBACT;
 
-       if(ob) {
+       if(ob && ob->type==OB_MESH) {
                object_panel_particle_system(ob);
 
                psys=psys_get_current(ob);
index 737b118a40b23bce811f184934543e242e773c53..52a8f9a34efb6771731d867225a1c05bb422e1f6 100644 (file)
@@ -5038,7 +5038,7 @@ void draw_object(Base *base, int flag)
        if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
 
        /* code for new particle system */
-       if(warning_recursive==0 && (flag & DRAW_PICKING)==0){
+       if(warning_recursive==0 && (flag & DRAW_PICKING)==0 && ob!=G.obedit){
                glDepthMask(GL_FALSE);
                if(col || (ob->flag & SELECT)) cpack(0xFFFFFF); /* for visibility, also while wpaint */
                if(ob->particlesystem.first) {
index cdd122a9ae1c47e214c6d4e8538595ce1db44fbe..08f90e31f67cbff9bb74f0fc5d2f68a5ab921304 100644 (file)
@@ -2134,7 +2134,7 @@ static void brush_add(Object *ob, ParticleSystem *psys, short *mval, short numbe
                /* warning, returns the derived mesh face */
 #if EXPERIMENTAL_DEFORM_ONLY_PAINTING
                if(psys_intersect_dm(ob,dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)) {
-                       add_pars[n].num_dmcache= psys_particle_dm_face_lookup(ob,dm,add_pars[n].num,add_pars[n].fuv,NULL);
+                       add_pars[n].num_dmcache= psys_particle_dm_face_lookup(ob,psmd->dm,add_pars[n].num,add_pars[n].fuv,NULL);
                        n++;
                }
 #else