Code Cleanup - Style tweaks

This commit is contained in:
Joshua Leung 2016-03-28 02:33:14 +13:00
parent bfbbc8ec40
commit 00cfbeef11
3 changed files with 62 additions and 65 deletions

@ -126,6 +126,23 @@ extern ListBase gp_strokes_copypastebuf;
void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *next_stroke, int tag_flags);
/**
* Apply smooth to stroke
*
* \param gps Stroke to smooth
* \param i Point index
* \param inf Smooth factor
*/
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf);
/**
* Subdivide a stroke
* \param gps Stroke data
* \param new_totpoints Total number of points
*/
void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints);
/* Layers Enums -------------------------------------- */
struct EnumPropertyItem *ED_gpencil_layers_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free);
@ -208,21 +225,6 @@ void gpencil_undo_init(struct bGPdata *gpd);
void gpencil_undo_push(struct bGPdata *gpd);
void gpencil_undo_finish(void);
/**
* Apply smooth to stroke
*
* gps Stroke to smooth
* i Point index
* inf Smooth factor
*/
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf);
/* subdivide a stroke
* gps Stroke data
* new_totpoints Total number of points
*/
void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints);
/******************************************************* */
/* FILTERED ACTION DATA - TYPES ---> XXX DEPRECEATED OLD ANIM SYSTEM CODE! */

@ -568,10 +568,10 @@ static void gp_stroke_simplify(tGPsdata *p)
static void gp_stroke_newfrombuffer(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
bGPDlayer *gpl = p->gpl;
bGPDstroke *gps;
bGPDspoint *pt;
tGPspoint *ptc;
bGPDlayer *layer = gpencil_layer_getactive(p->gpd);
int i, totelem;
/* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
@ -612,14 +612,13 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
gps->inittime = p->inittime;
/* allocate enough memory for a continuous array for storage points */
int sublevel = layer->sublevel;
int sublevel = gpl->sublevel;
int new_totpoints = gps->totpoints;
for (i = 0; i < sublevel; ++i)
{
// Avoid error if subdivide is too big (assume totpoints is right)
if (new_totpoints + (new_totpoints - 1) > GP_STROKE_BUFFER_MAX)
{
sublevel = i; // reduce sublevel
for (i = 0; i < sublevel; i++) {
/* Avoid error if subdivide is too big (assume totpoints is right) */
if (new_totpoints + (new_totpoints - 1) > GP_STROKE_BUFFER_MAX) {
/* Reduce sublevel to avoid too-dense strokes */
sublevel = i;
break;
}
new_totpoints += new_totpoints - 1;
@ -745,21 +744,17 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
/* subdivide the stroke */
if (sublevel > 0)
{
if (sublevel > 0) {
int sub = gps->totpoints;
for (i = 0; i < sublevel; ++i)
{
for (i = 0; i < sublevel; i++) {
sub += sub - 1;
gp_subdivide_stroke(gps, sub);
}
}
/* smooth stroke */
if (layer->smooth_drawfac > 0.0f) // only if something to do
{
for (i = 0; i < gps->totpoints; i++)
{
gp_smooth_stroke(gps, i, layer->smooth_drawfac);
/* smooth stroke - only if there's somethign to do */
if (gpl->smooth_drawfac > 0.0f) {
for (i = 0; i < gps->totpoints; i++) {
gp_smooth_stroke(gps, i, gpl->smooth_drawfac);
}
}

@ -533,10 +533,11 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen
}
}
/* Apply smooth to stroke point
* gps Stroke to smooth
* i Point index
* inf Smooth factor
/**
* Apply smooth to stroke point
* \param gps Stroke to smooth
* \param i Point index
* \param inf Smooth factor
*/
bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf)
{
@ -593,42 +594,41 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf)
return true;
}
/* subdivide a stroke
* gps Stroke data
* new_totpoints Total number of points
/**
* Subdivide a stroke
* \param gps Stroke data
* \param new_totpoints Total number of points
*/
void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints)
{
int i;
// Subdivide stroke adding a point half way existing points
/* Subdivide stroke adding a point half way existing points */
bGPDspoint *pt_a;
bGPDspoint *pt_b;
bGPDspoint *pt_n;
/* Move points to insert subdivision */
int y = 1;
for (i = gps->totpoints - 1; i > 0; --i)
{
for (i = gps->totpoints - 1; i > 0; i--) {
pt_n = &gps->points[i];
gps->points[new_totpoints - y] = *pt_n;
y = y + 2;
}
/* Create interpolated points */
for (i = 0; i < new_totpoints - 1; ++i)
{
for (i = 0; i < new_totpoints - 1; i++) {
pt_a = &gps->points[i];
pt_n = &gps->points[i + 1];
pt_b = &gps->points[i + 2];
// Interpolate all values
/* Interpolate all values */
interp_v3_v3v3(&pt_n->x, &pt_a->x, &pt_b->x, 0.5f);
pt_n->pressure = interpf(pt_a->pressure, pt_b->pressure, 0.5f);
pt_n->time = interpf(pt_a->time, pt_b->time, 0.5f);
++i; // add to loop to jump next pair
i++; /* add to loop to jump next pair */
}
gps->totpoints = new_totpoints; // Increase number of points
gps->totpoints = new_totpoints; /* Increase number of points */
}
/* ******************************************************** */