Global rename: TextureAtlas -> Atlas
parent
4d43efa466
commit
692c0d1418
|
@ -38,7 +38,7 @@ local camera_last_dir = camera_dir
|
|||
local end_of_update_processing_us = 0
|
||||
|
||||
local voxel_reg = buildat.createVoxelRegistry()
|
||||
local atlas_reg = buildat.createTextureAtlasRegistry()
|
||||
local atlas_reg = buildat.createAtlasRegistry()
|
||||
|
||||
log:info("voxel_reg type: "..dump(buildat.class_info(voxel_reg).name))
|
||||
log:info("atlas_reg type: "..dump(buildat.class_info(atlas_reg).name))
|
||||
|
|
|
@ -264,7 +264,7 @@ struct Module: public interface::Module, public voxelworld::Interface
|
|||
interface::Server *m_server;
|
||||
|
||||
// Accessing any of these outside of Server::access_scene is disallowed
|
||||
sp_<interface::TextureAtlasRegistry> m_atlas_reg;
|
||||
sp_<interface::AtlasRegistry> m_atlas_reg;
|
||||
sp_<interface::VoxelRegistry> m_voxel_reg;
|
||||
sp_<interface::BlockRegistry> m_block_reg;
|
||||
|
||||
|
@ -318,7 +318,7 @@ struct Module: public interface::Module, public voxelworld::Interface
|
|||
{
|
||||
Context *context = scene->GetContext();
|
||||
|
||||
m_atlas_reg.reset(interface::createTextureAtlasRegistry(context));
|
||||
m_atlas_reg.reset(interface::createAtlasRegistry(context));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ buildat.safe.get_time_us = __buildat_get_time_us
|
|||
buildat.safe.profiler_block_begin = __buildat_profiler_block_begin
|
||||
buildat.safe.profiler_block_end = __buildat_profiler_block_end
|
||||
buildat.safe.createVoxelRegistry = createVoxelRegistry
|
||||
buildat.safe.createTextureAtlasRegistry = createTextureAtlasRegistry
|
||||
buildat.safe.createAtlasRegistry = createAtlasRegistry
|
||||
|
||||
-- NOTE: Maybe not actually safe
|
||||
buildat.safe.class_info = class_info -- Luabind class_info()
|
||||
|
|
|
@ -219,7 +219,7 @@ end)
|
|||
|
||||
-- TODO: Fill in some stuff to the voxel registry
|
||||
local voxel_reg = buildat.createVoxelRegistry()
|
||||
local atlas_reg = buildat.createTextureAtlasRegistry()
|
||||
local atlas_reg = buildat.createAtlasRegistry()
|
||||
|
||||
function setup_simple_voxel_data(node)
|
||||
local data = node:GetVar("simple_voxel_data"):GetBuffer()
|
||||
|
|
|
@ -31,7 +31,7 @@ struct Module: public interface::Module
|
|||
{
|
||||
interface::Server *m_server;
|
||||
uint m_slow_count = 0;
|
||||
sp_<interface::TextureAtlasRegistry> m_atlas_reg;
|
||||
sp_<interface::AtlasRegistry> m_atlas_reg;
|
||||
sp_<interface::VoxelRegistry> m_voxel_reg;
|
||||
|
||||
Module(interface::Server *server):
|
||||
|
@ -53,7 +53,7 @@ struct Module: public interface::Module
|
|||
m_server->access_scene([&](Scene *scene)
|
||||
{
|
||||
Context *context = scene->GetContext();
|
||||
m_atlas_reg.reset(interface::createTextureAtlasRegistry(context));
|
||||
m_atlas_reg.reset(interface::createAtlasRegistry(context));
|
||||
m_voxel_reg.reset(interface::createVoxelRegistry(m_atlas_reg.get()));
|
||||
{
|
||||
interface::VoxelDefinition vdef;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace client {
|
|||
}
|
||||
namespace interface {
|
||||
struct VoxelRegistry;
|
||||
struct TextureAtlasRegistry;
|
||||
struct AtlasRegistry;
|
||||
|
||||
namespace worker_thread {
|
||||
struct ThreadPool;
|
||||
|
|
|
@ -24,13 +24,13 @@ bool AtlasSegmentDefinition::operator==(const AtlasSegmentDefinition &other) con
|
|||
);
|
||||
}
|
||||
|
||||
struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
||||
struct CAtlasRegistry: public AtlasRegistry
|
||||
{
|
||||
magic::Context *m_context;
|
||||
sv_<TextureAtlasDefinition> m_defs;
|
||||
sv_<TextureAtlasCache> m_cache;
|
||||
sv_<AtlasDefinition> m_defs;
|
||||
sv_<AtlasCache> m_cache;
|
||||
|
||||
CTextureAtlasRegistry(magic::Context *context):
|
||||
CAtlasRegistry(magic::Context *context):
|
||||
m_context(context)
|
||||
{
|
||||
m_defs.resize(1); // id=0 is ATLAS_UNDEFINED
|
||||
|
@ -45,14 +45,14 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
magic::Image *seg_img = magic_cache->GetResource<magic::Image>(
|
||||
segment_def.resource_name.c_str());
|
||||
if(seg_img == nullptr)
|
||||
throw Exception("CTextureAtlasRegistry::add_segment(): Couldn't "
|
||||
throw Exception("CAtlasRegistry::add_segment(): Couldn't "
|
||||
"find image \""+segment_def.resource_name+"\" when adding "
|
||||
"segment");
|
||||
// Get resolution of texture
|
||||
magic::IntVector2 seg_img_size(seg_img->GetWidth(), seg_img->GetHeight());
|
||||
// Try to find a texture atlas for this texture size
|
||||
TextureAtlasDefinition *atlas_def = nullptr;
|
||||
for(TextureAtlasDefinition &def0 : m_defs){
|
||||
AtlasDefinition *atlas_def = nullptr;
|
||||
for(AtlasDefinition &def0 : m_defs){
|
||||
if(def0.id == ATLAS_UNDEFINED)
|
||||
continue;
|
||||
if(def0.segment_resolution == seg_img_size){
|
||||
|
@ -98,7 +98,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
// Add new atlas to cache
|
||||
const auto &id = atlas_def->id;
|
||||
m_cache.resize(id+1);
|
||||
TextureAtlasCache *cache = &m_cache[id];
|
||||
AtlasCache *cache = &m_cache[id];
|
||||
cache->image = atlas_img;
|
||||
cache->texture = atlas_tex;
|
||||
cache->segment_resolution = atlas_def->segment_resolution;
|
||||
|
@ -109,7 +109,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
atlas_def->segments.resize(seg_id + 1);
|
||||
atlas_def->segments[seg_id] = segment_def;
|
||||
// Update this segment in cache
|
||||
TextureAtlasCache &atlas_cache = m_cache[atlas_def->id];
|
||||
AtlasCache &atlas_cache = m_cache[atlas_def->id];
|
||||
atlas_cache.segments.resize(seg_id + 1);
|
||||
AtlasSegmentCache &seg_cache = atlas_cache.segments[seg_id];
|
||||
update_segment_cache(seg_id, seg_img, seg_cache, segment_def, atlas_cache);
|
||||
|
@ -139,7 +139,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
return add_segment(segment_def);
|
||||
}
|
||||
|
||||
const TextureAtlasDefinition* get_atlas_definition(uint atlas_id)
|
||||
const AtlasDefinition* get_atlas_definition(uint atlas_id)
|
||||
{
|
||||
if(atlas_id == ATLAS_UNDEFINED)
|
||||
return nullptr;
|
||||
|
@ -151,7 +151,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
const AtlasSegmentDefinition* get_segment_definition(
|
||||
const AtlasSegmentReference &ref)
|
||||
{
|
||||
const TextureAtlasDefinition *atlas = get_atlas_definition(ref.atlas_id);
|
||||
const AtlasDefinition *atlas = get_atlas_definition(ref.atlas_id);
|
||||
if(!atlas)
|
||||
return nullptr;
|
||||
if(ref.segment_id >= atlas->segments.size())
|
||||
|
@ -161,7 +161,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
|
||||
void update_segment_cache(uint seg_id, magic::Image *seg_img,
|
||||
AtlasSegmentCache &cache, const AtlasSegmentDefinition &def,
|
||||
const TextureAtlasCache &atlas)
|
||||
const AtlasCache &atlas)
|
||||
{
|
||||
// Check if atlas is full
|
||||
size_t max_segments = atlas.total_segments.x_ * atlas.total_segments.y_;
|
||||
|
@ -315,7 +315,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
atlas.image->Save(f);*/
|
||||
}
|
||||
|
||||
const TextureAtlasCache* get_atlas_cache(uint atlas_id)
|
||||
const AtlasCache* get_atlas_cache(uint atlas_id)
|
||||
{
|
||||
if(atlas_id == ATLAS_UNDEFINED)
|
||||
return nullptr;
|
||||
|
@ -328,7 +328,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
|
||||
const AtlasSegmentCache* get_texture(const AtlasSegmentReference &ref)
|
||||
{
|
||||
const TextureAtlasCache *cache = get_atlas_cache(ref.atlas_id);
|
||||
const AtlasCache *cache = get_atlas_cache(ref.atlas_id);
|
||||
if(cache == nullptr)
|
||||
return nullptr;
|
||||
if(ref.segment_id >= cache->segments.size()){
|
||||
|
@ -344,7 +344,7 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
// Re-create textures if a device reset has destroyed them
|
||||
for(uint atlas_id = ATLAS_UNDEFINED + 1;
|
||||
atlas_id < m_cache.size(); atlas_id++){
|
||||
TextureAtlasCache &cache = m_cache[atlas_id];
|
||||
AtlasCache &cache = m_cache[atlas_id];
|
||||
if(cache.texture->IsDataLost()){
|
||||
log_v(MODULE, "Atlas %i texture data lost - re-creating",
|
||||
atlas_id);
|
||||
|
@ -355,9 +355,9 @@ struct CTextureAtlasRegistry: public TextureAtlasRegistry
|
|||
}
|
||||
};
|
||||
|
||||
TextureAtlasRegistry* createTextureAtlasRegistry(magic::Context *context)
|
||||
AtlasRegistry* createAtlasRegistry(magic::Context *context)
|
||||
{
|
||||
return new CTextureAtlasRegistry(context);
|
||||
return new CAtlasRegistry(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ Model* create_8bit_voxel_physics_model(Context *context,
|
|||
// Set custom geometry from 8-bit voxel data, using a voxel registry
|
||||
void set_8bit_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
int w, int h, int d, const ss_ &source_data,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
if(w < 0 || h < 0 || d < 0)
|
||||
throw Exception("Negative dimension");
|
||||
|
@ -402,7 +402,7 @@ void assign_txcoords(size_t pv_vertex_i1, const AtlasSegmentCache *aseg,
|
|||
}
|
||||
|
||||
void preload_textures(pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
auto region = volume.getEnclosingRegion();
|
||||
auto &lc = region.getLowerCorner();
|
||||
|
@ -422,7 +422,7 @@ void preload_textures(pv::RawVolume<VoxelInstance> &volume,
|
|||
|
||||
void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
|
||||
pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg);
|
||||
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
|
||||
|
@ -556,7 +556,7 @@ void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
|
|||
|
||||
void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
const sm_<uint, TemporaryGeometry> &temp_geoms,
|
||||
TextureAtlasRegistry *atlas_reg)
|
||||
AtlasRegistry *atlas_reg)
|
||||
{
|
||||
ResourceCache *cache = context->GetSubsystem<ResourceCache>();
|
||||
|
||||
|
@ -568,7 +568,7 @@ void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
|||
unsigned cg_i = 0;
|
||||
for(auto &pair : temp_geoms){
|
||||
const TemporaryGeometry &tg = pair.second;
|
||||
const TextureAtlasCache *atlas_cache =
|
||||
const AtlasCache *atlas_cache =
|
||||
atlas_reg->get_atlas_cache(tg.atlas_id);
|
||||
if(atlas_cache == nullptr)
|
||||
throw Exception("atlas_cache == nullptr");
|
||||
|
@ -593,7 +593,7 @@ void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
|||
// Volume should be padded by one voxel on each edge
|
||||
void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
preload_textures(volume, voxel_reg, atlas_reg);
|
||||
|
||||
|
@ -652,7 +652,7 @@ up_<pv::RawVolume<VoxelInstance>> generate_voxel_lod_volume(
|
|||
void generate_voxel_lod_geometry(int lod,
|
||||
sm_<uint, TemporaryGeometry> &result,
|
||||
pv::RawVolume<VoxelInstance> &lod_volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
IsQuadNeededByRegistry<VoxelInstance> iqn(voxel_reg);
|
||||
pv::SurfaceMesh<pv::PositionMaterialNormal> pv_mesh;
|
||||
|
@ -758,7 +758,7 @@ void generate_voxel_lod_geometry(int lod,
|
|||
|
||||
void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
||||
const sm_<uint, TemporaryGeometry> &temp_geoms,
|
||||
TextureAtlasRegistry *atlas_reg)
|
||||
AtlasRegistry *atlas_reg)
|
||||
{
|
||||
ResourceCache *cache = context->GetSubsystem<ResourceCache>();
|
||||
|
||||
|
@ -770,7 +770,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
|||
unsigned cg_i = 0;
|
||||
for(auto &pair : temp_geoms){
|
||||
const TemporaryGeometry &tg = pair.second;
|
||||
const TextureAtlasCache *atlas_cache =
|
||||
const AtlasCache *atlas_cache =
|
||||
atlas_reg->get_atlas_cache(tg.atlas_id);
|
||||
if(atlas_cache == nullptr)
|
||||
throw Exception("atlas_cache == nullptr");
|
||||
|
@ -800,7 +800,7 @@ void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
|||
// Volume should be padded by one voxel on each edge
|
||||
void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
||||
pv::RawVolume<VoxelInstance> &volume_orig,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg)
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
up_<pv::RawVolume<VoxelInstance>> lod_volume = generate_voxel_lod_volume(
|
||||
lod, volume_orig);
|
||||
|
|
|
@ -187,7 +187,7 @@ struct CVoxelRegistry: public VoxelRegistry
|
|||
}
|
||||
|
||||
const CachedVoxelDefinition* get_cached(const VoxelTypeId &id,
|
||||
TextureAtlasRegistry *atlas_reg)
|
||||
AtlasRegistry *atlas_reg)
|
||||
{
|
||||
if(id >= m_defs.size()){
|
||||
log_w(MODULE, "CVoxelRegistry::get_cached(): id=%i not found", id);
|
||||
|
@ -210,7 +210,7 @@ struct CVoxelRegistry: public VoxelRegistry
|
|||
}
|
||||
|
||||
const CachedVoxelDefinition* get_cached(const VoxelInstance &v,
|
||||
TextureAtlasRegistry *atlas_reg)
|
||||
AtlasRegistry *atlas_reg)
|
||||
{
|
||||
return get_cached(v.getId(), atlas_reg);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ struct CVoxelRegistry: public VoxelRegistry
|
|||
}
|
||||
|
||||
void update_cache_textures(CachedVoxelDefinition &cache,
|
||||
const VoxelDefinition &def, TextureAtlasRegistry *atlas_reg)
|
||||
const VoxelDefinition &def, AtlasRegistry *atlas_reg)
|
||||
{
|
||||
log_d(MODULE, "CVoxelRegistry::update_cache_textures(): id=%i", def.id);
|
||||
for(size_t i = 0; i<6; i++){
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace interface
|
|||
magic::Vector2 coord1;
|
||||
};
|
||||
|
||||
struct TextureAtlasDefinition
|
||||
struct AtlasDefinition
|
||||
{
|
||||
uint id = ATLAS_UNDEFINED;
|
||||
magic::IntVector2 segment_resolution;
|
||||
|
@ -59,7 +59,7 @@ namespace interface
|
|||
sv_<AtlasSegmentDefinition> segments;
|
||||
};
|
||||
|
||||
struct TextureAtlasCache
|
||||
struct AtlasCache
|
||||
{
|
||||
magic::SharedPtr<magic::Image> image;
|
||||
magic::SharedPtr<magic::Texture2D> texture;
|
||||
|
@ -68,9 +68,9 @@ namespace interface
|
|||
sv_<AtlasSegmentCache> segments;
|
||||
};
|
||||
|
||||
struct TextureAtlasRegistry
|
||||
struct AtlasRegistry
|
||||
{
|
||||
virtual ~TextureAtlasRegistry(){}
|
||||
virtual ~AtlasRegistry(){}
|
||||
|
||||
// These two may only be called from Urho3D main thread
|
||||
virtual const AtlasSegmentReference add_segment(
|
||||
|
@ -78,12 +78,12 @@ namespace interface
|
|||
virtual const AtlasSegmentReference find_or_add_segment(
|
||||
const AtlasSegmentDefinition &segment_def) = 0;
|
||||
|
||||
virtual const TextureAtlasDefinition* get_atlas_definition(
|
||||
virtual const AtlasDefinition* get_atlas_definition(
|
||||
uint atlas_id) = 0;
|
||||
virtual const AtlasSegmentDefinition* get_segment_definition(
|
||||
const AtlasSegmentReference &ref) = 0;
|
||||
|
||||
virtual const TextureAtlasCache* get_atlas_cache(uint atlas_id) = 0;
|
||||
virtual const AtlasCache* get_atlas_cache(uint atlas_id) = 0;
|
||||
|
||||
virtual const AtlasSegmentCache* get_texture(
|
||||
const AtlasSegmentReference &ref) = 0;
|
||||
|
@ -91,6 +91,6 @@ namespace interface
|
|||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
TextureAtlasRegistry* createTextureAtlasRegistry(magic::Context *context);
|
||||
AtlasRegistry* createAtlasRegistry(magic::Context *context);
|
||||
}
|
||||
// vim: set noet ts=4 sw=4:
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace interface
|
|||
// Set custom geometry from 8-bit voxel data, using a voxel registry
|
||||
void set_8bit_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
int w, int h, int d, const ss_ &source_data,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
// Create a model from voxel volume, using a voxel registry, without
|
||||
// textures or normals, based on the physically_solid flag.
|
||||
|
@ -69,23 +69,23 @@ namespace interface
|
|||
#endif
|
||||
|
||||
void preload_textures(pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
// Can be called from any thread
|
||||
void generate_voxel_geometry(sm_<uint, TemporaryGeometry> &result,
|
||||
pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
const sm_<uint, TemporaryGeometry> &temp_geoms,
|
||||
TextureAtlasRegistry *atlas_reg);
|
||||
AtlasRegistry *atlas_reg);
|
||||
|
||||
// Set custom geometry from voxel volume, using a voxel registry
|
||||
// Volume should be padded by one voxel on each edge
|
||||
// NOTE: volume is non-const due to PolyVox deficiency
|
||||
void set_voxel_geometry(CustomGeometry *cg, Context *context,
|
||||
pv::RawVolume<VoxelInstance> &volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
// Voxel LOD geometry generation (lod=1 -> 1:1, lod=3 -> 1:3)
|
||||
|
||||
|
@ -97,15 +97,15 @@ namespace interface
|
|||
void generate_voxel_lod_geometry(int lod,
|
||||
sm_<uint, TemporaryGeometry> &result,
|
||||
pv::RawVolume<VoxelInstance> &lod_volume,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
||||
const sm_<uint, TemporaryGeometry> &temp_geoms,
|
||||
TextureAtlasRegistry *atlas_reg);
|
||||
AtlasRegistry *atlas_reg);
|
||||
|
||||
void set_voxel_lod_geometry(int lod, CustomGeometry *cg, Context *context,
|
||||
pv::RawVolume<VoxelInstance> &volume_orig,
|
||||
VoxelRegistry *voxel_reg, TextureAtlasRegistry *atlas_reg);
|
||||
VoxelRegistry *voxel_reg, AtlasRegistry *atlas_reg);
|
||||
|
||||
// Voxel physics generation
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ namespace interface
|
|||
|
||||
// atlas_reg may only be supplied when called from Urho3D main thread
|
||||
virtual const CachedVoxelDefinition* get_cached(const VoxelTypeId &id,
|
||||
TextureAtlasRegistry *atlas_reg = nullptr) = 0;
|
||||
AtlasRegistry *atlas_reg = nullptr) = 0;
|
||||
virtual const CachedVoxelDefinition* get_cached(const VoxelInstance &v,
|
||||
TextureAtlasRegistry *atlas_reg = nullptr) = 0;
|
||||
AtlasRegistry *atlas_reg = nullptr) = 0;
|
||||
|
||||
virtual void serialize(std::ostream &os) = 0;
|
||||
virtual void deserialize(std::istream &is) = 0;
|
||||
|
|
|
@ -15,19 +15,19 @@
|
|||
#pragma GCC diagnostic pop
|
||||
#define MODULE "lua_bindings"
|
||||
|
||||
using interface::TextureAtlasRegistry;
|
||||
using interface::AtlasRegistry;
|
||||
|
||||
namespace lua_bindings {
|
||||
|
||||
sp_<TextureAtlasRegistry> createTextureAtlasRegistry(lua_State *L)
|
||||
sp_<AtlasRegistry> createAtlasRegistry(lua_State *L)
|
||||
{
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "__buildat_app");
|
||||
app::App *buildat_app = (app::App*)lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
Urho3D::Context *context = buildat_app->get_scene()->GetContext();
|
||||
|
||||
return sp_<TextureAtlasRegistry>(
|
||||
interface::createTextureAtlasRegistry(context));
|
||||
return sp_<AtlasRegistry>(
|
||||
interface::createAtlasRegistry(context));
|
||||
}
|
||||
|
||||
void init_atlas(lua_State *L)
|
||||
|
@ -35,9 +35,9 @@ void init_atlas(lua_State *L)
|
|||
using namespace luabind;
|
||||
|
||||
module(L)[
|
||||
class_<TextureAtlasRegistry, bases<>, sp_<TextureAtlasRegistry>>("TextureAtlasRegistry")
|
||||
.def("update", &TextureAtlasRegistry::update),
|
||||
def("createTextureAtlasRegistry", &createTextureAtlasRegistry)
|
||||
class_<AtlasRegistry, bases<>, sp_<AtlasRegistry>>("AtlasRegistry")
|
||||
.def("update", &AtlasRegistry::update),
|
||||
def("createAtlasRegistry", &createAtlasRegistry)
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace pv = PolyVox;
|
|||
|
||||
using interface::VoxelInstance;
|
||||
using interface::VoxelRegistry;
|
||||
using interface::TextureAtlasRegistry;
|
||||
using interface::AtlasRegistry;
|
||||
using namespace Urho3D;
|
||||
|
||||
namespace lua_bindings {
|
||||
|
@ -84,7 +84,7 @@ void set_simple_voxel_model(const luabind::object &node_o,
|
|||
|
||||
void set_8bit_voxel_geometry(const luabind::object &node_o,
|
||||
int w, int h, int d, const luabind::object &buffer_o,
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<TextureAtlasRegistry> atlas_reg)
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg)
|
||||
{
|
||||
lua_State *L = node_o.interpreter();
|
||||
|
||||
|
@ -145,13 +145,13 @@ struct SetVoxelGeometryTask: public interface::worker_thread::Task
|
|||
Node *node;
|
||||
ss_ data;
|
||||
sp_<VoxelRegistry> voxel_reg;
|
||||
sp_<TextureAtlasRegistry> atlas_reg;
|
||||
sp_<AtlasRegistry> atlas_reg;
|
||||
|
||||
up_<pv::RawVolume<VoxelInstance>> volume;
|
||||
sm_<uint, interface::mesh::TemporaryGeometry> temp_geoms;
|
||||
|
||||
SetVoxelGeometryTask(Node *node, const ss_ &data,
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<TextureAtlasRegistry> atlas_reg):
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg):
|
||||
node(node), data(data), voxel_reg(voxel_reg), atlas_reg(atlas_reg)
|
||||
{
|
||||
ScopeTimer timer("pre geometry");
|
||||
|
@ -194,13 +194,13 @@ struct SetVoxelLodGeometryTask: public interface::worker_thread::Task
|
|||
Node *node;
|
||||
ss_ data;
|
||||
sp_<VoxelRegistry> voxel_reg;
|
||||
sp_<TextureAtlasRegistry> atlas_reg;
|
||||
sp_<AtlasRegistry> atlas_reg;
|
||||
|
||||
up_<pv::RawVolume<VoxelInstance>> lod_volume;
|
||||
sm_<uint, interface::mesh::TemporaryGeometry> temp_geoms;
|
||||
|
||||
SetVoxelLodGeometryTask(int lod, Node *node, const ss_ &data,
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<TextureAtlasRegistry> atlas_reg):
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg):
|
||||
lod(lod), node(node), data(data),
|
||||
voxel_reg(voxel_reg), atlas_reg(atlas_reg)
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ struct SetPhysicsBoxesTask: public interface::worker_thread::Task
|
|||
|
||||
void set_voxel_geometry(const luabind::object &node_o,
|
||||
const luabind::object &buffer_o,
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<TextureAtlasRegistry> atlas_reg)
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg)
|
||||
{
|
||||
lua_State *L = node_o.interpreter();
|
||||
|
||||
|
@ -351,7 +351,7 @@ void set_voxel_geometry(const luabind::object &node_o,
|
|||
|
||||
void set_voxel_lod_geometry(int lod, const luabind::object &node_o,
|
||||
const luabind::object &buffer_o,
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<TextureAtlasRegistry> atlas_reg)
|
||||
sp_<VoxelRegistry> voxel_reg, sp_<AtlasRegistry> atlas_reg)
|
||||
{
|
||||
lua_State *L = node_o.interpreter();
|
||||
|
||||
|
|
Loading…
Reference in New Issue