forked from bartvdbraak/blender
style cleanup: gpencil & metaball
This commit is contained in:
parent
f605679515
commit
81255ca8ce
@ -74,12 +74,12 @@
|
||||
|
||||
/* flags for sflag */
|
||||
typedef enum eDrawStrokeFlags {
|
||||
GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */
|
||||
GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */
|
||||
GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */
|
||||
GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */
|
||||
GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */
|
||||
GP_DRAWDATA_NO_XRAY = (1<<5), /* don't draw xray in 3D view (which is default) */
|
||||
GP_DRAWDATA_NOSTATUS = (1 << 0), /* don't draw status info */
|
||||
GP_DRAWDATA_ONLY3D = (1 << 1), /* only draw 3d-strokes */
|
||||
GP_DRAWDATA_ONLYV2D = (1 << 2), /* only draw 'canvas' strokes */
|
||||
GP_DRAWDATA_ONLYI2D = (1 << 3), /* only draw 'image' strokes */
|
||||
GP_DRAWDATA_IEDITHACK = (1 << 4), /* special hack for drawing strokes in Image Editor (weird coordinates) */
|
||||
GP_DRAWDATA_NO_XRAY = (1 << 5), /* don't draw xray in 3D view (which is default) */
|
||||
} eDrawStrokeFlags;
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ typedef enum eDrawStrokeFlags {
|
||||
/* ----- Tool Buffer Drawing ------ */
|
||||
|
||||
/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
|
||||
static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag)
|
||||
static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickness, short dflag, short sflag)
|
||||
{
|
||||
tGPspoint *pt;
|
||||
int i;
|
||||
@ -100,7 +100,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick
|
||||
return;
|
||||
|
||||
/* check if buffer can be drawn */
|
||||
if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D))
|
||||
if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
|
||||
return;
|
||||
|
||||
/* if drawing a single point, draw it larger */
|
||||
@ -122,7 +122,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick
|
||||
glLineWidth(oldpressure * thickness);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
|
||||
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
|
||||
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
|
||||
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
|
||||
*/
|
||||
@ -154,7 +154,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick
|
||||
/* ----- Existing Strokes Drawing (3D and Point) ------ */
|
||||
|
||||
/* draw a given stroke - just a single dot (only one point) */
|
||||
static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
|
||||
static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
|
||||
{
|
||||
/* draw point */
|
||||
if (sflag & GP_STROKE_3DSPACE) {
|
||||
@ -167,16 +167,16 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl
|
||||
|
||||
/* get coordinates of point */
|
||||
if (sflag & GP_STROKE_2DSPACE) {
|
||||
co[0]= points->x;
|
||||
co[1]= points->y;
|
||||
co[0] = points->x;
|
||||
co[1] = points->y;
|
||||
}
|
||||
else if (sflag & GP_STROKE_2DIMAGE) {
|
||||
co[0]= (points->x * winx) + offsx;
|
||||
co[1]= (points->y * winy) + offsy;
|
||||
co[0] = (points->x * winx) + offsx;
|
||||
co[1] = (points->y * winy) + offsy;
|
||||
}
|
||||
else {
|
||||
co[0]= (points->x / 100 * winx) + offsx;
|
||||
co[1]= (points->y / 100 * winy) + offsy;
|
||||
co[0] = (points->x / 100 * winx) + offsx;
|
||||
co[1] = (points->y / 100 * winy) + offsy;
|
||||
}
|
||||
|
||||
/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok
|
||||
@ -206,7 +206,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl
|
||||
}
|
||||
|
||||
/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
|
||||
static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short debug)
|
||||
static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug)
|
||||
{
|
||||
bGPDspoint *pt;
|
||||
float oldpressure = 0.0f;
|
||||
@ -214,7 +214,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes
|
||||
|
||||
/* draw stroke curve */
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
|
||||
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
|
||||
/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
|
||||
* and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
|
||||
*/
|
||||
@ -240,7 +240,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes
|
||||
/* draw debug points of curve on top? */
|
||||
if (debug) {
|
||||
glBegin(GL_POINTS);
|
||||
for (i=0, pt=points; i < totpoints && pt; i++, pt++)
|
||||
for (i = 0, pt = points; i < totpoints && pt; i++, pt++)
|
||||
glVertex3fv(&pt->x);
|
||||
glEnd();
|
||||
}
|
||||
@ -249,11 +249,11 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes
|
||||
/* ----- Fancy 2D-Stroke Drawing ------ */
|
||||
|
||||
/* draw a given stroke in 2d */
|
||||
static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
|
||||
static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag,
|
||||
short debug, int offsx, int offsy, int winx, int winy)
|
||||
{
|
||||
/* otherwise thickness is twice that of the 3D view */
|
||||
float thickness= (float)thickness_s * 0.5f;
|
||||
float thickness = (float)thickness_s * 0.5f;
|
||||
|
||||
/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better
|
||||
* - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke
|
||||
@ -265,19 +265,19 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
int i;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
|
||||
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
|
||||
if (sflag & GP_STROKE_2DSPACE) {
|
||||
glVertex2f(pt->x, pt->y);
|
||||
}
|
||||
else if (sflag & GP_STROKE_2DIMAGE) {
|
||||
const float x= (pt->x * winx) + offsx;
|
||||
const float y= (pt->y * winy) + offsy;
|
||||
const float x = (pt->x * winx) + offsx;
|
||||
const float y = (pt->y * winy) + offsy;
|
||||
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
else {
|
||||
const float x= (pt->x / 100 * winx) + offsx;
|
||||
const float y= (pt->y / 100 * winy) + offsy;
|
||||
const float x = (pt->x / 100 * winx) + offsx;
|
||||
const float y = (pt->y / 100 * winy) + offsy;
|
||||
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
@ -296,7 +296,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) {
|
||||
for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
|
||||
float s0[2], s1[2]; /* segment 'center' points */
|
||||
float t0[2], t1[2]; /* tessellated coordinates */
|
||||
float m1[2], m2[2]; /* gradient and normal */
|
||||
@ -305,58 +305,58 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
|
||||
/* get x and y coordinates from points */
|
||||
if (sflag & GP_STROKE_2DSPACE) {
|
||||
s0[0]= pt1->x; s0[1]= pt1->y;
|
||||
s1[0]= pt2->x; s1[1]= pt2->y;
|
||||
s0[0] = pt1->x; s0[1] = pt1->y;
|
||||
s1[0] = pt2->x; s1[1] = pt2->y;
|
||||
}
|
||||
else if (sflag & GP_STROKE_2DIMAGE) {
|
||||
s0[0]= (pt1->x * winx) + offsx;
|
||||
s0[1]= (pt1->y * winy) + offsy;
|
||||
s1[0]= (pt2->x * winx) + offsx;
|
||||
s1[1]= (pt2->y * winy) + offsy;
|
||||
s0[0] = (pt1->x * winx) + offsx;
|
||||
s0[1] = (pt1->y * winy) + offsy;
|
||||
s1[0] = (pt2->x * winx) + offsx;
|
||||
s1[1] = (pt2->y * winy) + offsy;
|
||||
}
|
||||
else {
|
||||
s0[0]= (pt1->x / 100 * winx) + offsx;
|
||||
s0[1]= (pt1->y / 100 * winy) + offsy;
|
||||
s1[0]= (pt2->x / 100 * winx) + offsx;
|
||||
s1[1]= (pt2->y / 100 * winy) + offsy;
|
||||
s0[0] = (pt1->x / 100 * winx) + offsx;
|
||||
s0[1] = (pt1->y / 100 * winy) + offsy;
|
||||
s1[0] = (pt2->x / 100 * winx) + offsx;
|
||||
s1[1] = (pt2->y / 100 * winy) + offsy;
|
||||
}
|
||||
|
||||
/* calculate gradient and normal - 'angle'=(ny/nx) */
|
||||
m1[1]= s1[1] - s0[1];
|
||||
m1[0]= s1[0] - s0[0];
|
||||
m1[1] = s1[1] - s0[1];
|
||||
m1[0] = s1[0] - s0[0];
|
||||
normalize_v2(m1);
|
||||
m2[1]= -m1[0];
|
||||
m2[0]= m1[1];
|
||||
m2[1] = -m1[0];
|
||||
m2[0] = m1[1];
|
||||
|
||||
/* always use pressure from first point here */
|
||||
pthick= (pt1->pressure * thickness);
|
||||
pthick = (pt1->pressure * thickness);
|
||||
|
||||
/* if the first segment, start of segment is segment's normal */
|
||||
if (i == 0) {
|
||||
/* draw start cap first
|
||||
* - make points slightly closer to center (about halfway across)
|
||||
*/
|
||||
mt[0]= m2[0] * pthick * 0.5f;
|
||||
mt[1]= m2[1] * pthick * 0.5f;
|
||||
sc[0]= s0[0] - (m1[0] * pthick * 0.75f);
|
||||
sc[1]= s0[1] - (m1[1] * pthick * 0.75f);
|
||||
mt[0] = m2[0] * pthick * 0.5f;
|
||||
mt[1] = m2[1] * pthick * 0.5f;
|
||||
sc[0] = s0[0] - (m1[0] * pthick * 0.75f);
|
||||
sc[1] = s0[1] - (m1[1] * pthick * 0.75f);
|
||||
|
||||
t0[0]= sc[0] - mt[0];
|
||||
t0[1]= sc[1] - mt[1];
|
||||
t1[0]= sc[0] + mt[0];
|
||||
t1[1]= sc[1] + mt[1];
|
||||
t0[0] = sc[0] - mt[0];
|
||||
t0[1] = sc[1] - mt[1];
|
||||
t1[0] = sc[0] + mt[0];
|
||||
t1[1] = sc[1] + mt[1];
|
||||
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t1);
|
||||
|
||||
/* calculate points for start of segment */
|
||||
mt[0]= m2[0] * pthick;
|
||||
mt[1]= m2[1] * pthick;
|
||||
mt[0] = m2[0] * pthick;
|
||||
mt[1] = m2[1] * pthick;
|
||||
|
||||
t0[0]= s0[0] - mt[0];
|
||||
t0[1]= s0[1] - mt[1];
|
||||
t1[0]= s0[0] + mt[0];
|
||||
t1[1]= s0[1] + mt[1];
|
||||
t0[0] = s0[0] - mt[0];
|
||||
t0[1] = s0[1] - mt[1];
|
||||
t1[0] = s0[0] + mt[0];
|
||||
t1[1] = s0[1] + mt[1];
|
||||
|
||||
/* draw this line twice (first to finish off start cap, then for stroke) */
|
||||
glVertex2fv(t1);
|
||||
@ -370,29 +370,29 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
float athick, dfac; /* actual thickness, difference between thicknesses */
|
||||
|
||||
/* calculate gradient of bisector (as average of normals) */
|
||||
mb[0]= (pm[0] + m2[0]) / 2;
|
||||
mb[1]= (pm[1] + m2[1]) / 2;
|
||||
mb[0] = (pm[0] + m2[0]) / 2;
|
||||
mb[1] = (pm[1] + m2[1]) / 2;
|
||||
normalize_v2(mb);
|
||||
|
||||
/* calculate gradient to apply
|
||||
* - as basis, use just pthick * bisector gradient
|
||||
* - if cross-section not as thick as it should be, add extra padding to fix it
|
||||
*/
|
||||
mt[0]= mb[0] * pthick;
|
||||
mt[1]= mb[1] * pthick;
|
||||
athick= len_v2(mt);
|
||||
dfac= pthick - (athick * 2);
|
||||
mt[0] = mb[0] * pthick;
|
||||
mt[1] = mb[1] * pthick;
|
||||
athick = len_v2(mt);
|
||||
dfac = pthick - (athick * 2);
|
||||
|
||||
if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0)) {
|
||||
if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) {
|
||||
mt[0] += (mb[0] * dfac);
|
||||
mt[1] += (mb[1] * dfac);
|
||||
}
|
||||
|
||||
/* calculate points for start of segment */
|
||||
t0[0]= s0[0] - mt[0];
|
||||
t0[1]= s0[1] - mt[1];
|
||||
t1[0]= s0[0] + mt[0];
|
||||
t1[1]= s0[1] + mt[1];
|
||||
t0[0] = s0[0] - mt[0];
|
||||
t0[1] = s0[1] - mt[1];
|
||||
t1[0] = s0[0] + mt[0];
|
||||
t1[1] = s0[1] + mt[1];
|
||||
|
||||
/* draw this line twice (once for end of current segment, and once for start of next) */
|
||||
glVertex2fv(t1);
|
||||
@ -402,18 +402,18 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
}
|
||||
|
||||
/* if last segment, also draw end of segment (defined as segment's normal) */
|
||||
if (i == totpoints-2) {
|
||||
if (i == totpoints - 2) {
|
||||
/* for once, we use second point's pressure (otherwise it won't be drawn) */
|
||||
pthick= (pt2->pressure * thickness);
|
||||
pthick = (pt2->pressure * thickness);
|
||||
|
||||
/* calculate points for end of segment */
|
||||
mt[0]= m2[0] * pthick;
|
||||
mt[1]= m2[1] * pthick;
|
||||
mt[0] = m2[0] * pthick;
|
||||
mt[1] = m2[1] * pthick;
|
||||
|
||||
t0[0]= s1[0] - mt[0];
|
||||
t0[1]= s1[1] - mt[1];
|
||||
t1[0]= s1[0] + mt[0];
|
||||
t1[1]= s1[1] + mt[1];
|
||||
t0[0] = s1[0] - mt[0];
|
||||
t0[1] = s1[1] - mt[1];
|
||||
t1[0] = s1[0] + mt[0];
|
||||
t1[1] = s1[1] + mt[1];
|
||||
|
||||
/* draw this line twice (once for end of stroke, and once for endcap)*/
|
||||
glVertex2fv(t1);
|
||||
@ -425,15 +425,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
/* draw end cap as last step
|
||||
* - make points slightly closer to center (about halfway across)
|
||||
*/
|
||||
mt[0]= m2[0] * pthick * 0.5f;
|
||||
mt[1]= m2[1] * pthick * 0.5f;
|
||||
sc[0]= s1[0] + (m1[0] * pthick * 0.75f);
|
||||
sc[1]= s1[1] + (m1[1] * pthick * 0.75f);
|
||||
mt[0] = m2[0] * pthick * 0.5f;
|
||||
mt[1] = m2[1] * pthick * 0.5f;
|
||||
sc[0] = s1[0] + (m1[0] * pthick * 0.75f);
|
||||
sc[1] = s1[1] + (m1[1] * pthick * 0.75f);
|
||||
|
||||
t0[0]= sc[0] - mt[0];
|
||||
t0[1]= sc[1] - mt[1];
|
||||
t1[0]= sc[0] + mt[0];
|
||||
t1[1]= sc[1] + mt[1];
|
||||
t0[0] = sc[0] - mt[0];
|
||||
t0[1] = sc[1] - mt[1];
|
||||
t1[0] = sc[0] + mt[0];
|
||||
t1[1] = sc[1] + mt[1];
|
||||
|
||||
glVertex2fv(t1);
|
||||
glVertex2fv(t0);
|
||||
@ -452,19 +452,19 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
int i;
|
||||
|
||||
glBegin(GL_POINTS);
|
||||
for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
|
||||
for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
|
||||
if (sflag & GP_STROKE_2DSPACE) {
|
||||
glVertex2fv(&pt->x);
|
||||
}
|
||||
else if (sflag & GP_STROKE_2DIMAGE) {
|
||||
const float x= (float)((pt->x * winx) + offsx);
|
||||
const float y= (float)((pt->y * winy) + offsy);
|
||||
const float x = (float)((pt->x * winx) + offsx);
|
||||
const float y = (float)((pt->y * winy) + offsy);
|
||||
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
else {
|
||||
const float x= (float)(pt->x / 100 * winx) + offsx;
|
||||
const float y= (float)(pt->y / 100 * winy) + offsy;
|
||||
const float x = (float)(pt->x / 100 * winx) + offsx;
|
||||
const float y = (float)(pt->y / 100 * winy) + offsy;
|
||||
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
@ -476,7 +476,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s
|
||||
/* ----- General Drawing ------ */
|
||||
|
||||
/* draw a set of strokes */
|
||||
static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
|
||||
static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
|
||||
short debug, short lthick, float color[4])
|
||||
{
|
||||
bGPDstroke *gps;
|
||||
@ -484,7 +484,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int
|
||||
/* set color first (may need to reset it again later too) */
|
||||
glColor4fv(color);
|
||||
|
||||
for (gps= gpf->strokes.first; gps; gps= gps->next) {
|
||||
for (gps = gpf->strokes.first; gps; gps = gps->next) {
|
||||
/* check if stroke can be drawn - checks here generally fall into pairs */
|
||||
if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
|
||||
continue;
|
||||
@ -505,7 +505,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int
|
||||
if (gps->totpoints == 1)
|
||||
gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
|
||||
else if (dflag & GP_DRAWDATA_ONLY3D) {
|
||||
const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY);
|
||||
const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY);
|
||||
int mask_orig = 0;
|
||||
|
||||
if (no_xray) {
|
||||
@ -540,7 +540,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int
|
||||
}
|
||||
|
||||
/* draw grease-pencil datablock */
|
||||
static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag)
|
||||
static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag)
|
||||
{
|
||||
bGPDlayer *gpl;
|
||||
|
||||
@ -555,11 +555,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* loop over layers, drawing them */
|
||||
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
|
||||
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
bGPDframe *gpf;
|
||||
|
||||
short debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? 1 : 0;
|
||||
short lthick= gpl->thickness;
|
||||
short lthick = gpl->thickness;
|
||||
float color[4], tcolor[4];
|
||||
|
||||
/* don't draw layer if hidden */
|
||||
@ -567,7 +567,7 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
continue;
|
||||
|
||||
/* get frame to draw */
|
||||
gpf= gpencil_layer_getframe(gpl, cfra, 0);
|
||||
gpf = gpencil_layer_getframe(gpl, cfra, 0);
|
||||
if (gpf == NULL)
|
||||
continue;
|
||||
|
||||
@ -590,11 +590,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
float fac;
|
||||
|
||||
/* draw previous frames first */
|
||||
for (gf=gpf->prev; gf; gf=gf->prev) {
|
||||
for (gf = gpf->prev; gf; gf = gf->prev) {
|
||||
/* check if frame is drawable */
|
||||
if ((gpf->framenum - gf->framenum) <= gpl->gstep) {
|
||||
/* alpha decreases with distance from curframe index */
|
||||
fac= 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
|
||||
fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
|
||||
tcolor[3] = color[3] * fac * 0.66f;
|
||||
gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
|
||||
}
|
||||
@ -603,11 +603,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
}
|
||||
|
||||
/* now draw next frames */
|
||||
for (gf= gpf->next; gf; gf=gf->next) {
|
||||
for (gf = gpf->next; gf; gf = gf->next) {
|
||||
/* check if frame is drawable */
|
||||
if ((gf->framenum - gpf->framenum) <= gpl->gstep) {
|
||||
/* alpha decreases with distance from curframe index */
|
||||
fac= 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1));
|
||||
fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1));
|
||||
tcolor[3] = color[3] * fac * 0.66f;
|
||||
gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
|
||||
}
|
||||
@ -636,7 +636,7 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
}
|
||||
|
||||
/* draw the strokes already in active frame */
|
||||
tcolor[3]= color[3];
|
||||
tcolor[3] = color[3];
|
||||
gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor);
|
||||
|
||||
/* Check if may need to draw the active stroke cache, only if this layer is the active layer
|
||||
@ -671,16 +671,16 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
|
||||
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
|
||||
void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bGPdata *gpd;
|
||||
int offsx, offsy, sizex, sizey;
|
||||
int dflag = GP_DRAWDATA_NOSTATUS;
|
||||
|
||||
/* check that we have grease-pencil stuff to draw */
|
||||
if (ELEM(NULL, sa, ibuf)) return;
|
||||
gpd= gpencil_data_get_active(C); // XXX
|
||||
gpd = gpencil_data_get_active(C); // XXX
|
||||
if (gpd == NULL) return;
|
||||
|
||||
/* calculate rect */
|
||||
@ -691,24 +691,24 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf)
|
||||
|
||||
/* just draw using standard scaling (settings here are currently ignored anyways) */
|
||||
// FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled
|
||||
offsx= 0;
|
||||
offsy= 0;
|
||||
sizex= ar->winx;
|
||||
sizey= ar->winy;
|
||||
offsx = 0;
|
||||
offsy = 0;
|
||||
sizex = ar->winx;
|
||||
sizey = ar->winy;
|
||||
|
||||
wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax);
|
||||
|
||||
dflag |= GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_IEDITHACK;
|
||||
dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK;
|
||||
}
|
||||
break;
|
||||
#if 0 /* removed since 2.5x, needs to be added back */
|
||||
case SPACE_SEQ: /* sequence */
|
||||
{
|
||||
SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first;
|
||||
SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first;
|
||||
float zoom, zoomx, zoomy;
|
||||
|
||||
/* calculate accessory values */
|
||||
zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom));
|
||||
zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom));
|
||||
if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
|
||||
/* XXX sequencer zoom should store it? */
|
||||
zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp);
|
||||
@ -718,20 +718,20 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf)
|
||||
zoomx = zoomy = zoom;
|
||||
|
||||
/* calculate transforms (Note: we use ibuf here, as we have it) */
|
||||
sizex= (int)(zoomx * ibuf->x);
|
||||
sizey= (int)(zoomy * ibuf->y);
|
||||
offsx= (int)( (ar->winx-sizex)/2 + sseq->xof );
|
||||
offsy= (int)( (ar->winy-sizey)/2 + sseq->yof );
|
||||
sizex = (int)(zoomx * ibuf->x);
|
||||
sizey = (int)(zoomy * ibuf->y);
|
||||
offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof);
|
||||
offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof);
|
||||
|
||||
dflag |= GP_DRAWDATA_ONLYI2D;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default: /* for spacetype not yet handled */
|
||||
offsx= 0;
|
||||
offsy= 0;
|
||||
sizex= ar->winx;
|
||||
sizey= ar->winy;
|
||||
offsx = 0;
|
||||
offsy = 0;
|
||||
sizex = ar->winx;
|
||||
sizey = ar->winy;
|
||||
|
||||
dflag |= GP_DRAWDATA_ONLYI2D;
|
||||
break;
|
||||
@ -747,15 +747,15 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf)
|
||||
*/
|
||||
void draw_gpencil_view2d(bContext *C, short onlyv2d)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bGPdata *gpd;
|
||||
int dflag = 0;
|
||||
|
||||
/* check that we have grease-pencil stuff to draw */
|
||||
if (sa == NULL) return;
|
||||
gpd= gpencil_data_get_active(C); // XXX
|
||||
gpd = gpencil_data_get_active(C); // XXX
|
||||
if (gpd == NULL) return;
|
||||
|
||||
/* special hack for Image Editor */
|
||||
@ -764,7 +764,7 @@ void draw_gpencil_view2d(bContext *C, short onlyv2d)
|
||||
dflag |= GP_DRAWDATA_IEDITHACK;
|
||||
|
||||
/* draw it! */
|
||||
if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_NOSTATUS);
|
||||
if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
|
||||
gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag);
|
||||
}
|
||||
|
||||
@ -777,10 +777,10 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d)
|
||||
bGPdata *gpd;
|
||||
int dflag = 0;
|
||||
rcti rect;
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
/* check that we have grease-pencil stuff to draw */
|
||||
gpd= gpencil_data_get_active_v3d(scene); // XXX
|
||||
gpd = gpencil_data_get_active_v3d(scene); // XXX
|
||||
if (gpd == NULL) return;
|
||||
|
||||
/* when rendering to the offscreen buffer we don't want to
|
||||
@ -798,7 +798,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d)
|
||||
}
|
||||
|
||||
/* draw it! */
|
||||
if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS);
|
||||
if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
|
||||
|
||||
gp_draw_data(gpd, rect.xmin, rect.ymin, rect.xmax, rect.ymax, CFRA, dflag);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ short gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDfr
|
||||
return 0;
|
||||
|
||||
/* do loop */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
/* execute callback */
|
||||
if (gpf_cb(gpf, scene))
|
||||
return 1;
|
||||
@ -95,12 +95,12 @@ void gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel)
|
||||
return;
|
||||
|
||||
/* loop through gp-frames, adding */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) {
|
||||
ce= MEM_callocN(sizeof(CfraElem), "CfraElem");
|
||||
ce = MEM_callocN(sizeof(CfraElem), "CfraElem");
|
||||
|
||||
ce->cfra= (float)gpf->framenum;
|
||||
ce->sel= (gpf->flag & GP_FRAME_SELECT) ? 1 : 0;
|
||||
ce->cfra = (float)gpf->framenum;
|
||||
ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0;
|
||||
|
||||
BLI_addtail(elems, ce);
|
||||
}
|
||||
@ -120,7 +120,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl)
|
||||
return 0;
|
||||
|
||||
/* stop at the first one found */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
return 1;
|
||||
}
|
||||
@ -130,7 +130,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl)
|
||||
}
|
||||
|
||||
/* helper function - select gp-frame based on SELECT_* mode */
|
||||
static void gpframe_select (bGPDframe *gpf, short select_mode)
|
||||
static void gpframe_select(bGPDframe *gpf, short select_mode)
|
||||
{
|
||||
if (gpf == NULL)
|
||||
return;
|
||||
@ -158,7 +158,7 @@ void select_gpencil_frames(bGPDlayer *gpl, short select_mode)
|
||||
return;
|
||||
|
||||
/* handle according to mode */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
gpframe_select(gpf, select_mode);
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ void select_gpencil_frame(bGPDlayer *gpl, int selx, short select_mode)
|
||||
return;
|
||||
|
||||
/* search through frames for a match */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
/* there should only be one frame with this frame-number */
|
||||
if (gpf->framenum == selx) {
|
||||
gpframe_select(gpf, select_mode);
|
||||
@ -201,7 +201,7 @@ void borderselect_gplayer_frames(bGPDlayer *gpl, float min, float max, short sel
|
||||
return;
|
||||
|
||||
/* only select those frames which are in bounds */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
|
||||
if (IN_RANGE(gpf->framenum, min, max))
|
||||
gpframe_select(gpf, select_mode);
|
||||
}
|
||||
@ -220,8 +220,8 @@ void delete_gplayer_frames(bGPDlayer *gpl)
|
||||
return;
|
||||
|
||||
/* check for frames to delete */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
|
||||
gpfn= gpf->next;
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
|
||||
gpfn = gpf->next;
|
||||
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
gpencil_layer_delframe(gpl, gpf);
|
||||
@ -238,15 +238,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl)
|
||||
return;
|
||||
|
||||
/* duplicate selected frames */
|
||||
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
|
||||
gpfn= gpf->next;
|
||||
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
|
||||
gpfn = gpf->next;
|
||||
|
||||
/* duplicate this frame */
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
bGPDframe *gpfd;
|
||||
|
||||
/* duplicate frame, and deselect self */
|
||||
gpfd= gpencil_frame_duplicate(gpf);
|
||||
gpfd = gpencil_frame_duplicate(gpf);
|
||||
gpf->flag &= ~GP_FRAME_SELECT;
|
||||
|
||||
BLI_insertlinkafter(&gpl->frames, gpf, gpfd);
|
||||
@ -267,15 +267,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl)
|
||||
|
||||
/* globals for copy/paste data (like for other copy/paste buffers) */
|
||||
ListBase gpcopybuf = {NULL, NULL};
|
||||
static int gpcopy_firstframe= 999999999;
|
||||
static int gpcopy_firstframe = 999999999;
|
||||
|
||||
/* This function frees any MEM_calloc'ed copy/paste buffer data */
|
||||
void free_gpcopybuf()
|
||||
{
|
||||
free_gpencil_layers(&gpcopybuf);
|
||||
|
||||
gpcopybuf.first= gpcopybuf.last= NULL;
|
||||
gpcopy_firstframe= 999999999;
|
||||
gpcopybuf.first = gpcopybuf.last = NULL;
|
||||
gpcopy_firstframe = 999999999;
|
||||
}
|
||||
|
||||
/* This function adds data to the copy/paste buffer, freeing existing data first
|
||||
@ -293,39 +293,39 @@ void copy_gpdata()
|
||||
free_gpcopybuf();
|
||||
|
||||
/* get data */
|
||||
data= get_action_context(&datatype);
|
||||
data = get_action_context(&datatype);
|
||||
if (data == NULL) return;
|
||||
if (datatype != ACTCONT_GPENCIL) return;
|
||||
|
||||
/* filter data */
|
||||
filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL);
|
||||
filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL);
|
||||
actdata_filter(&act_data, filter, data, datatype);
|
||||
|
||||
/* assume that each of these is an ipo-block */
|
||||
for (ale= act_data.first; ale; ale= ale->next) {
|
||||
for (ale = act_data.first; ale; ale = ale->next) {
|
||||
bGPDlayer *gpls, *gpln;
|
||||
bGPDframe *gpf, *gpfn;
|
||||
|
||||
/* get new layer to put into buffer */
|
||||
gpls= (bGPDlayer *)ale->data;
|
||||
gpln= MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer");
|
||||
gpls = (bGPDlayer *)ale->data;
|
||||
gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer");
|
||||
|
||||
gpln->frames.first= gpln->frames.last= NULL;
|
||||
gpln->frames.first = gpln->frames.last = NULL;
|
||||
BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info));
|
||||
|
||||
BLI_addtail(&gpcopybuf, gpln);
|
||||
|
||||
/* loop over frames, and copy only selected frames */
|
||||
for (gpf= gpls->frames.first; gpf; gpf= gpf->next) {
|
||||
for (gpf = gpls->frames.first; gpf; gpf = gpf->next) {
|
||||
/* if frame is selected, make duplicate it and its strokes */
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
/* add frame to buffer */
|
||||
gpfn= gpencil_frame_duplicate(gpf);
|
||||
gpfn = gpencil_frame_duplicate(gpf);
|
||||
BLI_addtail(&gpln->frames, gpfn);
|
||||
|
||||
/* check if this is the earliest frame encountered so far */
|
||||
if (gpf->framenum < gpcopy_firstframe)
|
||||
gpcopy_firstframe= gpf->framenum;
|
||||
gpcopy_firstframe = gpf->framenum;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ void paste_gpdata(Scene *scene)
|
||||
short datatype;
|
||||
|
||||
const int offset = (CFRA - gpcopy_firstframe);
|
||||
short no_name= 0;
|
||||
short no_name = 0;
|
||||
|
||||
/* check if buffer is empty */
|
||||
if (ELEM(NULL, gpcopybuf.first, gpcopybuf.last)) {
|
||||
@ -356,27 +356,27 @@ void paste_gpdata(Scene *scene)
|
||||
}
|
||||
/* check if single channel in buffer (disregard names if so) */
|
||||
if (gpcopybuf.first == gpcopybuf.last)
|
||||
no_name= 1;
|
||||
no_name = 1;
|
||||
|
||||
/* get data */
|
||||
data= get_action_context(&datatype);
|
||||
data = get_action_context(&datatype);
|
||||
if (data == NULL) return;
|
||||
if (datatype != ACTCONT_GPENCIL) return;
|
||||
|
||||
/* filter data */
|
||||
filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT);
|
||||
filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT);
|
||||
actdata_filter(&act_data, filter, data, datatype);
|
||||
|
||||
/* from selected channels */
|
||||
for (ale= act_data.first; ale; ale= ale->next) {
|
||||
bGPDlayer *gpld= (bGPDlayer *)ale->data;
|
||||
bGPDlayer *gpls= NULL;
|
||||
for (ale = act_data.first; ale; ale = ale->next) {
|
||||
bGPDlayer *gpld = (bGPDlayer *)ale->data;
|
||||
bGPDlayer *gpls = NULL;
|
||||
bGPDframe *gpfs, *gpf;
|
||||
|
||||
/* find suitable layer from buffer to use to paste from */
|
||||
for (gpls= gpcopybuf.first; gpls; gpls= gpls->next) {
|
||||
for (gpls = gpcopybuf.first; gpls; gpls = gpls->next) {
|
||||
/* check if layer name matches */
|
||||
if ((no_name) || (strcmp(gpls->info, gpld->info)==0))
|
||||
if ((no_name) || (strcmp(gpls->info, gpld->info) == 0))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -385,12 +385,12 @@ void paste_gpdata(Scene *scene)
|
||||
continue;
|
||||
|
||||
/* add frames from buffer */
|
||||
for (gpfs= gpls->frames.first; gpfs; gpfs= gpfs->next) {
|
||||
for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) {
|
||||
/* temporarily apply offset to buffer-frame while copying */
|
||||
gpfs->framenum += offset;
|
||||
|
||||
/* get frame to copy data into (if no frame returned, then just ignore) */
|
||||
gpf= gpencil_layer_getframe(gpld, gpfs->framenum, 1);
|
||||
gpf = gpencil_layer_getframe(gpld, gpfs->framenum, 1);
|
||||
if (gpf) {
|
||||
bGPDstroke *gps, *gpsn;
|
||||
ScrArea *sa;
|
||||
@ -404,12 +404,12 @@ void paste_gpdata(Scene *scene)
|
||||
* - we cannot just add a duplicate frame, as that would cause errors
|
||||
* - need to check for compatible types to minimise memory usage (copying 'junk' over)
|
||||
*/
|
||||
for (gps= gpfs->strokes.first; gps; gps= gps->next) {
|
||||
for (gps = gpfs->strokes.first; gps; gps = gps->next) {
|
||||
short stroke_ok;
|
||||
|
||||
/* if there's an area, check that it supports this type of stroke */
|
||||
if (sa) {
|
||||
stroke_ok= 0;
|
||||
stroke_ok = 0;
|
||||
|
||||
/* check if spacetype supports this type of stroke
|
||||
* - NOTE: must sync this with gp_paint_initstroke() in gpencil.c
|
||||
@ -417,30 +417,30 @@ void paste_gpdata(Scene *scene)
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_VIEW3D: /* 3D-View: either screen-aligned or 3d-space */
|
||||
if ((gps->flag == 0) || (gps->flag & GP_STROKE_3DSPACE))
|
||||
stroke_ok= 1;
|
||||
stroke_ok = 1;
|
||||
break;
|
||||
|
||||
case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */
|
||||
case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */
|
||||
case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */
|
||||
if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE))
|
||||
stroke_ok= 1;
|
||||
stroke_ok = 1;
|
||||
break;
|
||||
|
||||
case SPACE_SEQ: /* Sequence Editor: either screen-aligned or view-aligned */
|
||||
if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DIMAGE))
|
||||
stroke_ok= 1;
|
||||
stroke_ok = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
stroke_ok= 1;
|
||||
stroke_ok = 1;
|
||||
|
||||
/* if stroke is ok, we make a copy of this stroke and add to frame */
|
||||
if (stroke_ok) {
|
||||
/* make a copy of stroke, then of its points array */
|
||||
gpsn= MEM_dupallocN(gps);
|
||||
gpsn->points= MEM_dupallocN(gps->points);
|
||||
gpsn = MEM_dupallocN(gps);
|
||||
gpsn->points = MEM_dupallocN(gps->points);
|
||||
|
||||
/* append stroke to frame */
|
||||
BLI_addtail(&gpf->strokes, gpsn);
|
||||
@ -467,32 +467,32 @@ void paste_gpdata(Scene *scene)
|
||||
/* -------------------------------------- */
|
||||
/* Snap Tools */
|
||||
|
||||
static short snap_gpf_nearest (bGPDframe *gpf, Scene *scene)
|
||||
static short snap_gpf_nearest(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
gpf->framenum= (int)(floor(gpf->framenum+0.5));
|
||||
gpf->framenum = (int)(floor(gpf->framenum + 0.5));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short snap_gpf_nearestsec (bGPDframe *gpf, Scene *scene)
|
||||
static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
float secf = (float)FPS;
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
gpf->framenum= (int)(floor(gpf->framenum/secf + 0.5f) * secf);
|
||||
gpf->framenum = (int)(floor(gpf->framenum / secf + 0.5f) * secf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short snap_gpf_cframe (bGPDframe *gpf, Scene *scene)
|
||||
static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
gpf->framenum= (int)CFRA;
|
||||
gpf->framenum = (int)CFRA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short snap_gpf_nearmarker (bGPDframe *gpf, Scene *scene)
|
||||
static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
if (gpf->flag & GP_FRAME_SELECT)
|
||||
gpf->framenum= (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum);
|
||||
gpf->framenum = (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -522,43 +522,43 @@ void snap_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode)
|
||||
/* -------------------------------------- */
|
||||
/* Mirror Tools */
|
||||
|
||||
static short mirror_gpf_cframe (bGPDframe *gpf, Scene *scene)
|
||||
static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
int diff;
|
||||
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
diff= CFRA - gpf->framenum;
|
||||
gpf->framenum= CFRA;
|
||||
diff = CFRA - gpf->framenum;
|
||||
gpf->framenum = CFRA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short mirror_gpf_yaxis (bGPDframe *gpf, Scene *scene)
|
||||
static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
int diff;
|
||||
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
diff= -gpf->framenum;
|
||||
gpf->framenum= diff;
|
||||
diff = -gpf->framenum;
|
||||
gpf->framenum = diff;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short mirror_gpf_xaxis (bGPDframe *gpf, Scene *scene)
|
||||
static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
int diff;
|
||||
|
||||
if (gpf->flag & GP_FRAME_SELECT) {
|
||||
diff= -gpf->framenum;
|
||||
gpf->framenum= diff;
|
||||
diff = -gpf->framenum;
|
||||
gpf->framenum = diff;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene)
|
||||
static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene)
|
||||
{
|
||||
static TimeMarker *marker;
|
||||
static short initialized = 0;
|
||||
@ -575,8 +575,8 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene)
|
||||
if (gpf) {
|
||||
/* mirroring time */
|
||||
if ((gpf->flag & GP_FRAME_SELECT) && (marker)) {
|
||||
diff= (marker->frame - gpf->framenum);
|
||||
gpf->framenum= (marker->frame + diff);
|
||||
diff = (marker->frame - gpf->framenum);
|
||||
gpf->framenum = (marker->frame + diff);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -588,9 +588,9 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene)
|
||||
}
|
||||
else {
|
||||
/* try to find a marker */
|
||||
marker= ED_markers_get_first_selected(&scene->markers);
|
||||
marker = ED_markers_get_first_selected(&scene->markers);
|
||||
if (marker) {
|
||||
initialized= 1;
|
||||
initialized = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl)
|
||||
/* make sure the layer we want to remove is the active one */
|
||||
gpencil_layer_setactive(gpd, gpl);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */
|
||||
}
|
||||
|
||||
/* delete 'active' layer */
|
||||
@ -84,7 +84,7 @@ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl)
|
||||
gpencil_layer_setactive(gpd, gpl);
|
||||
gpencil_layer_delactive(gpd);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons
|
||||
uiItemR(sub, &ptr, "lock", 0, "", icon);
|
||||
|
||||
/* when layer is locked or hidden, only draw header */
|
||||
if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) {
|
||||
if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) {
|
||||
char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */
|
||||
|
||||
/* visibility button (only if hidden but not locked!) */
|
||||
@ -271,23 +271,23 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
|
||||
|
||||
/* check whether advanced 3D-View drawing space options can be used */
|
||||
if (is_v3d) {
|
||||
if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW))
|
||||
if (gpd->flag & (GP_DATA_DEPTH_STROKE | GP_DATA_DEPTH_VIEW))
|
||||
v3d_stroke_opts = STROKE_OPTS_V3D_ON;
|
||||
else
|
||||
v3d_stroke_opts = STROKE_OPTS_V3D_OFF;
|
||||
}
|
||||
|
||||
/* drawing space options */
|
||||
row= uiLayoutRow(col, 1);
|
||||
row = uiLayoutRow(col, 1);
|
||||
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE);
|
||||
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE);
|
||||
row= uiLayoutRow(col, 1);
|
||||
row = uiLayoutRow(col, 1);
|
||||
uiLayoutSetActive(row, v3d_stroke_opts);
|
||||
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE);
|
||||
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE);
|
||||
|
||||
row= uiLayoutRow(col, 0);
|
||||
uiLayoutSetActive(row, v3d_stroke_opts==STROKE_OPTS_V3D_ON);
|
||||
row = uiLayoutRow(col, 0);
|
||||
uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON);
|
||||
uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
|
@ -77,10 +77,10 @@
|
||||
/* Context Wrangling... */
|
||||
|
||||
/* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */
|
||||
bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
/* if there's an active area, check if the particular editor may
|
||||
* have defined any special Grease Pencil context for editing...
|
||||
@ -89,7 +89,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_VIEW3D: /* 3D-View */
|
||||
{
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
// TODO: we can include other data-types such as bones later if need be...
|
||||
|
||||
@ -104,7 +104,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
|
||||
case SPACE_NODE: /* Nodes Editor */
|
||||
{
|
||||
SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
|
||||
SpaceNode *snode = (SpaceNode *)CTX_wm_space_data(C);
|
||||
|
||||
/* return the GP data for the active node block/node */
|
||||
if (snode && snode->nodetree) {
|
||||
@ -129,7 +129,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
|
||||
case SPACE_IMAGE: /* Image/UV Editor */
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
|
||||
SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
|
||||
|
||||
/* for now, Grease Pencil data is associated with the space... */
|
||||
// XXX our convention for everything else is to link to data though...
|
||||
@ -140,8 +140,8 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
|
||||
case SPACE_CLIP: /* Nodes Editor */
|
||||
{
|
||||
SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C);
|
||||
MovieClip *clip= ED_space_clip(sc);
|
||||
SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C);
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
|
||||
if (clip) {
|
||||
/* for now, as long as there's a clip, default to using that in Clip Editor */
|
||||
@ -162,16 +162,16 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr)
|
||||
}
|
||||
|
||||
/* Get the active Grease Pencil datablock */
|
||||
bGPdata *gpencil_data_get_active (bContext *C)
|
||||
bGPdata *gpencil_data_get_active(bContext *C)
|
||||
{
|
||||
bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
return (gpd_ptr) ? *(gpd_ptr) : NULL;
|
||||
}
|
||||
|
||||
/* needed for offscreen rendering */
|
||||
bGPdata *gpencil_data_get_active_v3d (Scene *scene)
|
||||
bGPdata *gpencil_data_get_active_v3d(Scene *scene)
|
||||
{
|
||||
bGPdata *gpd= scene->basact ? scene->basact->object->gpd : NULL;
|
||||
bGPdata *gpd = scene->basact ? scene->basact->object->gpd : NULL;
|
||||
return gpd ? gpd : scene->gpd;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ bGPdata *gpencil_data_get_active_v3d (Scene *scene)
|
||||
/* Panel Operators */
|
||||
|
||||
/* poll callback for adding data/layers - special */
|
||||
static int gp_add_poll (bContext *C)
|
||||
static int gp_add_poll(bContext *C)
|
||||
{
|
||||
/* the base line we have is that we have somewhere to add Grease Pencil data */
|
||||
return gpencil_data_get_pointers(C, NULL) != NULL;
|
||||
@ -188,9 +188,9 @@ static int gp_add_poll (bContext *C)
|
||||
/* ******************* Add New Data ************************ */
|
||||
|
||||
/* add new datablock - wrapper around API */
|
||||
static int gp_data_add_exec (bContext *C, wmOperator *op)
|
||||
static int gp_data_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go");
|
||||
@ -198,14 +198,14 @@ static int gp_data_add_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
/* decrement user count and add new datablock */
|
||||
bGPdata *gpd= (*gpd_ptr);
|
||||
bGPdata *gpd = (*gpd_ptr);
|
||||
|
||||
id_us_min(&gpd->id);
|
||||
*gpd_ptr= gpencil_data_addnew("GPencil");
|
||||
*gpd_ptr = gpencil_data_addnew("GPencil");
|
||||
}
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -216,7 +216,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
|
||||
ot->name = "Grease Pencil Add New";
|
||||
ot->idname = "GPENCIL_OT_data_add";
|
||||
ot->description = "Add new Grease Pencil datablock";
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_data_add_exec;
|
||||
@ -226,9 +226,9 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
|
||||
/* ******************* Unlink Data ************************ */
|
||||
|
||||
/* poll callback for adding data/layers - special */
|
||||
static int gp_data_unlink_poll (bContext *C)
|
||||
static int gp_data_unlink_poll(bContext *C)
|
||||
{
|
||||
bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
|
||||
/* if we have access to some active data, make sure there's a datablock before enabling this */
|
||||
return (gpd_ptr && *gpd_ptr);
|
||||
@ -236,9 +236,9 @@ static int gp_data_unlink_poll (bContext *C)
|
||||
|
||||
|
||||
/* unlink datablock - wrapper around API */
|
||||
static int gp_data_unlink_exec (bContext *C, wmOperator *op)
|
||||
static int gp_data_unlink_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go");
|
||||
@ -246,14 +246,14 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
else {
|
||||
/* just unlink datablock now, decreasing its user count */
|
||||
bGPdata *gpd= (*gpd_ptr);
|
||||
bGPdata *gpd = (*gpd_ptr);
|
||||
|
||||
id_us_min(&gpd->id);
|
||||
*gpd_ptr= NULL;
|
||||
*gpd_ptr = NULL;
|
||||
}
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -264,7 +264,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
|
||||
ot->name = "Grease Pencil Unlink";
|
||||
ot->idname = "GPENCIL_OT_data_unlink";
|
||||
ot->description = "Unlink active Grease Pencil datablock";
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_data_unlink_exec;
|
||||
@ -274,9 +274,9 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
|
||||
/* ******************* Add New Layer ************************ */
|
||||
|
||||
/* add new layer - wrapper around API */
|
||||
static int gp_layer_add_exec (bContext *C, wmOperator *op)
|
||||
static int gp_layer_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
|
||||
/* if there's no existing Grease-Pencil data there, add some */
|
||||
if (gpd_ptr == NULL) {
|
||||
@ -284,13 +284,13 @@ static int gp_layer_add_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if (*gpd_ptr == NULL)
|
||||
*gpd_ptr= gpencil_data_addnew("GPencil");
|
||||
*gpd_ptr = gpencil_data_addnew("GPencil");
|
||||
|
||||
/* add new layer now */
|
||||
gpencil_layer_addnew(*gpd_ptr);
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work!
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -301,7 +301,7 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
|
||||
ot->name = "Add New Layer";
|
||||
ot->idname = "GPENCIL_OT_layer_add";
|
||||
ot->description = "Add new Grease Pencil layer for the active Grease Pencil datablock";
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_layer_add_exec;
|
||||
@ -310,22 +310,22 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
|
||||
|
||||
/* ******************* Delete Active Frame ************************ */
|
||||
|
||||
static int gp_actframe_delete_poll (bContext *C)
|
||||
static int gp_actframe_delete_poll(bContext *C)
|
||||
{
|
||||
bGPdata *gpd= gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl= gpencil_layer_getactive(gpd);
|
||||
bGPdata *gpd = gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
|
||||
|
||||
/* only if there's an active layer with an active frame */
|
||||
return (gpl && gpl->actframe);
|
||||
}
|
||||
|
||||
/* delete active frame - wrapper around API calls */
|
||||
static int gp_actframe_delete_exec (bContext *C, wmOperator *op)
|
||||
static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bGPdata *gpd= gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl= gpencil_layer_getactive(gpd);
|
||||
bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bGPdata *gpd = gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
|
||||
bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
|
||||
|
||||
/* if there's no existing Grease-Pencil data there, add some */
|
||||
if (gpd == NULL) {
|
||||
@ -341,7 +341,7 @@ static int gp_actframe_delete_exec (bContext *C, wmOperator *op)
|
||||
gpencil_layer_delframe(gpl, gpf);
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work!
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -352,7 +352,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
|
||||
ot->name = "Delete Active Frame";
|
||||
ot->idname = "GPENCIL_OT_active_frame_delete";
|
||||
ot->description = "Delete the active frame for the active Grease Pencil datablock";
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_actframe_delete_exec;
|
||||
@ -380,35 +380,35 @@ static EnumPropertyItem prop_gpencil_convertmodes[] = {
|
||||
/* convert the coordinates from the given stroke point into 3d-coordinates
|
||||
* - assumes that the active space is the 3D-View
|
||||
*/
|
||||
static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect)
|
||||
static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if (gps->flag & GP_STROKE_3DSPACE) {
|
||||
/* directly use 3d-coordinates */
|
||||
copy_v3_v3(p3d, &pt->x);
|
||||
}
|
||||
else {
|
||||
float *fp= give_cursor(scene, v3d);
|
||||
float *fp = give_cursor(scene, v3d);
|
||||
float mvalf[2];
|
||||
|
||||
/* get screen coordinate */
|
||||
if (gps->flag & GP_STROKE_2DSPACE) {
|
||||
int mvali[2];
|
||||
View2D *v2d= &ar->v2d;
|
||||
UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1);
|
||||
View2D *v2d = &ar->v2d;
|
||||
UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1);
|
||||
VECCOPY2D(mvalf, mvali);
|
||||
}
|
||||
else {
|
||||
if (subrect) {
|
||||
mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
|
||||
mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
|
||||
mvalf[0] = (((float)pt->x / 100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
|
||||
mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
|
||||
}
|
||||
else {
|
||||
mvalf[0]= (float)pt->x / 100.0f * ar->winx;
|
||||
mvalf[1]= (float)pt->y / 100.0f * ar->winy;
|
||||
mvalf[0] = (float)pt->x / 100.0f * ar->winx;
|
||||
mvalf[1] = (float)pt->y / 100.0f * ar->winy;
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi
|
||||
/* --- */
|
||||
|
||||
/* convert stroke to 3d path */
|
||||
static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
|
||||
static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
|
||||
{
|
||||
bGPDspoint *pt;
|
||||
Nurb *nu;
|
||||
@ -432,16 +432,16 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur
|
||||
/* create new 'nurb' within the curve */
|
||||
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)");
|
||||
|
||||
nu->pntsu= gps->totpoints;
|
||||
nu->pntsv= 1;
|
||||
nu->orderu= gps->totpoints;
|
||||
nu->flagu= CU_NURB_ENDPOINT;
|
||||
nu->resolu= 32;
|
||||
nu->pntsu = gps->totpoints;
|
||||
nu->pntsv = 1;
|
||||
nu->orderu = gps->totpoints;
|
||||
nu->flagu = CU_NURB_ENDPOINT;
|
||||
nu->resolu = 32;
|
||||
|
||||
nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*gps->totpoints, "bpoints");
|
||||
nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * gps->totpoints, "bpoints");
|
||||
|
||||
/* add points */
|
||||
for (i=0, pt=gps->points, bp=nu->bp; i < gps->totpoints; i++, pt++, bp++) {
|
||||
for (i = 0, pt = gps->points, bp = nu->bp; i < gps->totpoints; i++, pt++, bp++) {
|
||||
float p3d[3];
|
||||
|
||||
/* get coordinates to add at */
|
||||
@ -449,7 +449,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur
|
||||
copy_v3_v3(bp->vec, p3d);
|
||||
|
||||
/* set settings */
|
||||
bp->f1= SELECT;
|
||||
bp->f1 = SELECT;
|
||||
bp->radius = bp->weight = pt->pressure * gpl->thickness;
|
||||
}
|
||||
|
||||
@ -459,15 +459,15 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur
|
||||
|
||||
static int gp_camera_view_subrect(bContext *C, rctf *subrect)
|
||||
{
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
||||
if (v3d) {
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
|
||||
/* for camera view set the subrect */
|
||||
if (rv3d->persp == RV3D_CAMOB) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, TRUE); /* no shift */
|
||||
return 1;
|
||||
}
|
||||
@ -477,7 +477,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
|
||||
}
|
||||
|
||||
/* convert stroke to 3d bezier */
|
||||
static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
|
||||
static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect)
|
||||
{
|
||||
bGPDspoint *pt;
|
||||
Nurb *nu;
|
||||
@ -488,31 +488,31 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C
|
||||
/* create new 'nurb' within the curve */
|
||||
nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)");
|
||||
|
||||
nu->pntsu= gps->totpoints;
|
||||
nu->resolu= 12;
|
||||
nu->resolv= 12;
|
||||
nu->type= CU_BEZIER;
|
||||
nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints*sizeof(BezTriple), "bezts");
|
||||
nu->pntsu = gps->totpoints;
|
||||
nu->resolu = 12;
|
||||
nu->resolv = 12;
|
||||
nu->type = CU_BEZIER;
|
||||
nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints * sizeof(BezTriple), "bezts");
|
||||
|
||||
tot= gps->totpoints;
|
||||
tot = gps->totpoints;
|
||||
|
||||
/* get initial coordinates */
|
||||
pt=gps->points;
|
||||
pt = gps->points;
|
||||
if (tot) {
|
||||
gp_strokepoint_convertcoords(C, gps, pt, p3d_cur, subrect);
|
||||
if (tot > 1) {
|
||||
gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect);
|
||||
gp_strokepoint_convertcoords(C, gps, pt + 1, p3d_next, subrect);
|
||||
}
|
||||
}
|
||||
|
||||
/* add points */
|
||||
for (i=0, bezt=nu->bezt; i < tot; i++, pt++, bezt++) {
|
||||
for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) {
|
||||
float h1[3], h2[3];
|
||||
|
||||
if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3);
|
||||
else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3);
|
||||
|
||||
if (i < tot-1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3);
|
||||
if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3);
|
||||
else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3);
|
||||
|
||||
copy_v3_v3(bezt->vec[0], h1);
|
||||
@ -520,8 +520,8 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C
|
||||
copy_v3_v3(bezt->vec[2], h2);
|
||||
|
||||
/* set settings */
|
||||
bezt->h1= bezt->h2= HD_FREE;
|
||||
bezt->f1= bezt->f2= bezt->f3= SELECT;
|
||||
bezt->h1 = bezt->h2 = HD_FREE;
|
||||
bezt->f1 = bezt->f2 = bezt->f3 = SELECT;
|
||||
bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f;
|
||||
|
||||
/* shift coord vects */
|
||||
@ -541,16 +541,16 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C
|
||||
}
|
||||
|
||||
/* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */
|
||||
static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode)
|
||||
static void gp_layer_to_curve(bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
|
||||
bGPDstroke *gps;
|
||||
Object *ob;
|
||||
Curve *cu;
|
||||
|
||||
/* camera framing */
|
||||
rctf subrect, *subrect_ptr= NULL;
|
||||
rctf subrect, *subrect_ptr = NULL;
|
||||
|
||||
/* error checking */
|
||||
if (ELEM3(NULL, gpd, gpl, gpf))
|
||||
@ -562,16 +562,16 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
|
||||
|
||||
/* initialize camera framing */
|
||||
if (gp_camera_view_subrect(C, &subrect)) {
|
||||
subrect_ptr= &subrect;
|
||||
subrect_ptr = &subrect;
|
||||
}
|
||||
|
||||
/* init the curve object (remove rotation and get curve data from it)
|
||||
* - must clear transforms set on object, as those skew our results
|
||||
*/
|
||||
ob= BKE_object_add(scene, OB_CURVE);
|
||||
ob = BKE_object_add(scene, OB_CURVE);
|
||||
zero_v3(ob->loc);
|
||||
zero_v3(ob->rot);
|
||||
cu= ob->data;
|
||||
cu = ob->data;
|
||||
cu->flag |= CU_3D;
|
||||
|
||||
/* rename object and curve to layer name */
|
||||
@ -579,7 +579,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
|
||||
rename_id((ID *)cu, gpl->info);
|
||||
|
||||
/* add points to curve */
|
||||
for (gps= gpf->strokes.first; gps; gps= gps->next) {
|
||||
for (gps = gpf->strokes.first; gps; gps = gps->next) {
|
||||
switch (mode) {
|
||||
case GP_STROKECONVERT_PATH:
|
||||
gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr);
|
||||
@ -596,22 +596,22 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short
|
||||
|
||||
/* --- */
|
||||
|
||||
static int gp_convert_poll (bContext *C)
|
||||
static int gp_convert_poll(bContext *C)
|
||||
{
|
||||
bGPdata *gpd= gpencil_data_get_active(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bGPdata *gpd = gpencil_data_get_active(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* only if there's valid data, and the current view is 3D View */
|
||||
return ((sa && sa->spacetype == SPACE_VIEW3D) && gpencil_layer_getactive(gpd) && (scene->obedit == NULL));
|
||||
}
|
||||
|
||||
static int gp_convert_layer_exec (bContext *C, wmOperator *op)
|
||||
static int gp_convert_layer_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd= gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl= gpencil_layer_getactive(gpd);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
int mode= RNA_enum_get(op->ptr, "type");
|
||||
bGPdata *gpd = gpencil_data_get_active(C);
|
||||
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* check if there's data to work with */
|
||||
if (gpd == NULL) {
|
||||
@ -622,8 +622,8 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op)
|
||||
gp_layer_to_curve(C, gpd, gpl, mode);
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
|
||||
WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
@ -635,7 +635,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
|
||||
ot->name = "Convert Grease Pencil";
|
||||
ot->idname = "GPENCIL_OT_convert";
|
||||
ot->description = "Convert the active Grease Pencil layer to a new Object";
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke = WM_menu_invoke;
|
||||
@ -643,7 +643,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot)
|
||||
ot->poll = gp_convert_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", "");
|
||||
|
@ -96,14 +96,14 @@ typedef struct bActListElem {
|
||||
|
||||
/* filtering flags - under what circumstances should a channel be added */
|
||||
typedef enum ACTFILTER_FLAGS {
|
||||
ACTFILTER_VISIBLE = (1<<0), /* should channels be visible */
|
||||
ACTFILTER_SEL = (1<<1), /* should channels be selected */
|
||||
ACTFILTER_FOREDIT = (1<<2), /* does editable status matter */
|
||||
ACTFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */
|
||||
ACTFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */
|
||||
ACTFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */
|
||||
ACTFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */
|
||||
ACTFILTER_ACTGROUPED = (1<<7) /* belongs to the active group */
|
||||
ACTFILTER_VISIBLE = (1 << 0), /* should channels be visible */
|
||||
ACTFILTER_SEL = (1 << 1), /* should channels be selected */
|
||||
ACTFILTER_FOREDIT = (1 << 2), /* does editable status matter */
|
||||
ACTFILTER_CHANNELS = (1 << 3), /* do we only care that it is a channel */
|
||||
ACTFILTER_IPOKEYS = (1 << 4), /* only channels referencing ipo's */
|
||||
ACTFILTER_ONLYICU = (1 << 5), /* only reference ipo-curves */
|
||||
ACTFILTER_FORDRAWING = (1 << 6), /* make list for interface drawing */
|
||||
ACTFILTER_ACTGROUPED = (1 << 7) /* belongs to the active group */
|
||||
} ACTFILTER_FLAGS;
|
||||
|
||||
/* Action Editor - Main Data types */
|
||||
|
@ -54,17 +54,21 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf)
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
/* Draw */
|
||||
|
||||
/* draw */
|
||||
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY);
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY);
|
||||
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
|
||||
|
||||
/* draw - straight lines */
|
||||
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY);
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY);
|
||||
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT);
|
||||
|
||||
/* draw - poly lines */
|
||||
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY);
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY);
|
||||
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY);
|
||||
|
||||
/* erase */
|
||||
kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY);
|
||||
kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY);
|
||||
RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -65,25 +65,25 @@ int ED_gpencil_session_active(void)
|
||||
|
||||
int ED_undo_gpencil_step(bContext *C, int step, const char *name)
|
||||
{
|
||||
bGPdata **gpd_ptr= NULL, *new_gpd= NULL;
|
||||
bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
|
||||
|
||||
gpd_ptr= gpencil_data_get_pointers(C, NULL);
|
||||
gpd_ptr = gpencil_data_get_pointers(C, NULL);
|
||||
|
||||
if (step==1) { /* undo */
|
||||
if (step == 1) { /* undo */
|
||||
//printf("\t\tGP - undo step\n");
|
||||
if (cur_node->prev) {
|
||||
if (!name || strcmp(cur_node->name, name) == 0) {
|
||||
cur_node= cur_node->prev;
|
||||
new_gpd= cur_node->gpd;
|
||||
cur_node = cur_node->prev;
|
||||
new_gpd = cur_node->gpd;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (step==-1) {
|
||||
else if (step == -1) {
|
||||
//printf("\t\tGP - redo step\n");
|
||||
if (cur_node->next) {
|
||||
if (!name || strcmp(cur_node->name, name) == 0) {
|
||||
cur_node= cur_node->next;
|
||||
new_gpd= cur_node->gpd;
|
||||
cur_node = cur_node->next;
|
||||
new_gpd = cur_node->gpd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,24 +91,24 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
|
||||
if (new_gpd) {
|
||||
if (gpd_ptr) {
|
||||
if (*gpd_ptr) {
|
||||
bGPdata *gpd= *gpd_ptr;
|
||||
bGPdata *gpd = *gpd_ptr;
|
||||
bGPDlayer *gpl, *gpld;
|
||||
|
||||
free_gpencil_layers(&gpd->layers);
|
||||
|
||||
/* copy layers */
|
||||
gpd->layers.first= gpd->layers.last= NULL;
|
||||
gpd->layers.first = gpd->layers.last = NULL;
|
||||
|
||||
for (gpl= new_gpd->layers.first; gpl; gpl= gpl->next) {
|
||||
for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) {
|
||||
/* make a copy of source layer and its data */
|
||||
gpld= gpencil_layer_duplicate(gpl);
|
||||
gpld = gpencil_layer_duplicate(gpl);
|
||||
BLI_addtail(&gpd->layers, gpld);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -126,41 +126,41 @@ void gpencil_undo_push(bGPdata *gpd)
|
||||
|
||||
if (cur_node) {
|
||||
/* remove all un-done nodes from stack */
|
||||
undo_node= cur_node->next;
|
||||
undo_node = cur_node->next;
|
||||
|
||||
while (undo_node) {
|
||||
bGPundonode *next_node= undo_node->next;
|
||||
bGPundonode *next_node = undo_node->next;
|
||||
|
||||
BKE_gpencil_free(undo_node->gpd);
|
||||
MEM_freeN(undo_node->gpd);
|
||||
|
||||
BLI_freelinkN(&undo_nodes, undo_node);
|
||||
|
||||
undo_node= next_node;
|
||||
undo_node = next_node;
|
||||
}
|
||||
}
|
||||
|
||||
/* create new undo node */
|
||||
undo_node= MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
|
||||
undo_node->gpd= gpencil_data_duplicate(gpd);
|
||||
undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
|
||||
undo_node->gpd = gpencil_data_duplicate(gpd);
|
||||
|
||||
cur_node= undo_node;
|
||||
cur_node = undo_node;
|
||||
|
||||
BLI_addtail(&undo_nodes, undo_node);
|
||||
}
|
||||
|
||||
void gpencil_undo_finish(void)
|
||||
{
|
||||
bGPundonode *undo_node= undo_nodes.first;
|
||||
bGPundonode *undo_node = undo_nodes.first;
|
||||
|
||||
while (undo_node) {
|
||||
BKE_gpencil_free(undo_node->gpd);
|
||||
MEM_freeN(undo_node->gpd);
|
||||
|
||||
undo_node= undo_node->next;
|
||||
undo_node = undo_node->next;
|
||||
}
|
||||
|
||||
BLI_freelistN(&undo_nodes);
|
||||
|
||||
cur_node= NULL;
|
||||
cur_node = NULL;
|
||||
}
|
||||
|
@ -509,9 +509,9 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines)
|
||||
rect.xmax = (line->to->x1 + line->to->x2) / 2.0f;
|
||||
rect.ymax = (line->to->y1 + line->to->y2) / 2.0f;
|
||||
|
||||
if(line->flag & UI_SELECT)
|
||||
glColor3ub(100,100,100);
|
||||
else if(hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
|
||||
if (line->flag & UI_SELECT)
|
||||
glColor3ub(100, 100, 100);
|
||||
else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)))
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
else
|
||||
glColor3ub(0, 0, 0);
|
||||
@ -528,9 +528,9 @@ static void ui_draw_links(uiBlock *block)
|
||||
// As we go, remember if we see any active or selected lines.
|
||||
int foundselectline = 0;
|
||||
int foundactiveline = 0;
|
||||
for (but=block->buttons.first; but; but=but->next) {
|
||||
if(but->type==LINK && but->link) {
|
||||
for (line=but->link->lines.first; line; line=line->next) {
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (but->type == LINK && but->link) {
|
||||
for (line = but->link->lines.first; line; line = line->next) {
|
||||
if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE))
|
||||
ui_draw_linkline(line, 0);
|
||||
else
|
||||
@ -545,9 +545,9 @@ static void ui_draw_links(uiBlock *block)
|
||||
// Draw any active lines (lines with either button being hovered over).
|
||||
// Do this last so they appear on top of inactive lines.
|
||||
if (foundactiveline) {
|
||||
for (but=block->buttons.first; but; but=but->next) {
|
||||
if(but->type==LINK && but->link) {
|
||||
for (line=but->link->lines.first; line; line=line->next) {
|
||||
for (but = block->buttons.first; but; but = but->next) {
|
||||
if (but->type == LINK && but->link) {
|
||||
for (line = but->link->lines.first; line; line = line->next) {
|
||||
if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))
|
||||
ui_draw_linkline(line, !foundselectline);
|
||||
}
|
||||
|
@ -178,8 +178,8 @@ struct uiBut {
|
||||
|
||||
/* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */
|
||||
#if 0
|
||||
void (*embossfunc)(int , int , float, float, float, float, float, int);
|
||||
void (*sliderfunc)(int , float, float, float, float, float, float, int);
|
||||
void (*embossfunc)(int, int, float, float, float, float, float, int);
|
||||
void (*sliderfunc)(int, float, float, float, float, float, float, int);
|
||||
#endif
|
||||
|
||||
uiButCompleteFunc autocomplete_func;
|
||||
@ -268,7 +268,7 @@ struct uiBlock {
|
||||
float minx, miny, maxx, maxy;
|
||||
float aspect;
|
||||
|
||||
int puphash; // popup menu hash for memory
|
||||
int puphash; /* popup menu hash for memory */
|
||||
|
||||
uiButHandleFunc func;
|
||||
void *func_arg1;
|
||||
@ -316,7 +316,7 @@ struct uiBlock {
|
||||
|
||||
uiPopupBlockHandle *handle; // handle
|
||||
|
||||
struct wmOperator *ui_operator;// use so presets can find the operator,
|
||||
struct wmOperator *ui_operator; // use so presets can find the operator,
|
||||
// across menus and from nested popups which fail for operator context.
|
||||
|
||||
void *evil_C; // XXX hack for dynamic operator enums
|
||||
@ -425,7 +425,7 @@ void ui_searchbox_apply(uiBut *but, struct ARegion *ar);
|
||||
void ui_searchbox_free(struct bContext *C, struct ARegion *ar);
|
||||
void ui_but_search_test(uiBut *but);
|
||||
|
||||
typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
|
||||
typedef uiBlock * (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1);
|
||||
|
||||
uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
|
||||
uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
|
||||
@ -466,14 +466,14 @@ extern int ui_button_is_active(struct ARegion *ar);
|
||||
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3);
|
||||
void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad);
|
||||
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
|
||||
uiWidgetColors* ui_tooltip_get_theme(void);
|
||||
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
|
||||
uiWidgetColors *ui_tooltip_get_theme(void);
|
||||
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect);
|
||||
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
|
||||
int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol);
|
||||
int ui_link_bezier_points(rcti * rect, float coord_array[][2], int resol);
|
||||
void ui_draw_link_bezier(rcti *rect);
|
||||
|
||||
extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
|
||||
/* theme color init */
|
||||
/* theme color init */
|
||||
struct ThemeUI;
|
||||
void ui_widget_color_init(struct ThemeUI *tui);
|
||||
|
||||
|
@ -857,7 +857,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
|
||||
@ -888,7 +888,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
|
||||
EnumPropertyItem *item;
|
||||
int value, free;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
|
||||
@ -926,7 +926,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||
PointerRNA ptr;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_boolean_set(&ptr, propname, value);
|
||||
@ -939,7 +939,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||
PointerRNA ptr;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_int_set(&ptr, propname, value);
|
||||
@ -952,7 +952,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||
PointerRNA ptr;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_float_set(&ptr, propname, value);
|
||||
@ -965,7 +965,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||
PointerRNA ptr;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_string_set(&ptr, propname, value);
|
||||
@ -1611,7 +1611,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname,
|
||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||
MenuItemLevel *lvl;
|
||||
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return);
|
||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||
|
||||
if (!ot->srna) {
|
||||
ui_item_disabled(layout, opname);
|
||||
@ -2726,8 +2726,8 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p
|
||||
|
||||
void uiLayoutContextCopy(uiLayout *layout, bContextStore *context)
|
||||
{
|
||||
uiBlock *block= layout->root->block;
|
||||
layout->context= CTX_store_add_all(&block->contexts, context);
|
||||
uiBlock *block = layout->root->block;
|
||||
layout->context = CTX_store_add_all(&block->contexts, context);
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,24 +67,24 @@
|
||||
/* This function is used to free all MetaElems from MetaBall */
|
||||
void free_editMball(Object *obedit)
|
||||
{
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
|
||||
mb->editelems= NULL;
|
||||
mb->lastelem= NULL;
|
||||
mb->editelems = NULL;
|
||||
mb->lastelem = NULL;
|
||||
}
|
||||
|
||||
/* This function is called, when MetaBall Object is
|
||||
* switched from object mode to edit mode */
|
||||
void make_editMball(Object *obedit)
|
||||
{
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
MetaElem *ml;/*, *newml;*/
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml; /*, *newml;*/
|
||||
|
||||
ml= mb->elems.first;
|
||||
ml = mb->elems.first;
|
||||
|
||||
while (ml) {
|
||||
if (ml->flag & SELECT) mb->lastelem = ml;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
mb->editelems = &mb->elems;
|
||||
@ -100,22 +100,22 @@ void load_editMball(Object *UNUSED(obedit))
|
||||
/* Add metaelem primitive to metaball object (which is in edit mode) */
|
||||
MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mball = (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mball = (MetaBall *)obedit->data;
|
||||
MetaElem *ml;
|
||||
|
||||
/* Deselect all existing metaelems */
|
||||
ml= mball->editelems->first;
|
||||
ml = mball->editelems->first;
|
||||
while (ml) {
|
||||
ml->flag &= ~SELECT;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
ml= BKE_mball_element_add(mball, type);
|
||||
ml = BKE_mball_element_add(mball, type);
|
||||
copy_v3_v3(&ml->x, mat[3]);
|
||||
|
||||
ml->flag |= SELECT;
|
||||
mball->lastelem= ml;
|
||||
mball->lastelem = ml;
|
||||
return ml;
|
||||
}
|
||||
|
||||
@ -125,12 +125,12 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU
|
||||
static int mball_select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
//Scene *scene= CTX_data_scene(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml;
|
||||
int action = RNA_enum_get(op->ptr, "action");
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
if (ml) {
|
||||
if (action == SEL_TOGGLE) {
|
||||
action = SEL_SELECT;
|
||||
@ -139,11 +139,11 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
|
||||
action = SEL_DESELECT;
|
||||
break;
|
||||
}
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
}
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
while (ml) {
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
@ -156,9 +156,9 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
|
||||
ml->flag ^= SELECT;
|
||||
break;
|
||||
}
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@ -176,7 +176,7 @@ void MBALL_OT_select_all(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
WM_operator_properties_select_all(ot);
|
||||
}
|
||||
@ -186,15 +186,15 @@ void MBALL_OT_select_all(wmOperatorType *ot)
|
||||
/* Random metaball selection */
|
||||
static int select_random_metaelems_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml;
|
||||
float percent= RNA_float_get(op->ptr, "percent");
|
||||
float percent = RNA_float_get(op->ptr, "percent");
|
||||
|
||||
if (percent == 0.0f)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
BLI_srand(BLI_rand()); /* Random seed */
|
||||
|
||||
/* Stupid version of random selection. Should be improved. */
|
||||
@ -203,10 +203,10 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
|
||||
ml->flag |= SELECT;
|
||||
else
|
||||
ml->flag &= ~SELECT;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -225,7 +225,7 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly", 0.0001f, 1.0f);
|
||||
@ -236,22 +236,22 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
|
||||
/* Duplicate selected MetaElements */
|
||||
static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml, *newml;
|
||||
|
||||
ml= mb->editelems->last;
|
||||
ml = mb->editelems->last;
|
||||
if (ml) {
|
||||
while (ml) {
|
||||
if (ml->flag & SELECT) {
|
||||
newml= MEM_dupallocN(ml);
|
||||
newml = MEM_dupallocN(ml);
|
||||
BLI_addtail(mb->editelems, newml);
|
||||
mb->lastelem= newml;
|
||||
mb->lastelem = newml;
|
||||
ml->flag &= ~SELECT;
|
||||
}
|
||||
ml= ml->prev;
|
||||
ml = ml->prev;
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
int retv= duplicate_metaelems_exec(C, op);
|
||||
int retv = duplicate_metaelems_exec(C, op);
|
||||
|
||||
if (retv == OPERATOR_FINISHED) {
|
||||
RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION);
|
||||
@ -284,7 +284,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* to give to transform */
|
||||
RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
|
||||
@ -295,22 +295,22 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
|
||||
/* Delete all selected MetaElems (not MetaBall) */
|
||||
static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb= (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml, *next;
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
if (ml) {
|
||||
while (ml) {
|
||||
next= ml->next;
|
||||
next = ml->next;
|
||||
if (ml->flag & SELECT) {
|
||||
if (mb->lastelem==ml) mb->lastelem= NULL;
|
||||
if (mb->lastelem == ml) mb->lastelem = NULL;
|
||||
BLI_remlink(mb->editelems, ml);
|
||||
MEM_freeN(ml);
|
||||
}
|
||||
ml= next;
|
||||
ml = next;
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/***************************** Hide operator *****************************/
|
||||
@ -337,20 +337,20 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot)
|
||||
/* Hide selected MetaElems */
|
||||
static int hide_metaelems_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb= (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml;
|
||||
const int invert= RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
|
||||
const int invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
|
||||
if (ml) {
|
||||
while (ml) {
|
||||
if ((ml->flag & SELECT) != invert)
|
||||
ml->flag |= MB_HIDE;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
|
||||
@ -380,18 +380,18 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot)
|
||||
/* Unhide all edited MetaElems */
|
||||
static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
MetaBall *mb= (MetaBall*)obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml;
|
||||
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
|
||||
if (ml) {
|
||||
while (ml) {
|
||||
ml->flag &= ~MB_HIDE;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb);
|
||||
DAG_id_tag_update(obedit->data, 0);
|
||||
}
|
||||
|
||||
@ -410,69 +410,69 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editmball;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* Select MetaElement with mouse click (user can select radius circle or
|
||||
* stiffness circle) */
|
||||
int mouse_mball(bContext *C, const int mval[2], int extend)
|
||||
{
|
||||
static MetaElem *startelem=NULL;
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
static MetaElem *startelem = NULL;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
ViewContext vc;
|
||||
MetaBall *mb = (MetaBall*)obedit->data;
|
||||
MetaElem *ml, *act=NULL;
|
||||
MetaBall *mb = (MetaBall *)obedit->data;
|
||||
MetaElem *ml, *act = NULL;
|
||||
int a, hits;
|
||||
unsigned int buffer[4*MAXPICKBUF];
|
||||
unsigned int buffer[4 * MAXPICKBUF];
|
||||
rcti rect;
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rect.xmin = mval[0]-12;
|
||||
rect.xmax = mval[0]+12;
|
||||
rect.ymin = mval[1]-12;
|
||||
rect.ymax = mval[1]+12;
|
||||
rect.xmin = mval[0] - 12;
|
||||
rect.xmax = mval[0] + 12;
|
||||
rect.ymin = mval[1] - 12;
|
||||
rect.ymax = mval[1] + 12;
|
||||
|
||||
hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
|
||||
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
|
||||
|
||||
/* does startelem exist? */
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
while (ml) {
|
||||
if (ml==startelem) break;
|
||||
ml= ml->next;
|
||||
if (ml == startelem) break;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
if (ml==NULL) startelem= mb->editelems->first;
|
||||
if (ml == NULL) startelem = mb->editelems->first;
|
||||
|
||||
if (hits>0) {
|
||||
ml= startelem;
|
||||
if (hits > 0) {
|
||||
ml = startelem;
|
||||
while (ml) {
|
||||
for (a=0; a<hits; a++) {
|
||||
for (a = 0; a < hits; a++) {
|
||||
/* index converted for gl stuff */
|
||||
if (ml->selcol1==buffer[ 4 * a + 3 ]) {
|
||||
if (ml->selcol1 == buffer[4 * a + 3]) {
|
||||
ml->flag |= MB_SCALE_RAD;
|
||||
act= ml;
|
||||
act = ml;
|
||||
}
|
||||
if (ml->selcol2==buffer[ 4 * a + 3 ]) {
|
||||
if (ml->selcol2 == buffer[4 * a + 3]) {
|
||||
ml->flag &= ~MB_SCALE_RAD;
|
||||
act= ml;
|
||||
act = ml;
|
||||
}
|
||||
}
|
||||
if (act) break;
|
||||
ml= ml->next;
|
||||
if (ml==NULL) ml= mb->editelems->first;
|
||||
if (ml==startelem) break;
|
||||
ml = ml->next;
|
||||
if (ml == NULL) ml = mb->editelems->first;
|
||||
if (ml == startelem) break;
|
||||
}
|
||||
|
||||
/* When some metaelem was found, then it is necessary to select or
|
||||
* deselect it. */
|
||||
if (act) {
|
||||
if (extend==0) {
|
||||
if (extend == 0) {
|
||||
/* Deselect all existing metaelems */
|
||||
ml= mb->editelems->first;
|
||||
ml = mb->editelems->first;
|
||||
while (ml) {
|
||||
ml->flag &= ~SELECT;
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
/* Select only metaelem clicked on */
|
||||
act->flag |= SELECT;
|
||||
@ -483,9 +483,9 @@ int mouse_mball(bContext *C, const int mval[2], int extend)
|
||||
else
|
||||
act->flag |= SELECT;
|
||||
}
|
||||
mb->lastelem= act;
|
||||
mb->lastelem = act;
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -502,54 +502,54 @@ static void freeMetaElemlist(ListBase *lb)
|
||||
{
|
||||
MetaElem *ml, *next;
|
||||
|
||||
if (lb==NULL) return;
|
||||
if (lb == NULL) return;
|
||||
|
||||
ml= lb->first;
|
||||
ml = lb->first;
|
||||
while (ml) {
|
||||
next= ml->next;
|
||||
next = ml->next;
|
||||
BLI_remlink(lb, ml);
|
||||
MEM_freeN(ml);
|
||||
ml= next;
|
||||
ml = next;
|
||||
}
|
||||
|
||||
lb->first= lb->last= NULL;
|
||||
lb->first = lb->last = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe))
|
||||
{
|
||||
ListBase *lb= lbu;
|
||||
ListBase *editelems= lbe;
|
||||
ListBase *lb = lbu;
|
||||
ListBase *editelems = lbe;
|
||||
MetaElem *ml, *newml;
|
||||
|
||||
freeMetaElemlist(editelems);
|
||||
|
||||
/* copy 'undo' MetaElems to 'edit' MetaElems */
|
||||
ml= lb->first;
|
||||
ml = lb->first;
|
||||
while (ml) {
|
||||
newml= MEM_dupallocN(ml);
|
||||
newml = MEM_dupallocN(ml);
|
||||
BLI_addtail(editelems, newml);
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe))
|
||||
{
|
||||
ListBase *editelems= lbe;
|
||||
ListBase *editelems = lbe;
|
||||
ListBase *lb;
|
||||
MetaElem *ml, *newml;
|
||||
|
||||
/* allocate memory for undo ListBase */
|
||||
lb= MEM_callocN(sizeof(ListBase), "listbase undo");
|
||||
lb->first= lb->last= NULL;
|
||||
lb = MEM_callocN(sizeof(ListBase), "listbase undo");
|
||||
lb->first = lb->last = NULL;
|
||||
|
||||
/* copy contents of current ListBase to the undo ListBase */
|
||||
ml= editelems->first;
|
||||
ml = editelems->first;
|
||||
while (ml) {
|
||||
newml= MEM_dupallocN(ml);
|
||||
newml = MEM_dupallocN(ml);
|
||||
BLI_addtail(lb, newml);
|
||||
ml= ml->next;
|
||||
ml = ml->next;
|
||||
}
|
||||
|
||||
return lb;
|
||||
@ -558,7 +558,7 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe))
|
||||
/* free undo ListBase of MetaElems */
|
||||
static void free_undoMball(void *lbv)
|
||||
{
|
||||
ListBase *lb= lbv;
|
||||
ListBase *lb = lbv;
|
||||
|
||||
freeMetaElemlist(lb);
|
||||
MEM_freeN(lb);
|
||||
@ -566,8 +566,8 @@ static void free_undoMball(void *lbv)
|
||||
|
||||
static ListBase *metaball_get_editelems(Object *ob)
|
||||
{
|
||||
if (ob && ob->type==OB_MBALL) {
|
||||
struct MetaBall *mb= (struct MetaBall*)ob->data;
|
||||
if (ob && ob->type == OB_MBALL) {
|
||||
struct MetaBall *mb = (struct MetaBall *)ob->data;
|
||||
return mb->editelems;
|
||||
}
|
||||
return NULL;
|
||||
@ -576,7 +576,7 @@ static ListBase *metaball_get_editelems(Object *ob)
|
||||
|
||||
static void *get_data(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
return metaball_get_editelems(obedit);
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
|
||||
PTCacheID *pid;
|
||||
ListBase pidlist;
|
||||
SpaceTimeCache *stc = stime->caches.first;
|
||||
float yoffs=0.f;
|
||||
float yoffs = 0.f;
|
||||
|
||||
if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
|
||||
return;
|
||||
@ -106,10 +106,10 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
|
||||
|
||||
/* iterate over pointcaches on the active object,
|
||||
* add spacetimecache and vertex array for each */
|
||||
for (pid=pidlist.first; pid; pid=pid->next) {
|
||||
for (pid = pidlist.first; pid; pid = pid->next) {
|
||||
float col[4], *fp;
|
||||
int i, sta = pid->cache->startframe, end = pid->cache->endframe;
|
||||
int len = (end - sta + 1)*4;
|
||||
int len = (end - sta + 1) * 4;
|
||||
|
||||
switch (pid->type) {
|
||||
case PTCACHE_TYPE_SOFTBODY:
|
||||
@ -134,7 +134,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
|
||||
continue;
|
||||
|
||||
/* make sure we have stc with correct array length */
|
||||
if (stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) {
|
||||
if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) {
|
||||
if (stc) {
|
||||
MEM_freeN(stc->array);
|
||||
}
|
||||
@ -143,32 +143,32 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
|
||||
BLI_addtail(&stime->caches, stc);
|
||||
}
|
||||
|
||||
stc->array = MEM_callocN(len*2*sizeof(float), "SpaceTimeCache array");
|
||||
stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array");
|
||||
}
|
||||
|
||||
/* fill the vertex array with a quad for each cached frame */
|
||||
for (i=sta, fp=stc->array; i<=end; i++) {
|
||||
if (pid->cache->cached_frames[i-sta]) {
|
||||
fp[0] = (float)i-0.5f;
|
||||
for (i = sta, fp = stc->array; i <= end; i++) {
|
||||
if (pid->cache->cached_frames[i - sta]) {
|
||||
fp[0] = (float)i - 0.5f;
|
||||
fp[1] = 0.0;
|
||||
fp+=2;
|
||||
fp += 2;
|
||||
|
||||
fp[0] = (float)i-0.5f;
|
||||
fp[0] = (float)i - 0.5f;
|
||||
fp[1] = 1.0;
|
||||
fp+=2;
|
||||
fp += 2;
|
||||
|
||||
fp[0] = (float)i+0.5f;
|
||||
fp[0] = (float)i + 0.5f;
|
||||
fp[1] = 1.0;
|
||||
fp+=2;
|
||||
fp += 2;
|
||||
|
||||
fp[0] = (float)i+0.5f;
|
||||
fp[0] = (float)i + 0.5f;
|
||||
fp[1] = 0.0;
|
||||
fp+=2;
|
||||
fp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0);
|
||||
glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
|
||||
glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0);
|
||||
|
||||
switch (pid->type) {
|
||||
@ -212,7 +212,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, stc->array);
|
||||
glDrawArrays(GL_QUADS, 0, (fp-stc->array)/2);
|
||||
glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -240,7 +240,7 @@ static void time_cache_free(SpaceTime *stime)
|
||||
{
|
||||
SpaceTimeCache *stc;
|
||||
|
||||
for (stc= stime->caches.first; stc; stc=stc->next) {
|
||||
for (stc = stime->caches.first; stc; stc = stc->next) {
|
||||
if (stc->array) {
|
||||
MEM_freeN(stc->array);
|
||||
stc->array = NULL;
|
||||
@ -257,9 +257,9 @@ static void time_cache_refresh(SpaceTime *stime)
|
||||
}
|
||||
|
||||
/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */
|
||||
static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe)
|
||||
static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe)
|
||||
{
|
||||
ActKeyColumn *akn= NULL;
|
||||
ActKeyColumn *akn = NULL;
|
||||
|
||||
/* sanity checks */
|
||||
if (ak == NULL)
|
||||
@ -267,9 +267,9 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe)
|
||||
|
||||
/* check if this is a match, or whether it is in some subtree */
|
||||
if (cframe < ak->cfra)
|
||||
akn= time_cfra_find_ak(ak->left, cframe);
|
||||
akn = time_cfra_find_ak(ak->left, cframe);
|
||||
else if (cframe > ak->cfra)
|
||||
akn= time_cfra_find_ak(ak->right, cframe);
|
||||
akn = time_cfra_find_ak(ak->right, cframe);
|
||||
|
||||
/* if no match found (or found match), just use the current one */
|
||||
if (akn == NULL)
|
||||
@ -281,7 +281,7 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe)
|
||||
/* helper for time_draw_keyframes() */
|
||||
static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
|
||||
{
|
||||
bDopeSheet ads= {NULL};
|
||||
bDopeSheet ads = {NULL};
|
||||
DLRBT_Tree keys;
|
||||
ActKeyColumn *ak;
|
||||
|
||||
@ -311,9 +311,9 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
|
||||
* - draw within a single GL block to be faster
|
||||
*/
|
||||
glBegin(GL_LINES);
|
||||
for ( ak=time_cfra_find_ak(keys.root, v2d->cur.xmin);
|
||||
for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin);
|
||||
(ak) && (ak->cfra <= v2d->cur.xmax);
|
||||
ak=ak->next )
|
||||
ak = ak->next)
|
||||
{
|
||||
glVertex2f(ak->cfra, v2d->tot.ymin);
|
||||
glVertex2f(ak->cfra, v2d->tot.ymax);
|
||||
@ -327,16 +327,16 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
|
||||
/* draw keyframe lines for timeline */
|
||||
static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= CTX_data_active_object(C);
|
||||
View2D *v2d= &ar->v2d;
|
||||
short onlysel= (stime->flag & TIME_ONLYACTSEL);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
View2D *v2d = &ar->v2d;
|
||||
short onlysel = (stime->flag & TIME_ONLYACTSEL);
|
||||
|
||||
/* draw scene keyframes first
|
||||
* - don't try to do this when only drawing active/selected data keyframes,
|
||||
* since this can become quite slow
|
||||
*/
|
||||
if (scene && onlysel==0) {
|
||||
if (scene && onlysel == 0) {
|
||||
/* set draw color */
|
||||
glColor3ub(0xDD, 0xA7, 0x00);
|
||||
time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel);
|
||||
@ -357,14 +357,14 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
|
||||
short active_done = 0;
|
||||
|
||||
/* draw keyframes from all selected objects */
|
||||
CTX_DATA_BEGIN (C, Object*, obsel, selected_objects)
|
||||
CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
|
||||
{
|
||||
/* last arg is 0, since onlysel doesn't apply here... */
|
||||
time_draw_idblock_keyframes(v2d, (ID *)obsel, 0);
|
||||
|
||||
/* if this object is the active one, set flag so that we don't draw again */
|
||||
if (obsel == ob)
|
||||
active_done= 1;
|
||||
active_done = 1;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
@ -379,7 +379,7 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar
|
||||
static void time_refresh(const bContext *UNUSED(C), ScrArea *sa)
|
||||
{
|
||||
/* find the main timeline region and refresh cache display*/
|
||||
ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
if (ar) {
|
||||
SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
|
||||
time_cache_refresh(stime);
|
||||
@ -414,8 +414,8 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
ARegion *ar;
|
||||
Scene *scene = wmn->reference;
|
||||
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->regiontype==RGN_TYPE_WINDOW) {
|
||||
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
||||
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
ar->v2d.tot.xmin = (float)(SFRA - 4);
|
||||
ar->v2d.tot.xmax = (float)(EFRA + 4);
|
||||
break;
|
||||
@ -456,13 +456,13 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceTime *stime= CTX_wm_space_time(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SpaceTime *stime = CTX_wm_space_time(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DGrid *grid;
|
||||
View2DScrollers *scrollers;
|
||||
int unit, flag=0;
|
||||
int unit, flag = 0;
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_ThemeClearColor(TH_BACK);
|
||||
@ -471,9 +471,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
/* grid */
|
||||
unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS;
|
||||
grid= UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
|
||||
UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
|
||||
unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
|
||||
grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
|
||||
UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS));
|
||||
UI_view2d_grid_free(grid);
|
||||
|
||||
/* start and end frame */
|
||||
@ -481,7 +481,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
/* current frame */
|
||||
flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */
|
||||
if ((stime->flag & TIME_DRAWFRAMES)==0) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
ANIM_draw_cfra(C, v2d, flag);
|
||||
|
||||
@ -501,7 +501,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
@ -551,7 +551,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* context changes */
|
||||
switch (wmn->category) {
|
||||
case NC_SCREEN:
|
||||
if (wmn->data==ND_ANIMPLAY)
|
||||
if (wmn->data == ND_ANIMPLAY)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
|
||||
@ -577,57 +577,57 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
|
||||
static SpaceLink *time_new(const bContext *C)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ARegion *ar;
|
||||
SpaceTime *stime;
|
||||
|
||||
stime= MEM_callocN(sizeof(SpaceTime), "inittime");
|
||||
stime = MEM_callocN(sizeof(SpaceTime), "inittime");
|
||||
|
||||
stime->spacetype= SPACE_TIME;
|
||||
stime->spacetype = SPACE_TIME;
|
||||
stime->flag |= TIME_DRAWFRAMES;
|
||||
|
||||
/* header */
|
||||
ar= MEM_callocN(sizeof(ARegion), "header for time");
|
||||
ar = MEM_callocN(sizeof(ARegion), "header for time");
|
||||
|
||||
BLI_addtail(&stime->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_HEADER;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM;
|
||||
ar->regiontype = RGN_TYPE_HEADER;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for time");
|
||||
ar = MEM_callocN(sizeof(ARegion), "main area for time");
|
||||
|
||||
BLI_addtail(&stime->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
|
||||
ar->v2d.tot.xmin = (float)(SFRA - 4);
|
||||
ar->v2d.tot.ymin = 0.0f;
|
||||
ar->v2d.tot.xmax = (float)(EFRA + 4);
|
||||
ar->v2d.tot.ymax = 50.0f;
|
||||
|
||||
ar->v2d.cur= ar->v2d.tot;
|
||||
ar->v2d.cur = ar->v2d.tot;
|
||||
|
||||
ar->v2d.min[0]= 1.0f;
|
||||
ar->v2d.min[1]= 50.0f;
|
||||
ar->v2d.min[0] = 1.0f;
|
||||
ar->v2d.min[1] = 50.0f;
|
||||
|
||||
ar->v2d.max[0]= MAXFRAMEF;
|
||||
ar->v2d.max[1]= 50.0;
|
||||
ar->v2d.max[0] = MAXFRAMEF;
|
||||
ar->v2d.max[1] = 50.0;
|
||||
|
||||
ar->v2d.minzoom= 0.1f;
|
||||
ar->v2d.maxzoom= 10.0;
|
||||
ar->v2d.minzoom = 0.1f;
|
||||
ar->v2d.maxzoom = 10.0;
|
||||
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
|
||||
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
|
||||
ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
|
||||
|
||||
|
||||
return (SpaceLink*)stime;
|
||||
return (SpaceLink *)stime;
|
||||
}
|
||||
|
||||
/* not spacelink itself */
|
||||
static void time_free(SpaceLink *sl)
|
||||
{
|
||||
SpaceTime *stime= (SpaceTime *)sl;
|
||||
SpaceTime *stime = (SpaceTime *)sl;
|
||||
|
||||
time_cache_free(stime);
|
||||
}
|
||||
@ -636,20 +636,20 @@ static void time_free(SpaceLink *sl)
|
||||
/* validate spacedata, add own area level handlers */
|
||||
static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
|
||||
{
|
||||
SpaceTime *stime= (SpaceTime *)sa->spacedata.first;
|
||||
SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
|
||||
|
||||
time_cache_free(stime);
|
||||
|
||||
/* enable all cache display */
|
||||
stime->cache_display |= TIME_CACHE_DISPLAY;
|
||||
stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
|
||||
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
|
||||
stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
|
||||
stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
|
||||
}
|
||||
|
||||
static SpaceLink *time_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceTime *stime= (SpaceTime *)sl;
|
||||
SpaceTime *stimen= MEM_dupallocN(stime);
|
||||
SpaceTime *stime = (SpaceTime *)sl;
|
||||
SpaceTime *stimen = MEM_dupallocN(stime);
|
||||
|
||||
stimen->caches.first = stimen->caches.last = NULL;
|
||||
|
||||
@ -660,41 +660,41 @@ static SpaceLink *time_duplicate(SpaceLink *sl)
|
||||
/* it defines all callbacks to maintain spaces */
|
||||
void ED_spacetype_time(void)
|
||||
{
|
||||
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time");
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid= SPACE_TIME;
|
||||
st->spaceid = SPACE_TIME;
|
||||
strncpy(st->name, "Timeline", BKE_ST_MAXNAME);
|
||||
|
||||
st->new= time_new;
|
||||
st->free= time_free;
|
||||
st->init= time_init;
|
||||
st->duplicate= time_duplicate;
|
||||
st->operatortypes= time_operatortypes;
|
||||
st->keymap= NULL;
|
||||
st->listener= time_listener;
|
||||
st->refresh= time_refresh;
|
||||
st->new = time_new;
|
||||
st->free = time_free;
|
||||
st->init = time_init;
|
||||
st->duplicate = time_duplicate;
|
||||
st->operatortypes = time_operatortypes;
|
||||
st->keymap = NULL;
|
||||
st->listener = time_listener;
|
||||
st->refresh = time_refresh;
|
||||
|
||||
/* regions: main window */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
|
||||
art->regionid = RGN_TYPE_WINDOW;
|
||||
art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES;
|
||||
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
|
||||
|
||||
art->init= time_main_area_init;
|
||||
art->draw= time_main_area_draw;
|
||||
art->listener= time_main_area_listener;
|
||||
art->keymap= time_keymap;
|
||||
art->init = time_main_area_init;
|
||||
art->draw = time_main_area_draw;
|
||||
art->listener = time_main_area_listener;
|
||||
art->keymap = time_keymap;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey= HEADERY;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
|
||||
|
||||
art->init= time_header_area_init;
|
||||
art->draw= time_header_area_draw;
|
||||
art->listener= time_header_area_listener;
|
||||
art->init = time_header_area_init;
|
||||
art->draw = time_header_area_draw;
|
||||
art->listener = time_header_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
|
@ -47,35 +47,35 @@
|
||||
#include "time_intern.h"
|
||||
|
||||
/* ****************** Start/End Frame Operators *******************************/
|
||||
static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int frame;
|
||||
|
||||
if (scene == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
frame= CFRA;
|
||||
frame = CFRA;
|
||||
|
||||
/* if Preview Range is defined, set the 'start' frame for that */
|
||||
if (PRVRANGEON)
|
||||
scene->r.psfra= frame;
|
||||
scene->r.psfra = frame;
|
||||
else
|
||||
scene->r.sfra= frame;
|
||||
scene->r.sfra = frame;
|
||||
|
||||
if (PEFRA < frame) {
|
||||
if (PRVRANGEON)
|
||||
scene->r.pefra= frame;
|
||||
scene->r.pefra = frame;
|
||||
else
|
||||
scene->r.efra= frame;
|
||||
scene->r.efra = frame;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void TIME_OT_start_frame_set (wmOperatorType *ot)
|
||||
static void TIME_OT_start_frame_set(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Set Start Frame";
|
||||
@ -87,39 +87,39 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot)
|
||||
ot->poll = ED_operator_timeline_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int frame;
|
||||
|
||||
if (scene == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
frame= CFRA;
|
||||
frame = CFRA;
|
||||
|
||||
/* if Preview Range is defined, set the 'end' frame for that */
|
||||
if (PRVRANGEON)
|
||||
scene->r.pefra= frame;
|
||||
scene->r.pefra = frame;
|
||||
else
|
||||
scene->r.efra= frame;
|
||||
scene->r.efra = frame;
|
||||
|
||||
if (PSFRA > frame) {
|
||||
if (PRVRANGEON)
|
||||
scene->r.psfra= frame;
|
||||
scene->r.psfra = frame;
|
||||
else
|
||||
scene->r.sfra= frame;
|
||||
scene->r.sfra = frame;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void TIME_OT_end_frame_set (wmOperatorType *ot)
|
||||
static void TIME_OT_end_frame_set(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Set End Frame";
|
||||
@ -131,16 +131,16 @@ static void TIME_OT_end_frame_set (wmOperatorType *ot)
|
||||
ot->poll = ED_operator_timeline_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************ View All Operator *******************************/
|
||||
|
||||
static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
View2D *v2d= (ar) ? &ar->v2d : NULL;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
View2D *v2d = (ar) ? &ar->v2d : NULL;
|
||||
float extra;
|
||||
|
||||
if (ELEM(NULL, scene, ar))
|
||||
@ -151,7 +151,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
v2d->cur.xmax = (float)PEFRA;
|
||||
|
||||
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
|
||||
extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
@ -161,7 +161,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void TIME_OT_view_all (wmOperatorType *ot)
|
||||
static void TIME_OT_view_all(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "View All";
|
||||
@ -173,7 +173,7 @@ static void TIME_OT_view_all (wmOperatorType *ot)
|
||||
ot->poll = ED_operator_timeline_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************** registration **********************************/
|
||||
|
Loading…
Reference in New Issue
Block a user