commit cabae4964c8deaa089f9150b41fc757cd80b9da3
parent 2e7b833fadf36269772afc2d4642d2f5301a8780
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 30 Nov 2016 10:47:40 +0100
Fix the face orientation of the cylinder "top cap"
Diffstat:
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/s3dut.h b/src/s3dut.h
@@ -61,25 +61,29 @@ s3dut_mesh_get_data
(struct s3dut_mesh* mesh,
struct s3dut_mesh_data* data);
-/* Create a triangulared UV sphere discretized in `nslices' around the Z axis
+/* Create a triangulated UV sphere discretized in `nslices' around the Z axis
* and `nstacks' along the Z axis. Face vertices are CCW ordered with respect
* to the sphere center, i.e. they are CW ordered from the outside point of
* view. */
S3DUT_API res_T
s3dut_create_sphere
(struct mem_allocator* allocator, /* May be NULL <=> use default allocator */
- const double radius,
- const unsigned nslices, /* # subdivisions around Z axis */
- const unsigned nstacks, /* # subdivisions along Z axis */
+ const double radius, /* In ]0, INF) */
+ const unsigned nslices, /* # subdivisions around Z axis in [2, INF) */
+ const unsigned nstacks, /* # subdivisions along Z axis in [2, INF) */
struct s3dut_mesh** sphere);
+/* Create a triangulated cylinder centered in 0 discretized in `nslices' around
+ * the Z axis and `nstacks' along the Z axis. Face vertices are CCW ordered
+ * with respect to the cylinder center, i.e. they are CW ordered from the
+ * outside point of view. */
S3DUT_API res_T
s3dut_create_cylinder
(struct mem_allocator* allocator, /* May be NULL <=> use default allocator */
- const double radius,
- const double height,
- const unsigned nslices, /* # subdivisions around Z axis */
- const unsigned nstacks, /* # subdivision along Z axis */
+ const double radius, /* In ]0, INF) */
+ const double height, /* In ]0, INF) */
+ const unsigned nslices, /* # subdivisions around Z axis in [2, INF) */
+ const unsigned nstacks, /* # subdivision along Z axis in [1, INF) */
struct s3dut_mesh** cylinder);
#endif /* S3DUT_H */
diff --git a/src/s3dut_cylinder.c b/src/s3dut_cylinder.c
@@ -101,8 +101,8 @@ setup_cylinder_indices
itop = ibottom + 1;
FOR_EACH(islice, 0, nslices) {
ids[i++] = itop;
- ids[i++] = islice * (nstacks+1) + nstacks;
ids[i++] = ((islice+1)%nslices) * (nstacks+1) + nstacks;
+ ids[i++] = islice * (nstacks+1) + nstacks;
}
}