Sculptmode now works properly with shape keys (Merry Christmas.) Fixes bug #5499, Sculpt mode don't works correctly with Shape Key.
This commit is contained in:
@@ -63,6 +63,8 @@
|
|||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
|
|
||||||
|
#include "blendef.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -1303,6 +1305,11 @@ int do_ob_key(Object *ob)
|
|||||||
if(key==NULL)
|
if(key==NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Don't apply key for sculptmode */
|
||||||
|
if(key==NULL || ((G.f & G_SCULPTMODE) && !G.obedit && ob==OBACT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
if(ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)) {
|
if(ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)) {
|
||||||
KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
|
KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1);
|
||||||
|
|
||||||
|
|||||||
@@ -3134,6 +3134,7 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
|||||||
|
|
||||||
sce->toolsettings= newdataadr(fd, sce->toolsettings);
|
sce->toolsettings= newdataadr(fd, sce->toolsettings);
|
||||||
|
|
||||||
|
sce->sculptdata.session= NULL;
|
||||||
/* SculptData textures */
|
/* SculptData textures */
|
||||||
for(a=0; a<MAX_MTEX; ++a)
|
for(a=0; a<MAX_MTEX; ++a)
|
||||||
sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
|
sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
struct uiBlock;
|
struct uiBlock;
|
||||||
struct BrushData;
|
struct BrushData;
|
||||||
struct IndexNode;
|
struct IndexNode;
|
||||||
struct Key;
|
struct KeyBlock;
|
||||||
struct Mesh;
|
struct Mesh;
|
||||||
struct Object;
|
struct Object;
|
||||||
struct PartialVisibility;
|
struct PartialVisibility;
|
||||||
@@ -59,6 +59,8 @@ typedef struct PropsetData {
|
|||||||
} PropsetData;
|
} PropsetData;
|
||||||
|
|
||||||
typedef struct SculptSession {
|
typedef struct SculptSession {
|
||||||
|
struct Object *active_ob;
|
||||||
|
|
||||||
/* Cache of the OpenGL matrices */
|
/* Cache of the OpenGL matrices */
|
||||||
double modelviewmat[16];
|
double modelviewmat[16];
|
||||||
double projectionmat[16];
|
double projectionmat[16];
|
||||||
@@ -82,7 +84,7 @@ typedef struct SculptSession {
|
|||||||
/* For rotating around a pivot point */
|
/* For rotating around a pivot point */
|
||||||
vec3f pivot;
|
vec3f pivot;
|
||||||
|
|
||||||
struct Key *key;
|
struct KeyBlock *keyblock;
|
||||||
} SculptSession;
|
} SculptSession;
|
||||||
|
|
||||||
SculptSession *sculpt_session();
|
SculptSession *sculpt_session();
|
||||||
|
|||||||
@@ -600,9 +600,11 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
|
|||||||
|
|
||||||
case B_ADDKEY:
|
case B_ADDKEY:
|
||||||
insert_shapekey(ob);
|
insert_shapekey(ob);
|
||||||
|
set_sculpt_object(ob);
|
||||||
break;
|
break;
|
||||||
case B_SETKEY:
|
case B_SETKEY:
|
||||||
ob->shapeflag |= OB_SHAPE_TEMPLOCK;
|
ob->shapeflag |= OB_SHAPE_TEMPLOCK;
|
||||||
|
set_sculpt_object(ob);
|
||||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
allqueue(REDRAWIPO, 0);
|
allqueue(REDRAWIPO, 0);
|
||||||
@@ -610,6 +612,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
|
|||||||
break;
|
break;
|
||||||
case B_LOCKKEY:
|
case B_LOCKKEY:
|
||||||
ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
|
ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
|
||||||
|
set_sculpt_object(ob);
|
||||||
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
allqueue(REDRAWVIEW3D, 0);
|
allqueue(REDRAWVIEW3D, 0);
|
||||||
allqueue(REDRAWIPO, 0);
|
allqueue(REDRAWIPO, 0);
|
||||||
@@ -621,6 +624,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
|
|||||||
if(ob->shapenr == BLI_countlist(&key->block))
|
if(ob->shapenr == BLI_countlist(&key->block))
|
||||||
ob->shapenr= 1;
|
ob->shapenr= 1;
|
||||||
else ob->shapenr++;
|
else ob->shapenr++;
|
||||||
|
set_sculpt_object(ob);
|
||||||
do_common_editbuts(B_SETKEY);
|
do_common_editbuts(B_SETKEY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -630,6 +634,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
|
|||||||
if(ob->shapenr <= 1)
|
if(ob->shapenr <= 1)
|
||||||
ob->shapenr= BLI_countlist(&key->block);
|
ob->shapenr= BLI_countlist(&key->block);
|
||||||
else ob->shapenr--;
|
else ob->shapenr--;
|
||||||
|
set_sculpt_object(ob);
|
||||||
do_common_editbuts(B_SETKEY);
|
do_common_editbuts(B_SETKEY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -638,7 +643,9 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
|
|||||||
allqueue (REDRAWIPO, 0);
|
allqueue (REDRAWIPO, 0);
|
||||||
break;
|
break;
|
||||||
case B_DELKEY:
|
case B_DELKEY:
|
||||||
|
set_sculpt_object(NULL);
|
||||||
delete_key(OBACT);
|
delete_key(OBACT);
|
||||||
|
set_sculpt_object(ob);
|
||||||
allqueue(REDRAWACTION, 0);
|
allqueue(REDRAWACTION, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -194,9 +194,11 @@ void sculptmode_init(Scene *sce)
|
|||||||
sd->tablet_strength=10;
|
sd->tablet_strength=10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sculptmode_undo_init();
|
||||||
void sculpt_init_session()
|
void sculpt_init_session()
|
||||||
{
|
{
|
||||||
sculpt_data()->session= MEM_callocN(sizeof(SculptSession), "SculptSession");
|
sculpt_data()->session= MEM_callocN(sizeof(SculptSession), "SculptSession");
|
||||||
|
sculptmode_undo_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free G.sculptdata->vertexusers */
|
/* Free G.sculptdata->vertexusers */
|
||||||
@@ -595,8 +597,31 @@ void calc_vertex_users()
|
|||||||
|
|
||||||
void set_sculpt_object(Object *ob)
|
void set_sculpt_object(Object *ob)
|
||||||
{
|
{
|
||||||
if(ob)
|
SculptSession *ss= sculpt_session();
|
||||||
|
|
||||||
|
if(ss) {
|
||||||
|
if(ss->keyblock) {
|
||||||
|
Mesh *me= get_mesh(ss->active_ob);
|
||||||
|
if(me) {
|
||||||
|
mesh_to_key(me, ss->keyblock);
|
||||||
|
DAG_object_flush_update(G.scene, ss->active_ob, OB_RECALC_DATA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ob) {
|
||||||
|
Mesh *me= get_mesh(ob);
|
||||||
calc_vertex_users();
|
calc_vertex_users();
|
||||||
|
|
||||||
|
/* Load in key */
|
||||||
|
ss->keyblock= ob_get_keyblock(ob);
|
||||||
|
if(ss->keyblock)
|
||||||
|
key_to_mesh(ss->keyblock, me);
|
||||||
|
|
||||||
|
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
ss->active_ob= ob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===== INTERFACE =====
|
/* ===== INTERFACE =====
|
||||||
@@ -1597,8 +1622,8 @@ void sculptmode_draw_mesh(int only_damaged) {
|
|||||||
|
|
||||||
void sculptmode_correct_state()
|
void sculptmode_correct_state()
|
||||||
{
|
{
|
||||||
//if(get_mesh( != get_mesh(OBACT))
|
if(get_mesh(sculpt_session()->active_ob) != get_mesh(OBACT))
|
||||||
//set_sculpt_object(OBACT);
|
set_sculpt_object(OBACT);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
@@ -1823,8 +1848,6 @@ void set_sculptmode()
|
|||||||
set_sculpt_object(NULL);
|
set_sculpt_object(NULL);
|
||||||
|
|
||||||
sculptmode_free_session(G.scene);
|
sculptmode_free_session(G.scene);
|
||||||
|
|
||||||
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
|
|
||||||
} else {
|
} else {
|
||||||
G.f |= G_SCULPTMODE;
|
G.f |= G_SCULPTMODE;
|
||||||
|
|
||||||
@@ -1836,8 +1859,6 @@ void set_sculptmode()
|
|||||||
sculpt_init_session();
|
sculpt_init_session();
|
||||||
set_sculpt_object(OBACT);
|
set_sculpt_object(OBACT);
|
||||||
|
|
||||||
sculptmode_undo_init();
|
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user