Fix coding style

This commit is contained in:
Perttu Ahola 2014-10-19 14:38:59 +03:00
parent a6d5421e98
commit 4d43efa466
11 changed files with 55 additions and 50 deletions

View File

@ -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)

View File

@ -37,8 +37,8 @@
#include <Profiler.h>
#pragma GCC diagnostic pop
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lua.h>
#include <lauxlib.h>
}
#include <signal.h>
#define MODULE "__app"

View File

@ -17,7 +17,7 @@ namespace interface {
namespace worker_thread {
struct ThreadPool;
};
}
}
namespace app

View File

@ -475,7 +475,7 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &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_<pv::RawVolume<VoxelInstance>> generate_voxel_lod_volume(
int lod, pv::RawVolume<VoxelInstance> &volume_orig)
int lod, pv::RawVolume<VoxelInstance>&volume_orig)
{
pv::Region region_orig = volume_orig.getEnclosingRegion();
auto &lc_orig = region_orig.getLowerCorner();

View File

@ -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:

View File

@ -42,7 +42,7 @@ struct CThreadPool: public ThreadPool
};
sv_<Thread> 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> 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

View File

@ -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_<float> vertex_data; // vertex(3) + normal(3) + texcoord(2)
sv_<unsigned> index_data; // Urho3D eats unsigned as large indices
};
#else
#else
struct TemporaryGeometry
{
uint atlas_id = 0;
// CustomGeometry can't handle an index buffer
PODVector<CustomGeometryVertex> vertex_data;
};
#endif
#endif
void preload_textures(pv::RawVolume<VoxelInstance> &volume,
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
@ -91,7 +91,7 @@ namespace interface
// Can be called from any thread
up_<pv::RawVolume<VoxelInstance>> generate_voxel_lod_volume(
int lod, pv::RawVolume<VoxelInstance> &volume_orig);
int lod, pv::RawVolume<VoxelInstance>&volume_orig);
// Can be called from any thread
void generate_voxel_lod_geometry(int lod,

View File

@ -20,13 +20,13 @@ namespace interface
/*struct Thread
{
virtual ~Thread(){}
virtual void add_task(up_<Task> 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> 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();*/

View File

@ -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:

View File

@ -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<RigidBody>();
if(body)
body->OnSetEnabled();
return true; }
{
RigidBody *body = node->GetComponent<RigidBody>();
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:

View File

@ -25,9 +25,9 @@ void init_voxel(lua_State *L)
module(L)[
class_<VoxelRegistry, bases<>, sp_<VoxelRegistry>>("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: