From 1a8eeaf0af5929ed47eda4a65a8c22878bf37f05 Mon Sep 17 00:00:00 2001 From: Basher207 Date: Mon, 30 Nov 2015 16:02:36 +0000 Subject: [PATCH] Fixed octet compiling on mac using make file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -octet/MakeFile Added std=c++11 for lambda usage -octet/src/scene/mesh.h: cast to int32_t unsigned ints to int32_t for edge constructor -octet/src/scene/scene_node.h using sqrt instead of std::sqrt (Compiler error: “error: no member named 'sqrt' in namespace 'std'; did you mean simply 'sqrt’?” ) --- octet/Makefile | 2 +- octet/src/scene/mesh.h | 14 +++++++------- octet/src/scene/scene_node.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/octet/Makefile b/octet/Makefile index 29e776f0..c93afb7e 100644 --- a/octet/Makefile +++ b/octet/Makefile @@ -25,7 +25,7 @@ else endif ifeq ($(UNAME_S),Darwin) CC = clang - CCFLAGS += -g -O2 -Wswitch -D OCTET_MAC -F/System/Library/Frameworks -framework GLUT -framework OpenGL -framework OpenAL -lstdc++ -DOCTET_PREFIX=\"\" -Iopen_source/bullet + CCFLAGS += -g -O2 -Wswitch -D OCTET_MAC -F/System/Library/Frameworks -framework GLUT -framework OpenGL -framework OpenAL -lstdc++ -std=c++11 -DOCTET_PREFIX=\"\" -Iopen_source/bullet endif endif diff --git a/octet/src/scene/mesh.h b/octet/src/scene/mesh.h index 9e406b98..1aae11cc 100644 --- a/octet/src/scene/mesh.h +++ b/octet/src/scene/mesh.h @@ -87,7 +87,7 @@ namespace octet { namespace scene { // add a new edge to a hash map. (index, index) -> (triangle+1, triangle+1) static void add_edge(dynarray &edges, unsigned tri_idx, unsigned i0, unsigned i1) { - edge e = { std::min(i0, i1), std::max(i0, i1), tri_idx, ~0 }; + edge e = { static_cast (std::min(i0,i1)), static_cast (std::max(i0, i1)), static_cast (tri_idx), ~0 }; edges.push_back(e); } @@ -383,13 +383,13 @@ namespace octet { namespace scene { // note that it is your responsibility to deallocate resources! btIndexedMesh mesh; mesh.m_numTriangles = get_num_indices() / 3; - mesh.m_triangleIndexBase = (const unsigned char *)malloc(get_indices()->get_size()); - mesh.m_triangleIndexStride = sizeof(uint32_t) * 3; + mesh.m_triangleIndexBase = (const unsigned char *)malloc(get_indices()->get_size()); + mesh.m_triangleIndexStride = sizeof(uint32_t) * 3; mesh.m_numVertices = get_num_vertices(); - mesh.m_vertexBase = (const unsigned char *)malloc(get_vertices()->get_size()); - mesh.m_vertexStride = get_stride(); - - { + mesh.m_vertexBase = (const unsigned char *)malloc(get_vertices()->get_size()); + mesh.m_vertexStride = get_stride(); + + { gl_resource::rolock idx_lock(get_indices()); gl_resource::rolock vtx_lock(get_vertices()); memcpy((void*)mesh.m_triangleIndexBase, idx_lock.u8() + get_index_size() * first_index, get_indices()->get_size()); diff --git a/octet/src/scene/scene_node.h b/octet/src/scene/scene_node.h index db8c0867..fed02a76 100644 --- a/octet/src/scene/scene_node.h +++ b/octet/src/scene/scene_node.h @@ -346,7 +346,7 @@ namespace octet { namespace scene { btVector3 vel = rigid_body->getLinearVelocity(); float s2 = vel.dot(vel); if (s2 > max_speed * max_speed) { - rigid_body->setLinearVelocity(vel * (max_speed/std::sqrt(s2))); + rigid_body->setLinearVelocity(vel * (max_speed/sqrt(s2))); } } #endif