commit 1f7742d672f85e2f446d199e35cbfd7019c294dc
parent caf88ecfd4ea252d024b7b0f79c7679b14e4bcbb
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 11 Jan 2019 15:36:42 +0100
Fix how invalid meshes are handled against the RT backend
Diffstat:
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/s3d_scene_view.c b/src/s3d_scene_view.c
@@ -469,16 +469,22 @@ scene_view_register_mesh
struct geometry* geom = NULL;
size_t iattr;
unsigned shape_id;
-
+ int is_valid;
res_T res = RES_OK;
ASSERT(scnview && shape && shape->type == GEOM_MESH);
+ is_valid = shape->data.mesh->indices && shape->data.mesh->attribs[S3D_POSITION];
+
/* Retrieve the cached geometry */
S3D(shape_get_id(shape, &shape_id));
pgeom = htable_geom_find(&scnview->cached_geoms, &shape_id);
if(pgeom) {
geom = *pgeom;
- } else {
+ if(!is_valid) {
+ scene_view_destroy_geometry(scnview, geom);
+ htable_geom_erase(&scnview->cached_geoms, &shape_id);
+ }
+ } else if(is_valid) {
res = geometry_create(scnview->scn->dev, &geom);
if(res != RES_OK) goto error;
res = mesh_create(scnview->scn->dev, &geom->data.mesh);
@@ -489,19 +495,7 @@ scene_view_register_mesh
geom->name = shape->id.index;
}
- /* Discard the geometry that is not geometrically valid */
- if(!shape->data.mesh->indices || !shape->data.mesh->attribs[S3D_POSITION]) {
- if(geom->rtc != NULL) {
- if(geom->rtc_id != RTC_INVALID_GEOMETRY_ID) {
- rtcDetachGeometry(scnview->rtc_scn, geom->rtc_id);
- geom->rtc_id = RTC_INVALID_GEOMETRY_ID;
- }
- rtcReleaseGeometry(geom->rtc);
- geom->rtc = NULL;
- }
- mesh_clear(geom->data.mesh);
- goto exit;
- }
+ if(!is_valid) goto exit;
/* Get a reference onto the shape mesh indices */
if(geom->data.mesh->indices != shape->data.mesh->indices) {