2014-10-12 10:06:07 +03:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
|
|
|
|
#pragma once
|
|
|
|
#include "interface/event.h"
|
|
|
|
#include "interface/server.h"
|
|
|
|
#include "interface/module.h"
|
2014-10-12 14:26:19 +03:00
|
|
|
#include "interface/voxel.h"
|
|
|
|
#include <PolyVoxCore/Vector.h>
|
2014-10-12 16:54:04 +03:00
|
|
|
#include <PolyVoxCore/Region.h>
|
2014-10-12 10:06:07 +03:00
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
namespace Urho3D
|
|
|
|
{
|
|
|
|
class Context;
|
|
|
|
class Scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace voxelworld
|
|
|
|
{
|
|
|
|
namespace magic = Urho3D;
|
2014-10-12 14:26:19 +03:00
|
|
|
namespace pv = PolyVox;
|
|
|
|
|
|
|
|
struct GenerationRequest: public interface::Event::Private
|
|
|
|
{
|
|
|
|
pv::Vector3DInt16 section_p;
|
|
|
|
|
|
|
|
GenerationRequest(const pv::Vector3DInt16 §ion_p):
|
|
|
|
section_p(section_p)
|
|
|
|
{}
|
|
|
|
};
|
2014-10-12 10:06:07 +03:00
|
|
|
|
|
|
|
struct Interface
|
|
|
|
{
|
2014-10-12 14:26:19 +03:00
|
|
|
virtual void load_or_generate_section(
|
|
|
|
const pv::Vector3DInt16 §ion_p) = 0;
|
|
|
|
|
2014-10-12 16:54:04 +03:00
|
|
|
virtual pv::Region get_section_region(
|
|
|
|
const pv::Vector3DInt16 §ion_p) = 0;
|
2014-10-12 14:26:19 +03:00
|
|
|
|
|
|
|
virtual void set_voxel(const pv::Vector3DInt32 &p,
|
|
|
|
const interface::VoxelInstance &v) = 0;
|
2014-10-12 14:49:11 +03:00
|
|
|
|
|
|
|
virtual void commit() = 0;
|
2014-10-13 01:07:09 +03:00
|
|
|
|
|
|
|
virtual interface::VoxelRegistry* get_voxel_reg() = 0;
|
2014-10-12 10:06:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
inline bool access(interface::Server *server,
|
|
|
|
std::function<void(voxelworld::Interface*)> cb)
|
|
|
|
{
|
|
|
|
return server->access_module("voxelworld", [&](interface::Module *module){
|
2014-10-12 14:49:11 +03:00
|
|
|
auto *iface = (voxelworld::Interface*)module->check_interface();
|
|
|
|
cb(iface);
|
|
|
|
iface->commit();
|
2014-10-12 10:06:07 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// vim: set noet ts=4 sw=4:
|