From 969cbed49b027b8eb05f2f1606f684a6acf4b7af Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sun, 23 Sep 2018 13:10:31 +0300 Subject: 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 --- source/blender/blenkernel/intern/effect.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/effect.c') 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 -- cgit v1.2.3