Particles

=========

- Bugfix: synchronize modifier enable with particle enable flag to
  prevent crash.
This commit is contained in:
Brecht Van Lommel 2007-11-27 12:34:59 +00:00
parent 2a743951fc
commit da3c35db47
3 changed files with 23 additions and 9 deletions

@ -5089,7 +5089,7 @@ static void particleSystemModifier_deformVerts(
ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md;
ParticleSystem * psys=0; ParticleSystem * psys=0;
int totvert=0,totedge=0,totface=0,needsFree=0; int totvert=0,totedge=0,totface=0,needsFree=0;
if(ob->particlesystem.first) if(ob->particlesystem.first)
psys=psmd->psys; psys=psmd->psys;
else else
@ -6759,9 +6759,10 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
mti = INIT_TYPE(ParticleSystem); mti = INIT_TYPE(ParticleSystem);
mti->type = eModifierTypeType_OnlyDeform; mti->type = eModifierTypeType_OnlyDeform;
mti->flags = eModifierTypeFlag_AcceptsMesh; mti->flags = eModifierTypeFlag_AcceptsMesh
| eModifierTypeFlag_SupportsMapping;
#if 0 #if 0
|eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_SupportsEditmode;
|eModifierTypeFlag_EnableInEditmode; |eModifierTypeFlag_EnableInEditmode;
#endif #endif
mti->initData = particleSystemModifier_initData; mti->initData = particleSystemModifier_initData;
@ -6850,9 +6851,8 @@ int modifier_supportsMapping(ModifierData *md)
{ {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
return ( (mti->flags & eModifierTypeFlag_SupportsEditmode) && return (mti->type==eModifierTypeType_OnlyDeform ||
( (mti->type==eModifierTypeType_OnlyDeform || (mti->flags & eModifierTypeFlag_SupportsMapping));
(mti->flags & eModifierTypeFlag_SupportsMapping))) );
} }
ModifierData *modifiers_findByType(Object *ob, ModifierType type) ModifierData *modifiers_findByType(Object *ob, ModifierType type)

@ -1755,11 +1755,13 @@ static int render_new_particle_system(Render *re, Object *ob, ParticleSystem *ps
return 1; return 1;
} }
psmd= psys_get_modifier(ob,psys);
if(!(psmd->modifier.mode & eModifierMode_Render))
return 0;
psys->flag|=PSYS_DRAWING; psys->flag|=PSYS_DRAWING;
BLI_srandom(psys->seed); BLI_srandom(psys->seed);
psmd= psys_get_modifier(ob,psys);
ma= give_render_material(re, ob, part->omat); ma= give_render_material(re, ob, part->omat);

@ -1609,6 +1609,16 @@ void modifiers_explodeFacepa(void *arg1, void *arg2)
emd->flag |= eExplodeFlag_CalcFaces; emd->flag |= eExplodeFlag_CalcFaces;
} }
static void modifiers_psysEnable(void *ob_v, void *md_v)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData*) md_v;
if(psmd->modifier.mode & eModifierMode_Realtime)
psmd->psys->flag |= PSYS_ENABLED;
else
psmd->psys->flag &= ~PSYS_ENABLED;
}
static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex) static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex)
{ {
ModifierTypeInfo *mti = modifierType_getInfo(md->type); ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@ -1647,7 +1657,9 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
/* Softbody not allowed in this situation, enforce! */ /* Softbody not allowed in this situation, enforce! */
if (md->type!=eModifierType_Softbody || !(ob->pd && ob->pd->deflect)) { if (md->type!=eModifierType_Softbody || !(ob->pd && ob->pd->deflect)) {
uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering"); uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display"); but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
if (md->type==eModifierType_ParticleSystem)
uiButSetFunc(but, modifiers_psysEnable, ob, md);
if (mti->flags&eModifierTypeFlag_SupportsEditmode) { if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, VICON_EDIT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)"); uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, VICON_EDIT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
} }