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 = split.column()
|
||||||
col.label(text="Vertex Group:")
|
col.label(text="Vertex Group:")
|
||||||
col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
col.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
|
||||||
|
|
||||||
|
layout.separator()
|
||||||
|
layout.prop(md, "influence", slider=True)
|
||||||
|
|
||||||
def MASK(self, layout, ob, md):
|
def MASK(self, layout, ob, md):
|
||||||
split = layout.split()
|
split = layout.split()
|
||||||
|
@ -42,7 +42,7 @@ extern "C" {
|
|||||||
* and keep comment above the defines.
|
* and keep comment above the defines.
|
||||||
* Use STRINGIFY() rather than defining with quotes */
|
* Use STRINGIFY() rather than defining with quotes */
|
||||||
#define BLENDER_VERSION 262
|
#define BLENDER_VERSION 262
|
||||||
#define BLENDER_SUBVERSION 2
|
#define BLENDER_SUBVERSION 3
|
||||||
|
|
||||||
#define BLENDER_MINVERSION 250
|
#define BLENDER_MINVERSION 250
|
||||||
#define BLENDER_MINSUBVERSION 0
|
#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,
|
void lattice_deform_verts(struct Object *laOb, struct Object *target,
|
||||||
struct DerivedMesh *dm, float (*vertexCos)[3],
|
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,
|
void armature_deform_verts(struct Object *armOb, struct Object *target,
|
||||||
struct DerivedMesh *dm, float (*vertexCos)[3],
|
struct DerivedMesh *dm, float (*vertexCos)[3],
|
||||||
float (*defMats)[3][3], int numVerts, int deformflag,
|
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);
|
copy_m4_m4(mat, ltOb->obmat);
|
||||||
unit_m4(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);
|
copy_m4_m4(ltOb->obmat, mat);
|
||||||
|
|
||||||
lt->typeu = typeu;
|
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,
|
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 a;
|
||||||
int use_vgroups;
|
int use_vgroups;
|
||||||
@ -824,13 +824,13 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
|
|||||||
weight= defvert_find_weight(dvert, index);
|
weight= defvert_find_weight(dvert, index);
|
||||||
|
|
||||||
if (weight > 0.0f)
|
if (weight > 0.0f)
|
||||||
calc_latt_deform(laOb, vertexCos[a], weight);
|
calc_latt_deform(laOb, vertexCos[a], weight*influence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (a = 0; a < numVerts; a++) {
|
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);
|
end_latt_deform(laOb);
|
||||||
@ -843,7 +843,7 @@ int object_deform_mball(Object *ob, ListBase *dispbase)
|
|||||||
|
|
||||||
for (dl=dispbase->first; dl; dl=dl->next) {
|
for (dl=dispbase->first; dl; dl=dl->next) {
|
||||||
lattice_deform_verts(ob->parent, ob, NULL,
|
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;
|
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 */
|
/* Default for old files is to save particle rotations to pointcache */
|
||||||
|
@ -135,6 +135,8 @@ typedef struct LatticeModifierData {
|
|||||||
|
|
||||||
struct Object *object;
|
struct Object *object;
|
||||||
char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */
|
char name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */
|
||||||
|
float influence;
|
||||||
|
char pad[4];
|
||||||
} LatticeModifierData;
|
} LatticeModifierData;
|
||||||
|
|
||||||
typedef struct CurveModifierData {
|
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");
|
"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_string_funcs(prop, NULL, NULL, "rna_LatticeModifier_vgroup_set");
|
||||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
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)
|
static void rna_def_modifier_curve(BlenderRNA *brna)
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
|
|
||||||
|
|
||||||
#include "BKE_cdderivedmesh.h"
|
#include "BKE_cdderivedmesh.h"
|
||||||
#include "BKE_lattice.h"
|
#include "BKE_lattice.h"
|
||||||
#include "BKE_modifier.h"
|
#include "BKE_modifier.h"
|
||||||
@ -49,6 +48,11 @@
|
|||||||
|
|
||||||
#include "MOD_util.h"
|
#include "MOD_util.h"
|
||||||
|
|
||||||
|
static void initData(ModifierData *md)
|
||||||
|
{
|
||||||
|
LatticeModifierData *lmd = (LatticeModifierData*) md;
|
||||||
|
lmd->influence = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
static void copyData(ModifierData *md, ModifierData *target)
|
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 */
|
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
|
||||||
|
|
||||||
lattice_deform_verts(lmd->object, ob, derivedData,
|
lattice_deform_verts(lmd->object, ob, derivedData,
|
||||||
vertexCos, numVerts, lmd->name);
|
vertexCos, numVerts, lmd->name, lmd->influence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deformVertsEM(
|
static void deformVertsEM(
|
||||||
@ -146,7 +150,7 @@ ModifierTypeInfo modifierType_Lattice = {
|
|||||||
/* deformMatricesEM */ NULL,
|
/* deformMatricesEM */ NULL,
|
||||||
/* applyModifier */ NULL,
|
/* applyModifier */ NULL,
|
||||||
/* applyModifierEM */ NULL,
|
/* applyModifierEM */ NULL,
|
||||||
/* initData */ NULL,
|
/* initData */ initData,
|
||||||
/* requiredDataMask */ requiredDataMask,
|
/* requiredDataMask */ requiredDataMask,
|
||||||
/* freeData */ NULL,
|
/* freeData */ NULL,
|
||||||
/* isDisabled */ isDisabled,
|
/* isDisabled */ isDisabled,
|
||||||
|
Loading…
Reference in New Issue
Block a user