summaryrefslogtreecommitdiff
path: root/src/primitives.cc
diff options
context:
space:
mode:
authormeta <s@w23.at>2011-01-18 23:17:31 (GMT)
committermeta <s@w23.at>2011-01-18 23:17:31 (GMT)
commita117735f7631a86d15075a6c1ca404b24e0a1bee (patch)
treebcca5c5f62e758d0c57cb2f07779fe97e2702b48 /src/primitives.cc
parenta7bf88a9cbb78feb6bd2c9e34ce64cc428d6b708 (diff)
don't use C99 variable length arrays
Diffstat (limited to 'src/primitives.cc')
-rw-r--r--src/primitives.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/primitives.cc b/src/primitives.cc
index ac1f0a3..901d035 100644
--- a/src/primitives.cc
+++ b/src/primitives.cc
@@ -278,7 +278,7 @@ PolySet *PrimitiveNode::render_polyset(render_mode_e) const
};
int rings = get_fragments_from_r(r1, fn, fs, fa);
- ring_s ring[rings];
+ ring_s *ring = new ring_s[rings];
for (int i = 0; i < rings; i++) {
double phi = (M_PI * (i + 0.5)) / rings;
@@ -332,6 +332,8 @@ sphere_next_r2:
p->append_poly();
for (int i = 0; i < ring[rings-1].fragments; i++)
p->insert_vertex(ring[rings-1].points[i].x, ring[rings-1].points[i].y, ring[rings-1].z);
+
+ delete[] ring;
}
if (type == CYLINDER && h > 0 && r1 >=0 && r2 >= 0 && (r1 > 0 || r2 > 0))
@@ -351,8 +353,8 @@ sphere_next_r2:
double x, y;
};
- point2d circle1[fragments];
- point2d circle2[fragments];
+ point2d *circle1 = new point2d[fragments];
+ point2d *circle2 = new point2d[fragments];
for (int i=0; i<fragments; i++) {
double phi = (M_PI*2*i) / fragments;
@@ -399,6 +401,9 @@ sphere_next_r2:
for (int i=0; i<fragments; i++)
p->append_vertex(circle2[i].x, circle2[i].y, z2);
}
+
+ delete[] circle1;
+ delete[] circle2;
}
if (type == POLYHEDRON)
@@ -444,22 +449,13 @@ sphere_next_r2:
{
int fragments = get_fragments_from_r(r1, fn, fs, fa);
- struct point2d {
- double x, y;
- };
-
- point2d circle[fragments];
+ p->is2d = true;
+ p->append_poly();
- for (int i=0; i<fragments; i++) {
+ for (int i=0; i < fragments; i++) {
double phi = (M_PI*2*i) / fragments;
- circle[i].x = r1*cos(phi);
- circle[i].y = r1*sin(phi);
+ p->append_vertex(r1*cos(phi), r1*sin(phi));
}
-
- p->is2d = true;
- p->append_poly();
- for (int i=0; i<fragments; i++)
- p->append_vertex(circle[i].x, circle[i].y);
}
if (type == POLYGON)
contact: Jan Huwald // Impressum