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
This commit is contained in:
parent
2721700b7a
commit
969cbed49b
Notes:
blender-bot
2023-02-14 05:16:31 +01:00
Referenced by issue #56899, MeshDeform can't bind (Cannot get mesh from cage object)
|
@ -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
|
||||
|
|
|
@ -348,6 +348,7 @@ typedef struct SoftBody {
|
|||
#define PFIELD_SHAPE_PLANE 1
|
||||
#define PFIELD_SHAPE_SURFACE 2
|
||||
#define PFIELD_SHAPE_POINTS 3
|
||||
#define PFIELD_SHAPE_LINE 4
|
||||
|
||||
/* pd->tex_mode */
|
||||
#define PFIELD_TEX_RGB 0
|
||||
|
|
|
@ -42,10 +42,11 @@
|
|||
#include "WM_types.h"
|
||||
|
||||
static const EnumPropertyItem effector_shape_items[] = {
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
|
||||
{PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", ""},
|
||||
{PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", ""},
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
|
||||
{PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"},
|
||||
{PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", "Field originates from the surface of the object"},
|
||||
{PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", "Field originates from all of the vertices of the object"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -56,15 +57,17 @@ static const EnumPropertyItem effector_shape_items[] = {
|
|||
|
||||
/* type specific return values only used from functions */
|
||||
static const EnumPropertyItem curve_shape_items[] = {
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
|
||||
{PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", ""},
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
|
||||
{PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"},
|
||||
{PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", "Field originates from the curve itself"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static const EnumPropertyItem empty_shape_items[] = {
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
|
||||
{PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
|
||||
{PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
|
||||
{PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", "Field originates from the local XY plane of the object"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue