Merge branch 'master' into blender2.8

This commit is contained in:
2018-04-18 13:55:09 +02:00

View File

@@ -79,14 +79,14 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md; ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
ParticleSystem *psys; ParticleSystem *psys;
ModifierData *ob_md; ModifierData *ob_md;
if (!pimd->ob) if (!pimd->ob)
return true; return true;
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
if (psys == NULL) if (psys == NULL)
return true; return true;
/* If the psys modifier is disabled we cannot use its data. /* If the psys modifier is disabled we cannot use its data.
* First look up the psys modifier from the object, then check if it is enabled. * First look up the psys modifier from the object, then check if it is enabled.
*/ */
@@ -95,18 +95,18 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md; ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md;
if (psmd->psys == psys) { if (psmd->psys == psys) {
int required_mode; int required_mode;
if (useRenderParams) required_mode = eModifierMode_Render; if (useRenderParams) required_mode = eModifierMode_Render;
else required_mode = eModifierMode_Realtime; else required_mode = eModifierMode_Realtime;
if (!modifier_isEnabled(md->scene, ob_md, required_mode)) if (!modifier_isEnabled(md->scene, ob_md, required_mode))
return true; return true;
break; break;
} }
} }
} }
return false; return false;
} }
@@ -115,6 +115,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md;
if (pimd->ob != NULL) { if (pimd->ob != NULL) {
DEG_add_object_relation(ctx->node, pimd->ob, DEG_OB_COMP_TRANSFORM, "Particle Instance Modifier"); DEG_add_object_relation(ctx->node, pimd->ob, DEG_OB_COMP_TRANSFORM, "Particle Instance Modifier");
DEG_add_object_relation(ctx->node, pimd->ob, DEG_OB_COMP_GEOMETRY, "Particle Instance Modifier");
} }
} }
@@ -157,7 +158,7 @@ static int particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *psy
if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return 1; if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) return 1;
if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return 1; if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) return 1;
} }
return 0; return 0;
} }
@@ -273,7 +274,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
for (p = 0, p_skip = 0; p < totpart; p++) { for (p = 0, p_skip = 0; p < totpart; p++) {
float prev_dir[3]; float prev_dir[3];
float frame[4]; /* frame orientation quaternion */ float frame[4]; /* frame orientation quaternion */
/* skip particle? */ /* skip particle? */
if (particle_skip(pimd, psys, p)) if (particle_skip(pimd, psys, p))
continue; continue;
@@ -323,7 +324,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
if (k == 0) { if (k == 0) {
float hairmat[4][4]; float hairmat[4][4];
float mat[3][3]; float mat[3][3];
if (first_particle + p < psys->totpart) if (first_particle + p < psys->totpart)
pa = psys->particles + first_particle + p; pa = psys->particles + first_particle + p;
else { else {
@@ -334,7 +335,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
copy_m3_m4(mat, hairmat); copy_m3_m4(mat, hairmat);
/* to quaternion */ /* to quaternion */
mat3_to_quat(frame, mat); mat3_to_quat(frame, mat);
/* note: direction is same as normal vector currently, /* note: direction is same as normal vector currently,
* but best to keep this separate so the frame can be * but best to keep this separate so the frame can be
* rotated later if necessary * rotated later if necessary
@@ -343,14 +344,14 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
} }
else { else {
float rot[4]; float rot[4];
/* incrementally rotate along bend direction */ /* incrementally rotate along bend direction */
rotation_between_vecs_to_quat(rot, prev_dir, state.vel); rotation_between_vecs_to_quat(rot, prev_dir, state.vel);
mul_qt_qtqt(frame, rot, frame); mul_qt_qtqt(frame, rot, frame);
copy_v3_v3(prev_dir, state.vel); copy_v3_v3(prev_dir, state.vel);
} }
copy_qt_qt(state.rot, frame); copy_qt_qt(state.rot, frame);
#if 0 #if 0
/* Absolute Frame (Frenet Frame) */ /* Absolute Frame (Frenet Frame) */
@@ -361,9 +362,9 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Depsgraph *depsgraph,
float cross[3]; float cross[3];
float temp[3] = {0.0f, 0.0f, 0.0f}; float temp[3] = {0.0f, 0.0f, 0.0f};
temp[axis] = 1.0f; temp[axis] = 1.0f;
cross_v3_v3v3(cross, temp, state.vel); cross_v3_v3v3(cross, temp, state.vel);
/* state.vel[axis] is the only component surviving from a dot product with the axis */ /* state.vel[axis] is the only component surviving from a dot product with the axis */
axis_angle_to_quat(state.rot, cross, saacos(state.vel[axis])); axis_angle_to_quat(state.rot, cross, saacos(state.vel[axis]));
} }