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
path: root/source
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2009-01-17 19:58:05 +0300
committerNicholas Bishop <nicholasbishop@gmail.com>2009-01-17 19:58:05 +0300
commit69e49c6f0c33743d32ba5313e735c1320911c679 (patch)
tree0d011ae7d20e4b7f5fd4702454ed07987bfe96e4 /source
parent5caec606deea380f7b0dcb22fcb2a1402c1bb60a (diff)
Make sculpt data more like vpaint/weightpaint. SculptData is now in scene->toolsettings, moved the RNA to reflect that too.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_scene.h1
-rw-r--r--source/blender/blenkernel/BKE_sculpt.h7
-rw-r--r--source/blender/blenkernel/intern/scene.c68
-rw-r--r--source/blender/blenloader/intern/readfile.c15
-rw-r--r--source/blender/blenloader/intern/writefile.c3
-rw-r--r--source/blender/editors/sculpt/sculpt.c108
-rw-r--r--source/blender/editors/sculpt/sculpt_intern.h10
-rw-r--r--source/blender/editors/sculpt/stroke.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_header.c5
-rw-r--r--source/blender/makesdna/DNA_scene_types.h56
-rw-r--r--source/blender/makesrna/RNA_access.h3
-rw-r--r--source/blender/makesrna/intern/rna_scene.c30
12 files changed, 127 insertions, 185 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 2c58c5d6d8c..734687adafb 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -37,7 +37,6 @@ struct Object;
struct Base;
struct AviCodecData;
struct QuicktimeCodecData;
-struct SculptData;
struct RenderData;
/* note; doesn't work when scene is empty */
diff --git a/source/blender/blenkernel/BKE_sculpt.h b/source/blender/blenkernel/BKE_sculpt.h
index 772dec21643..54d750db3af 100644
--- a/source/blender/blenkernel/BKE_sculpt.h
+++ b/source/blender/blenkernel/BKE_sculpt.h
@@ -33,7 +33,7 @@
struct NumInput;
struct RadialControl;
struct Scene;
-struct SculptData;
+struct Sculpt;
struct SculptSession;
struct StrokeCache;
@@ -65,10 +65,7 @@ typedef struct SculptSession {
struct StrokeCache *cache;
} SculptSession;
-void sculptdata_init(struct Scene *sce);
-void sculptdata_free(struct Scene *sce);
-void sculptsession_free(struct Scene *sce);
+void sculptsession_free(struct Sculpt *sculpt);
void sculpt_vertexusers_free(struct SculptSession *ss);
-void sculpt_reset_curve(struct SculptData *sd);
#endif
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 8fbbe83373e..cfd88d3d438 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -174,6 +174,10 @@ void free_scene(Scene *sce)
MEM_freeN(sce->toolsettings->vpaint);
if(sce->toolsettings->wpaint)
MEM_freeN(sce->toolsettings->wpaint);
+ if(sce->toolsettings->sculpt) {
+ sculptsession_free(sce->toolsettings->sculpt);
+ MEM_freeN(sce->toolsettings->sculpt);
+ }
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
@@ -188,8 +192,6 @@ void free_scene(Scene *sce)
ntreeFreeTree(sce->nodetree);
MEM_freeN(sce->nodetree);
}
-
- sculptdata_free(sce);
}
Scene *add_scene(char *name)
@@ -304,8 +306,6 @@ Scene *add_scene(char *name)
BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa= 8;
- sculptdata_init(sce);
-
/* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
scene_add_render_layer(sce);
@@ -653,60 +653,6 @@ void scene_add_render_layer(Scene *sce)
srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
}
-/* Initialize 'permanent' sculpt data that is saved with file kept after
- switching out of sculptmode. */
-void sculptdata_init(Scene *sce)
-{
- SculptData *sd;
-
- if(!sce)
- return;
-
- sd= &sce->sculptdata;
-
- memset(sd, 0, sizeof(SculptData));
-
- /* XXX: create preset brushes here
- sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size =
- sd->inflatebrush.size = sd->grabbrush.size =
- sd->layerbrush.size = sd->flattenbrush.size = 50;
- sd->drawbrush.strength = sd->smoothbrush.strength =
- sd->pinchbrush.strength = sd->inflatebrush.strength =
- sd->grabbrush.strength = sd->layerbrush.strength =
- sd->flattenbrush.strength = 25;
- sd->drawbrush.dir = sd->pinchbrush.dir = sd->inflatebrush.dir = sd->layerbrush.dir= 1;
- sd->drawbrush.flag = sd->smoothbrush.flag =
- sd->pinchbrush.flag = sd->inflatebrush.flag =
- sd->layerbrush.flag = sd->flattenbrush.flag = 0;
- sd->drawbrush.view= 0;
- sd->brush_type= DRAW_BRUSH;
- sd->texact= -1;
- sd->texfade= 1;
- sd->averaging= 1;
- sd->texsep= 0;
- sd->texrept= SCULPTREPT_DRAG;
- sd->flags= SCULPT_DRAW_BRUSH;
- sd->tablet_size=3;
- sd->tablet_strength=10;
- sd->rake=0;*/
-}
-
-void sculptdata_free(Scene *sce)
-{
- SculptData *sd= &sce->sculptdata;
- int a;
-
- sculptsession_free(sce);
-
- for(a=0; a<MAX_MTEX; a++) {
- MTex *mtex= sd->mtex[a];
- if(mtex) {
- if(mtex->tex) mtex->tex->id.us--;
- MEM_freeN(mtex);
- }
- }
-}
-
void sculpt_vertexusers_free(SculptSession *ss)
{
if(ss && ss->vertex_users){
@@ -718,9 +664,9 @@ void sculpt_vertexusers_free(SculptSession *ss)
}
}
-void sculptsession_free(Scene *sce)
+void sculptsession_free(Sculpt *sculpt)
{
- SculptSession *ss= sce->sculptdata.session;
+ SculptSession *ss= sculpt->session;
if(ss) {
if(ss->projverts)
MEM_freeN(ss->projverts);
@@ -732,7 +678,7 @@ void sculptsession_free(Scene *sce)
if(ss->texcache)
MEM_freeN(ss->texcache);
MEM_freeN(ss);
- sce->sculptdata.session= NULL;
+ sculpt->session= NULL;
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5fb5ada09c0..5224b51d92d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3505,7 +3505,6 @@ static void lib_link_scene(FileData *fd, Main *main)
Base *base, *next;
Sequence *seq;
SceneRenderLayer *srl;
- int a;
sce= main->scene.first;
while(sce) {
@@ -3521,13 +3520,6 @@ static void lib_link_scene(FileData *fd, Main *main)
sce->toolsettings->imapaint.brush=
newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush);
- /* Sculptdata textures */
- for(a=0; a<MAX_MTEX; ++a) {
- MTex *mtex= sce->sculptdata.mtex[a];
- if(mtex)
- mtex->tex= newlibadr_us(fd, sce->id.lib, mtex->tex);
- }
-
for(base= sce->base.first; base; base= next) {
next= base->next;
@@ -3593,7 +3585,6 @@ static void direct_link_scene(FileData *fd, Scene *sce)
Editing *ed;
Sequence *seq;
MetaStack *ms;
- int a;
sce->theDag = NULL;
sce->dagisvalid = 0;
@@ -3610,11 +3601,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
if(sce->toolsettings) {
sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint);
sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint);
+ if(sce->toolsettings->sculpt)
+ sce->toolsettings->sculpt->session= NULL;
}
- sce->sculptdata.session= NULL;
- /* SculptData textures */
- for(a=0; a<MAX_MTEX; ++a)
- sce->sculptdata.mtex[a]= newdataadr(fd,sce->sculptdata.mtex[a]);
if(sce->ed) {
ListBase *old_seqbasep= &((Editing *)sce->ed)->seqbase;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 436980ef421..df6f233a20f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1477,9 +1477,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
if(sce->toolsettings->wpaint)
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint);
- for(a=0; a<MAX_MTEX; ++a)
- writestruct(wd, DATA, "MTex", 1, sce->sculptdata.mtex[a]);
-
ed= sce->ed;
if(ed) {
writestruct(wd, DATA, "Editing", 1, ed);
diff --git a/source/blender/editors/sculpt/sculpt.c b/source/blender/editors/sculpt/sculpt.c
index 918027e918a..b88eb188464 100644
--- a/source/blender/editors/sculpt/sculpt.c
+++ b/source/blender/editors/sculpt/sculpt.c
@@ -276,7 +276,7 @@ static void project(bglMats *mats, const float v[3], short p[2])
shrink the brush. Skipped for grab brush because only the first mouse down
size is used, which is small if the user has just touched the pen to the
tablet */
-static char brush_size(SculptData *sd)
+static char brush_size(Sculpt *sd)
{
float size= sd->brush->size;
#if 0
@@ -298,7 +298,7 @@ static char brush_size(SculptData *sd)
/* Return modified brush strength. Includes the direction of the brush, positive
values pull vertices, negative values push. Uses tablet pressure and a
special multiplier found experimentally to scale the strength factor. */
-static float brush_strength(SculptData *sd, StrokeCache *cache)
+static float brush_strength(Sculpt *sd, StrokeCache *cache)
{
float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure= 1;
@@ -350,7 +350,7 @@ static void sculpt_clip(StrokeCache *cache, float *co, const float val[3])
}
}
-static void sculpt_axislock(SculptData *sd, float *co)
+static void sculpt_axislock(Sculpt *sd, float *co)
{
if (sd->flags & (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z)) return;
/* XXX: if(G.vd->twmode == V3D_MANIP_LOCAL) { */
@@ -385,7 +385,7 @@ static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], cons
/* Currently only for the draw brush; finds average normal for all active
vertices */
-static void calc_area_normal(SculptData *sd, float out[3], const ListBase* active_verts)
+static void calc_area_normal(Sculpt *sd, float out[3], const ListBase* active_verts)
{
StrokeCache *cache = sd->session->cache;
ActiveData *node = active_verts->first;
@@ -419,7 +419,7 @@ static void calc_area_normal(SculptData *sd, float out[3], const ListBase* activ
Normalize(out);
}
-static void do_draw_brush(SculptData *sd, SculptSession *ss, const ListBase* active_verts)
+static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_verts)
{
float area_normal[3];
ActiveData *node= active_verts->first;
@@ -517,7 +517,7 @@ static void do_pinch_brush(SculptSession *ss, const ListBase* active_verts)
}
}
-static void do_grab_brush(SculptData *sd, SculptSession *ss)
+static void do_grab_brush(Sculpt *sd, SculptSession *ss)
{
ActiveData *node= ss->cache->grab_active_verts[ss->cache->symmetry].first;
float add[3];
@@ -539,7 +539,7 @@ static void do_grab_brush(SculptData *sd, SculptSession *ss)
}
-static void do_layer_brush(SculptData *sd, SculptSession *ss, const ListBase *active_verts)
+static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts)
{
float area_normal[3];
ActiveData *node= active_verts->first;
@@ -623,7 +623,7 @@ static void calc_flatten_center(SculptSession *ss, ActiveData *node, float co[3]
VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE);
}
-static void do_flatten_brush(SculptData *sd, SculptSession *ss, const ListBase *active_verts)
+static void do_flatten_brush(Sculpt *sd, SculptSession *ss, const ListBase *active_verts)
{
ActiveData *node= active_verts->first;
/* area_normal and cntr define the plane towards which vertices are squashed */
@@ -680,17 +680,19 @@ static void flip_coord(float out[3], float in[3], const char symm)
}
/* Use the warpfac field in MTex to store a rotation value for sculpt textures. Value is in degrees */
-static float sculpt_tex_angle(SculptData *sd)
+static float sculpt_tex_angle(Sculpt *sd)
{
- if(sd->texact!=-1 && sd->mtex[sd->texact])
- return sd->mtex[sd->texact]->warpfac;
+ Brush *br = sd->brush;
+ if(br->texact!=-1 && br->mtex[br->texact])
+ return br->mtex[br->texact]->warpfac;
return 0;
}
-static void set_tex_angle(SculptData *sd, const float f)
+static void set_tex_angle(Sculpt *sd, const float f)
{
- if(sd->texact != -1 && sd->mtex[sd->texact])
- sd->mtex[sd->texact]->warpfac = f;
+ Brush *br = sd->brush;
+ if(br->texact != -1 && br->mtex[br->texact])
+ br->mtex[br->texact]->warpfac = f;
}
static float to_rad(const float deg)
@@ -741,12 +743,13 @@ static float get_texcache_pixel_bilinear(const SculptSession *ss, float u, float
}
/* Return a multiplier for brush strength on a particular vertex. */
-static float tex_strength(SculptData *sd, float *point, const float len)
+static float tex_strength(Sculpt *sd, float *point, const float len)
{
SculptSession *ss= sd->session;
+ Brush *br = sd->brush;
float avg= 1;
- if(sd->texact==-1 || !sd->mtex[sd->texact])
+ if(br->texact==-1 || !br->mtex[sd->texact])
avg= 1;
else if(sd->texrept==SCULPTREPT_3D) {
/* Get strength by feeding the vertex location directly
@@ -755,11 +758,11 @@ static float tex_strength(SculptData *sd, float *point, const float len)
const float factor= 0.01;
MTex mtex;
memset(&mtex,0,sizeof(MTex));
- mtex.tex= sd->mtex[sd->texact]->tex;
+ mtex.tex= br->mtex[br->texact]->tex;
mtex.projx= 1;
mtex.projy= 2;
mtex.projz= 3;
- VecCopyf(mtex.size, sd->mtex[sd->texact]->size);
+ VecCopyf(mtex.size, br->mtex[br->texact]->size);
VecMulf(mtex.size, factor);
if(!sd->texsep)
mtex.size[1]= mtex.size[2]= mtex.size[0];
@@ -782,8 +785,8 @@ static float tex_strength(SculptData *sd, float *point, const float len)
/* For Tile and Drag modes, get the 2D screen coordinates of the
and scale them up or down to the texture size. */
if(sd->texrept==SCULPTREPT_TILE) {
- const int sx= (const int)sd->mtex[sd->texact]->size[0];
- const int sy= (const int)sd->texsep ? sd->mtex[sd->texact]->size[1] : sx;
+ const int sx= (const int)br->mtex[br->texact]->size[0];
+ const int sy= (const int)sd->texsep ? br->mtex[br->texact]->size[1] : sx;
float fx= point_2d[0];
float fy= point_2d[1];
@@ -885,7 +888,7 @@ static void sculpt_clear_damaged_areas(SculptSession *ss)
}
}
-static void do_brush_action(SculptData *sd, StrokeCache *cache)
+static void do_brush_action(Sculpt *sd, StrokeCache *cache)
{
SculptSession *ss = sd->session;
float av_dist;
@@ -989,7 +992,7 @@ static void calc_brushdata_symm(StrokeCache *cache, const char symm)
cache->symmetry= symm;
}
-static void do_symmetrical_brush_actions(SculptData *sd, StrokeCache *cache)
+static void do_symmetrical_brush_actions(Sculpt *sd, StrokeCache *cache)
{
const char symm = sd->flags & 7;
int i;
@@ -1074,10 +1077,11 @@ static void projverts_clear_inside(SculptSession *ss)
ss->projverts[i].inside = 0;
}
-static void sculptmode_update_tex(SculptData *sd)
+static void sculptmode_update_tex(Sculpt *sd)
{
SculptSession *ss= sd->session;
- MTex *mtex = sd->mtex[sd->texact];
+ Brush *br = sd->brush;
+ MTex *mtex = br->mtex[br->texact];
TexResult texres;
float x, y, step=2.0/TC_SIZE, co[3];
int hasrgb, ix, iy;
@@ -1085,7 +1089,7 @@ static void sculptmode_update_tex(SculptData *sd)
memset(&texres, 0, sizeof(TexResult));
/* Skip Default brush shape and non-textures */
- if(sd->texact == -1 || !sd->mtex[sd->texact]) return;
+ if(br->texact == -1 || !br->mtex[sd->texact]) return;
if(ss->texcache) {
MEM_freeN(ss->texcache);
@@ -1096,7 +1100,7 @@ static void sculptmode_update_tex(SculptData *sd)
ss->texcache = MEM_callocN(sizeof(int) * ss->texcache_w * ss->texcache_h, "Sculpt Texture cache");
if(mtex && mtex->tex) {
- BKE_image_get_ibuf(sd->mtex[sd->texact]->tex->ima, NULL);
+ BKE_image_get_ibuf(br->mtex[br->texact]->tex->ima, NULL);
/*do normalized cannonical view coords for texture*/
for (y=-1.0, iy=0; iy<TC_SIZE; iy++, y += step) {
@@ -1128,7 +1132,7 @@ static void sculptmode_update_tex(SculptData *sd)
#if 0
/* pr_mouse is only used for the grab brush, can be NULL otherwise */
-static void init_brushaction(SculptData *sd, BrushAction *a, short *mouse, short *pr_mouse)
+static void init_brushaction(Sculpt *sd, BrushAction *a, short *mouse, short *pr_mouse)
{
SculptSession *ss = sd->session;
Brush *b = sd->brush;
@@ -1253,7 +1257,7 @@ static void sculpt_radialcontrol_callback(const int mode, const int val)
/* Returns GL handle to brush texture */
static GLuint sculpt_radialcontrol_calctex()
{
- SculptData *sd= sculpt_data();
+ Sculpt *sd= sculpt_data();
SculptSession *ss= sculpt_session();
int i, j;
const int tsz = TC_SIZE;
@@ -1288,7 +1292,7 @@ static GLuint sculpt_radialcontrol_calctex()
void sculpt_radialcontrol_start(int mode)
{
- SculptData *sd = sculpt_data();
+ Sculpt *sd = sculpt_data();
SculptSession *ss = sculpt_session();
BrushData *br = sculptmode_brush();
int orig=1, max=100;
@@ -1343,7 +1347,7 @@ void sculptmode_selectbrush_menu(void)
{
/* XXX: I guess menus belong elsewhere too?
- SculptData *sd= sculpt_data();
+ Sculpt *sd= sculpt_data();
int val;
pupmenu_set_active(sd->brush_type);
@@ -1511,7 +1515,7 @@ void sculptmode_draw_mesh(int only_damaged)
/* XXX */
#if 0
-static void sculpt_undo_push(SculptData *sd)
+static void sculpt_undo_push(Sculpt *sd)
{
switch(sd->brush->sculpt_tool) {
case SCULPT_TOOL_DRAW:
@@ -1588,7 +1592,7 @@ static void sculpt_cache_free(StrokeCache *cache)
}
/* Initialize the stroke cache invariants from operator properties */
-static void sculpt_update_cache_invariants(SculptData *sd, bContext *C, wmOperator *op)
+static void sculpt_update_cache_invariants(Sculpt *sd, bContext *C, wmOperator *op)
{
StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache");
int i;
@@ -1633,7 +1637,7 @@ static void sculpt_update_cache_invariants(SculptData *sd, bContext *C, wmOperat
}
/* Initialize the stroke cache variants from operator properties */
-static void sculpt_update_cache_variants(SculptData *sd, PointerRNA *ptr)
+static void sculpt_update_cache_variants(Sculpt *sd, PointerRNA *ptr)
{
StrokeCache *cache = sd->session->cache;
float grab_location[3];
@@ -1667,7 +1671,7 @@ static void sculpt_update_cache_variants(SculptData *sd, PointerRNA *ptr)
/* Initialize stroke operator properties */
static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmEvent *event, SculptSession *ss)
{
- SculptData *sd = &CTX_data_scene(C)->sculptdata;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob= CTX_data_active_object(C);
ModifierData *md;
ViewContext vc;
@@ -1710,7 +1714,7 @@ static void sculpt_brush_stroke_init_properties(bContext *C, wmOperator *op, wmE
static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- SculptData *sd = &CTX_data_scene(C)->sculptdata;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
view3d_operator_needs_opengl(C);
sculpt_brush_stroke_init_properties(C, op, event, sd->session);
@@ -1723,7 +1727,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
return OPERATOR_RUNNING_MODAL;
}
-static void sculpt_restore_mesh(SculptData *sd)
+static void sculpt_restore_mesh(Sculpt *sd)
{
StrokeCache *cache = sd->session->cache;
int i;
@@ -1749,7 +1753,7 @@ static void sculpt_post_stroke_free(SculptSession *ss)
static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
{
PointerRNA itemptr;
- SculptData *sd = &CTX_data_scene(C)->sculptdata;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob= CTX_data_active_object(C);
ARegion *ar = CTX_wm_region(C);
float center[3];
@@ -1766,7 +1770,7 @@ static int sculpt_brush_stroke_modal(bContext *C, wmOperator *op, wmEvent *event
sculpt_update_cache_variants(sd, &itemptr);
sculpt_restore_mesh(sd);
- do_symmetrical_brush_actions(&CTX_data_scene(C)->sculptdata, sd->session->cache);
+ do_symmetrical_brush_actions(CTX_data_tool_settings(C)->sculpt, sd->session->cache);
sculpt_post_stroke_free(sd->session);
@@ -1789,7 +1793,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
ARegion *ar = CTX_wm_region(C);
- SculptData *sd = &CTX_data_scene(C)->sculptdata;
+ Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
view3d_operator_needs_opengl(C);
sculpt_update_cache_invariants(sd, C, op);
@@ -1853,7 +1857,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
/* XXX: The code for drawing all the paint cursors is really the same, would be better to unify them */
static void draw_paint_cursor(bContext *C, int x, int y)
{
- SculptData *sd= &CTX_data_scene(C)->sculptdata;
+ Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
glTranslatef((float)x, (float)y, 0.0f);
@@ -1867,30 +1871,40 @@ static void draw_paint_cursor(bContext *C, int x, int y)
glTranslatef((float)-x, (float)-y, 0.0f);
}
+static void init_sculpt(ToolSettings *ts)
+{
+ ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data");
+
+ /* XXX: initialize persistent sculpt settings */
+}
+
static int sculpt_toggle_mode(bContext *C, wmOperator *op)
{
- Scene *sce = CTX_data_scene(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
if(G.f & G_SCULPTMODE) {
/* Leave sculptmode */
G.f &= ~G_SCULPTMODE;
- WM_paint_cursor_end(CTX_wm_manager(C), sce->sculptdata.session->cursor);
+ WM_paint_cursor_end(CTX_wm_manager(C), ts->sculpt->session->cursor);
- sculptsession_free(sce);
+ sculptsession_free(ts->sculpt);
}
else {
/* Enter sculptmode */
G.f |= G_SCULPTMODE;
- sce->sculptdata.session = MEM_callocN(sizeof(SculptSession), "sculpt session");
+ if(!ts->sculpt)
+ init_sculpt(ts);
+
+ ts->sculpt->session = MEM_callocN(sizeof(SculptSession), "sculpt session");
/* Needed for testing, if there's no brush then create one */
- sce->sculptdata.brush = add_brush("test brush");
+ ts->sculpt->brush = add_brush("test brush");
/* Activate visible brush */
- sce->sculptdata.session->cursor =
+ ts->sculpt->session->cursor =
WM_paint_cursor_activate(CTX_wm_manager(C), sculpt_brush_stroke_poll, draw_paint_cursor);
}
@@ -1915,7 +1929,7 @@ void ED_operatortypes_sculpt()
WM_operatortype_append(SCULPT_OT_toggle_mode);
}
-void sculpt(SculptData *sd)
+void sculpt(Sculpt *sd)
{
#if 0
SculptSession *ss= sd->session;
diff --git a/source/blender/editors/sculpt/sculpt_intern.h b/source/blender/editors/sculpt/sculpt_intern.h
index dc936ca575c..dd668125aff 100644
--- a/source/blender/editors/sculpt/sculpt_intern.h
+++ b/source/blender/editors/sculpt/sculpt_intern.h
@@ -43,7 +43,7 @@ struct Object;
struct PartialVisibility;
struct Scene;
struct ScrArea;
-struct SculptData;
+struct Sculpt;
struct SculptStroke;
/* Interface */
@@ -54,17 +54,17 @@ void sculpt_stroke_draw(struct SculptStroke *);
void sculpt_radialcontrol_start(int mode);
struct Brush *sculptmode_brush(void);
-//void do_symmetrical_brush_actions(struct SculptData *sd, struct wmOperator *wm, struct BrushAction *a, short *, short *);
+//void do_symmetrical_brush_actions(struct Sculpt *sd, struct wmOperator *wm, struct BrushAction *a, short *, short *);
char sculpt_modifiers_active(struct Object *ob);
-void sculpt(SculptData *sd);
+void sculpt(Sculpt *sd);
/* Stroke */
struct SculptStroke *sculpt_stroke_new(const int max);
void sculpt_stroke_free(struct SculptStroke *);
void sculpt_stroke_add_point(struct SculptStroke *, const short x, const short y);
-void sculpt_stroke_apply(struct SculptData *sd, struct SculptStroke *);
-void sculpt_stroke_apply_all(struct SculptData *sd, struct SculptStroke *);
+void sculpt_stroke_apply(struct Sculpt *sd, struct SculptStroke *);
+void sculpt_stroke_apply_all(struct Sculpt *sd, struct SculptStroke *);
/* Partial Mesh Visibility */
void sculptmode_pmv(int mode);
diff --git a/source/blender/editors/sculpt/stroke.c b/source/blender/editors/sculpt/stroke.c
index 24811ac3dbd..ffcb938a33f 100644
--- a/source/blender/editors/sculpt/stroke.c
+++ b/source/blender/editors/sculpt/stroke.c
@@ -172,7 +172,7 @@ static float sculpt_stroke_final_length(SculptStroke *stroke)
}
/* If partial is nonzero, cuts off apply after that length has been processed */
-static StrokePoint *sculpt_stroke_apply_generic(SculptData *sd, SculptStroke *stroke, const int partial)
+static StrokePoint *sculpt_stroke_apply_generic(Sculpt *sd, SculptStroke *stroke, const int partial)
{
const int sdspace = sd->spacing;
const short spacing = sdspace > 0 ? sdspace : 2;
@@ -215,7 +215,7 @@ static StrokePoint *sculpt_stroke_apply_generic(SculptData *sd, SculptStroke *st
return p ? p->next : NULL;
}
-void sculpt_stroke_apply(SculptData *sd, SculptStroke *stroke)
+void sculpt_stroke_apply(Sculpt *sd, SculptStroke *stroke)
{
/* TODO: make these values user-modifiable? */
const int partial_len = 100;
@@ -242,7 +242,7 @@ void sculpt_stroke_apply(SculptData *sd, SculptStroke *stroke)
}
}
-void sculpt_stroke_apply_all(SculptData *sd, SculptStroke *stroke)
+void sculpt_stroke_apply_all(Sculpt *sd, SculptStroke *stroke)
{
sculpt_stroke_create_final(stroke);
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index e06d8f16330..33f7308ba03 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -4843,10 +4843,9 @@ void do_view3d_sculptmenu(bContext *C, void *arg, int event)
uiBlock *view3d_sculpt_inputmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unused)
{
- Scene *scene= CTX_data_scene(C);
uiBlock *block;
short yco= 0, menuwidth= 120;
- SculptData *sd= &scene->sculptdata;
+ Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
block= uiBeginBlock(C, handle->region, "view3d_sculpt_inputmenu", UI_EMBOSSP, UI_HELV);
uiBlockSetButmFunc(block, do_view3d_sculpt_inputmenu, NULL);
@@ -4866,7 +4865,7 @@ uiBlock *view3d_sculptmenu(bContext *C, uiMenuBlockHandle *handle, void *arg_unu
ScrArea *sa= CTX_wm_area(C);
View3D *v3d= sa->spacedata.first;
uiBlock *block;
- SculptData *sd= &scene->sculptdata;
+ Sculpt *sd= CTX_data_tool_settings(C)->sculpt;
// XXX const BrushData *br= sculptmode_brush();
short yco= 0, menuwidth= 120;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 4e9dfada96c..3a40df66585 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -375,6 +375,25 @@ typedef struct TransformOrientation {
float mat[3][3];
} TransformOrientation;
+struct SculptSession;
+typedef struct Sculpt
+{
+ /* Note! a deep copy of this struct must be done header_info.c's copy_scene function */
+ /* Data stored only from entering sculptmode until exiting sculptmode */
+ struct SculptSession *session;
+ struct Brush *brush;
+
+ /* For rotating around a pivot point */
+ float pivot[3];
+ int flags;
+ /* For the Brush Shape */
+ short texact, texnr, spacing;
+ char texrept, texsep, averaging;
+ /* Control tablet input */
+ char tablet_size, tablet_strength;
+ char pad[5];
+} Sculpt;
+
typedef struct VPaint {
float r, g, b, a; /* paint color */
float weight; /* weight paint */
@@ -399,10 +418,10 @@ typedef struct VPaint {
#define VP_ONLYVGROUP 128
-
typedef struct ToolSettings {
VPaint *vpaint; /* vertex paint */
VPaint *wpaint; /* weight paint */
+ Sculpt *sculpt;
/* Subdivide Settings */
short cornertype;
@@ -483,38 +502,6 @@ typedef struct ToolSettings {
char edge_mode;
} ToolSettings;
-struct SculptSession;
-typedef struct SculptData
-{
- /* Note! a deep copy of this struct must be done header_info.c's copy_scene function */
-
- /* Data stored only from entering sculptmode until exiting sculptmode */
- struct SculptSession *session;
-
- /* Pointers to all of sculptmodes's textures */
- struct MTex *mtex[18];
-
- struct Brush *brush;
-
- /* For rotating around a pivot point */
- float pivot[3];
-
- int flags;
-
- /* For the Brush Shape */
- short texact, texnr;
- short spacing;
- char texrept;
- char texsep;
-
- char averaging;
-
- /* Control tablet input */
- char tablet_size, tablet_strength;
-
- char pad[5];
-} SculptData;
-
typedef struct bStats {
/* scene totals for visible layers */
int totobj, totlamp, totobjsel, totcurve, totmesh, totarmature;
@@ -579,9 +566,6 @@ typedef struct Scene {
short dagisvalid, dagflags;
short pad4, recalc; /* recalc = counterpart of ob->recalc */
- /* Sculptmode data */
- struct SculptData sculptdata;
-
/* frame step. */
int frame_step;
int pad;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index c86544d397f..fa8871ff378 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -198,7 +198,7 @@ extern StructRNA RNA_Scene;
extern StructRNA RNA_SceneSequence;
extern StructRNA RNA_Screen;
extern StructRNA RNA_ScriptLink;
-extern StructRNA RNA_SculptData;
+extern StructRNA RNA_Sculpt;
extern StructRNA RNA_Sensor;
extern StructRNA RNA_Sequence;
extern StructRNA RNA_SequenceColorBalance;
@@ -251,6 +251,7 @@ extern StructRNA RNA_ThemeTimeline;
extern StructRNA RNA_ThemeUserInterface;
extern StructRNA RNA_ThemeUserPreferences;
extern StructRNA RNA_ThemeView3D;
+extern StructRNA RNA_ToolSettings;
extern StructRNA RNA_TouchSensor;
extern StructRNA RNA_TransformSequence;
extern StructRNA RNA_UVProjectModifier;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ff2ba8ed0b5..f1b13780439 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -80,12 +80,12 @@ static void rna_Scene_frame_update(bContext *C, PointerRNA *ptr)
#else
-void rna_def_sculptdata(BlenderRNA *brna)
+void rna_def_sculpt(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- srna= RNA_def_struct(brna, "SculptData", NULL);
+ srna= RNA_def_struct(brna, "Sculpt", NULL);
RNA_def_struct_nested(brna, srna, "Scene");
RNA_def_struct_ui_text(srna, "Sculpt", "");
@@ -122,6 +122,22 @@ void rna_def_sculptdata(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Partial Redraw", "Optimize sculpting by only refreshing modified faces.");
}
+void rna_def_tool_settings(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "ToolSettings", NULL);
+ RNA_def_struct_nested(brna, srna, "Scene");
+ RNA_def_struct_ui_text(srna, "Tool Settings", "");
+
+ prop= RNA_def_property(srna, "sculpt", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Sculpt");
+ RNA_def_property_ui_text(prop, "Sculpt", "");
+
+ rna_def_sculpt(brna);
+}
+
void RNA_def_scene(BlenderRNA *brna)
{
StructRNA *srna;
@@ -211,12 +227,12 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "radio");
RNA_def_property_ui_text(prop, "Radiosity", "");
- prop= RNA_def_property(srna, "sculpt", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "sculptdata");
- RNA_def_property_struct_type(prop, "SculptData");
- RNA_def_property_ui_text(prop, "Sculpt", "");
+ prop= RNA_def_property(srna, "tool_settings", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "toolsettings");
+ RNA_def_property_struct_type(prop, "ToolSettings");
+ RNA_def_property_ui_text(prop, "Tool Settings", "");
- rna_def_sculptdata(brna);
+ rna_def_tool_settings(brna);
}
#endif