[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18426] branches/blender2.5/blender/source /blender/editors/sculpt: More sculpt cleanup, removed sculpt_data and sculpt_session functions,
Nicholas Bishop
nicholasbishop at gmail.com
Fri Jan 9 01:38:50 CET 2009
Revision: 18426
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18426
Author: nicholasbishop
Date: 2009-01-09 01:38:48 +0100 (Fri, 09 Jan 2009)
Log Message:
-----------
More sculpt cleanup, removed sculpt_data and sculpt_session functions,
both of which used G(lobal)
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
branches/blender2.5/blender/source/blender/editors/sculpt/sculpt_intern.h
branches/blender2.5/blender/source/blender/editors/sculpt/stroke.c
Modified: branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c 2009-01-08 22:49:03 UTC (rev 18425)
+++ branches/blender2.5/blender/source/blender/editors/sculpt/sculpt.c 2009-01-09 00:38:48 UTC (rev 18426)
@@ -32,8 +32,6 @@
*
*/
-// XXX #include "GHOST_Types.h"
-
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
@@ -164,39 +162,25 @@
static Object *active_ob= NULL;
-SculptData *sculpt_data(void)
-{
- return NULL; /*XXX: return &G.scene->sculptdata; */
-}
+static void init_brushaction(SculptData *sd, BrushAction *a, short *, short *);
-static void sculpt_init_session(void);
-static void init_brushaction(BrushAction *a, short *, short *);
-static void sculpt_undo_push(const short);
-SculptSession *sculpt_session(void)
-{
- if(!sculpt_data()->session)
- sculpt_init_session();
- return sculpt_data()->session;
-}
-
/* ===== MEMORY =====
*
* Allocate/initialize/free data
*/
-static void sculpt_init_session(void)
+static void sculpt_init_session(SculptData *sd)
{
- if(sculpt_data()->session)
+ if(sd->session)
;/*XXX: sculptsession_free(G.scene); */
- sculpt_data()->session= MEM_callocN(sizeof(SculptSession), "SculptSession");
+ sd->session= MEM_callocN(sizeof(SculptSession), "SculptSession");
}
/* vertex_users is an array of Lists that store all the faces that use a
particular vertex. vertex_users is in the same order as mesh.mvert */
-static void calc_vertex_users()
+static void calc_vertex_users(SculptSession *ss)
{
- SculptSession *ss= sculpt_session();
int i,j;
IndexNode *node= NULL;
@@ -292,9 +276,8 @@
/* Uses window coordinates (x,y) and depth component z to find a point in
modelspace */
-void unproject(float out[3], const short x, const short y, const float z)
+void unproject(SculptSession *ss, float out[3], const short x, const short y, const float z)
{
- SculptSession *ss= sculpt_session();
double ux, uy, uz;
gluUnProject(x,y,z, ss->mats->modelview, ss->mats->projection,
@@ -305,9 +288,8 @@
}
/* Convert a point in model coordinates to 2D screen coordinates. */
-static void projectf(const float v[3], float p[2])
+static void projectf(SculptSession *ss, const float v[3], float p[2])
{
- SculptSession *ss= sculpt_session();
double ux, uy, uz;
gluProject(v[0],v[1],v[2], ss->mats->modelview, ss->mats->projection,
@@ -316,10 +298,10 @@
p[1]= uy;
}
-static void project(const float v[3], short p[2])
+static void project(SculptSession *ss, const float v[3], short p[2])
{
float f[2];
- projectf(v, f);
+ projectf(ss, v, f);
p[0]= f[0];
p[1]= f[1];
@@ -333,9 +315,8 @@
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 */
-char brush_size(Brush *b)
+char brush_size(SculptData *sd, Brush *b)
{
- SculptData *sd = NULL; /* XXX */
float size= b->size;
float pressure= 0; /* XXX: get_pressure(); */
short activedevice= get_activedevice();
@@ -355,9 +336,8 @@
/* 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. */
-float brush_strength(Brush *b, BrushAction *a)
+float brush_strength(SculptData *sd, Brush *b, BrushAction *a)
{
- SculptData *sd = NULL; /* XXX */
float dir= b->flag & BRUSH_DIR_IN ? -1 : 1;
float pressure= 1;
short activedevice= get_activedevice();
@@ -408,9 +388,8 @@
}
}
-void sculpt_axislock(float *co)
+void sculpt_axislock(SculptData *sd, float *co)
{
- SculptData *sd = sculpt_data();
if (sd->flags & (SCULPT_LOCK_X|SCULPT_LOCK_Y|SCULPT_LOCK_Z)) return;
/* XXX: if(G.vd->twmode == V3D_MANIP_LOCAL) { */
if(0) {
@@ -444,10 +423,9 @@
/* Currently only for the draw brush; finds average normal for all active
vertices */
-void calc_area_normal(float out[3], const BrushAction *a, const float *outdir, const ListBase* active_verts)
+void calc_area_normal(SculptData *sd, float out[3], const BrushAction *a, const float *outdir, const ListBase* active_verts)
{
ActiveData *node = active_verts->first;
- SculptData *sd = sculpt_data();
const int view = 0; /* XXX: should probably be a flag, not number: sd->brush_type==SCULPT_TOOL_DRAW ? sculptmode_brush()->view : 0; */
float out_flip[3];
@@ -477,14 +455,14 @@
Normalize(out);
}
-void do_draw_brush(SculptSession *ss, const BrushAction *a, const ListBase* active_verts)
+void do_draw_brush(SculptData *sd, SculptSession *ss, const BrushAction *a, const ListBase* active_verts)
{
float area_normal[3];
ActiveData *node= active_verts->first;
- calc_area_normal(area_normal, a, a->symm.out, active_verts);
+ calc_area_normal(sd, area_normal, a, a->symm.out, active_verts);
- sculpt_axislock(area_normal);
+ sculpt_axislock(sd, area_normal);
while(node){
float *co= ss->mvert[node->Index].co;
@@ -576,14 +554,14 @@
}
}
-void do_grab_brush(SculptSession *ss, BrushAction *a)
+void do_grab_brush(SculptData *sd, SculptSession *ss, BrushAction *a)
{
ActiveData *node= a->grab_active_verts[a->symm.index].first;
float add[3];
float grab_delta[3];
VecCopyf(grab_delta, a->symm.grab_delta);
- sculpt_axislock(grab_delta);
+ sculpt_axislock(sd, grab_delta);
while(node) {
float *co= ss->mvert[node->Index].co;
@@ -598,13 +576,13 @@
}
-void do_layer_brush(SculptSession *ss, BrushAction *a, const ListBase *active_verts)
+void do_layer_brush(SculptData *sd, SculptSession *ss, BrushAction *a, const ListBase *active_verts)
{
float area_normal[3];
ActiveData *node= active_verts->first;
- const float bstr= brush_strength(sculptmode_brush(), a);
+ const float bstr= brush_strength(sd, sculptmode_brush(), a);
- calc_area_normal(area_normal, a, NULL, active_verts);
+ calc_area_normal(sd, area_normal, a, NULL, active_verts);
while(node){
float *disp= &a->layer_disps[node->Index];
@@ -682,14 +660,14 @@
VecMulf(co, 1.0f / FLATTEN_SAMPLE_SIZE);
}
-void do_flatten_brush(SculptSession *ss, const BrushAction *a, const ListBase *active_verts)
+void do_flatten_brush(SculptData *sd, SculptSession *ss, const BrushAction *a, const ListBase *active_verts)
{
ActiveData *node= active_verts->first;
/* area_normal and cntr define the plane towards which vertices are squashed */
float area_normal[3];
float cntr[3];
- calc_area_normal(area_normal, a, a->symm.out, active_verts);
+ calc_area_normal(sd, area_normal, a, a->symm.out, active_verts);
calc_flatten_center(ss, node, cntr);
while(node){
@@ -733,17 +711,15 @@
}
/* Use the warpfac field in MTex to store a rotation value for sculpt textures. Value is in degrees */
-float sculpt_tex_angle(void)
+float sculpt_tex_angle(SculptData *sd)
{
- SculptData *sd= sculpt_data();
if(sd->texact!=-1 && sd->mtex[sd->texact])
return sd->mtex[sd->texact]->warpfac;
return 0;
}
-void set_tex_angle(const float f)
+void set_tex_angle(SculptData *sd, const float f)
{
- SculptData *sd = sculpt_data();
if(sd->texact != -1 && sd->mtex[sd->texact])
sd->mtex[sd->texact]->warpfac = f;
}
@@ -796,10 +772,9 @@
}
/* Return a multiplier for brush strength on a particular vertex. */
-float tex_strength(BrushAction *a, float *point, const float len,const unsigned vindex)
+float tex_strength(SculptData *sd, BrushAction *a, float *point, const float len,const unsigned vindex)
{
- SculptData *sd= sculpt_data();
- SculptSession *ss= sculpt_session();
+ SculptSession *ss= sd->session;
float avg= 1;
if(sd->texact==-1 || !sd->mtex[sd->texact])
@@ -824,7 +799,7 @@
}
else if(ss->texcache) {
const float bsize= a->radius * 2;
- const float rot= to_rad(sculpt_tex_angle()) + a->anchored_rot;
+ const float rot= to_rad(sculpt_tex_angle(sd)) + a->anchored_rot;
int px, py;
float flip[3], point_2d[2];
@@ -833,7 +808,7 @@
that the brush texture will be oriented correctly. */
VecCopyf(flip, point);
flip_coord(flip, a->symm.index);
- projectf(flip, point_2d);
+ projectf(ss, flip, point_2d);
/* For Tile and Drag modes, get the 2D screen coordinates of the
and scale them up or down to the texture size. */
@@ -881,22 +856,21 @@
/* Mark area around the brush as damaged. projverts are marked if they are
inside the area and the damaged rectangle in 2D screen coordinates is
added to damaged_rects. */
-void sculpt_add_damaged_rect(BrushAction *a)
+void sculpt_add_damaged_rect(SculptSession *ss, BrushAction *a)
{
short p[2];
RectNode *rn= MEM_mallocN(sizeof(RectNode),"RectNode");
- SculptSession *ss = sculpt_session();
const float radius = a->radius > a->prev_radius ? a->radius : a->prev_radius;
unsigned i;
/* Find center */
- project(a->symm.center_3d, p);
+ project(ss, a->symm.center_3d, p);
rn->r.xmin= p[0] - radius;
rn->r.ymin= p[1] - radius;
rn->r.xmax= p[0] + radius;
rn->r.ymax= p[1] + radius;
- BLI_addtail(&sculpt_session()->damaged_rects, rn);
+ BLI_addtail(&ss->damaged_rects, rn);
/* Update insides */
for(i=0; i<ss->totvert; ++i) {
@@ -939,7 +913,7 @@
}
}
-void do_brush_action(Brush *b, BrushAction *a)
+void do_brush_action(SculptData *sd, BrushAction *a)
{
int i;
float av_dist;
@@ -947,12 +921,12 @@
ActiveData *adata= 0;
float *vert;
Mesh *me= NULL; /*XXX: get_mesh(OBACT); */
- const float bstrength= brush_strength(sculptmode_brush(), a);
+ const float bstrength= brush_strength(sd, sculptmode_brush(), a);
KeyBlock *keyblock= NULL; /*XXX: ob_get_keyblock(OBACT); */
- SculptData *sd = sculpt_data();
- SculptSession *ss = sculpt_session();
+ SculptSession *ss = sd->session;
+ Brush *b = sd->brush;
- sculpt_add_damaged_rect(a);
+ sculpt_add_damaged_rect(ss, a);
/* Build a list of all vertices that are potentially within the brush's
area of influence. Only do this once for the grab brush. */
@@ -969,7 +943,7 @@
adata->Index = i;
/* Fade is used to store the final strength at which the brush
should modify a particular vertex. */
- adata->Fade= tex_strength(a, vert, av_dist, i) * bstrength;
+ adata->Fade= tex_strength(sd, a, vert, av_dist, i) * bstrength;
adata->dist = av_dist;
if(b->sculpt_tool == SCULPT_TOOL_GRAB && a->firsttime)
@@ -986,7 +960,7 @@
/* Apply one type of brush action */
switch(b->sculpt_tool){
case SCULPT_TOOL_DRAW:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list