star-3d

Surface structuring for efficient 3D geometric queries
git clone git://git.meso-star.fr/star-3d.git
Log | Files | Refs | README | LICENSE

commit 075fc57755d581e2d250bce07caf61435681af7d
parent 6423486c5bc0e451bd7c3a13d68e203948c371e8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 20 Mar 2015 11:56:31 +0100

Enable custum C++ build

Fix several warnings and link errors

Diffstat:
Mcmake/CMakeLists.txt | 8+++++++-
Asrc/s3d_backend.h | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/s3d_device.c | 3+--
Msrc/s3d_scene.c | 9+++------
Msrc/s3d_scene_c.h | 4++--
Msrc/s3d_shape.c | 17+++++++----------
6 files changed, 71 insertions(+), 21 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -68,12 +68,18 @@ rcmake_prepend_path(S3D_FILES_INC ${S3D_SOURCE_DIR}) set_source_files_properties(${S3D_FILES_SRC} PROPERTIES LANGUAGE CXX) add_library(s3d SHARED ${S3D_FILES_SRC} ${S3D_FILES_INC}) -target_link_libraries(s3d Embree m) +target_link_libraries(s3d RSys Embree m) set_target_properties(s3d PROPERTIES DEFINE_SYMBOL S3D_SHARED_BUILD LINKER_LANGUAGE CXX VERSION ${VERSION} SOVERSION ${VERSION_MAJOR}) + +if(CMAKE_COMPILER_IS_GNUCXX) + # Shut up the use of variadic macros by Embree + set_target_properties(s3d PROPERTIES COMPILE_FLAGS "-Wno-variadic-macros") +endif() + rcmake_setup_devel(s3d s3d ${VERSION} se/s3d_version.h) ################################################################################ diff --git a/src/s3d_backend.h b/src/s3d_backend.h @@ -0,0 +1,51 @@ +/* Copyright (C) |Meso|Star> 2015 (contact@meso-star.com) + * + * This software is a computer program whose purpose is to describe a + * virtual 3D environment that can be ray-traced and sampled both robustly + * and efficiently. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. */ + +#ifndef S3D_BACKEND_H +#define S3D_BACKEND_H + +#include <rsys/rsys.h> + +#ifdef COMPILER_GCC + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" + #pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +#include <embree2/rtcore.h> +#include <embree2/rtcore_ray.h> + +#ifdef COMPILER_GCC + #pragma GCC diagnostic pop +#endif + +#endif /* S3D_BACKEND_H */ diff --git a/src/s3d_device.c b/src/s3d_device.c @@ -31,9 +31,9 @@ * knowledge of the CeCILL license and that you accept its terms. */ #include "s3d.h" +#include "s3d_backend.h" #include "s3d_device_c.h" -#include <embree2/rtcore.h> #include <rsys/logger.h> #include <rsys/mem_allocator.h> @@ -66,7 +66,6 @@ s3d_device_create { struct s3d_device* dev = NULL; struct mem_allocator* allocator; - enum RTCError err; res_T res = RES_OK; if(!out_dev) { diff --git a/src/s3d_scene.c b/src/s3d_scene.c @@ -40,8 +40,6 @@ #include <rsys/mem_allocator.h> #include <rsys/mutex.h> -#include <embree2/rtcore_ray.h> - /******************************************************************************* * Helper functions ******************************************************************************/ @@ -396,7 +394,6 @@ s3d_scene_trace_ray struct s3d_hit* hit) { struct RTCRay ray; - res_T res = RES_OK; if(!scn || !org || !dir || !range || !hit) return RES_BAD_ARG; if(!f3_is_normalized(dir)) @@ -421,7 +418,7 @@ s3d_scene_trace_ray rtcIntersect(scn->rtc_scn, ray); mutex_rw_unlock(scn->lock_rtc); - if(ray.geomID == RTC_INVALID_GEOMETRY_ID) { + if((unsigned)ray.geomID == RTC_INVALID_GEOMETRY_ID) { *hit = S3D_HIT_NULL; } else { f3_set(hit->normal, ray.Ng); @@ -429,9 +426,9 @@ s3d_scene_trace_ray hit->uv[1] = ray.v; hit->distance = ray.tfar; hit->iprim = ray.primID; - ASSERT(ray.geomID < darray_geom2shape_size_get(&scn->geom2shape)); + ASSERT((unsigned)ray.geomID < darray_geom2shape_size_get(&scn->geom2shape)); hit->shape = darray_geom2shape_data_get(&scn->geom2shape)[ray.geomID]; - ASSERT(hit->shape != NULL && ray.geomID == hit->shape->rtc_geom); + ASSERT(hit->shape != NULL && (unsigned)ray.geomID == hit->shape->rtc_geom); } return RES_OK; } diff --git a/src/s3d_scene_c.h b/src/s3d_scene_c.h @@ -33,12 +33,12 @@ #ifndef S3D_SCENE_C_H #define S3D_SCENE_C_H +#include "s3d_backend.h" + #include <rsys/dynamic_array.h> #include <rsys/list.h> #include <rsys/ref_count.h> -#include <embree2/rtcore.h> - #define DARRAY_NAME geom2shape #define DARRAY_DATA struct s3d_shape* #include <rsys/dynamic_array.h> diff --git a/src/s3d_shape.c b/src/s3d_shape.c @@ -41,7 +41,7 @@ /******************************************************************************* * Helper functions ******************************************************************************/ -static INLINE size_t +static INLINE unsigned get_s3d_type_dimension(const enum s3d_type type) { switch(type) { @@ -97,7 +97,7 @@ mesh_setup_indices ASSERT(mesh && ntris && get_indices && nverts); nids = ntris * 3; - nids_prev = darray_u32_size_get(&mesh->indices); + nids_prev = (unsigned)darray_u32_size_get(&mesh->indices); ASSERT(get_indices != S3D_KEEP || nids == nids_prev); if(get_indices == S3D_KEEP) { @@ -142,7 +142,7 @@ mesh_setup_positions res_T res; ASSERT(mesh && nverts && attr && attr->usage == S3D_POSITION); - nverts_prev = darray_float_size_get(&mesh->attribs[S3D_POSITION]); + nverts_prev = (unsigned)darray_float_size_get(&mesh->attribs[S3D_POSITION]); ASSERT(nverts_prev % 3 == 0); nverts_prev /= 3; if(attr->get == S3D_KEEP) { @@ -201,13 +201,13 @@ mesh_setup_attribs void* data) { float* attr_data; - size_t attr_dimension; + unsigned attr_dimension; unsigned ivert, nverts_prev; res_T res; ASSERT(mesh && nverts && attr); ASSERT(attr->usage >= S3D_ATTRIB_0 && attr->usage < S3D_ATTRIBS_COUNT__); - nverts_prev = darray_float_size_get(&mesh->attribs[attr->usage]); + nverts_prev = (unsigned)darray_float_size_get(&mesh->attribs[attr->usage]); attr_dimension = get_s3d_type_dimension(mesh->attribs_type[attr->usage]); ASSERT(nverts_prev % attr_dimension == 0); nverts_prev /= attr_dimension; @@ -441,11 +441,7 @@ s3d_shape_mesh_setup_indexed_vertices struct s3d_vertex_data attribs[], void* data) { - uint32_t* indices; - unsigned itri; - unsigned nids, nids_prev; unsigned iattr; - unsigned nverts_check, nverts_prev; char has_position = 0; res_T res = RES_OK; @@ -457,7 +453,8 @@ s3d_shape_mesh_setup_indexed_vertices /* Check indices description */ if(get_indices == S3D_KEEP) { - const unsigned nids_prev = darray_u32_size_get(&shape->data.mesh.indices); + const unsigned nids_prev = (unsigned) + darray_u32_size_get(&shape->data.mesh.indices); const unsigned ntris_prev = nids_prev / 3; if(ntris_prev != ntris) { /* Inconsistant data */ res = RES_BAD_ARG;