forked from bartvdbraak/blender
Patch: [#30652] Influence slider for Lattice Modifier
* This patch adds a influence slider for the lattice modifier, which affects the strength of the deformation. Patch by Patrick Boelens (senshi), thanks a lot!
This commit is contained in:
parent
c379b78d8a
commit
aede928bdc
@ -318,6 +318,9 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
col = split.column()
|
||||
col.label(text="Vertex Group:")
|
||||
col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||
|
||||
layout.separator()
|
||||
layout.prop(md, "influence", slider=True)
|
||||
|
||||
def MASK(self, layout, ob, md):
|
||||
split = layout.split()
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
||||
* and keep comment above the defines.
|
||||
* Use STRINGIFY() rather than defining with quotes */
|
||||
#define BLENDER_VERSION 262
|
||||
#define BLENDER_SUBVERSION 2
|
||||
#define BLENDER_SUBVERSION 3
|
||||
|
||||
#define BLENDER_MINVERSION 250
|
||||
#define BLENDER_MINSUBVERSION 0
|
||||
|
@ -63,7 +63,7 @@ void curve_deform_vector(struct Scene *scene, struct Object *cuOb, struct Object
|
||||
|
||||
void lattice_deform_verts(struct Object *laOb, struct Object *target,
|
||||
struct DerivedMesh *dm, float (*vertexCos)[3],
|
||||
int numVerts, const char *vgroup);
|
||||
int numVerts, const char *vgroup, float influence);
|
||||
void armature_deform_verts(struct Object *armOb, struct Object *target,
|
||||
struct DerivedMesh *dm, float (*vertexCos)[3],
|
||||
float (*defMats)[3][3], int numVerts, int deformflag,
|
||||
|
@ -153,7 +153,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
||||
|
||||
copy_m4_m4(mat, ltOb->obmat);
|
||||
unit_m4(ltOb->obmat);
|
||||
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL);
|
||||
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL, 1.0f);
|
||||
copy_m4_m4(ltOb->obmat, mat);
|
||||
|
||||
lt->typeu = typeu;
|
||||
@ -785,7 +785,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target,
|
||||
}
|
||||
|
||||
void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
|
||||
float (*vertexCos)[3], int numVerts, const char *vgroup)
|
||||
float (*vertexCos)[3], int numVerts, const char *vgroup, float influence)
|
||||
{
|
||||
int a;
|
||||
int use_vgroups;
|
||||
@ -824,13 +824,13 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
|
||||
weight= defvert_find_weight(dvert, index);
|
||||
|
||||
if (weight > 0.0f)
|
||||
calc_latt_deform(laOb, vertexCos[a], weight);
|
||||
calc_latt_deform(laOb, vertexCos[a], weight*influence);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (a = 0; a < numVerts; a++) {
|
||||
calc_latt_deform(laOb, vertexCos[a], 1.0f);
|
||||
calc_latt_deform(laOb, vertexCos[a], influence);
|
||||
}
|
||||
}
|
||||
end_latt_deform(laOb);
|
||||
@ -843,7 +843,7 @@ int object_deform_mball(Object *ob, ListBase *dispbase)
|
||||
|
||||
for (dl=dispbase->first; dl; dl=dl->next) {
|
||||
lattice_deform_verts(ob->parent, ob, NULL,
|
||||
(float(*)[3]) dl->verts, dl->nr, NULL);
|
||||
(float(*)[3]) dl->verts, dl->nr, NULL, 1.0f);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -13329,6 +13329,22 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 3))
|
||||
{
|
||||
Object *ob;
|
||||
ModifierData *md;
|
||||
|
||||
for(ob = main->object.first; ob; ob = ob->id.next) {
|
||||
for(md=ob->modifiers.first; md; md=md->next) {
|
||||
if(md->type == eModifierType_Lattice) {
|
||||
LatticeModifierData *lmd = (LatticeModifierData *)md;
|
||||
lmd->influence = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
/* Default for old files is to save particle rotations to pointcache */
|
||||
|
@ -135,6 +135,8 @@ typedef struct LatticeModifierData {
|
||||
|
||||
struct Object *object;
|
||||
char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */
|
||||
float influence;
|
||||
char pad[4];
|
||||
} LatticeModifierData;
|
||||
|
||||
typedef struct CurveModifierData {
|
||||
|
@ -960,6 +960,12 @@ static void rna_def_modifier_lattice(BlenderRNA *brna)
|
||||
"Name of Vertex Group which determines influence of modifier per point");
|
||||
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LatticeModifier_vgroup_set");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0, 1, 10, 2);
|
||||
RNA_def_property_ui_text(prop, "Influence", "Strength of modifier effect");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
static void rna_def_modifier_curve(BlenderRNA *brna)
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_lattice.h"
|
||||
#include "BKE_modifier.h"
|
||||
@ -49,6 +48,11 @@
|
||||
|
||||
#include "MOD_util.h"
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
{
|
||||
LatticeModifierData *lmd = (LatticeModifierData*) md;
|
||||
lmd->influence = 1.0f;
|
||||
}
|
||||
|
||||
static void copyData(ModifierData *md, ModifierData *target)
|
||||
{
|
||||
@ -115,7 +119,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
|
||||
|
||||
lattice_deform_verts(lmd->object, ob, derivedData,
|
||||
vertexCos, numVerts, lmd->name);
|
||||
vertexCos, numVerts, lmd->name, lmd->influence);
|
||||
}
|
||||
|
||||
static void deformVertsEM(
|
||||
@ -146,7 +150,7 @@ ModifierTypeInfo modifierType_Lattice = {
|
||||
/* deformMatricesEM */ NULL,
|
||||
/* applyModifier */ NULL,
|
||||
/* applyModifierEM */ NULL,
|
||||
/* initData */ NULL,
|
||||
/* initData */ initData,
|
||||
/* requiredDataMask */ requiredDataMask,
|
||||
/* freeData */ NULL,
|
||||
/* isDisabled */ isDisabled,
|
||||
|
Loading…
Reference in New Issue
Block a user