diff --git a/games/digger/main/main.cpp b/games/digger/main/main.cpp index f058974..0cf6ee6 100644 --- a/games/digger/main/main.cpp +++ b/games/digger/main/main.cpp @@ -278,7 +278,7 @@ struct Module: public interface::Module break; } y++;*/ - size_t noise_i = (z-lc.getZ())*d + (x-lc.getX()); + size_t noise_i = (z-lc.getZ())*d + (x-lc.getX()); double a = noise.result[noise_i]; int y = a + 11.0; if(y < lc.getY() - 5 || y > uc.getY() - 5) diff --git a/src/client/app.cpp b/src/client/app.cpp index e6fadc1..7ee1963 100644 --- a/src/client/app.cpp +++ b/src/client/app.cpp @@ -37,8 +37,8 @@ #include #pragma GCC diagnostic pop extern "C" { -#include -#include + #include + #include } #include #define MODULE "__app" diff --git a/src/client/app.h b/src/client/app.h index f437021..2f35472 100644 --- a/src/client/app.h +++ b/src/client/app.h @@ -17,7 +17,7 @@ namespace interface { namespace worker_thread { struct ThreadPool; - }; + } } namespace app diff --git a/src/impl/mesh.cpp b/src/impl/mesh.cpp index 7907426..01156dc 100644 --- a/src/impl/mesh.cpp +++ b/src/impl/mesh.cpp @@ -475,7 +475,7 @@ void generate_voxel_geometry(sm_ &result, throw Exception("No atlas segment cache for voxel "+itos(voxel_id0)+ " face "+itos(face_id)); #if 0 -// TODO: Create a custom Drawable that can use an index buffer + // TODO: Create a custom Drawable that can use an index buffer // Get or create the appropriate temporary geometry for this atlas TemporaryGeometry &tg = result[seg_ref.atlas_id]; if(tg.vertex_data.empty()){ @@ -604,7 +604,7 @@ void set_voxel_geometry(CustomGeometry *cg, Context *context, } up_> generate_voxel_lod_volume( - int lod, pv::RawVolume &volume_orig) + int lod, pv::RawVolume&volume_orig) { pv::Region region_orig = volume_orig.getEnclosingRegion(); auto &lc_orig = region_orig.getLowerCorner(); diff --git a/src/impl/sha1.cpp b/src/impl/sha1.cpp index 820851c..7266c95 100644 --- a/src/impl/sha1.cpp +++ b/src/impl/sha1.cpp @@ -6,22 +6,22 @@ namespace interface { namespace sha1 { - ss_ calculate(const ss_ &data) - { - unsigned char result[20]; - smallsha1::calc(data.c_str(), data.size(), result); - return ss_((char*)result, 20); - } +ss_ calculate(const ss_ &data) +{ + unsigned char result[20]; + smallsha1::calc(data.c_str(), data.size(), result); + return ss_((char*)result, 20); +} - ss_ hex(const ss_ &raw) - { - if(raw.size() != 20) - throw Exception("interface::sha1::hex() only accepts raw.size()=20"); - char result[41]; - smallsha1::toHexString((const unsigned char*)raw.c_str(), result); - return ss_(result, 40); - } +ss_ hex(const ss_ &raw) +{ + if(raw.size() != 20) + throw Exception("interface::sha1::hex() only accepts raw.size()=20"); + char result[41]; + smallsha1::toHexString((const unsigned char*)raw.c_str(), result); + return ss_(result, 40); +} - } +} } // vim: set noet ts=4 sw=4: diff --git a/src/impl/worker_thread.cpp b/src/impl/worker_thread.cpp index 32213a4..67dd6cc 100644 --- a/src/impl/worker_thread.cpp +++ b/src/impl/worker_thread.cpp @@ -42,7 +42,7 @@ struct CThreadPool: public ThreadPool }; sv_ m_threads; - static void *run_thread(void *arg) + static void* run_thread(void *arg) { log_d(MODULE, "Worker thread %p start", arg); Thread *thread = (Thread*)arg; @@ -61,7 +61,7 @@ struct CThreadPool: public ThreadPool } // Run the task's threaded part try { - while(!current->thread()); + while(!current->thread()) ; } catch(std::exception &e){ log_w(MODULE, "Worker task failed: %s", e.what()); } @@ -82,7 +82,7 @@ struct CThreadPool: public ThreadPool void add_task(up_ task) { // TODO: Limit task->pre() execution time per frame - while(!task->pre()); + while(!task->pre()) ; interface::MutexScope ms(m_mutex); m_input_queue.push_back(std::move(task)); m_tasks_sem.post(); @@ -178,7 +178,7 @@ struct CThreadPool: public ThreadPool int64_t t2 = get_timeofday_us(); log_v(MODULE, "output post(): %ius (%zu calls; queue size: %zu%s)", (int)(t2 - t1), post_count, queue_size, - (last_was_partly_procesed?"; last was partly processed":"")); + (last_was_partly_procesed ? "; last was partly processed" : "")); #else (void)last_was_partly_procesed; // Unused #endif diff --git a/src/interface/mesh.h b/src/interface/mesh.h index 54e056d..6035d80 100644 --- a/src/interface/mesh.h +++ b/src/interface/mesh.h @@ -51,7 +51,7 @@ namespace interface // Voxel geometry generation - #if 0 +#if 0 // TODO: Create a custom Drawable that can use an index buffer struct TemporaryGeometry { @@ -59,14 +59,14 @@ namespace interface sv_ vertex_data; // vertex(3) + normal(3) + texcoord(2) sv_ index_data; // Urho3D eats unsigned as large indices }; - #else +#else struct TemporaryGeometry { uint atlas_id = 0; // CustomGeometry can't handle an index buffer PODVector vertex_data; }; - #endif +#endif void preload_textures(pv::RawVolume &volume, VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg); @@ -91,7 +91,7 @@ namespace interface // Can be called from any thread up_> generate_voxel_lod_volume( - int lod, pv::RawVolume &volume_orig); + int lod, pv::RawVolume&volume_orig); // Can be called from any thread void generate_voxel_lod_geometry(int lod, diff --git a/src/interface/worker_thread.h b/src/interface/worker_thread.h index 2be9c6e..40cd2da 100644 --- a/src/interface/worker_thread.h +++ b/src/interface/worker_thread.h @@ -20,13 +20,13 @@ namespace interface /*struct Thread { - virtual ~Thread(){} - virtual void add_task(up_ task) = 0; - virtual void start() = 0; - virtual void request_stop() = 0; - virtual void join() = 0; - virtual bool is_running() = 0; - virtual void main() = 0; // Allow task to do stuff in main thread + virtual ~Thread(){} + virtual void add_task(up_ task) = 0; + virtual void start() = 0; + virtual void request_stop() = 0; + virtual void join() = 0; + virtual bool is_running() = 0; + virtual void main() = 0; // Allow task to do stuff in main thread }; Thread* createThread();*/ diff --git a/src/lua_bindings/atlas.cpp b/src/lua_bindings/atlas.cpp index 7252805..693539b 100644 --- a/src/lua_bindings/atlas.cpp +++ b/src/lua_bindings/atlas.cpp @@ -43,4 +43,5 @@ void init_atlas(lua_State *L) } // namespace lua_bindingss +// codestyle:disable (currently util/codestyle.sh screws up the .def formatting) // vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/mesh.cpp b/src/lua_bindings/mesh.cpp index b2767f3..abb8ab2 100644 --- a/src/lua_bindings/mesh.cpp +++ b/src/lua_bindings/mesh.cpp @@ -38,7 +38,7 @@ namespace lua_bindings { tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \ throw Exception("Expected \"" #type "\""); \ } \ - } \ +} \ type *result_name = (type*)tolua_tousertype(L, index, 0); #define TRY_GET_TOLUA_STUFF(result_name, index, type) \ type *result_name = nullptr; \ @@ -67,7 +67,7 @@ void set_simple_voxel_model(const luabind::object &node_o, if((int)data.size() != w * h * d){ throw Exception(ss_()+"set_simple_voxel_model(): Data size does not match" - " with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")"); + " with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")"); } lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app"); @@ -102,7 +102,7 @@ void set_8bit_voxel_geometry(const luabind::object &node_o, if((int)data.size() != w * h * d){ throw Exception(ss_()+"set_8bit_voxel_geometry(): Data size does not match" - " with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")"); + " with dimensions ("+cs(data.size())+" vs. "+cs(w*h*d)+")"); } lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app"); @@ -123,7 +123,7 @@ void set_8bit_voxel_geometry(const luabind::object &node_o, struct ScopeTimer { const char *name; uint64_t t0; - ScopeTimer(const char *name="unknown"): name(name){ + ScopeTimer(const char *name = "unknown"): name(name){ t0 = get_timeofday_us(); } ~ScopeTimer(){ @@ -136,7 +136,7 @@ struct ScopeTimer { }; #else struct ScopeTimer { - ScopeTimer(const char *name=""){} + ScopeTimer(const char *name = ""){} }; #endif @@ -300,16 +300,18 @@ struct SetPhysicsBoxesTask: public interface::worker_thread::Task interface::mesh::set_voxel_physics_boxes( node, context, result_boxes, false); break; - case 3: { + case 3: // Times on Dell Precision M6800: // 0 boxes -> 30us // 1 box -> 64us // 160 boxes -> 8419us (hilly forest) // 259 boxes -> 15704us (hilly forest, bad case) - RigidBody *body = node->GetComponent(); - if(body) - body->OnSetEnabled(); - return true; } + { + RigidBody *body = node->GetComponent(); + if(body) + body->OnSetEnabled(); + } + return true; } post_step++; return false; @@ -440,9 +442,10 @@ void clear_voxel_physics_boxes(const luabind::object &node_o) node->RemoveComponent(previous_shapes[i]); } +#define LUABIND_FUNC(name) def("__buildat_" #name, name) + void init_mesh(lua_State *L) { -#define LUABIND_FUNC(name) def("__buildat_" #name, name) using namespace luabind; module(L)[ LUABIND_FUNC(set_simple_voxel_model), @@ -457,5 +460,5 @@ void init_mesh(lua_State *L) } // namespace lua_bindingss -// vim: set noet ts=4 sw=4: +// vim: set noet ts=4 sw=4: diff --git a/src/lua_bindings/voxel.cpp b/src/lua_bindings/voxel.cpp index f8617db..017aff0 100644 --- a/src/lua_bindings/voxel.cpp +++ b/src/lua_bindings/voxel.cpp @@ -25,9 +25,9 @@ void init_voxel(lua_State *L) module(L)[ class_, sp_>("VoxelRegistry") - .def("serialize", (ss_(VoxelRegistry::*)()) + .def("serialize", (ss_(VoxelRegistry::*) ()) &VoxelRegistry::serialize) - .def("deserialize", (void(VoxelRegistry::*)(const ss_&)) + .def("deserialize", (void(VoxelRegistry::*) (const ss_ &)) &VoxelRegistry::deserialize), def("createVoxelRegistry", &createVoxelRegistry) ]; @@ -35,4 +35,5 @@ void init_voxel(lua_State *L) } // namespace lua_bindingss +// codestyle:disable (currently util/codestyle.sh screws up the .def formatting) // vim: set noet ts=4 sw=4: