diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-09-23 13:10:31 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-09-24 13:57:59 +0300 |
commit | 969cbed49b027b8eb05f2f1606f684a6acf4b7af (patch) | |
tree | e639be8576471ea06a33ef8b7275310ff99a128d /source/blender/blenkernel/intern/effect.c | |
parent | 2721700b7ad07ca8de55f2d270dec3e64f4b12a6 (diff) |
Add support for a one-dimensional Force Field source shape.
The fields currently support a Point source and a two-dimensional
Plane source, but there is no way to create a field that pulls
toward or from a line in space other than using the Texture field
type. This adds a new simple shape option to do that.
The line is aligned along the Z axis so that it works meaningfully
with the Tube and Cone falloff modes.
Reviewers: brecht, mont29, LucaRood
Differential Revision: https://developer.blender.org/D3721
Diffstat (limited to 'source/blender/blenkernel/intern/effect.c')
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index a123b12d385..e6e138f8a43 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -544,7 +544,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU if (falloff == 0.0f) break; - r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point))); + r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point2))); falloff*= falloff_func_rad(eff->pd, r_fac); break; @@ -667,13 +667,13 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* use z-axis as normal*/ normalize_v3_v3(efd->nor, ob->obmat[2]); - if (eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { + if (eff->pd && ELEM(eff->pd->shape, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_LINE)) { float temp[3], translate[3]; sub_v3_v3v3(temp, point->loc, ob->obmat[3]); project_v3_v3v3(translate, temp, efd->nor); /* for vortex the shape chooses between old / new force */ - if (eff->pd->forcefield == PFIELD_VORTEX) + if (eff->pd->forcefield == PFIELD_VORTEX || eff->pd->shape == PFIELD_SHAPE_LINE) add_v3_v3v3(efd->loc, ob->obmat[3], translate); else /* normally efd->loc is closest point on effector xy-plane */ sub_v3_v3v3(efd->loc, point->loc, translate); @@ -900,7 +900,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected } break; case PFIELD_MAGNET: - if (eff->pd->shape == PFIELD_SHAPE_POINT) + if (ELEM(eff->pd->shape, PFIELD_SHAPE_POINT, PFIELD_SHAPE_LINE)) /* magnetic field of a moving charge */ cross_v3_v3v3(temp, efd->nor, efd->vec_to_point); else |