Fix coding style

This commit is contained in:
Perttu Ahola 2014-10-17 13:49:55 +03:00
parent ad528c2443
commit f64adf35d6
46 changed files with 292 additions and 287 deletions

View File

@ -46,7 +46,7 @@ std::string stripFilename(const std::string &path)
return "";
}
#ifdef _WIN32 // WINDOWS
#ifdef _WIN32 // WINDOWS
#define _WIN32_WINNT 0x0501
#include <windows.h>
@ -188,7 +188,7 @@ bool RecursiveDelete(std::string path)
return true;
}
#else // POSIX
#else // POSIX
#include <unistd.h>
#include <sys/types.h>
@ -348,6 +348,6 @@ bool CreateAllDirs(std::string path)
return true;
}
} // namespace fs
} // namespace fs
// vim: set noet ts=4 sw=4:

View File

@ -49,7 +49,7 @@ namespace c55fs
// Only pass full paths to this one. True on success.
bool RecursiveDeleteContent(std::string path);
} //fs
} //fs
#endif

View File

@ -2,16 +2,16 @@
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
#pragma once
#include <functional>
#include <cstring> // memset()
#include <unistd.h> // usleep()
#include "os.h" // get_timeofday_us()
#include <cstring> // memset()
#include <unistd.h> // usleep()
#include "os.h" // get_timeofday_us()
#include "log.h"
// If f() returns false, loop ends
void interval_loop(int interval_us, std::function<bool(float load_avg)> f)
{
int64_t t_scheduled_tick_start = get_timeofday_us();
t_scheduled_tick_start /= interval_us; // Align to round numbers
t_scheduled_tick_start /= interval_us; // Align to round numbers
t_scheduled_tick_start *= interval_us;
float load_sum = 0;
const int load_avg_length = interval_us < 500000 ? 5000000 / interval_us : 1;

View File

@ -22,7 +22,7 @@ struct FileInfo {
ss_ name;
ss_ content;
ss_ hash;
ss_ path; // Empty if not a physical file
ss_ path; // Empty if not a physical file
FileInfo(const ss_ &name, const ss_ &content, const ss_ &hash, const ss_ &path):
name(name), content(content), hash(hash), path(path){}
};

View File

@ -128,13 +128,13 @@ struct ResolveState
if(m_promised_modules.count(dep.module)){
log_w(MODULE, "%s: Reverse dependency %s ignored (already "
"marked to be loaded)", cs(name), cs(dep.module));
continue; // Adding the dependency would have no effect
continue; // Adding the dependency would have no effect
}
// Store dependency information
interface::ModuleDependency forward_dep;
forward_dep = dep; // Base dependency on reverted one
forward_dep.module = name; // The other module depends now on this
forward_dep = dep; // Base dependency on reverted one
forward_dep.module = name; // The other module depends now on this
// dep.module is the other module which should depeend on this one
m_reverse_dependencies[dep.module].push_back(forward_dep);
@ -257,7 +257,7 @@ struct ResolveState
set_error("Missing dependencies");
}
return !m_failed; // Make sure to return any leftover failure as false
return !m_failed; // Make sure to return any leftover failure as false
}
};
@ -265,7 +265,7 @@ struct Module: public interface::Module, public loader::Interface
{
interface::Server *m_server;
bool m_activated = false;
sv_<ss_> m_module_load_paths; // In order of preference
sv_<ss_> m_module_load_paths; // In order of preference
Module(interface::Server *server):
interface::Module("loader"),

View File

@ -16,7 +16,7 @@
#include <sys/socket.h>
#endif
#include <deque>
#include <cstring> // strerror()
#include <cstring> // strerror()
using interface::Event;

View File

@ -462,7 +462,7 @@ struct Module: public interface::Module, public replicate::Interface
sv_<PeerId> find_peers_that_know_node(uint node_id)
{
sv_<PeerId> result;
for(auto &pair: m_scene_states){
for(auto &pair : m_scene_states){
PeerId peer_id = pair.first;
magic::SceneReplicationState &scene_state = pair.second;
auto &node_states = scene_state.nodeStates_;

View File

@ -27,7 +27,7 @@ namespace voxelworld
pv::Vector3DInt16 section_p;
GenerationRequest(const pv::Vector3DInt16 &section_p):
section_p(section_p)
section_p(section_p)
{}
};

View File

@ -93,7 +93,7 @@ static inline int container_coord(int x, int d)
return (x>=0 ? x : x-d+1) / d;
}
static inline pv::Vector3DInt32 container_coord(
const pv::Vector3DInt32 &p, const pv::Vector3DInt32 &d)
const pv::Vector3DInt32 &p, const pv::Vector3DInt32 &d)
{
return pv::Vector3DInt32(
container_coord(p.getX(), d.getX()),
@ -101,7 +101,7 @@ static inline pv::Vector3DInt32 container_coord(
container_coord(p.getZ(), d.getZ()));
}
static inline pv::Vector3DInt32 container_coord(
const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d)
const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d)
{
return pv::Vector3DInt32(
container_coord(p.getX(), d.getX()),
@ -109,7 +109,7 @@ static inline pv::Vector3DInt32 container_coord(
container_coord(p.getZ(), d.getZ()));
}
static inline pv::Vector3DInt16 container_coord16(
const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d)
const pv::Vector3DInt32 &p, const pv::Vector3DInt16 &d)
{
return pv::Vector3DInt16(
container_coord(p.getX(), d.getX()),
@ -127,9 +127,9 @@ struct ChunkBuffer
struct Section
{
pv::Vector3DInt16 section_p;// Position in sections
pv::Vector3DInt16 section_p; // Position in sections
pv::Vector3DInt16 chunk_size;
pv::Region contained_chunks;// Position and size in chunks
pv::Region contained_chunks; // Position and size in chunks
// Static voxel nodes (each contains one chunk); Initialized to 0.
sp_<pv::RawVolume<uint32_t>> node_ids;
size_t num_chunks = 0;
@ -157,8 +157,8 @@ struct Section
contained_chunks(contained_chunks),
node_ids(new pv::RawVolume<uint32_t>(contained_chunks)),
num_chunks(contained_chunks.getWidthInVoxels() *
contained_chunks.getHeightInVoxels() *
contained_chunks.getDepthInVoxels())
contained_chunks.getHeightInVoxels() *
contained_chunks.getDepthInVoxels())
{
chunk_buffers.resize(num_chunks);
// Cache these for speed
@ -186,7 +186,7 @@ size_t Section::get_chunk_i(const pv::Vector3DInt32 &chunk_p) // global chunk_p
size_t i = local_z * h * w + local_y * w + local_x;
if(i >= num_chunks) // NOTE: This is not accurate but it is safe and fast
throw Exception(ss_()+"get_chunk_i: Section "+cs(section_p)+
" does not contain chunk"+cs(chunk_p));
" does not contain chunk"+cs(chunk_p));
return i;
}
@ -222,7 +222,8 @@ ChunkBuffer& Section::get_buffer(const pv::Vector3DInt32 &chunk_p,
{
Node *n = scene->GetNode(node_id);
if(!n){
log_w("voxelworld", "Section::get_buffer(): Node %i not found in scene "
log_w("voxelworld",
"Section::get_buffer(): Node %i not found in scene "
"for chunk " PV3I_FORMAT " in section " PV3I_FORMAT,
node_id, PV3I_PARAMS(chunk_p), PV3I_PARAMS(section_p));
return;
@ -231,10 +232,11 @@ ChunkBuffer& Section::get_buffer(const pv::Vector3DInt32 &chunk_p,
const PODVector<unsigned char> &rawbuf = var.GetBuffer();
ss_ data((const char*)&rawbuf[0], rawbuf.Size());
up_<pv::RawVolume<VoxelInstance>> volume =
interface::deserialize_volume(data);
interface::deserialize_volume(data);
buf.volume = sp_<pv::RawVolume<VoxelInstance>>(std::move(volume));
if(!buf.volume){
log_w("voxelworld", "Section::get_buffer(): Voxel volume could not be "
log_w("voxelworld",
"Section::get_buffer(): Voxel volume could not be "
"loaded from node %i for chunk "
PV3I_FORMAT " in section " PV3I_FORMAT,
node_id, PV3I_PARAMS(chunk_p), PV3I_PARAMS(section_p));
@ -337,7 +339,7 @@ struct Module: public interface::Module, public voxelworld::Interface
seg.select_segment = magic::IntVector2(0, 0);
}
vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY;
m_voxel_reg->add_voxel(vdef); // id 1
m_voxel_reg->add_voxel(vdef); // id 1
}
{
interface::VoxelDefinition vdef;
@ -356,7 +358,7 @@ struct Module: public interface::Module, public voxelworld::Interface
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 2
m_voxel_reg->add_voxel(vdef); // id 2
}
{
interface::VoxelDefinition vdef;
@ -375,7 +377,7 @@ struct Module: public interface::Module, public voxelworld::Interface
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 3
m_voxel_reg->add_voxel(vdef); // id 3
}
{
interface::VoxelDefinition vdef;
@ -394,7 +396,7 @@ struct Module: public interface::Module, public voxelworld::Interface
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 4
m_voxel_reg->add_voxel(vdef); // id 4
}
{
interface::VoxelDefinition vdef;
@ -413,7 +415,7 @@ struct Module: public interface::Module, public voxelworld::Interface
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 5
m_voxel_reg->add_voxel(vdef); // id 5
}
}
@ -475,8 +477,8 @@ struct Module: public interface::Module, public voxelworld::Interface
// Remove everything managed by us from the scene
m_server->access_scene([&](Scene *scene)
{
for(auto &sector_pair : m_sections){
for(auto &section_pair : sector_pair.second){
for(auto &sector_pair: m_sections){
for(auto &section_pair: sector_pair.second){
Section &section = section_pair.second;
auto region = section.node_ids->getEnclosingRegion();
@ -520,7 +522,7 @@ struct Module: public interface::Module, public voxelworld::Interface
log_v(MODULE, "on_tick(): Doing %zu lazy node physics updates",
m_nodes_needing_physics_update.size());
}
for(QueuedNodePhysicsUpdate &update : m_nodes_needing_physics_update){
for(QueuedNodePhysicsUpdate &update: m_nodes_needing_physics_update){
uint node_id = update.node_id;
sp_<pv::RawVolume<VoxelInstance>> volume = update.volume;
Node *n = scene->GetNode(node_id);
@ -586,7 +588,7 @@ struct Module: public interface::Module, public voxelworld::Interface
ar((int32_t)event.node_id);
}
network::access(m_server, [&](network::Interface *inetwork){
for(auto &peer_id : peers){
for(auto &peer_id: peers){
inetwork->send(peer_id, "voxelworld:node_voxel_data_updated",
os.str());
}
@ -652,11 +654,11 @@ struct Module: public interface::Module, public voxelworld::Interface
Vector3 node_p(
chunk_p.getX() * m_chunk_size_voxels.getX() +
m_chunk_size_voxels.getX() / 2.0f,
m_chunk_size_voxels.getX() / 2.0f,
chunk_p.getY() * m_chunk_size_voxels.getY() +
m_chunk_size_voxels.getY() / 2.0f,
m_chunk_size_voxels.getY() / 2.0f,
chunk_p.getZ() * m_chunk_size_voxels.getZ() +
m_chunk_size_voxels.getZ() / 2.0f
m_chunk_size_voxels.getZ() / 2.0f
);
log_t(MODULE, "create_chunk_node(): node_p=(%f, %f, %f)",
node_p.x_, node_p.y_, node_p.z_);
@ -694,7 +696,7 @@ struct Module: public interface::Module, public voxelworld::Interface
ss_ data = interface::serialize_volume_compressed(volume);
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(), data.size())));
PODVector<uint8_t>((const uint8_t*)data.c_str(), data.size())));
// There are no collision shapes initially, but add the rigid body now
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
@ -750,8 +752,8 @@ struct Module: public interface::Module, public voxelworld::Interface
{
QueuedNodePhysicsUpdate update(node_id, volume);
auto it = std::lower_bound(m_nodes_needing_physics_update.begin(),
m_nodes_needing_physics_update.end(), update,
std::greater<QueuedNodePhysicsUpdate>());
m_nodes_needing_physics_update.end(), update,
std::greater<QueuedNodePhysicsUpdate>());
if(it == m_nodes_needing_physics_update.end()){
m_nodes_needing_physics_update.insert(it, update);
} else if(it->node_id != node_id){
@ -776,11 +778,11 @@ struct Module: public interface::Module, public voxelworld::Interface
{
pv::Vector3DInt32 p0 = pv::Vector3DInt32(
section_p.getX() * m_section_size_chunks.getX() *
m_chunk_size_voxels.getX(),
m_chunk_size_voxels.getX(),
section_p.getY() * m_section_size_chunks.getY() *
m_chunk_size_voxels.getY(),
m_chunk_size_voxels.getY(),
section_p.getZ() * m_section_size_chunks.getZ() *
m_chunk_size_voxels.getZ()
m_chunk_size_voxels.getZ()
);
pv::Vector3DInt32 p1 = p0 + pv::Vector3DInt32(
m_section_size_chunks.getX() * m_chunk_size_voxels.getX() - 1,
@ -830,15 +832,15 @@ struct Module: public interface::Module, public voxelworld::Interface
const PODVector<unsigned char> &buf = var.GetBuffer();
ss_ data((const char*)&buf[0], buf.Size());
volume = sp_<pv::RawVolume<VoxelInstance>>(std::move(
interface::deserialize_volume(data)
));
interface::deserialize_volume(data)
));
// NOTE: +1 offset needed for mesh generation
pv::Vector3DInt32 voxel_p(
p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX() + 1,
p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY() + 1,
p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ() + 1
);
p.getX() - chunk_p.getX() * m_chunk_size_voxels.getX() + 1,
p.getY() - chunk_p.getY() * m_chunk_size_voxels.getY() + 1,
p.getZ() - chunk_p.getZ() * m_chunk_size_voxels.getZ() + 1
);
log_t(MODULE, "set_voxel_direct() p=" PV3I_FORMAT ", v=%i: "
"Chunk " PV3I_FORMAT " in section " PV3I_FORMAT
"; internal position " PV3I_FORMAT,
@ -849,8 +851,8 @@ struct Module: public interface::Module, public voxelworld::Interface
ss_ new_data = interface::serialize_volume_compressed(*volume);
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
});
// Mark node for collision box update
@ -862,7 +864,7 @@ struct Module: public interface::Module, public voxelworld::Interface
{
// Don't log here; this is a too busy place for even ignored log calls
/*log_t(MODULE, "set_voxel() p=" PV3I_FORMAT ", v=%i",
PV3I_PARAMS(p), v.data);*/
PV3I_PARAMS(p), v.data);*/
pv::Vector3DInt32 chunk_p = container_coord(p, m_chunk_size_voxels);
pv::Vector3DInt16 section_p =
container_coord16(chunk_p, m_section_size_chunks);
@ -901,8 +903,8 @@ struct Module: public interface::Module, public voxelworld::Interface
// Set section buffer loaded flag
auto it = std::lower_bound(m_sections_with_loaded_buffers.begin(),
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
if(it == m_sections_with_loaded_buffers.end() || *it != section)
m_sections_with_loaded_buffers.insert(it, section);
}
@ -952,15 +954,15 @@ struct Module: public interface::Module, public voxelworld::Interface
}
n->SetVar(StringHash("buildat_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
PODVector<uint8_t>((const uint8_t*)new_data.c_str(),
new_data.size())));
});
// Tell replicate to emit events once it has done its job
replicate::access(m_server, [&](replicate::Interface *ireplicate){
ireplicate->emit_after_next_sync(Event(
"voxelworld:node_voxel_data_updated",
new NodeVoxelDataUpdatedEvent(node_id)));
"voxelworld:node_voxel_data_updated",
new NodeVoxelDataUpdatedEvent(node_id)));
});
// Mark node for collision box update
@ -1028,8 +1030,8 @@ struct Module: public interface::Module, public voxelworld::Interface
// Set section buffer loaded flag
auto it = std::lower_bound(m_sections_with_loaded_buffers.begin(),
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
m_sections_with_loaded_buffers.end(), section,
std::greater<Section*>()); // position in descending order
if(it == m_sections_with_loaded_buffers.end() || *it != section)
m_sections_with_loaded_buffers.insert(it, section);

View File

@ -118,14 +118,15 @@ struct Module: public interface::Module
voxelworld::access(m_server, [&](voxelworld::Interface *ivoxelworld)
{
interface::VoxelRegistry *voxel_reg = ivoxelworld->get_voxel_reg();
interface::VoxelRegistry *voxel_reg =
ivoxelworld->get_voxel_reg();
Node *n = scene->CreateChild("Testbox");
n->SetPosition(Vector3(30.0f, 30.0f, 40.0f));
n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
int w = 2, h = 2, d = 1;
ss_ data = "1333";
@ -136,8 +137,8 @@ struct Module: public interface::Module
}
n->SetVar(StringHash("simple_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
n->SetVar(StringHash("simple_voxel_w"), Variant(w));
n->SetVar(StringHash("simple_voxel_h"), Variant(h));
n->SetVar(StringHash("simple_voxel_d"), Variant(d));
@ -152,7 +153,8 @@ struct Module: public interface::Module
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
body->SetFriction(0.75f);
body->SetMass(1.0);
CollisionShape *shape = n->CreateComponent<CollisionShape>(LOCAL);
CollisionShape *shape =
n->CreateComponent<CollisionShape>(LOCAL);
shape->SetConvexHull(model, 0, Vector3::ONE);
//shape->SetTriangleMesh(model, 0, Vector3::ONE);
//shape->SetBox(Vector3::ONE);
@ -171,9 +173,9 @@ struct Module: public interface::Module
void on_tick(const interface::TickEvent &event)
{
/*m_server->access_scene([&](Scene *scene){
Node *n = scene->GetChild("Testbox");
auto p = n->GetPosition();
log_v(MODULE, "Testbox: (%f, %f, %f)", p.x_, p.y_, p.z_);
Node *n = scene->GetChild("Testbox");
auto p = n->GetPosition();
log_v(MODULE, "Testbox: (%f, %f, %f)", p.x_, p.y_, p.z_);
});*/
static uint a = 0;
if(((a++) % 100) == 0){
@ -201,7 +203,8 @@ struct Module: public interface::Module
voxelworld::access(m_server, [&](voxelworld::Interface *ivoxelworld)
{
const pv::Vector3DInt16 &section_p = event.section_p;
pv::Region region = ivoxelworld->get_section_region_voxels(section_p);
pv::Region region = ivoxelworld->get_section_region_voxels(
section_p);
pv::Vector3DInt32 p0 = region.getLowerCorner();
pv::Vector3DInt32 p1 = region.getUpperCorner();
@ -211,7 +214,7 @@ struct Module: public interface::Module
log_t(MODULE, "on_generation_request(): p1: (%i, %i, %i)",
p1.getX(), p1.getY(), p1.getZ());
interface::NoiseParams np(0, 35, interface::v3f(160,160,160),
interface::NoiseParams np(0, 35, interface::v3f(160, 160, 160),
1, 6, 0.475);
auto lc = region.getLowerCorner();
@ -253,27 +256,27 @@ struct Module: public interface::Module
}
// Add random trees
auto extent = uc - lc + pv::Vector3DInt32(1,1,1);
auto extent = uc - lc + pv::Vector3DInt32(1, 1, 1);
int area = extent.getX() * extent.getZ();
auto pr = interface::PseudoRandom(13241);
for(int i = 0; i < area / 100; i++){
int x = pr.range(lc.getX(), uc.getX());
int z = pr.range(lc.getZ(), uc.getZ());
/*int y = 50;
for(; y>-50; y--){
pv::Vector3DInt32 p(x, y, z);
VoxelInstance v = ivoxelworld->get_voxel(p);
if(v.getId() != 1)
break;
}
y++;*/
/*int y = 50;
for(; y>-50; y--){
pv::Vector3DInt32 p(x, y, z);
VoxelInstance v = ivoxelworld->get_voxel(p);
if(v.getId() != 1)
break;
}
y++;*/
double a = interface::NoisePerlin2D(&np, x, z, 0);
int y = a + 11.0;
if(y < lc.getY() - 5 || y > uc.getY() - 5)
continue;
for(int y1=y; y1<y+4; y1++){
for(int y1 = y; y1<y+4; y1++){
pv::Vector3DInt32 p(x, y1, z);
ivoxelworld->set_voxel(p, VoxelInstance(3), true);
}

View File

@ -73,13 +73,13 @@ struct Module: public interface::Module
// NOTE: Modified or created materials will not be replicated to the
// client. Make sure to always have a resource file or create
// the material on the client.
/*m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));*/
/*Material *m = new Material(context);
m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));
m->SetTechnique(0, cache->GetResource<Technique>(
"Techniques/Diff.xml"));*/
/*m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));*/
/*Material *m = new Material(context);
m->SetTexture(TU_DIFFUSE,
cache->GetResource<Texture2D>("main/green_texture.png"));
m->SetTechnique(0, cache->GetResource<Technique>(
"Techniques/Diff.xml"));*/
{
Node *node = scene->CreateChild("DirectionalLight");

View File

@ -77,8 +77,8 @@ struct Module: public interface::Module
n->SetPosition(Vector3(0.0f, 6.0f, 0.0f));
n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
int w = 2, h = 2, d = 1;
ss_ data = "0111";

View File

@ -71,7 +71,7 @@ struct Module: public interface::Module
seg.select_segment = magic::IntVector2(0, 0);
}
vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY;
m_voxel_reg->add_voxel(vdef); // id 1
m_voxel_reg->add_voxel(vdef); // id 1
}
{
interface::VoxelDefinition vdef;
@ -90,7 +90,7 @@ struct Module: public interface::Module
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 2
m_voxel_reg->add_voxel(vdef); // id 2
}
{
interface::VoxelDefinition vdef;
@ -109,7 +109,7 @@ struct Module: public interface::Module
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 3
m_voxel_reg->add_voxel(vdef); // id 3
}
});
}
@ -145,8 +145,8 @@ struct Module: public interface::Module
n->SetPosition(Vector3(0.0f, 6.0f, 0.0f));
n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
/*int w = 1, h = 1, d = 1;
ss_ data = "1";*/
int w = 2, h = 2, d = 1;
ss_ data = "1333";

View File

@ -16,7 +16,7 @@ struct Module: public interface::Module
{
interface::Server *m_server;
Event::Type m_EventType_test1_thing;// You can cache these for more speed
Event::Type m_EventType_test1_thing; // You can cache these for more speed
Module(interface::Server *server):
interface::Module("test1"),

View File

@ -43,22 +43,22 @@ struct Module: public interface::Module
{
log_i(MODULE, "test2 start(): Calling test1");
{ // Raw
{ // Raw
Event::Type type = Event::t("test1:thing");
Event event(type, up_<Event::Private>(new test1::Thing("Nakki")));
m_server->emit_event(std::move(event));
}
{ // Simplified raw
{ // Simplified raw
Event event("test1:thing", new test1::Thing("Kebab"));
m_server->emit_event(std::move(event));
}
{ // Even simpler
{ // Even simpler
m_server->emit_event("test1:thing", new test1::Thing("Pitsa"));
}
{ // Inline wrapper
{ // Inline wrapper
test1::do_thing(m_server, "Rulla");
}
}

View File

@ -19,8 +19,8 @@
#include <Input.h>
#include <ResourceCache.h>
#include <Graphics.h>
#include <GraphicsEvents.h> // E_SCREENMODE
#include <IOEvents.h> // E_LOGMESSAGE
#include <GraphicsEvents.h> // E_SCREENMODE
#include <IOEvents.h> // E_LOGMESSAGE
#include <Log.h>
#include <DebugHud.h>
#include <XMLFile.h>
@ -121,7 +121,7 @@ struct CApp: public App, public magic::Application
sv_<ss_> resource_paths = {
g_client_config.cache_path+"/tmp",
g_client_config.share_path+"/extensions", // Could be unsafe
g_client_config.share_path+"/extensions", // Could be unsafe
g_client_config.urho3d_path+"/Bin/CoreData",
g_client_config.urho3d_path+"/Bin/Data",
};
@ -150,7 +150,7 @@ struct CApp: public App, public magic::Application
engineParameters_["ResourcePaths"] = resource_paths_s.c_str();
engineParameters_["AutoloadPaths"] = "";
engineParameters_["LogName"] = "";
engineParameters_["LogQuiet"] = true; // Don't log to stdout
engineParameters_["LogQuiet"] = true; // Don't log to stdout
// Graphics options
engineParameters_["FullScreen"] = m_options.graphics.fullscreen;
@ -210,7 +210,7 @@ struct CApp: public App, public magic::Application
seg.select_segment = magic::IntVector2(0, 0);
}
vdef.edge_material_id = interface::EDGEMATERIALID_EMPTY;
m_voxel_reg->add_voxel(vdef); // id 1
m_voxel_reg->add_voxel(vdef); // id 1
}
{
interface::VoxelDefinition vdef;
@ -229,7 +229,7 @@ struct CApp: public App, public magic::Application
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 2
m_voxel_reg->add_voxel(vdef); // id 2
}
{
interface::VoxelDefinition vdef;
@ -248,7 +248,7 @@ struct CApp: public App, public magic::Application
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 3
m_voxel_reg->add_voxel(vdef); // id 3
}
{
interface::VoxelDefinition vdef;
@ -267,7 +267,7 @@ struct CApp: public App, public magic::Application
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 4
m_voxel_reg->add_voxel(vdef); // id 4
}
{
interface::VoxelDefinition vdef;
@ -286,7 +286,7 @@ struct CApp: public App, public magic::Application
}
vdef.edge_material_id = interface::EDGEMATERIALID_GROUND;
vdef.physically_solid = true;
m_voxel_reg->add_voxel(vdef); // id 5
m_voxel_reg->add_voxel(vdef); // id 5
}
}
@ -515,7 +515,7 @@ struct CApp: public App, public magic::Application
void on_update(magic::StringHash event_type, magic::VariantMap &event_data)
{
/*magic::AutoProfileBlock profiler_block(
GetSubsystem<magic::Profiler>(), "App::on_update");*/
GetSubsystem<magic::Profiler>(), "App::on_update");*/
m_atlas_reg->update();

View File

@ -36,7 +36,7 @@ namespace app
bool resizable = true;
bool vsync = true;
bool triple_buffer = false;
int multisampling = 1; // 2 looks much better but is much heavier(?)
int multisampling = 1; // 2 looks much better but is much heavier(?)
int window_x = UNDEFINED_INT;
int window_y = UNDEFINED_INT;

View File

@ -20,7 +20,7 @@ bool g_sigint_received = false;
void sigint_handler(int sig)
{
if(!g_sigint_received){
fprintf(stdout, "\n"); // Newline after "^C"
fprintf(stdout, "\n"); // Newline after "^C"
log_i("process", "SIGINT");
g_sigint_received = true;
} else {

View File

@ -60,8 +60,8 @@ struct CState: public State
sp_<app::App> m_app;
ss_ m_remote_cache_path;
ss_ m_tmp_path;
sm_<ss_, ss_> m_file_hashes;// name -> hash
set_<ss_> m_waiting_files; // name
sm_<ss_, ss_> m_file_hashes; // name -> hash
set_<ss_> m_waiting_files; // name
bool m_tell_after_all_files_transferred_requested = false;
// Connecting is possible only once. After that has happened, the whole
// state has to be recreated for making a new connection.

View File

@ -8,9 +8,9 @@
#include <iomanip>
#include <fstream>
#include <streambuf>
#include <cinttypes>// PRId64
#include <cmath>// isnan/isinf
#include <cfloat> // DBL_MAX/DBL_MIN
#include <cinttypes> // PRId64
#include <cmath> // isnan/isinf
#include <cfloat> // DBL_MAX/DBL_MIN
#include "sajson.h"
using namespace json;

View File

@ -203,6 +203,6 @@ namespace json
};
}
#define JSON_INDENT(x) // Dummy for now
#define JSON_INDENT(x) // Dummy for now
// vim: set noet ts=4 sw=4:

View File

@ -103,21 +103,21 @@ static void print(int level, const char *sys, const char *fmt, va_list va_args)
if(use_colors && !file &&
(level != current_level || line_begin) && level <= max_level){
if(level == LOG_FATAL)
fprintf(stderr, "\033[0m\033[0;1;41m"); // reset, bright red bg
fprintf(stderr, "\033[0m\033[0;1;41m"); // reset, bright red bg
else if(level == LOG_ERROR)
fprintf(stderr, "\033[0m\033[1;31m"); // bright red fg, black bg
fprintf(stderr, "\033[0m\033[1;31m"); // bright red fg, black bg
else if(level == LOG_WARNING)
fprintf(stderr, "\033[0m\033[1;33m"); // bright yellow fg, black bg
fprintf(stderr, "\033[0m\033[1;33m"); // bright yellow fg, black bg
else if(level == LOG_INFO)
fprintf(stderr, "\033[0m"); // reset
fprintf(stderr, "\033[0m"); // reset
else if(level == LOG_VERBOSE)
fprintf(stderr, "\033[0m\033[0;36m"); // cyan fg, black bg
fprintf(stderr, "\033[0m\033[0;36m"); // cyan fg, black bg
else if(level == LOG_DEBUG)
fprintf(stderr, "\033[0m\033[1;30m"); // bright black fg, black bg
fprintf(stderr, "\033[0m\033[1;30m"); // bright black fg, black bg
else if(level == LOG_TRACE)
fprintf(stderr, "\033[0m\033[0;35m"); //
fprintf(stderr, "\033[0m\033[0;35m"); //
else
fprintf(stderr, "\033[0m"); // reset
fprintf(stderr, "\033[0m"); // reset
}
current_level = level;
if(level > max_level)

View File

@ -34,7 +34,7 @@
#include <cstdio>
#include <limits>
#include <string> // for error messages. kill someday?
#include <string> // for error messages. kill someday?
#if defined(__GNUC__) || defined(__clang__)
#define SAJSON_LIKELY(x) __builtin_expect(!!(x), 1)
@ -123,7 +123,7 @@ namespace sajson {
const char*const text;
const size_t _length;
string(); /*=delete*/
string(); /*=delete*/
};
class literal: public string {
@ -893,7 +893,7 @@ done:
int i = 0;
double d =
0.0;// gcc complains that d might be used uninitialized which isn't true. appease the warning anyway.
0.0; // gcc complains that d might be used uninitialized which isn't true. appease the warning anyway.
for(;;){
char c = *p;
if(c < '0' || c > '9'){
@ -1067,7 +1067,7 @@ done:
tag = out;
}
++p;// "
++p; // "
size_t start = p - input.get_data();
for(;;){
if(SAJSON_UNLIKELY(p >= input_end)){
@ -1113,7 +1113,7 @@ done:
}
u = v;
return TYPE_NULL; // ???
return TYPE_NULL; // ???
}
void write_utf8(unsigned codepoint, char* &end){
@ -1196,7 +1196,7 @@ replace:
return error("unexpected end of input h");
}
unsigned u =
0; // gcc's complaining that this could be used uninitialized. wrong.
0; // gcc's complaining that this could be used uninitialized. wrong.
parse_result result = read_hex(u);
if(!result){
return result;
@ -1213,7 +1213,7 @@ replace:
}
p += 2;
unsigned v =
0; // gcc's complaining that this could be used uninitialized. wrong.
0; // gcc's complaining that this could be used uninitialized. wrong.
result = read_hex(v);
if(!result){
return result;

View File

@ -7,10 +7,10 @@
#include <set>
#include <exception>
#include <cstdint>
#include <cinttypes>// PRId64
#include <cinttypes> // PRId64
#include <sstream>
#include <memory>
#include <stdio.h> // snprintf
#include <stdio.h> // snprintf
typedef unsigned int uint;
typedef unsigned char uchar;

View File

@ -30,7 +30,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
CTextureAtlasRegistry(magic::Context *context):
m_context(context)
{
m_defs.resize(1); // id=0 is ATLAS_UNDEFINED
m_defs.resize(1); // id=0 is ATLAS_UNDEFINED
}
const AtlasSegmentReference add_segment(
@ -55,7 +55,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
if(def0.segment_resolution == seg_img_size){
size_t max = def0.total_segments.x_ * def0.total_segments.y_;
if(def0.segments.size() >= max)
continue; // Full
continue; // Full
atlas_def = &def0;
break;
}

View File

@ -86,7 +86,7 @@ struct CBlockRegistry: public BlockRegistry
CBlockRegistry(VoxelRegistry *voxel_reg):
m_voxel_reg(voxel_reg)
{
m_defs.resize(1); // Id 0 is BLOCKTYPEID_UNDEFINEDD
m_defs.resize(1); // Id 0 is BLOCKTYPEID_UNDEFINEDD
}
BlockTypeId add_block_with_predefined_segments(const BlockDefinition &def)

View File

@ -13,11 +13,11 @@ namespace interface {
ss_ zerr(int ret)
{
switch (ret) {
switch(ret){
case Z_ERRNO:
if (ferror(stdin))
if(ferror(stdin))
return "error reading stdin";
if (ferror(stdout))
if(ferror(stdout))
return "error writing stdout";
return "errno";
case Z_STREAM_ERROR:
@ -48,7 +48,7 @@ void compress_zlib(const ss_ &data_in, std::ostream &os, int level)
ret = deflateInit(&z, level);
if(ret != Z_OK)
throw Exception("compress_zlib: deflateInit failed");
// Point zlib to our input buffer
z.next_in = (Bytef*)data_in.c_str();
z.avail_in = data_in.size();
@ -57,7 +57,7 @@ void compress_zlib(const ss_ &data_in, std::ostream &os, int level)
{
z.next_out = (Bytef*)output_buffer;
z.avail_out = bufsize;
status = deflate(&z, Z_FINISH);
if(status == Z_NEED_DICT || status == Z_DATA_ERROR
|| status == Z_MEM_ERROR)
@ -94,9 +94,9 @@ void decompress_zlib(std::istream &is, std::ostream &os)
ret = inflateInit(&z);
if(ret != Z_OK)
throw Exception("dcompress_zlib: inflateInit failed");
z.avail_in = 0;
//dstream<<"initial fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
for(;;)
@ -116,7 +116,7 @@ void decompress_zlib(std::istream &is, std::ostream &os)
//dstream<<"z.avail_in == 0"<<std::endl;
break;
}
//dstream<<"1 z.avail_in="<<z.avail_in<<std::endl;
status = inflate(&z, Z_NO_FLUSH);
//dstream<<"2 z.avail_in="<<z.avail_in<<std::endl;
@ -136,11 +136,11 @@ void decompress_zlib(std::istream &is, std::ostream &os)
if(status == Z_STREAM_END)
{
//dstream<<"Z_STREAM_END"<<std::endl;
//dstream<<"z.avail_in="<<z.avail_in<<std::endl;
//dstream<<"fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
// Unget all the data that inflate didn't take
for(size_t i=0; i < z.avail_in; i++)
for(size_t i = 0; i < z.avail_in; i++)
{
is.unget();
if(is.fail() || is.bad())
@ -150,7 +150,7 @@ void decompress_zlib(std::istream &is, std::ostream &os)
throw Exception("decompress_zlib: unget failed");
}
}
break;
}
}

View File

@ -11,16 +11,16 @@
#include <Scene.h>
#include <Node.h>
#include <StaticModel.h>
#include <Model.h> // Resource parameter of StaticModel
#include <Model.h> // Resource parameter of StaticModel
#include <Geometry.h>
#include <IndexBuffer.h>
#include <VertexBuffer.h>
#include <CustomGeometry.h> // A Drawable similarly as StaticModel
#include <CustomGeometry.h> // A Drawable similarly as StaticModel
#include <Material.h>
#include <Technique.h>
#include <Context.h>
#include <ResourceCache.h>
#include <Texture2D.h> // Allows cast to Texture
#include <Texture2D.h> // Allows cast to Texture
#include <CollisionShape.h>
#include <RigidBody.h>
#pragma GCC diagnostic pop
@ -70,7 +70,7 @@ Model* create_simple_voxel_model(Context *context,
const size_t num_indices = pv_indices.size();
sv_<float> vertex_data;
vertex_data.resize(num_vertices * 6); // vertex + normal
vertex_data.resize(num_vertices * 6); // vertex + normal
for(size_t i = 0; i < num_vertices; i++){
vertex_data[i*6 + 0] = pv_vertices[i].position.getX() - w/2.0f - 0.5f;
vertex_data[i*6 + 1] = pv_vertices[i].position.getY() - h/2.0f - 0.5f;
@ -183,7 +183,7 @@ public:
IsQuadNeededByRegistryPhysics(interface::VoxelRegistry *voxel_reg):
m_voxel_reg(voxel_reg)
{}
IsQuadNeededByRegistryPhysics():// PolyVox wants this
IsQuadNeededByRegistryPhysics(): // PolyVox wants this
m_voxel_reg(nullptr)
{}
bool operator()(VoxelType back, VoxelType front, uint32_t &materialToUse)
@ -197,7 +197,7 @@ public:
if(!back_def || !back_def->physically_solid)
return false;
if(!front_def || !front_def->physically_solid){
materialToUse = 1; // Doesn't matter
materialToUse = 1; // Doesn't matter
return true;
}
return false;
@ -215,7 +215,7 @@ Model* create_voxel_physics_model(Context *context,
IsQuadNeededByRegistryPhysics<VoxelInstance> iqn(voxel_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistryPhysics<VoxelInstance>>
IsQuadNeededByRegistryPhysics<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
@ -232,7 +232,7 @@ Model* create_voxel_physics_model(Context *context,
int h = volume.getHeight() - 2;
int d = volume.getDepth() - 2;
sv_<float> vertex_data;
vertex_data.resize(num_vertices * 6); // vertex + normal
vertex_data.resize(num_vertices * 6); // vertex + normal
for(size_t i = 0; i < num_vertices; i++){
vertex_data[i*6 + 0] = pv_vertices[i].position.getX() - w/2.0f - 1.0f;
vertex_data[i*6 + 1] = pv_vertices[i].position.getY() - h/2.0f - 1.0f;
@ -290,7 +290,7 @@ public:
interface::TextureAtlasRegistry *atlas_reg):
m_voxel_reg(voxel_reg), m_atlas_reg(atlas_reg)
{}
IsQuadNeededByRegistry(): // PolyVox wants this
IsQuadNeededByRegistry(): // PolyVox wants this
m_voxel_reg(nullptr),
m_atlas_reg(nullptr)
{}
@ -331,8 +331,8 @@ public:
struct TemporaryGeometry
{
uint atlas_id = 0;
sv_<float> vertex_data; // vertex(3) + normal(3) + texcoord(2)
sv_<unsigned> index_data; // Urho3D eats unsigned as large indices
sv_<float> vertex_data; // vertex(3) + normal(3) + texcoord(2)
sv_<unsigned> index_data; // Urho3D eats unsigned as large indices
};
#else
struct TemporaryGeometry
@ -430,7 +430,7 @@ void set_voxel_geometry(CustomGeometry *cg, Context *context,
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg, atlas_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistry<VoxelInstance>>
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
@ -601,8 +601,8 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
auto &lc_orig = region_orig.getLowerCorner();
auto &uc_orig = region_orig.getUpperCorner();
pv::Region region(lc_orig / lod - pv::Vector3DInt32(1,1,1),
uc_orig / lod + pv::Vector3DInt32(1,1,1));
pv::Region region(lc_orig / lod - pv::Vector3DInt32(1, 1, 1),
uc_orig / lod + pv::Vector3DInt32(1, 1, 1));
auto &lc = region.getLowerCorner();
auto &uc = region.getUpperCorner();
@ -632,7 +632,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
}
}
/*const interface::CachedVoxelDefinition *def =
voxel_reg->get_cached(v_orig);*/
voxel_reg->get_cached(v_orig);*/
volume.setVoxelAt(x, y, z, v_orig);
}
}
@ -641,7 +641,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg, atlas_reg);
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
pv::CubicSurfaceExtractorWithNormals<pv::RawVolume<VoxelInstance>,
IsQuadNeededByRegistry<VoxelInstance>>
IsQuadNeededByRegistry<VoxelInstance>>
surfaceExtractor(&volume, volume.getEnclosingRegion(), &pv_mesh, iqn);
surfaceExtractor.execute();
@ -901,15 +901,15 @@ z_plane_does_not_fit:
else
shape = node->CreateComponent<CollisionShape>(LOCAL);
shape->SetBox(Vector3(
x1 - x0 + 1,
y1 - y0 + 1,
z1 - z0 + 1
));
x1 - x0 + 1,
y1 - y0 + 1,
z1 - z0 + 1
));
shape->SetPosition(Vector3(
(x0 + x1)/2.0f - w/2 - 1.0f,
(y0 + y1)/2.0f - h/2 - 1.0f,
(z0 + z1)/2.0f - d/2 - 1.0f
));
(x0 + x1)/2.0f - w/2 - 1.0f,
(y0 + y1)/2.0f - h/2 - 1.0f,
(z0 + z1)/2.0f - d/2 - 1.0f
));
}
}
@ -925,5 +925,5 @@ z_plane_does_not_fit:
}
}
} // namespace interface
} // namespace interface
// vim: set noet ts=4 sw=4:

View File

@ -15,7 +15,7 @@
#define closesocket close
//typedef int socket_t;
#endif
#include <string.h> // strerror()
#include <string.h> // strerror()
#include <iostream>
#include <iomanip>
@ -120,7 +120,7 @@ struct CTCPSocket: public TCPSocket
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if(address == "any")
hints.ai_flags = AI_PASSIVE;// Wildcard address
hints.ai_flags = AI_PASSIVE; // Wildcard address
const char *address_c = (address == "any" ? NULL : address.c_str());
const char *port_c = (port == "any" ? NULL : port.c_str());
int err = getaddrinfo(address_c, port_c, &hints, &res0);
@ -194,7 +194,7 @@ struct CTCPSocket: public TCPSocket
hints.ai_family = AF_INET6;
}
if(address1 == "any"){
hints.ai_flags = AI_PASSIVE;// Wildcard address
hints.ai_flags = AI_PASSIVE; // Wildcard address
}
const char *address_c = (address1 == "any" ? NULL : address1.c_str());
const char *port_c = (port == "any" ? NULL : port.c_str());

View File

@ -51,7 +51,7 @@ struct CVoxelRegistry: public VoxelRegistry
CVoxelRegistry()
{
m_defs.resize(1); // Id 0 is VOXELTYPEID_UNDEFINEDD
m_defs.resize(1); // Id 0 is VOXELTYPEID_UNDEFINEDD
}
VoxelTypeId add_voxel(const VoxelDefinition &def)
@ -136,7 +136,7 @@ struct CVoxelRegistry: public VoxelRegistry
for(size_t i = 0; i<6; i++){
const AtlasSegmentDefinition &seg_def = def.textures[i];
if(seg_def.resource_name == ""){
AtlasSegmentReference seg_ref; // Use default values
AtlasSegmentReference seg_ref; // Use default values
cache.textures[i] = seg_ref;
for(size_t j = 0; j < VOXELDEF_NUM_LOD; j++){
cache.lod_textures[j][i] = seg_ref;
@ -155,11 +155,11 @@ struct CVoxelRegistry: public VoxelRegistry
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_TOP_FACE;
}
if(i == 5/*Z-*/){
if(i == 5 /*Z-*/){
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT1_FACE;
}
if(i == 2/*X+*/){
if(i == 2 /*X+*/){
lod_seg_def.lod_simulation |=
interface::ATLAS_LOD_SEMIBRIGHT2_FACE;
}

View File

@ -21,13 +21,13 @@ ss_ serialize_volume_simple(const pv::RawVolume<VoxelInstance> &volume)
auto region = volume.getEnclosingRegion();
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
for(size_t i=0; i<volume.m_dataSize; i++){
for(size_t i = 0; i<volume.m_dataSize; i++){
const VoxelInstance &v = volume.m_pData[i];
ar((uint32_t)v.data);
}
}
return os.str();
};
}
ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
{
@ -44,7 +44,7 @@ ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
auto region = volume.getEnclosingRegion();
auto lc = region.getLowerCorner();
auto uc = region.getUpperCorner();
for(size_t i=0; i<volume.m_dataSize; i++){
for(size_t i = 0; i<volume.m_dataSize; i++){
const VoxelInstance &v = volume.m_pData[i];
ar((uint32_t)v.data);
}
@ -55,7 +55,7 @@ ss_ serialize_volume_compressed(const pv::RawVolume<VoxelInstance> &volume)
ar(compressed_os.str());
}
return os.str();
};
}
up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
{
@ -71,7 +71,7 @@ up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
pv::Region region(0, 0, 0, w-1, h-1, d-1);
up_<pv::RawVolume<VoxelInstance>> volume(
new pv::RawVolume<VoxelInstance>(region));
for(size_t i=0; i<volume->m_dataSize; i++){
for(size_t i = 0; i<volume->m_dataSize; i++){
uint32_t v;
ar(v);
volume->m_pData[i].data = v;
@ -94,7 +94,7 @@ up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
{
std::istringstream raw_is(raw_os.str(), std::ios::binary);
cereal::PortableBinaryInputArchive ar(raw_is);
for(size_t i=0; i<volume->m_dataSize; i++){
for(size_t i = 0; i<volume->m_dataSize; i++){
uint32_t v;
ar(v);
volume->m_pData[i].data = v;
@ -102,7 +102,7 @@ up_<pv::RawVolume<VoxelInstance>> deserialize_volume(const ss_ &data)
}
return volume;
}
return up_<pv::RawVolume<VoxelInstance>>();;
return up_<pv::RawVolume<VoxelInstance>>();
}
}

View File

@ -20,7 +20,7 @@ namespace interface
struct AtlasSegmentReference
{
uint atlas_id = ATLAS_UNDEFINED;// 0 = undefined atlas
uint atlas_id = ATLAS_UNDEFINED; // 0 = undefined atlas
uint segment_id = 0;
};
@ -34,7 +34,7 @@ namespace interface
struct AtlasSegmentDefinition
{
ss_ resource_name; // If "", segment won't be added
ss_ resource_name; // If "", segment won't be added
magic::IntVector2 total_segments;
magic::IntVector2 select_segment;
// Mask 0x0f: LOD level, mask 0xf0: flags

View File

@ -17,19 +17,19 @@ namespace interface
{
BlockName name;
BlockTypeId id = BLOCKTYPEID_UNDEFINED;
uint8_t num_rotations = 0; // Supported: 0, 4, 24
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0);// Size in voxels
sv_<VoxelTypeId> segments; // Rotations*voxels
uint8_t num_rotations = 0; // Supported: 0, 4, 24
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels
sv_<VoxelTypeId> segments; // Rotations*voxels
};
// Voxels and a BlockDefinition can be generated based on this
struct BlockSourceDefinition
{
BlockName name;
uint8_t num_rotations = 0; // Supported: 0, 4, 24
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0);// Size in voxels
uint8_t num_rotations = 0; // Supported: 0, 4, 24
pv::Vector3DUint8 size = pv::Vector3DUint8(0, 0, 0); // Size in voxels
// Definitions for creating voxels
sv_<ss_> side_textures; // 6 resource names
sv_<ss_> side_textures; // 6 resource names
ss_ handler_module;
};

View File

@ -5,7 +5,7 @@
namespace interface
{
void compress_zlib(const ss_ &data_in, std::ostream &os, int level=6);
void compress_zlib(const ss_ &data_in, std::ostream &os, int level = 6);
void decompress_zlib(std::istream &is, std::ostream &os);
}
// vim: set noet ts=4 sw=4:

View File

@ -50,7 +50,7 @@ namespace interface
type(t(name)), p(up_<Private>(p))
{}
static Type t(const ss_ &name); // Shorthand function
static Type t(const ss_ &name); // Shorthand function
};
struct EventRegistry

View File

@ -15,12 +15,12 @@ namespace interface
struct VoxelName
{
ss_ block_name; // Name of the block this was instanced from
uint segment_x = 0; // Which segment of the block this was instanced from
ss_ block_name; // Name of the block this was instanced from
uint segment_x = 0; // Which segment of the block this was instanced from
uint segment_y = 0;
uint segment_z = 0;
uint rotation_primary = 0; // 4 possible rotations when looking at a face
uint rotation_secondary = 0;// 6 possible directions for a face to point to
uint rotation_primary = 0; // 4 possible rotations when looking at a face
uint rotation_secondary = 0; // 6 possible directions for a face to point to
ss_ dump() const;
bool operator==(const VoxelName &other) const;
@ -104,8 +104,8 @@ namespace interface
// Create voxel from raw data (MSBs are preserved)
VoxelInstance(uint32_t id): data(id){}
VoxelTypeId getId() const { return data & 0x001fffff; }
uint8_t getMSB() const { return (data>>24) & 0xff; }
VoxelTypeId getId() const {return data & 0x001fffff; }
uint8_t getMSB() const {return (data>>24) & 0xff; }
};
}
// vim: set noet ts=4 sw=4:

View File

@ -90,7 +90,7 @@ static void binary_input_read_value(lua_State *L, int type_L,
binary_input_read_value(L, array_type_L, ar);
lua_rawseti(L, value_result_table_L, i + 1);
}
lua_pop(L, 1); // array_type_L
lua_pop(L, 1); // array_type_L
// value_result_table_L is left on stack
} else if(outfield_type == "unordered_map"){
if(!has_table)
@ -110,8 +110,8 @@ static void binary_input_read_value(lua_State *L, int type_L,
binary_input_read_value(L, map_value_type_L, ar);
lua_rawset(L, value_result_table_L);
}
lua_pop(L, 1); // map_value_type_L
lua_pop(L, 1); // map_key_type_L
lua_pop(L, 1); // map_value_type_L
lua_pop(L, 1); // map_key_type_L
// value_result_table_L is left on stack
} else if(outfield_type == "object"){
if(!has_table)
@ -125,14 +125,14 @@ static void binary_input_read_value(lua_State *L, int type_L,
if(field_i != 0){
log_t(MODULE, "object field %zu", field_i);
int field_def_L = lua_gettop(L);
lua_rawgeti(L, field_def_L, 1); // name
lua_rawgeti(L, field_def_L, 2); // type
lua_rawgeti(L, field_def_L, 1); // name
lua_rawgeti(L, field_def_L, 2); // type
log_t(MODULE, " = object[\"%s\"]", lua_tostring(L, -2));
binary_input_read_value(L, -1, ar); // Uses type, pushes value
lua_remove(L, -2); // Remove type
lua_rawset(L, value_result_table_L);// Set t[#-2] = #-1
binary_input_read_value(L, -1, ar); // Uses type, pushes value
lua_remove(L, -2); // Remove type
lua_rawset(L, value_result_table_L); // Set t[#-2] = #-1
}
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
field_i++;
}
// value_result_table_L is left on stack
@ -189,7 +189,7 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
uint64_t num_entries = 0;
lua_pushnil(L);
while(lua_next(L, value_L) != 0){
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
num_entries++;
}
ar(num_entries);
@ -198,10 +198,10 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
while(lua_next(L, value_L) != 0){
log_t(MODULE, "array[%i]", i);
binary_output_write_value(L, -1, array_type_L, ar);
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
i++;
}
lua_pop(L, 1); // array_type_L
lua_pop(L, 1); // array_type_L
// value_result_table_L is left on stack
} else if(outfield_type == "unordered_map"){
if(!has_table)
@ -214,7 +214,7 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
uint64_t num_entries = 0;
lua_pushnil(L);
while(lua_next(L, value_L) != 0){
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
num_entries++;
}
ar(num_entries);
@ -225,10 +225,10 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
log_t(MODULE, "unordered_map[%s]", lua_tostring(L, key_L));
binary_output_write_value(L, key_L, map_key_type_L, ar);
binary_output_write_value(L, value_L, map_value_type_L, ar);
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
}
lua_pop(L, 1); // map_value_type_L
lua_pop(L, 1); // map_key_type_L
lua_pop(L, 1); // map_value_type_L
lua_pop(L, 1); // map_key_type_L
// value_result_table_L is left on stack
} else if(outfield_type == "object"){
if(!has_table)
@ -240,17 +240,17 @@ static void binary_output_write_value(lua_State *L, int value_L, int type_L,
if(field_i != 0){
log_t(MODULE, "object field %zu", field_i);
int field_def_L = lua_gettop(L);
lua_rawgeti(L, field_def_L, 2); // type
lua_rawgeti(L, field_def_L, 1); // name
lua_rawgeti(L, field_def_L, 2); // type
lua_rawgeti(L, field_def_L, 1); // name
log_t(MODULE, " = object[\"%s\"]", lua_tostring(L, -1));
// Get value_L[name]; name is replaced by value
lua_rawget(L, value_L);
// Recurse into this value
binary_output_write_value(L, -1, -2, ar);
lua_pop(L, 1); // Pop value
lua_pop(L, 1); // Pop type
lua_pop(L, 1); // Pop value
lua_pop(L, 1); // Pop type
}
lua_pop(L, 1); // Continue iterating by popping table value
lua_pop(L, 1); // Continue iterating by popping table value
field_i++;
}
} else {
@ -304,6 +304,6 @@ void init_cereal(lua_State *L)
DEF_BUILDAT_FUNC(cereal_binary_output)
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -22,5 +22,5 @@ void init(lua_State *L)
init_misc_urho3d(L);
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -98,5 +98,5 @@ void init_misc(lua_State *L)
DEF_BUILDAT_FUNC(get_time_us)
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -19,16 +19,16 @@ using namespace Urho3D;
namespace lua_bindings {
#define GET_TOLUA_STUFF(result_name, index, type)\
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\
return 0;\
}\
#define GET_TOLUA_STUFF(result_name, index, type) \
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \
return 0; \
} \
type *result_name = (type*)tolua_tousertype(L, index, 0);
#define TRY_GET_TOLUA_STUFF(result_name, index, type)\
type *result_name = nullptr;\
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\
result_name = (type*)tolua_tousertype(L, index, 0);\
#define TRY_GET_TOLUA_STUFF(result_name, index, type) \
type *result_name = nullptr; \
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
result_name = (type*)tolua_tousertype(L, index, 0); \
}
static int l_profiler_block_begin(lua_State *L)
@ -71,6 +71,6 @@ void init_misc_urho3d(lua_State *L)
DEF_BUILDAT_FUNC(profiler_block_end);
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -8,21 +8,21 @@
#include <algorithm>
#define MODULE "lua_bindings"
#define DEF_METHOD(name){\
lua_pushcfunction(L, l_##name);\
lua_setfield(L, -2, #name);\
#define DEF_METHOD(name){ \
lua_pushcfunction(L, l_##name); \
lua_setfield(L, -2, #name); \
}
#define GET_TOLUA_STUFF(result_name, index, type)\
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\
return 0;\
}\
#define GET_TOLUA_STUFF(result_name, index, type) \
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \
return 0; \
} \
type *result_name = (type*)tolua_tousertype(L, index, 0);
#define TRY_GET_TOLUA_STUFF(result_name, index, type)\
type *result_name = nullptr;\
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\
result_name = (type*)tolua_tousertype(L, index, 0);\
#define TRY_GET_TOLUA_STUFF(result_name, index, type) \
type *result_name = nullptr; \
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
result_name = (type*)tolua_tousertype(L, index, 0); \
}
// Just do this; Urho3D's stuff doesn't really clash with anything in buildat
@ -81,7 +81,7 @@ struct SpatialUpdateQueue
void insert(const Value &value, std::list<Item>::iterator queue_it){
Entry entry(value, queue_it);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
std::greater<Entry>());
if(it == m_set.end())
m_set.insert(it, entry);
else if(it->value.node_id != value.node_id ||
@ -93,15 +93,15 @@ struct SpatialUpdateQueue
void remove(const Value &value){
Entry entry(value);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
std::greater<Entry>());
if(it == m_set.end())
return;
m_set.erase(it);
}
std::list<Item>::iterator* find(const Value &value){
std::list<Item>::iterator*find(const Value &value){
Entry entry(value);
auto it = std::lower_bound(m_set.begin(), m_set.end(), entry,
std::greater<Entry>());
std::greater<Entry>());
if(it == m_set.end())
return nullptr;
if(it->value.node_id != value.node_id ||
@ -125,7 +125,7 @@ struct SpatialUpdateQueue
return;
log_d(MODULE, "SpatialUpdateQueue(): Items in old queue: %zu",
m_old_queue.size());
for(int i=0; i<max_operations; i++){
for(int i = 0; i<max_operations; i++){
if(m_old_queue.empty())
break;
Item &item = m_old_queue.back();
@ -190,7 +190,7 @@ struct SpatialUpdateQueue
}
auto it = std::lower_bound(m_queue.begin(), m_queue.end(),
item, std::greater<Item>()); // position in descending order
item, std::greater<Item>()); // position in descending order
auto inserted_it = m_queue.insert(it, item);
m_queue_length++;
m_value_set.insert(item.value, inserted_it);
@ -264,7 +264,7 @@ struct LuaSUQ
{
static constexpr const char *class_name = "SpatialUpdateQueue";
SpatialUpdateQueue internal;
static int gc_object(lua_State *L){
delete *(LuaSUQ**)(lua_touserdata(L, 1));
return 0;
@ -303,7 +303,7 @@ struct LuaSUQ
value.node_id = luaL_checkinteger(L, -1);
lua_pop(L, 1);
o->internal.put(*p, near_weight, near_trigger_d,
far_weight, far_trigger_d, value);
far_weight, far_trigger_d, value);
return 0;
}
static int l_get(lua_State *L){
@ -406,6 +406,6 @@ void init_spatial_update_queue(lua_State *L)
DEF_BUILDAT_FUNC(SpatialUpdateQueue);
}
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -61,6 +61,6 @@ int handle_error(lua_State *L)
return 1;
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -27,16 +27,16 @@ using namespace Urho3D;
namespace lua_bindings {
#define GET_TOLUA_STUFF(result_name, index, type)\
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){\
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err);\
return 0;\
}\
#define GET_TOLUA_STUFF(result_name, index, type) \
if(!tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
tolua_error(L, __PRETTY_FUNCTION__, &tolua_err); \
return 0; \
} \
type *result_name = (type*)tolua_tousertype(L, index, 0);
#define TRY_GET_TOLUA_STUFF(result_name, index, type)\
type *result_name = nullptr;\
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){\
result_name = (type*)tolua_tousertype(L, index, 0);\
#define TRY_GET_TOLUA_STUFF(result_name, index, type) \
type *result_name = nullptr; \
if(tolua_isusertype(L, index, #type, 0, &tolua_err)){ \
result_name = (type*)tolua_tousertype(L, index, 0); \
}
// NOTE: This API is designed this way because otherwise ownership management of
@ -296,6 +296,6 @@ void init_voxel(lua_State *L)
DEF_BUILDAT_FUNC(clear_voxel_physics_boxes);
}
} // namespace lua_bindingss
} // namespace lua_bindingss
// vim: set noet ts=4 sw=4:

View File

@ -23,8 +23,8 @@
#include <iostream>
#include <climits>
#include <signal.h>
#include <string.h> // strerror()
#include <time.h> // struct timeval
#include <string.h> // strerror()
#include <time.h> // struct timeval
#define MODULE "main"
namespace magic = Urho3D;
@ -35,7 +35,7 @@ bool g_sigint_received = false;
void sigint_handler(int sig)
{
if(!g_sigint_received){
fprintf(stdout, "\n"); // Newline after "^C"
fprintf(stdout, "\n"); // Newline after "^C"
log_i("process", "SIGINT");
g_sigint_received = true;
} else {

View File

@ -190,5 +190,5 @@ Compiler* createCompiler(const ss_ &compiler_command)
return new CCompiler(compiler_command);
}
} // rccpp
} // rccpp
// vim: set noet ts=4 sw=4:

View File

@ -216,16 +216,16 @@ struct CState: public State, public interface::Server
// modules. In every other case modules must use access_scene().
// NOTE: If not locked, creating or destructing Urho3D Objects can cause a
// crash.
interface::Mutex m_magic_mutex; // Lock for all of Urho3D
interface::Mutex m_magic_mutex; // Lock for all of Urho3D
sm_<ss_, interface::ModuleInfo> m_module_info; // Info of every seen module
sm_<ss_, ModuleContainer> m_modules;// Currently loaded modules
sm_<ss_, interface::ModuleInfo> m_module_info; // Info of every seen module
sm_<ss_, ModuleContainer> m_modules; // Currently loaded modules
set_<ss_> m_unloads_requested;
sm_<ss_, sp_<interface::FileWatch>> m_module_file_watches;
// Module modifications are accumulated here and core:module_modified events
// are fired every event loop based on this to lump multiple modifications
// into one (generally a modification causes many notifications)
set_<ss_> m_modified_modules; // Module names
set_<ss_> m_modified_modules; // Module names
// TODO: Handle properly in reloads (unload by popping from top, then reload
// everything until top)
sv_<ss_> m_module_load_order;
@ -275,7 +275,7 @@ struct CState: public State, public interface::Server
g_server_config.urho3d_path+"/Source/Engine/"+subdir);
}
m_compiler->include_directories.push_back(
g_server_config.urho3d_path+"/Build/Engine"); // Urho3D.h
g_server_config.urho3d_path+"/Build/Engine"); // Urho3D.h
m_compiler->library_directories.push_back(
g_server_config.urho3d_path+"/Lib");
m_compiler->libraries.push_back("-lUrho3D");
@ -302,7 +302,7 @@ struct CState: public State, public interface::Server
magic::VariantMap params;
params["ResourcePaths"] = resource_paths_s.c_str();
params["Headless"] = true;
params["LogName"] = ""; // Don't log to file
params["LogName"] = ""; // Don't log to file
//params["LogQuiet"] = true; // Don't log to stdout
if(!m_magic_engine->Initialize(params))
throw Exception("Urho3D engine initialization failed");
@ -761,7 +761,7 @@ struct CState: public State, public interface::Server
void handle_events()
{
magic::AutoProfileBlock profiler_block(m_magic_context->
GetSubsystem<magic::Profiler>(), "Buildat|handle_events");
GetSubsystem<magic::Profiler>(), "Buildat|handle_events");
// Get modified modules and push events to queue
{
@ -821,8 +821,8 @@ struct CState: public State, public interface::Server
interface::MutexScope ms(m_modules_mutex);
for(auto it = m_unloads_requested.begin();
it != m_unloads_requested.end();){
ss_ module_name = *it; // Copy
it++; // Increment before unload_module_u; it erases this
ss_ module_name = *it; // Copy
it++; // Increment before unload_module_u; it erases this
log_i("state", "Unloading %s as requested", cs(module_name));
unload_module_u(module_name);
}