@@ -68,31 +68,32 @@ bool make_face(const vertex_id* restrict a, const vertex_id* restrict b,
68
68
return true;
69
69
}
70
70
71
- shape_t * new_revolution (const shape_t * standard , const unsigned m , const unsigned n )
71
+ shape_t * new_revolution (const shape_t * standard , const unsigned m )
72
72
{
73
73
shape_t * ret = new_shape ();
74
74
shape_t * prev = new_shape ();
75
- for (unsigned i = 0 ; i < n + 1 ; ++ i ) {
75
+ const unsigned n = standard -> num_vertices ;
76
+ for (unsigned i = 0 ; i < n ; ++ i ) {
76
77
const vertex_id v = standard -> vertices [i ];
77
78
add_vertex (prev , v );
78
79
add_vertex (ret , v );
79
80
}
80
81
for (unsigned rot = 1 ; rot < m ; ++ rot ) {
81
82
shape_t * current = new_shape ();
82
83
const double theta = rot * (2 * M_PI / m );
83
- for (unsigned i = 0 ; i < n + 1 ; ++ i ) {
84
+ for (unsigned i = 0 ; i < n ; ++ i ) {
84
85
const vertex_t vs = get_point (standard -> vertices [i ]);
85
86
const double x = vs .x * cos (theta );
86
87
const double z = vs .x * sin (theta );
87
88
const vertex_id v = new_vertex (x , vs .y , z );
88
89
add_vertex (current , v );
89
90
add_vertex (ret , v );
90
91
}
91
- make_face (prev -> vertices , current -> vertices , n + 1 );
92
+ make_face (prev -> vertices , current -> vertices , n );
92
93
free_shape (prev );
93
94
prev = current ;
94
95
}
95
- make_face (prev -> vertices , standard -> vertices , n + 1 );
96
+ make_face (prev -> vertices , standard -> vertices , n );
96
97
free_shape (prev );
97
98
return ret ;
98
99
}
@@ -130,7 +131,7 @@ shape_t *new_cylinder(const double r, const double height, const unsigned m, con
130
131
for (unsigned i = 0 ; i < rn + 1 ; ++ i ) {
131
132
add_vertex (standard , new_vertex (r - i * r / rn , height / 2 , 0 ));
132
133
}
133
- shape_t * ret = new_revolution (standard , m , 2 * rn + hn + 2 );
134
+ shape_t * ret = new_revolution (standard , m );
134
135
free_shape (standard );
135
136
return ret ;
136
137
}
@@ -144,7 +145,7 @@ shape_t *new_taurus(const double offset, const double r,
144
145
const vertex_id v = new_vertex (r * cos (theta ) + offset , r * sin (theta ), 0 );
145
146
add_vertex (standard , v );
146
147
}
147
- shape_t * ret = new_revolution (standard , m , n );
148
+ shape_t * ret = new_revolution (standard , m );
148
149
free_shape (standard );
149
150
return ret ;
150
151
}
@@ -157,7 +158,7 @@ shape_t *new_sphere(const double r, const unsigned m, const unsigned n)
157
158
const vertex_id v = new_vertex (r * cos (theta ), r * sin (theta ), 0 );
158
159
add_vertex (standard , v );
159
160
}
160
- shape_t * ret = new_revolution (standard , m , n );
161
+ shape_t * ret = new_revolution (standard , m );
161
162
free_shape (standard );
162
163
return ret ;
163
164
}
0 commit comments