forked from bartvdbraak/blender
Curve: use zero length array for BevList for less confusing syntax
This commit is contained in:
parent
716430ab64
commit
57372f4ef8
@ -513,7 +513,7 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
|
||||
dist = (float *)MEM_mallocN(sizeof(float) * (tot + 1), "calcpathdist");
|
||||
|
||||
/* all lengths in *dist */
|
||||
bevp = bevpfirst = (BevPoint *)(bl + 1);
|
||||
bevp = bevpfirst = bl->bevpoints;
|
||||
fp = dist;
|
||||
*fp = 0.0f;
|
||||
for (a = 0; a < tot; a++) {
|
||||
|
@ -1855,7 +1855,7 @@ static bool bevelinside(BevList *bl1, BevList *bl2)
|
||||
|
||||
/* take first vertex of possible hole */
|
||||
|
||||
bevp = (BevPoint *)(bl2 + 1);
|
||||
bevp = bl2->bevpoints;
|
||||
hvec1[0] = bevp->vec[0];
|
||||
hvec1[1] = bevp->vec[1];
|
||||
hvec1[2] = 0.0;
|
||||
@ -1865,7 +1865,7 @@ static bool bevelinside(BevList *bl1, BevList *bl2)
|
||||
/* test it with all edges of potential surounding poly */
|
||||
/* count number of transitions left-right */
|
||||
|
||||
bevp = (BevPoint *)(bl1 + 1);
|
||||
bevp = bl1->bevpoints;
|
||||
nr = bl1->nr;
|
||||
prevbevp = bevp + (nr - 1);
|
||||
|
||||
@ -2051,7 +2051,7 @@ static void bevel_list_calc_bisect(BevList *bl)
|
||||
bool is_cyclic = bl->poly != -1;
|
||||
|
||||
if (is_cyclic) {
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
nr = bl->nr;
|
||||
@ -2065,7 +2065,7 @@ static void bevel_list_calc_bisect(BevList *bl)
|
||||
* of direction for this guys.
|
||||
*/
|
||||
|
||||
bevp0 = (BevPoint *)(bl + 1);
|
||||
bevp0 = bl->bevpoints;
|
||||
bevp1 = bevp0 + 1;
|
||||
bevp2 = bevp1 + 1;
|
||||
|
||||
@ -2086,7 +2086,7 @@ static void bevel_list_flip_tangents(BevList *bl)
|
||||
BevPoint *bevp2, *bevp1, *bevp0;
|
||||
int nr;
|
||||
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2107,7 +2107,7 @@ static void bevel_list_apply_tilt(BevList *bl)
|
||||
int nr;
|
||||
float q[4];
|
||||
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
|
||||
nr = bl->nr;
|
||||
@ -2131,7 +2131,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
|
||||
int a;
|
||||
|
||||
for (a = 0; a < smooth_iter; a++) {
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2177,7 +2177,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter)
|
||||
|
||||
static void make_bevel_list_3D_zup(BevList *bl)
|
||||
{
|
||||
BevPoint *bevp = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp = bl->bevpoints;
|
||||
int nr = bl->nr;
|
||||
|
||||
bevel_list_calc_bisect(bl);
|
||||
@ -2212,7 +2212,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
|
||||
|
||||
bevel_list_calc_bisect(bl);
|
||||
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2250,7 +2250,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
|
||||
BevPoint *bevp_last;
|
||||
|
||||
|
||||
bevp_first = (BevPoint *)(bl + 1);
|
||||
bevp_first = bl->bevpoints;
|
||||
bevp_first += bl->nr - 1;
|
||||
bevp_last = bevp_first;
|
||||
bevp_last--;
|
||||
@ -2278,7 +2278,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
|
||||
if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f))
|
||||
angle = -angle;
|
||||
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2300,11 +2300,11 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
|
||||
* using it's own direction, which might not correspond
|
||||
* the twist of neighbor point.
|
||||
*/
|
||||
bevp1 = (BevPoint *)(bl + 1);
|
||||
bevp1 = bl->bevpoints;
|
||||
bevp0 = bevp1 + 1;
|
||||
minimum_twist_between_two_points(bevp1, bevp0);
|
||||
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
minimum_twist_between_two_points(bevp1, bevp0);
|
||||
@ -2322,7 +2322,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
|
||||
bevel_list_flip_tangents(bl);
|
||||
|
||||
/* correct the tangents */
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2340,7 +2340,7 @@ static void make_bevel_list_3D_tangent(BevList *bl)
|
||||
|
||||
|
||||
/* now for the real twist calc */
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
|
||||
@ -2387,7 +2387,7 @@ static void make_bevel_list_segment_3D(BevList *bl)
|
||||
{
|
||||
float q[4];
|
||||
|
||||
BevPoint *bevp2 = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp2 = bl->bevpoints;
|
||||
BevPoint *bevp1 = bevp2 + 1;
|
||||
|
||||
/* simple quat/dir */
|
||||
@ -2406,7 +2406,7 @@ static void make_bevel_list_segment_3D(BevList *bl)
|
||||
/* only for 2 points */
|
||||
static void make_bevel_list_segment_2D(BevList *bl)
|
||||
{
|
||||
BevPoint *bevp2 = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp2 = bl->bevpoints;
|
||||
BevPoint *bevp1 = bevp2 + 1;
|
||||
|
||||
const float x1 = bevp1->vec[0] - bevp2->vec[0];
|
||||
@ -2429,13 +2429,13 @@ static void make_bevel_list_2D(BevList *bl)
|
||||
int nr;
|
||||
|
||||
if (bl->poly != -1) {
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
bevp1 = bevp2 + (bl->nr - 1);
|
||||
bevp0 = bevp1 - 1;
|
||||
nr = bl->nr;
|
||||
}
|
||||
else {
|
||||
bevp0 = (BevPoint *)(bl + 1);
|
||||
bevp0 = bl->bevpoints;
|
||||
bevp1 = bevp0 + 1;
|
||||
bevp2 = bevp1 + 1;
|
||||
|
||||
@ -2467,14 +2467,14 @@ static void make_bevel_list_2D(BevList *bl)
|
||||
float angle;
|
||||
|
||||
/* first */
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
angle = atan2(bevp->dir[0], bevp->dir[1]) - M_PI / 2.0;
|
||||
bevp->sina = sinf(angle);
|
||||
bevp->cosa = cosf(angle);
|
||||
vec_to_quat(bevp->quat, bevp->dir, 5, 1);
|
||||
|
||||
/* last */
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
bevp += (bl->nr - 1);
|
||||
angle = atan2(bevp->dir[0], bevp->dir[1]) - M_PI / 2.0;
|
||||
bevp->sina = sinf(angle);
|
||||
@ -2489,7 +2489,7 @@ static void bevlist_firstlast_direction_calc_from_bpoint(Nurb *nu, BevList *bl)
|
||||
BPoint *first_bp = nu->bp, *last_bp = nu->bp + (nu->pntsu - 1);
|
||||
BevPoint *first_bevp, *last_bevp;
|
||||
|
||||
first_bevp = (BevPoint *)(bl + 1);
|
||||
first_bevp = bl->bevpoints;
|
||||
last_bevp = first_bevp + (bl->nr - 1);
|
||||
|
||||
sub_v3_v3v3(first_bevp->dir, (first_bp + 1)->vec, first_bp->vec);
|
||||
@ -2570,7 +2570,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
bl->nr = len;
|
||||
bl->dupe_nr = 0;
|
||||
bl->charidx = nu->charidx;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
bp = nu->bp;
|
||||
|
||||
while (len--) {
|
||||
@ -2595,7 +2595,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
|
||||
bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
|
||||
bl->charidx = nu->charidx;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
|
||||
a = nu->pntsu - 1;
|
||||
bezt = nu->bezt;
|
||||
@ -2689,7 +2689,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
bl->dupe_nr = 0;
|
||||
bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
|
||||
bl->charidx = nu->charidx;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
|
||||
BKE_nurb_makeCurve(nu, &bevp->vec[0],
|
||||
do_tilt ? &bevp->alfa : NULL,
|
||||
@ -2712,11 +2712,11 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
bool is_cyclic = bl->poly != -1;
|
||||
nr = bl->nr;
|
||||
if (is_cyclic) {
|
||||
bevp1 = (BevPoint *)(bl + 1);
|
||||
bevp1 = bl->bevpoints;
|
||||
bevp0 = bevp1 + (nr - 1);
|
||||
}
|
||||
else {
|
||||
bevp0 = (BevPoint *)(bl + 1);
|
||||
bevp0 = bl->bevpoints;
|
||||
bevp1 = bevp0 + 1;
|
||||
}
|
||||
nr--;
|
||||
@ -2745,8 +2745,8 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
blnew->nr = 0;
|
||||
BLI_remlink(bev, bl);
|
||||
BLI_insertlinkbefore(bev, blnext, blnew); /* to make sure bevlijst is tuned with nurblist */
|
||||
bevp0 = (BevPoint *)(bl + 1);
|
||||
bevp1 = (BevPoint *)(blnew + 1);
|
||||
bevp0 = bl->bevpoints;
|
||||
bevp1 = blnew->bevpoints;
|
||||
nr = bl->nr;
|
||||
while (nr--) {
|
||||
if (bevp0->dupe_tag == 0) {
|
||||
@ -2782,7 +2782,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
if (bl->poly > 0) {
|
||||
|
||||
min = 300000.0;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
nr = bl->nr;
|
||||
while (nr--) {
|
||||
if (min > bevp->vec[0]) {
|
||||
@ -2794,14 +2794,14 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
sd->bl = bl;
|
||||
sd->left = min;
|
||||
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
if (bevp1 == bevp)
|
||||
bevp0 = bevp + (bl->nr - 1);
|
||||
else
|
||||
bevp0 = bevp1 - 1;
|
||||
bevp = bevp + (bl->nr - 1);
|
||||
if (bevp1 == bevp)
|
||||
bevp2 = (BevPoint *)(bl + 1);
|
||||
bevp2 = bl->bevpoints;
|
||||
else
|
||||
bevp2 = bevp1 + 1;
|
||||
|
||||
@ -2840,7 +2840,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
for (a = 0; a < poly; a++, sd++) {
|
||||
if (sd->bl->hole == sd->dir) {
|
||||
bl = sd->bl;
|
||||
bevp1 = (BevPoint *)(bl + 1);
|
||||
bevp1 = bl->bevpoints;
|
||||
bevp2 = bevp1 + (bl->nr - 1);
|
||||
nr = bl->nr / 2;
|
||||
while (nr--) {
|
||||
@ -2859,7 +2859,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
/* 2D Curves */
|
||||
for (bl = bev->first; bl; bl = bl->next) {
|
||||
if (bl->nr < 2) {
|
||||
BevPoint *bevp = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp = bl->bevpoints;
|
||||
unit_qt(bevp->quat);
|
||||
}
|
||||
else if (bl->nr == 2) { /* 2 pnt, treat separate */
|
||||
@ -2874,7 +2874,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
|
||||
/* 3D Curves */
|
||||
for (bl = bev->first; bl; bl = bl->next) {
|
||||
if (bl->nr < 2) {
|
||||
BevPoint *bevp = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp = bl->bevpoints;
|
||||
unit_qt(bevp->quat);
|
||||
}
|
||||
else if (bl->nr == 2) { /* 2 pnt, treat separate */
|
||||
|
@ -1425,7 +1425,7 @@ static void calc_bevfac_mapping(
|
||||
|
||||
bevp_array = MEM_mallocN(sizeof(*bevp_array) * (bl->nr - 1), "bevp_dists");
|
||||
segments = MEM_callocN(sizeof(*segments) * segcount, "bevp_segmentlengths");
|
||||
bevp_prev = (BevPoint *)(bl + 1);
|
||||
bevp_prev = bl->bevpoints;
|
||||
bevp = bevp_prev + 1;
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
@ -1644,7 +1644,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
dl->rt = nu->flag & ~CU_2D;
|
||||
|
||||
a = dl->nr;
|
||||
bevp = (BevPoint *)(bl + 1);
|
||||
bevp = bl->bevpoints;
|
||||
data = dl->verts;
|
||||
while (a--) {
|
||||
data[0] = bevp->vec[0] + widfac * bevp->sina;
|
||||
@ -1704,9 +1704,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
"bevelSplitFlag");
|
||||
|
||||
/* for each point of poly make a bevel piece */
|
||||
bevp_first = (BevPoint *)(bl + 1);
|
||||
bevp_last = (BevPoint *)(bl + 1) + (bl->nr - 1);
|
||||
bevp = (BevPoint *)(bl + 1) + start;
|
||||
bevp_first = bl->bevpoints;
|
||||
bevp_last = &bl->bevpoints[bl->nr - 1];
|
||||
bevp = &bl->bevpoints[start];
|
||||
for (i = start, a = 0; a < steps; i++, bevp++, a++) {
|
||||
float fac = 1.0;
|
||||
float *cur_data = data;
|
||||
|
@ -5913,7 +5913,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
||||
|
||||
UI_ThemeColor(TH_WIRE_EDIT);
|
||||
for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
|
||||
BevPoint *bevp = (BevPoint *)(bl + 1);
|
||||
BevPoint *bevp = bl->bevpoints;
|
||||
int nr = bl->nr;
|
||||
int skip = nu->resolu / 16;
|
||||
|
||||
|
@ -68,16 +68,6 @@ typedef struct Path {
|
||||
float totdist;
|
||||
} Path;
|
||||
|
||||
/* These two Lines with # tell makesdna this struct can be excluded. */
|
||||
#
|
||||
#
|
||||
typedef struct BevList {
|
||||
struct BevList *next, *prev;
|
||||
int nr, dupe_nr;
|
||||
int poly, hole;
|
||||
int charidx;
|
||||
} BevList;
|
||||
|
||||
/* These two Lines with # tell makesdna this struct can be excluded. */
|
||||
#
|
||||
#
|
||||
@ -88,6 +78,19 @@ typedef struct BevPoint {
|
||||
short split_tag, dupe_tag;
|
||||
} BevPoint;
|
||||
|
||||
/* These two Lines with # tell makesdna this struct can be excluded. */
|
||||
#
|
||||
#
|
||||
typedef struct BevList {
|
||||
struct BevList *next, *prev;
|
||||
int nr, dupe_nr;
|
||||
int poly, hole;
|
||||
int charidx;
|
||||
|
||||
/* over-alloc */
|
||||
BevPoint bevpoints[0];
|
||||
} BevList;
|
||||
|
||||
/**
|
||||
* Keyframes on F-Curves (allows code reuse of Bezier eval code) and
|
||||
* Points on Bezier Curves/Paths are generally BezTriples
|
||||
|
Loading…
Reference in New Issue
Block a user