commit f9a9faac3dab4203db16f27a55cd37905902b628
parent 6631bcbdeefc3c52e828c21e63017b518f6aaf17
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 1 Sep 2015 16:20:07 +0200
Fix obj with no triangle
The triangulation process remove degenerated vertices. Consequently, the
resulting mesh can have no triangle. Such meshes are now skipped and thus
empty Star-3D shapes are not created anymore.
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -57,7 +57,7 @@ include(rcmake_runtime)
################################################################################
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
-set(VERSION_PATCH 0)
+set(VERSION_PATCH 1)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(S3DAW_FILES_SRC s3daw.c)
diff --git a/src/s3daw.c b/src/s3daw.c
@@ -255,14 +255,15 @@ shape_register(struct s3daw* s3daw, const struct aw_obj_named_group* obj_mtl)
/* Create the S3D shape */
- res = s3d_shape_create_mesh(s3daw->s3d, &shape);
- if(res != RES_OK) goto error;
-
nverts = darray_vertex_size_get(&s3daw->vertices);
ntris = darray_size_t_size_get(&s3daw->indices);
- ASSERT(ntris);
+ if(!ntris) goto exit;
+ ASSERT(!(ntris % 3));
ntris /= 3;
+ res = s3d_shape_create_mesh(s3daw->s3d, &shape);
+ if(res != RES_OK) goto error;
+
vertex_data[0].usage = S3D_POSITION;
vertex_data[0].type = S3D_FLOAT3;
vertex_data[0].get = get_position;