- update displistmesh_to_mesh to free existing mesh data (including
sticky, dvert, and keys if number of verts don't match) - changed modifier panel to not allow manual addition of hook or softbody modifiers - changed apply modifier to apply to existing mesh (fixes bug with materials) and to warn about loss of tface/mcol/keys/dvert/sticky for all modifier types - changed modifier UI to not display disclosure triangle for virtual modifiers - changed softbody ui to allow enable/disable
This commit is contained in:
@@ -98,13 +98,9 @@ static DispListMesh *meshDM_convertToDispListMesh(DerivedMesh *dm, int allowShar
|
||||
|
||||
if (!allowShared) {
|
||||
dlm->mvert = MEM_dupallocN(dlm->mvert);
|
||||
if (dlm->medge) dlm->medge = MEM_dupallocN(dlm->medge);
|
||||
dlm->mface = MEM_dupallocN(dlm->mface);
|
||||
if (dlm->tface) dlm->tface = MEM_dupallocN(dlm->tface);
|
||||
if (dlm->mcol) dlm->mcol = MEM_dupallocN(dlm->mcol);
|
||||
if (dlm->nors) dlm->nors = MEM_dupallocN(dlm->nors);
|
||||
|
||||
dlm->dontFreeVerts = dlm->dontFreeOther = dlm->dontFreeNors = 0;
|
||||
dlm->dontFreeVerts = dlm->dontFreeNors = 0;
|
||||
}
|
||||
|
||||
return dlm;
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_lattice_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
@@ -147,24 +148,51 @@ DispListMesh *displistmesh_copyShared(DispListMesh *odlm)
|
||||
|
||||
void displistmesh_to_mesh(DispListMesh *dlm, Mesh *me)
|
||||
{
|
||||
if (dlm->totvert>MESH_MAX_VERTS) {
|
||||
error("Too many vertices");
|
||||
} else {
|
||||
/* We assume, rather courageously, that any
|
||||
* shared data came from the mesh itself and so
|
||||
* we can ignore the dlm->dontFreeOther flag.
|
||||
*/
|
||||
|
||||
if (me->mvert && dlm->mvert!=me->mvert) MEM_freeN(me->mvert);
|
||||
if (me->mface && dlm->mface!=me->mface) MEM_freeN(me->mface);
|
||||
if (me->tface && dlm->tface!=me->tface) MEM_freeN(me->tface);
|
||||
if (me->mcol && dlm->mcol!=me->mcol) MEM_freeN(me->mcol);
|
||||
if (me->medge && dlm->medge!=me->medge) MEM_freeN(me->medge);
|
||||
|
||||
me->tface = NULL;
|
||||
me->mcol = NULL;
|
||||
me->medge = NULL;
|
||||
|
||||
if (dlm->totvert!=me->totvert) {
|
||||
if (me->msticky) MEM_freeN(me->msticky);
|
||||
me->msticky = NULL;
|
||||
|
||||
if (me->dvert) free_dverts(me->dvert, me->totvert);
|
||||
me->dvert = NULL;
|
||||
|
||||
if(me->key) me->key->id.us--;
|
||||
me->key = NULL;
|
||||
}
|
||||
|
||||
me->totface= dlm->totface;
|
||||
me->totvert= dlm->totvert;
|
||||
me->totedge= 0;
|
||||
|
||||
me->mvert= MEM_dupallocN(dlm->mvert);
|
||||
me->mface= MEM_dupallocN(dlm->mface);
|
||||
me->mvert= dlm->mvert;
|
||||
me->mface= dlm->mface;
|
||||
if (dlm->tface)
|
||||
me->tface= MEM_dupallocN(dlm->tface);
|
||||
me->tface= dlm->tface;
|
||||
if (dlm->mcol)
|
||||
me->mcol= MEM_dupallocN(dlm->mcol);
|
||||
me->mcol= dlm->mcol;
|
||||
|
||||
if(dlm->medge) {
|
||||
me->totedge= dlm->totedge;
|
||||
me->medge= MEM_dupallocN(dlm->medge);
|
||||
}
|
||||
me->medge= dlm->medge;
|
||||
}
|
||||
|
||||
if (dlm->nors && !dlm->dontFreeNors) MEM_freeN(dlm->nors);
|
||||
|
||||
MEM_freeN(dlm);
|
||||
}
|
||||
|
||||
void free_disp_elem(DispList *dl)
|
||||
|
||||
@@ -2074,10 +2074,6 @@ static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts)
|
||||
mdverts[i].dw=newdataadr(fd, mdverts[i].dw);
|
||||
if (!mdverts[i].dw)
|
||||
mdverts[i].totweight=0;
|
||||
|
||||
for (j=0; j< mdverts[i].totweight; j++) {
|
||||
mdverts[i].dw[j].data = NULL; // not saved in file, clear pointer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -553,8 +553,8 @@ static uiBlock *modifiers_add_menu(void *ob_v)
|
||||
for (i=eModifierType_None+1; i<NUM_MODIFIER_TYPES; i++) {
|
||||
ModifierTypeInfo *mti = modifierType_getInfo(i);
|
||||
|
||||
if (i==eModifierType_Softbody && modifiers_findByType(ob, eModifierType_Softbody))
|
||||
continue;
|
||||
/* Only allow adding through appropriate other interfaces */
|
||||
if (ELEM(i, eModifierType_Softbody, eModifierType_Hook)) continue;
|
||||
|
||||
if ( (mti->flags&eModifierTypeFlag_AcceptsCVs) ||
|
||||
(ob->type==OB_MESH && (mti->flags&eModifierTypeFlag_AcceptsMesh))) {
|
||||
@@ -691,6 +691,7 @@ static void modifiers_applyModifier(void *obv, void *mdv)
|
||||
DerivedMesh *dm;
|
||||
DispListMesh *dlm;
|
||||
Mesh *me = ob->data;
|
||||
int converted = 0;
|
||||
|
||||
if (G.obedit) {
|
||||
error("Modifiers cannot be applied in editmode");
|
||||
@@ -700,13 +701,8 @@ static void modifiers_applyModifier(void *obv, void *mdv)
|
||||
return;
|
||||
}
|
||||
|
||||
if (md->type==eModifierType_Decimate && (me->tface || me->mcol)) {
|
||||
if (!okee("Applying decimate modifier will remove mesh UVs and vertex colors, continue?"))
|
||||
return;
|
||||
}
|
||||
|
||||
if (md!=ob->modifiers.first) {
|
||||
if (!okee("Modifier is not first, continue with apply?"))
|
||||
if (!okee("Modifier is not first"))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -718,15 +714,22 @@ static void modifiers_applyModifier(void *obv, void *mdv)
|
||||
return;
|
||||
}
|
||||
|
||||
dlm= dm->convertToDispListMesh(dm, 1);
|
||||
dlm= dm->convertToDispListMesh(dm, 0);
|
||||
|
||||
ob->data= add_mesh();
|
||||
displistmesh_to_mesh(dlm, ob->data);
|
||||
if ((!me->tface || dlm->tface) || okee("Applying will delete mesh UVs and vertex colors")) {
|
||||
if ((!me->mcol || dlm->mcol) || okee("Applying will delete mesh vertex colors")) {
|
||||
if (dlm->totvert==me->totvert || okee("Applying will delete mesh sticky, keys, and vertex groups")) {
|
||||
displistmesh_to_mesh(dlm, me);
|
||||
converted = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!converted) {
|
||||
displistmesh_free(dlm);
|
||||
}
|
||||
dm->release(dm);
|
||||
|
||||
free_libblock_us(&G.main->mesh, me);
|
||||
|
||||
BLI_remlink(&ob->modifiers, md);
|
||||
modifier_free(md);
|
||||
}
|
||||
@@ -812,10 +815,10 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
|
||||
if (isVirtual) {
|
||||
uiSetButLock(1, "Modifier is virtual and cannot be edited.");
|
||||
color = TH_BUT_SETTING1;
|
||||
}
|
||||
|
||||
} else {
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, B_MODIFIER_REDRAW, VICON_DISCLOSURE_TRI_RIGHT, x-10, y-2, 20, 20, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
|
||||
}
|
||||
|
||||
BIF_ThemeColor(color);
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
@@ -1456,6 +1456,11 @@ static void object_softbodies__enable(void *ob_v, void *arg2)
|
||||
Object *ob = ob_v;
|
||||
ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody);
|
||||
|
||||
if (modifiers_isSoftbodyEnabled(ob)) {
|
||||
if (md) {
|
||||
md->mode &= ~(eModifierMode_Render|eModifierMode_Realtime);
|
||||
}
|
||||
} else {
|
||||
if (!md) {
|
||||
md = modifier_new(eModifierType_Softbody);
|
||||
BLI_addhead(&ob->modifiers, md);
|
||||
@@ -1463,6 +1468,16 @@ static void object_softbodies__enable(void *ob_v, void *arg2)
|
||||
|
||||
md->mode |= eModifierMode_Render|eModifierMode_Realtime;
|
||||
|
||||
if (!ob->soft) {
|
||||
ob->soft= sbNew();
|
||||
ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
|
||||
if(ob->type==OB_MESH) {
|
||||
Mesh *me= ob->data;
|
||||
if(me->medge==NULL) make_edges(me);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
}
|
||||
|
||||
@@ -1479,12 +1494,14 @@ static void object_softbodies(Object *ob)
|
||||
uiDefBut(block, LABEL, 0, "Object has Deflection,", 10,160,300,20, NULL, 0.0, 0, 0, 0, "");
|
||||
uiDefBut(block, LABEL, 0, "no Softbody possible", 10,140,300,20, NULL, 0.0, 0, 0, 0, "");
|
||||
} else {
|
||||
if (!modifiers_isSoftbodyEnabled(ob)) {
|
||||
uiBut *but = uiDefButS(block, BUT, REDRAWBUTSOBJECT, "Enable Soft Body", 10,200,150,20, &ob->softflag, 0, 0, 0, 0, "Sets object to become soft body");
|
||||
static int val;
|
||||
uiBut *but;
|
||||
|
||||
val = modifiers_isSoftbodyEnabled(ob);
|
||||
but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Enable Soft Body", 10,200,150,20, &val, 0, 0, 0, 0, "Sets object to become soft body");
|
||||
uiButSetFunc(but, object_softbodies__enable, ob, NULL);
|
||||
uiDefBut(block, LABEL, 0, "", 160, 200,150,20, NULL, 0.0, 0.0, 0, 0, ""); // alignment reason
|
||||
}
|
||||
}
|
||||
|
||||
if(modifiers_isSoftbodyEnabled(ob)) {
|
||||
SoftBody *sb= ob->soft;
|
||||
|
||||
@@ -2223,7 +2223,6 @@ void convertmenu(void)
|
||||
dm= mesh_create_derived_no_deform(ob, NULL);
|
||||
dlm= dm->convertToDispListMesh(dm, 1);
|
||||
displistmesh_to_mesh(dlm, ob1->data);
|
||||
displistmesh_free(dlm);
|
||||
dm->release(dm);
|
||||
}
|
||||
else if(ob->type==OB_FONT) {
|
||||
|
||||
Reference in New Issue
Block a user