Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h4
-rw-r--r--source/blender/blenkernel/BKE_modifier.h6
-rw-r--r--source/blender/blenkernel/BKE_multires.h1
-rw-r--r--source/blender/blenkernel/BKE_paint.h9
-rw-r--r--source/blender/blenkernel/BKE_subsurf.h1
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c81
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c12
-rw-r--r--source/blender/blenkernel/intern/multires.c16
-rw-r--r--source/blender/blenkernel/intern/object.c7
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c62
-rw-r--r--source/blender/blenlib/BLI_pbvh.h2
-rw-r--r--source/blender/blenlib/intern/math_matrix.c14
-rw-r--r--source/blender/blenlib/intern/pbvh.c20
-rw-r--r--source/blender/editors/include/ED_sculpt.h1
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c204
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c33
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c15
-rw-r--r--source/blender/modifiers/intern/MOD_array.c1
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c1
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c1
-rw-r--r--source/blender/modifiers/intern/MOD_build.c1
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c1
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c1
-rw-r--r--source/blender/modifiers/intern/MOD_collision.c1
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c1
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c1
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c1
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c1
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c1
-rw-r--r--source/blender/modifiers/intern/MOD_fluidsim.c1
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c1
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c1
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c1
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c1
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c1
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c1
-rw-r--r--source/blender/modifiers/intern/MOD_none.c1
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c1
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c1
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c1
-rw-r--r--source/blender/modifiers/intern/MOD_shapekey.c25
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c1
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c1
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c1
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c1
-rw-r--r--source/blender/modifiers/intern/MOD_softbody.c1
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c1
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c1
-rw-r--r--source/blender/modifiers/intern/MOD_surface.c1
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c1
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c1
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c1
53 files changed, 408 insertions, 143 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 5ce6c522e90..48127d3cf4c 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -508,6 +508,10 @@ void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct EditMesh *em
int editmesh_get_first_deform_matrices(struct Scene *, struct Object *, struct EditMesh *em,
float (**deformmats)[3][3], float (**deformcos)[3]);
+/* returns an array of deform matrices for crazyspace correction when sculpting */
+void sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob,
+ float (**deformmats)[3][3], float (**deformcos)[3]);
+
void weight_to_rgb(float input, float *fr, float *fg, float *fb);
/* convert layers requested by a GLSL material to actually available layers in
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 97bef6ab565..5bef7527c87 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -134,6 +134,12 @@ typedef struct ModifierTypeInfo {
float (*vertexCos)[3], int numVerts,
int useRenderParams, int isFinalCalc);
+ /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */
+ void (*deformMatrices)(
+ struct ModifierData *md, struct Object *ob,
+ struct DerivedMesh *derivedData,
+ float (*vertexCos)[3], float (*defMats)[3][3], int numVerts);
+
/* Like deformVerts but called during editmode (for supporting modifiers)
*/
void (*deformVertsEM)(
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 5cafd24c1fd..23fabce68ba 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -53,6 +53,7 @@ struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*
struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene,
struct ModifierData *lastmd);
+struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, int use_first);
struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd,
struct Object *ob);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 20742033a2e..2203277b301 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -78,8 +78,11 @@ typedef struct SculptSession {
/* PBVH acceleration structure */
struct PBVH *pbvh;
- /* Used temporarily per-stroke */
- float *vertexcosnos;
+ /* Paiting on deformed mesh */
+ int modifiers_active; /* object is deformed with some modifiers */
+ float (*orig_cos)[3]; /* coords of undeformed mesh */
+ float (*deform_cos)[3]; /* coords of deformed mesh but without stroke displacement */
+ float (*deform_imats)[3][3]; /* crazyspace deformation matricies */
/* Partial redraw */
int partial_redraw;
@@ -95,8 +98,6 @@ typedef struct SculptSession {
struct GPUDrawObject *drawobject;
- int modifiers_active;
-
rcti previous_r;
} SculptSession;
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index 940a0027d0b..ef3ad3ad2e9 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -72,7 +72,6 @@ typedef struct CCGDerivedMesh {
char *faceFlags;
struct PBVH *pbvh;
- int pbvh_draw;
struct ListBase *fmap;
struct IndexNode *fmap_mem;
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index a2ef625c6e6..658d29f0046 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -53,6 +53,7 @@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_texture.h"
+#include "BKE_multires.h"
#include "BLO_sys_types.h" // for intptr_t support
@@ -65,6 +66,8 @@
#include "GPU_extensions.h"
#include "GPU_material.h"
+#include "ED_sculpt.h" /* for ED_sculpt_modifiers_changed */
+
///////////////////////////////////
///////////////////////////////////
@@ -1676,6 +1679,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
int required_mode;
int isPrevDeform= FALSE;
int skipVirtualArmature = (useDeform < 0);
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
+ int has_multires = mmd != NULL, multires_applied = 0;
+ int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
+
+ if(mmd && !mmd->sculptlvl)
+ has_multires = 0;
if(!skipVirtualArmature) {
firstmd = modifiers_getVirtualModifierList(ob);
@@ -1714,6 +1723,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
if(mti->type == eModifierTypeType_OnlyDeform) {
+ if(sculpt_mode && !has_multires)
+ if(!ELEM(md->type, eModifierType_Armature, eModifierType_ShapeKey)) {
+ modifier_setError(md, "Not supported in sculpt mode.");
+ continue;
+ }
+
if(!deformedVerts)
deformedVerts = mesh_getVertexCos(me, &numVerts);
@@ -1759,13 +1774,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
md->scene= scene;
-
+
if(!modifier_isEnabled(scene, md, required_mode)) continue;
if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue;
if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) {
modifier_setError(md, "Modifier requires original data, bad stack position.");
continue;
}
+ if(sculpt_mode && (!has_multires || multires_applied))
+ if(md->type != eModifierType_Armature || multires_applied) {
+ modifier_setError(md, "Not supported in sculpt mode.");
+ continue;
+ }
if(needMapping && !modifier_supportsMapping(md)) continue;
if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
@@ -1928,6 +1948,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
/* grab modifiers until index i */
if((index >= 0) && (modifiers_indexInObject(ob, md) >= index))
break;
+
+ if(sculpt_mode && md->type == eModifierType_Multires)
+ multires_applied = 1;
}
for(md=firstmd; md; md=md->next)
@@ -2222,14 +2245,9 @@ static void clear_mesh_caches(Object *ob)
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform= NULL;
}
- /* we free pbvh on changes, except during sculpt since it can't deal with
- changing PVBH node organization, we hope topology does not change in
- the meantime .. weak */
- if(ob->sculpt && ob->sculpt->pbvh) {
- if(!ob->sculpt->cache) {
- BLI_pbvh_free(ob->sculpt->pbvh);
- ob->sculpt->pbvh= NULL;
- }
+
+ if(ob->sculpt) {
+ ED_sculpt_modifiers_changed(ob);
}
}
@@ -2523,6 +2541,51 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f
return numleft;
}
+void sculpt_get_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
+{
+ ModifierData *md;
+ DerivedMesh *dm;
+ int a, numVerts= 0;
+ float (*defmats)[3][3]= NULL, (*deformedVerts)[3]= NULL;
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
+ int has_multires = mmd != NULL && mmd->sculptlvl > 0;
+
+ if(has_multires) {
+ *deformmats= NULL;
+ *deformcos= NULL;
+ return;
+ }
+
+ dm= NULL;
+ md= modifiers_getVirtualModifierList(ob);
+
+ for(; md; md= md->next) {
+ ModifierTypeInfo *mti= modifierType_getInfo(md->type);
+
+ if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
+
+ if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatrices) {
+ if(!defmats) {
+ Mesh *me= (Mesh*)ob->data;
+ dm= getMeshDerivedMesh(me, ob, NULL);
+ deformedVerts= mesh_getVertexCos(me, &numVerts);
+ defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
+
+ for(a=0; a<numVerts; a++)
+ unit_m3(defmats[a]);
+ }
+
+ mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts);
+ }
+ }
+
+ if(dm)
+ dm->release(dm);
+
+ *deformmats= defmats;
+ *deformcos= deformedVerts;
+}
+
/* ******************* GLSL ******************** */
void DM_add_tangent_layer(DerivedMesh *dm)
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 71e704fe6c8..932be711938 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -76,6 +76,7 @@ typedef struct {
/* Cached */
struct PBVH *pbvh;
int pbvh_draw;
+
/* Mesh connectivity */
struct ListBase *fmap;
struct IndexNode *fmap_mem;
@@ -222,6 +223,17 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
cddm->pbvh_draw = can_pbvh_draw(ob, dm);
BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert,
me->totface, me->totvert);
+
+ if(ob->sculpt->modifiers_active) {
+ float (*vertCos)[3];
+ int totvert;
+
+ totvert= dm->getNumVerts(dm);
+ vertCos= MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos");
+ dm->getVertCos(dm, vertCos);
+ BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos);
+ MEM_freeN(vertCos);
+ }
}
return cddm->pbvh;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index c67abc47e6f..2a3052d10c9 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -92,8 +92,10 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData *
return NULL;
}
-/* used for applying scale on mdisps layer and syncing subdivide levels when joining objects */
-static MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob)
+/* used for applying scale on mdisps layer and syncing subdivide levels when joining objects
+ use_first - return first multires modifier if all multires'es are disabled
+*/
+MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first)
{
ModifierData *md;
MultiresModifierData *mmd= NULL, *firstmmd= NULL;
@@ -111,7 +113,7 @@ static MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob)
}
}
- if(!mmd) {
+ if(!mmd && use_first) {
/* active multires have not been found
try to use first one */
return firstmmd;
@@ -1568,8 +1570,8 @@ void multires_load_old(Object *ob, Mesh *me)
static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
{
- MultiresModifierData *mmd= get_multires_modifier(scene, ob);
- MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob);
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
+ MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1);
if(!mmd) {
/* object could have MDISP even when there is no multires modifier
@@ -1599,7 +1601,7 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
int *gridOffset;
int i, /*numGrids,*/ gridSize, dGridSize, dSkip, totvert;
float (*vertCos)[3] = NULL;
- MultiresModifierData *mmd= get_multires_modifier(scene, ob);
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
MultiresModifierData high_mmd;
CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
@@ -1725,7 +1727,7 @@ void multires_topology_changed(Scene *scene, Object *ob)
Mesh *me= (Mesh*)ob->data;
MDisps *mdisp= NULL, *cur= NULL;
int i, grid= 0, corners;
- MultiresModifierData *mmd= get_multires_modifier(scene, ob);
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
if(mmd)
multires_set_tot_mdisps(me, mmd->totlvl);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 9df55b825b7..0d3fb7107f0 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -246,6 +246,13 @@ void free_sculptsession(Object *ob)
if(ss->layer_co)
MEM_freeN(ss->layer_co);
+ if(ss->orig_cos)
+ MEM_freeN(ss->orig_cos);
+ if(ss->deform_cos)
+ MEM_freeN(ss->deform_cos);
+ if(ss->deform_imats)
+ MEM_freeN(ss->deform_imats);
+
MEM_freeN(ss);
ob->sculpt = NULL;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index e75dc27c7b5..a2d3016099d 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -70,8 +70,6 @@ static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v);
static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e);
static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f);
-static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm);
-
///
static void *arena_alloc(CCGAllocatorHDL a, int numBytes) {
@@ -1150,7 +1148,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) {
static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm)
{
- if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) {
+ if(ccgdm->pbvh) {
CCGFace **faces;
int totface;
@@ -2240,28 +2238,10 @@ static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm)
return ccgdm->fmap;
}
-static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm)
-{
- ModifierData *md;
- MultiresModifierData *mmd= ccgdm->multires.mmd;
-
- /* in sync with sculpt mode, only use multires grid pbvh if we are
- the last enabled modifier in the stack, otherwise we use the base
- mesh */
- if(!mmd)
- return 0;
-
- for(md=mmd->modifier.next; md; md= md->next)
- if(modifier_isEnabled(mmd->modifier.scene, md, eModifierMode_Realtime))
- return 0;
-
- return 1;
-}
-
static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
- int gridSize, numGrids, grid_pbvh;
+ int gridSize, numGrids;
if(!ob) {
ccgdm->pbvh= NULL;
@@ -2271,21 +2251,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
if(!ob->sculpt)
return NULL;
- grid_pbvh = ccgDM_use_grid_pbvh(ccgdm);
-
- if(ob->sculpt->pbvh) {
- if(grid_pbvh) {
- /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm
- but this can be freed on ccgdm release, this updates the pointers
- when the ccgdm gets remade, the assumption is that the topology
- does not change. */
- ccgdm_create_grids(dm);
- BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces);
- }
-
+ if(ob->sculpt->pbvh)
ccgdm->pbvh = ob->sculpt->pbvh;
- ccgdm->pbvh_draw = grid_pbvh;
- }
if(ccgdm->pbvh)
return ccgdm->pbvh;
@@ -2293,25 +2260,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
/* no pbvh exists yet, we need to create one. only in case of multires
we build a pbvh over the modified mesh, in other cases the base mesh
is being sculpted, so we build a pbvh from that. */
- if(grid_pbvh) {
- ccgdm_create_grids(dm);
-
- gridSize = ccgDM_getGridSize(dm);
- numGrids = ccgDM_getNumGrids(dm);
+ ccgdm_create_grids(dm);
- ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
- BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
- numGrids, gridSize, (void**)ccgdm->gridFaces);
- ccgdm->pbvh_draw = 1;
- }
- else if(ob->type == OB_MESH) {
- Mesh *me= ob->data;
+ gridSize = ccgDM_getGridSize(dm);
+ numGrids = ccgDM_getNumGrids(dm);
- ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
- BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert,
- me->totface, me->totvert);
- ccgdm->pbvh_draw = 0;
- }
+ ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new();
+ BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
+ numGrids, gridSize, (void**)ccgdm->gridFaces);
return ccgdm->pbvh;
}
diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h
index 4797aeb2364..f89068c885e 100644
--- a/source/blender/blenlib/BLI_pbvh.h
+++ b/source/blender/blenlib/BLI_pbvh.h
@@ -118,8 +118,6 @@ float BLI_pbvh_node_get_tmin(PBVHNode* node);
void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]);
void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]);
void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface);
-void BLI_pbvh_grids_update(PBVH *bvh, struct DMGridData **grids,
- struct DMGridAdjacency *gridadj, void **gridfaces);
/* vertex deformer */
float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3];
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 77ef825ee34..75134358c31 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -109,6 +109,20 @@ void copy_m4_m3(float m1[][4], float m2[][3]) /* no clear */
}
+void swap_m3m3(float m1[][3], float m2[][3])
+{
+ float t;
+ int i, j;
+
+ for(i = 0; i < 3; i++) {
+ for (j = 0; j < 3; j++) {
+ t = m1[i][j];
+ m1[i][j] = m2[i][j];
+ m2[i][j] = t;
+ }
+ }
+}
+
void swap_m4m4(float m1[][4], float m2[][4])
{
float t;
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 8727fab7086..9be42f9f5fc 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -1475,13 +1475,6 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], int smo
}
}
-void BLI_pbvh_grids_update(PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, void **gridfaces)
-{
- bvh->grids= grids;
- bvh->gridadj= gridadj;
- bvh->gridfaces= gridfaces;
-}
-
float (*BLI_pbvh_get_vertCos(PBVH *pbvh))[3]
{
int a;
@@ -1520,13 +1513,22 @@ void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3])
}
if (pbvh->verts) {
+ MVert *mvert= pbvh->verts;
/* copy new verts coords */
- for (a= 0; a < pbvh->totvert; ++a) {
- copy_v3_v3(pbvh->verts[a].co, vertCos[a]);
+ for (a= 0; a < pbvh->totvert; ++a, ++mvert) {
+ copy_v3_v3(mvert->co, vertCos[a]);
+ mvert->flag |= ME_VERT_PBVH_UPDATE;
}
/* coordinates are new -- normals should also be updated */
mesh_calc_normals(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL);
+
+ for (a= 0; a < pbvh->totnode; ++a)
+ BLI_pbvh_node_mark_update(&pbvh->nodes[a]);
+
+ BLI_pbvh_update(pbvh, PBVH_UpdateBB, NULL);
+ BLI_pbvh_update(pbvh, PBVH_UpdateOriginalBB, NULL);
+
}
}
diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index f46ab37823b..cac6a1a2d13 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -40,6 +40,7 @@ void ED_operatortypes_sculpt(void);
void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
struct RegionView3D *rv3d, struct Object *ob);
void ED_sculpt_force_update(struct bContext *C);
+void ED_sculpt_modifiers_changed(struct Object *ob);
/* paint_ops.c */
void ED_operatortypes_paint(void);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 58398bd1f5c..01f280f6572 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -58,6 +58,7 @@
#include "BKE_multires.h"
#include "BKE_paint.h"
#include "BKE_report.h"
+#include "BKE_lattice.h" /* for armature_deform_verts */
#include "BIF_glutil.h"
@@ -91,12 +92,29 @@ void ED_sculpt_force_update(bContext *C)
multires_force_update(ob);
}
+void ED_sculpt_modifiers_changed(Object *ob)
+{
+ SculptSession *ss= ob->sculpt;
+
+ if(!ss->cache) {
+ /* we free pbvh on changes, except during sculpt since it can't deal with
+ changing PVBH node organization, we hope topology does not change in
+ the meantime .. weak */
+ if(ss->pbvh) {
+ BLI_pbvh_free(ss->pbvh);
+ ss->pbvh= NULL;
+ }
+
+ sculpt_free_deformMats(ob->sculpt);
+ }
+}
+
/* Sculpt mode handles multires differently from regular meshes, but only if
it's the last modifier on the stack and it is not on the first level */
struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
{
Mesh *me= (Mesh*)ob->data;
- ModifierData *md, *nmd;
+ ModifierData *md;
if(!CustomData_get_layer(&me->fdata, CD_MDISPS)) {
/* multires can't work without displacement layer */
@@ -107,40 +125,52 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob)
if(md->type == eModifierType_Multires) {
MultiresModifierData *mmd= (MultiresModifierData*)md;
- /* Check if any of the modifiers after multires are active
- * if not it can use the multires struct */
- for(nmd= md->next; nmd; nmd= nmd->next)
- if(modifier_isEnabled(scene, nmd, eModifierMode_Realtime))
- break;
+ if(!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ continue;
- if(!nmd && mmd->sculptlvl > 0)
- return mmd;
+ if(mmd->sculptlvl > 0) return mmd;
+ else return NULL;
}
}
return NULL;
}
-/* Checks whether full update mode (slower) needs to be used to work with modifiers */
+/* Check if there are any active modifiers in stack (used for flushing updates at enter/exit sculpt mode) */
+int sculpt_has_active_modifiers(Scene *scene, Object *ob)
+{
+ ModifierData *md;
+
+ md= modifiers_getVirtualModifierList(ob);
+
+ /* exception for shape keys because we can edit those */
+ for(; md; md= md->next) {
+ if(modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Checks if there are any supported deformation modifiers active */
int sculpt_modifiers_active(Scene *scene, Object *ob)
{
ModifierData *md;
MultiresModifierData *mmd= sculpt_multires_active(scene, ob);
- /* check if there are any modifiers after what we are sculpting,
- for a multires modifier with a deform modifier in front, we
- do no need to recalculate the modifier stack. note that this
- needs to be in sync with ccgDM_use_grid_pbvh! */
- if(mmd)
- md= mmd->modifier.next;
- else
- md= modifiers_getVirtualModifierList(ob);
-
+ if(mmd) return 0;
+
+ md= modifiers_getVirtualModifierList(ob);
+
/* exception for shape keys because we can edit those */
for(; md; md= md->next) {
- if(modifier_isEnabled(scene, md, eModifierMode_Realtime))
- if(md->type != eModifierType_ShapeKey)
- return 1;
+ ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+ if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
+ if(md->type==eModifierType_ShapeKey) continue;
+
+ if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatrices)
+ return 1;
}
return 0;
@@ -890,7 +920,9 @@ static void neighbor_average(SculptSession *ss, float avg[3], const unsigned ver
/* Don't modify corner vertices */
if(ncount==1) {
- copy_v3_v3(avg, ss->mvert[vert].co);
+ if(ss->deform_cos) copy_v3_v3(avg, ss->deform_cos[vert]);
+ else copy_v3_v3(avg, ss->mvert[vert].co);
+
return;
}
@@ -906,7 +938,8 @@ static void neighbor_average(SculptSession *ss, float avg[3], const unsigned ver
for(i=0; i<(f->v4?4:3); ++i) {
if(i != skip && (ncount!=2 || BLI_countlist(&ss->fmap[(&f->v1)[i]]) <= 2)) {
- add_v3_v3(avg, ss->mvert[(&f->v1)[i]].co);
+ if(ss->deform_cos) add_v3_v3(avg, ss->deform_cos[(&f->v1)[i]]);
+ else add_v3_v3(avg, ss->mvert[(&f->v1)[i]].co);
++total;
}
}
@@ -916,8 +949,10 @@ static void neighbor_average(SculptSession *ss, float avg[3], const unsigned ver
if(total>0)
mul_v3_fl(avg, 1.0f / total);
- else
- copy_v3_v3(avg, ss->mvert[vert].co);
+ else {
+ if(ss->deform_cos) copy_v3_v3(avg, ss->deform_cos[vert]);
+ else copy_v3_v3(avg, ss->mvert[vert].co);
+ }
}
static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength)
@@ -2198,9 +2233,8 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
ofs= key_to_vertcos(ob, kb);
/* calculate key coord offsets (from previous location) */
- for (a= 0; a < me->totvert; a++) {
+ for (a= 0; a < me->totvert; a++)
VECSUB(ofs[a], vertCos[a], ofs[a]);
- }
/* apply offsets on other keys */
currkey = me->key->block.first;
@@ -2230,17 +2264,6 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
vertcos_to_key(ob, kb, vertCos);
}
-/* copy the modified vertices from bvh to the active key */
-static void sculpt_update_keyblock(SculptSession *ss)
-{
- float (*vertCos)[3]= BLI_pbvh_get_vertCos(ss->pbvh);
-
- if (vertCos) {
- sculpt_vertcos_to_key(ss->ob, ss->kb, vertCos);
- MEM_freeN(vertCos);
- }
-}
-
static void do_brush_action(Sculpt *sd, SculptSession *ss, Brush *brush)
{
SculptSearchSphereData data;
@@ -2326,15 +2349,6 @@ static void do_brush_action(Sculpt *sd, SculptSession *ss, Brush *brush)
}
}
- /* copy the modified vertices from mesh to the active key */
- if(ss->kb)
- mesh_to_key(ss->ob->data, ss->kb);
-
- /* optimization: we could avoid copying new coords to keyblock at each */
- /* stroke step if there are no modifiers due to pbvh is used for displaying */
- /* so to increase speed we'll copy new coords to keyblock when stroke is done */
- if(ss->kb && ss->modifiers_active) sculpt_update_keyblock(ss);
-
MEM_freeN(nodes);
}
}
@@ -2388,6 +2402,59 @@ static void sculpt_combine_proxies(Sculpt *sd, SculptSession *ss)
MEM_freeN(nodes);
}
+/* copy the modified vertices from bvh to the active key */
+static void sculpt_update_keyblock(SculptSession *ss)
+{
+ float (*vertCos)[3];
+
+ /* Keyblock update happens after hadning deformation caused by modifiers,
+ so ss->orig_cos would be updated with new stroke */
+ if(ss->orig_cos) vertCos = ss->orig_cos;
+ else vertCos = BLI_pbvh_get_vertCos(ss->pbvh);
+
+ if (vertCos) {
+ sculpt_vertcos_to_key(ss->ob, ss->kb, vertCos);
+
+ if(vertCos != ss->orig_cos)
+ MEM_freeN(vertCos);
+ }
+}
+
+/* flush displacement from deformed PBVH to original layer */
+static void sculpt_flush_deformation(SculptSession *ss)
+{
+ float (*vertCos)[3];
+
+ vertCos= BLI_pbvh_get_vertCos(ss->pbvh);
+
+ if (vertCos) {
+ Object *ob= ss->ob;
+ Mesh *me= (Mesh*)ob->data;
+ MVert *mvert= me->mvert;
+ int a;
+
+ for(a = 0; a < me->totvert; ++a, ++mvert) {
+ float disp[3], newco[3];
+ sub_v3_v3v3(disp, vertCos[a], ss->deform_cos[a]);
+ mul_m3_v3(ss->deform_imats[a], disp);
+ add_v3_v3v3(newco, disp, ss->orig_cos[a]);
+
+ copy_v3_v3(ss->deform_cos[a], vertCos[a]);
+ copy_v3_v3(ss->orig_cos[a], newco);
+
+ if(!ss->kb)
+ copy_v3_v3(mvert->co, newco);
+ }
+
+ if(ss->kb)
+ sculpt_update_keyblock(ss);
+
+ mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
+
+ MEM_freeN(vertCos);
+ }
+}
+
//static int max_overlap_count(Sculpt *sd)
//{
// int count[3];
@@ -2496,6 +2563,9 @@ static void do_symmetrical_brush_actions(Sculpt *sd, SculptSession *ss)
/* hack to fix noise texture tearing mesh */
sculpt_fix_noise_tear(sd, ss);
+ if (ss->modifiers_active)
+ sculpt_flush_deformation(ss);
+
cache->first_time= 0;
}
@@ -2517,6 +2587,17 @@ static void sculpt_update_tex(Sculpt *sd, SculptSession *ss)
}
}
+void sculpt_free_deformMats(SculptSession *ss)
+{
+ if(ss->orig_cos) MEM_freeN(ss->orig_cos);
+ if(ss->deform_cos) MEM_freeN(ss->deform_cos);
+ if(ss->deform_imats) MEM_freeN(ss->deform_imats);
+
+ ss->orig_cos = NULL;
+ ss->deform_cos = NULL;
+ ss->deform_imats = NULL;
+}
+
void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap)
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
@@ -2551,6 +2632,23 @@ void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap)
ss->pbvh = dm->getPBVH(ob, dm);
ss->fmap = (need_fmap && dm->getFaceMap)? dm->getFaceMap(ob, dm): NULL;
+ if(ss->modifiers_active) {
+ if(!ss->orig_cos) {
+ int a;
+
+ sculpt_free_deformMats(ss);
+
+ if(ss->kb) ss->orig_cos = key_to_vertcos(ob, ss->kb);
+ else ss->orig_cos = mesh_getVertexCos(ob->data, NULL);
+
+ sculpt_get_deform_matrices(scene, ob, &ss->deform_imats, &ss->deform_cos);
+ BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
+
+ for(a = 0; a < ((Mesh*)ob->data)->totvert; ++a)
+ invert_m3(ss->deform_imats[a]);
+ }
+ } else sculpt_free_deformMats(ss);
+
/* if pbvh is deformed, key block is already applied to it */
if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) {
float (*vertCos)[3]= key_to_vertcos(ob, ss->kb);
@@ -2792,8 +2890,12 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio
ss->layer_co= MEM_mallocN(sizeof(float) * 3 * ss->totvert,
"sculpt mesh vertices copy");
- for(i = 0; i < ss->totvert; ++i)
- copy_v3_v3(ss->layer_co[i], ss->mvert[i].co);
+ if(ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert);
+ else {
+ for(i = 0; i < ss->totvert; ++i) {
+ copy_v3_v3(ss->layer_co[i], ss->mvert[i].co);
+ }
+ }
}
}
@@ -3214,7 +3316,6 @@ static void sculpt_flush_update(bContext *C)
rcti r;
BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB, NULL);
-
if (sculpt_get_redraw_rect(ar, CTX_wm_region_view3d(C), ob, &r)) {
//rcti tmp;
@@ -3489,7 +3590,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *unused)
/* multires in sculpt mode could have different from object mode subdivision level */
flush_recalc |= mmd && mmd->sculptlvl != mmd->lvl;
/* if object has got active modifiers, it's dm could be different in sculpt mode */
- //flush_recalc |= sculpt_modifiers_active(scene, ob);
+ flush_recalc |= sculpt_has_active_modifiers(scene, ob);
if(ob->mode & OB_MODE_SCULPT) {
if(mmd)
@@ -3554,4 +3655,3 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_sculptmode_toggle);
WM_operatortype_append(SCULPT_OT_set_persistent_base);
}
-
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index a48d6d8d9c9..76a7349606c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -61,6 +61,9 @@ void sculpt(Sculpt *sd);
int sculpt_poll(struct bContext *C);
void sculpt_update_mesh_elements(struct Scene *scene, struct Object *ob, int need_fmap);
+/* Deformed mesh sculpt */
+void sculpt_free_deformMats(struct SculptSession *ss);
+
/* Stroke */
struct SculptStroke *sculpt_stroke_new(const int max);
void sculpt_stroke_free(struct SculptStroke *);
@@ -78,6 +81,7 @@ typedef struct SculptUndoNode {
void *node; /* only during push, not valid afterwards! */
float (*co)[3];
+ float (*orig_co)[3];
short (*no)[3];
int totvert;
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index a8fee6ea39d..d136fdaf6e0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -67,6 +67,12 @@ static void update_cb(PBVHNode *node, void *unused)
BLI_pbvh_node_mark_update(node);
}
+static void sculpt_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3])
+{
+ swap_v3_v3(coord, unode->orig_co[uindex]);
+ copy_v3_v3(unode->co[uindex], ss->deform_cos[oindex]);
+}
+
static void sculpt_undo_restore(bContext *C, ListBase *lb)
{
Scene *scene = CTX_data_scene(C);
@@ -117,8 +123,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
float (*vertCos)[3];
vertCos= key_to_vertcos(ob, ss->kb);
- for(i=0; i<unode->totvert; i++)
- swap_v3_v3(vertCos[index[i]], unode->co[i]);
+ for(i=0; i<unode->totvert; i++) {
+ if(ss->modifiers_active) sculpt_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
+ else swap_v3_v3(vertCos[index[i]], unode->co[i]);
+ }
/* propagate new coords to keyblock */
sculpt_vertcos_to_key(ob, ss->kb, vertCos);
@@ -130,7 +138,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
MEM_freeN(vertCos);
} else {
for(i=0; i<unode->totvert; i++) {
- swap_v3_v3(mvert[index[i]].co, unode->co[i]);
+ if(ss->modifiers_active) sculpt_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
+ else swap_v3_v3(mvert[index[i]].co, unode->co[i]);
mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
}
}
@@ -162,6 +171,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
}
if(update) {
+ int tag_update= 0;
/* we update all nodes still, should be more clever, but also
needs to work correct when exiting/entering sculpt mode and
the nodes get recreated, though in that case it could do all */
@@ -171,7 +181,14 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
if((mmd=sculpt_multires_active(scene, ob)))
multires_mark_as_modified(ob);
- if(ss->modifiers_active || ((Mesh*)ob->data)->id.us > 1)
+ tag_update= ((Mesh*)ob->data)->id.us > 1;
+
+ if(ss->modifiers_active) {
+ sculpt_free_deformMats(ss);
+ tag_update|= 1;
+ }
+
+ if(tag_update)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* for non-PBVH drawing, need to recreate VBOs */
@@ -194,6 +211,8 @@ static void sculpt_undo_free(ListBase *lb)
MEM_freeN(unode->grids);
if(unode->layer_disp)
MEM_freeN(unode->layer_disp);
+ if(unode->orig_co)
+ MEM_freeN(unode->orig_co);
}
}
@@ -255,6 +274,9 @@ SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node)
unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index");
}
+ if(ss->modifiers_active)
+ unode->orig_co= MEM_callocN(allvert*sizeof(*unode->orig_co), "undoSculpt orig_cos");
+
BLI_unlock_thread(LOCK_CUSTOM1);
/* copy threaded, hopefully this is the performance critical part */
@@ -266,6 +288,9 @@ SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node)
if(vd.no) VECCOPY(unode->no[vd.i], vd.no)
else normal_float_to_short_v3(unode->no[vd.i], vd.fno);
if(vd.vert_indices) unode->index[vd.i]= vd.vert_indices[vd.i];
+
+ if(ss->modifiers_active)
+ copy_v3_v3(unode->orig_co[vd.i], ss->orig_cos[unode->index[vd.i]]);
}
BLI_pbvh_vertex_iter_end;
}
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index d06ec92d4df..ac25987871d 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -34,6 +34,7 @@
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
#include "BLI_utildefines.h"
@@ -161,6 +162,19 @@ static void deformMatricesEM(
if(!derivedData) dm->release(dm);
}
+static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+ float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
+{
+ ArmatureModifierData *amd = (ArmatureModifierData*) md;
+ DerivedMesh *dm = derivedData;
+
+ if(!derivedData) dm = CDDM_from_mesh((Mesh*)ob->data, ob);
+
+ armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
+ amd->deformflag, NULL, amd->defgrp_name);
+
+ if(!derivedData) dm->release(dm);
+}
ModifierTypeInfo modifierType_Armature = {
/* name */ "Armature",
@@ -172,6 +186,7 @@ ModifierTypeInfo modifierType_Armature = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ deformMatrices,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ deformMatricesEM,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index f6d497b763f..1fdfe6c192c 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -807,6 +807,7 @@ ModifierTypeInfo modifierType_Array = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index e775d7e4262..effc376943e 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -129,6 +129,7 @@ ModifierTypeInfo modifierType_Bevel = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index 112618a2bd6..c40d6cfb79e 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -139,6 +139,7 @@ ModifierTypeInfo modifierType_Boolean = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c
index 1588d1f44d5..704caf0aff8 100644
--- a/source/blender/modifiers/intern/MOD_build.c
+++ b/source/blender/modifiers/intern/MOD_build.c
@@ -287,6 +287,7 @@ ModifierTypeInfo modifierType_Build = {
| eModifierTypeFlag_AcceptsCVs,
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index c3400a6541d..17c2ec40b7e 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -619,6 +619,7 @@ ModifierTypeInfo modifierType_Cast = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index a0566d32c73..1cb46c0992f 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -196,6 +196,7 @@ ModifierTypeInfo modifierType_Cloth = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c
index bf324030424..8decb460d6a 100644
--- a/source/blender/modifiers/intern/MOD_collision.c
+++ b/source/blender/modifiers/intern/MOD_collision.c
@@ -243,6 +243,7 @@ ModifierTypeInfo modifierType_Collision = {
/* copyData */ 0,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index b1a5965cbe3..c4e41941acc 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -142,6 +142,7 @@ ModifierTypeInfo modifierType_Curve = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index 7903e1adb47..2f1723cf9bb 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -197,6 +197,7 @@ ModifierTypeInfo modifierType_Decimate = {
/* flags */ eModifierTypeFlag_AcceptsMesh,
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index 931865409cb..919814edf59 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -357,6 +357,7 @@ ModifierTypeInfo modifierType_Displace = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 105e4777e87..56138552000 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -1278,6 +1278,7 @@ ModifierTypeInfo modifierType_EdgeSplit = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index e6a3dc49668..a0765b56808 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -895,6 +895,7 @@ ModifierTypeInfo modifierType_Explode = {
/* flags */ eModifierTypeFlag_AcceptsMesh,
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c
index bbb88ba09e3..19111b0cafc 100644
--- a/source/blender/modifiers/intern/MOD_fluidsim.c
+++ b/source/blender/modifiers/intern/MOD_fluidsim.c
@@ -142,6 +142,7 @@ ModifierTypeInfo modifierType_Fluidsim = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index adf19882419..79493d2c549 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -284,6 +284,7 @@ ModifierTypeInfo modifierType_Hook = {
| eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 136998dbc78..c5fb87c8ffc 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -137,6 +137,7 @@ ModifierTypeInfo modifierType_Lattice = {
| eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 05a7bbecaea..b2f2c86c46d 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -399,6 +399,7 @@ ModifierTypeInfo modifierType_Mask = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 6df57bf372e..61e7f950e0f 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -445,6 +445,7 @@ ModifierTypeInfo modifierType_MeshDeform = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index c07bd10d6fa..9546bf1300b 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -338,6 +338,7 @@ ModifierTypeInfo modifierType_Mirror = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 96dcde12180..10b135aaa77 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -109,6 +109,7 @@ ModifierTypeInfo modifierType_Multires = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c
index cc27d3b659b..c08335d638a 100644
--- a/source/blender/modifiers/intern/MOD_none.c
+++ b/source/blender/modifiers/intern/MOD_none.c
@@ -59,6 +59,7 @@ ModifierTypeInfo modifierType_None = {
/* copyData */ 0,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index f0e7699c292..c36581d9317 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -330,6 +330,7 @@ ModifierTypeInfo modifierType_ParticleInstance = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 9b77a904887..c7638afbbcc 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -229,6 +229,7 @@ ModifierTypeInfo modifierType_ParticleSystem = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
/* deformVertsEM */ 0 /* deformVertsEM */ ,
+ /* deformMatrices */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
/* applyModifierEM */ 0,
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 96e1c6c0d01..7e8fad2801e 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -884,6 +884,7 @@ ModifierTypeInfo modifierType_Screw = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c
index 5466d240dd2..e03783e8eeb 100644
--- a/source/blender/modifiers/intern/MOD_shapekey.c
+++ b/source/blender/modifiers/intern/MOD_shapekey.c
@@ -64,6 +64,27 @@ static void deformVerts(ModifierData *md, Object *ob,
}
}
+static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+ float (*vertexCos)[3], float (*defMats)[3][3], int numVerts)
+{
+ Key *key= ob_get_key(ob);
+ KeyBlock *kb= ob_get_keyblock(ob);
+ float scale[3][3];
+ int a;
+
+ (void)vertexCos; /* unused */
+
+ if(kb && kb->totelem==numVerts && kb!=key->refkey) {
+ if(ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
+ else scale_m3_fl(scale, kb->curval);
+
+ for(a=0; a<numVerts; a++)
+ copy_m3_m3(defMats[a], scale);
+ }
+
+ deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0);
+}
+
static void deformVertsEM(ModifierData *md, Object *ob,
struct EditMesh *UNUSED(editData),
DerivedMesh *derivedData,
@@ -87,7 +108,7 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
KeyBlock *kb= ob_get_keyblock(ob);
float scale[3][3];
int a;
-
+
(void)vertexCos; /* unused */
if(kb && kb->totelem==numVerts && kb!=key->refkey) {
@@ -98,7 +119,6 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
}
}
-
ModifierTypeInfo modifierType_ShapeKey = {
/* name */ "ShapeKey",
/* structName */ "ShapeKeyModifierData",
@@ -109,6 +129,7 @@ ModifierTypeInfo modifierType_ShapeKey = {
/* copyData */ 0,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ deformMatrices,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ deformMatricesEM,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index a7de27c0bf6..56a5b4b8577 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -167,6 +167,7 @@ ModifierTypeInfo modifierType_Shrinkwrap = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index 003b206f9bc..1c3e40a4193 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -375,6 +375,7 @@ ModifierTypeInfo modifierType_SimpleDeform = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index 2edfee7e6e4..0227d2008e5 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -154,6 +154,7 @@ ModifierTypeInfo modifierType_Smoke = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index bc04b253cec..7761995a419 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -256,6 +256,7 @@ ModifierTypeInfo modifierType_Smooth = {
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c
index 24af10fde2b..7322628267c 100644
--- a/source/blender/modifiers/intern/MOD_softbody.c
+++ b/source/blender/modifiers/intern/MOD_softbody.c
@@ -68,6 +68,7 @@ ModifierTypeInfo modifierType_Softbody = {
/* copyData */ 0,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 6485076bde4..4faf955b953 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -651,6 +651,7 @@ ModifierTypeInfo modifierType_Solidify = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 1238c891f33..4ba139305d8 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -133,6 +133,7 @@ ModifierTypeInfo modifierType_Subsurf = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c
index d68ba84d58b..8d6f6954e18 100644
--- a/source/blender/modifiers/intern/MOD_surface.c
+++ b/source/blender/modifiers/intern/MOD_surface.c
@@ -173,6 +173,7 @@ ModifierTypeInfo modifierType_Surface = {
/* copyData */ 0,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 3f43924d6a2..8eaf0d5fbcb 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -413,6 +413,7 @@ ModifierTypeInfo modifierType_UVProject = {
/* copyData */ copyData,
/* deformVerts */ 0,
+ /* deformMatrices */ 0,
/* deformVertsEM */ 0,
/* deformMatricesEM */ 0,
/* applyModifier */ applyModifier,
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 69c9f1165ce..dae9fc471cd 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -452,6 +452,7 @@ ModifierTypeInfo modifierType_Wave = {
| eModifierTypeFlag_SupportsEditmode,
/* copyData */ copyData,
/* deformVerts */ deformVerts,
+ /* deformMatrices */ 0,
/* deformVertsEM */ deformVertsEM,
/* deformMatricesEM */ 0,
/* applyModifier */ 0,
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 5fd58128f6a..c831c2a477e 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -431,6 +431,7 @@ float sculpt_get_brush_unprojected_radius(struct Brush *brush){return 0.0f;}
void sculpt_set_brush_unprojected_radius(struct Brush *brush, float unprojected_radius){}
float sculpt_get_brush_alpha(struct Brush *brush){return 0.0f;}
void sculpt_set_brush_alpha(struct Brush *brush, float alpha){}
+void ED_sculpt_modifiers_changed(struct Object *ob){};
char blender_path[] = "";