Skip to content

Commit

Permalink
Same treatment to methods in VoxelManLibrary.
Browse files Browse the repository at this point in the history
  • Loading branch information
Relintai committed Oct 27, 2020
1 parent 3734684 commit 9a151ff
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 217 deletions.
185 changes: 96 additions & 89 deletions library/voxelman_library.cpp

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions library/voxelman_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,58 +57,58 @@ class VoxelmanLibrary : public Resource {
bool get_initialized() const;
void set_initialized(const bool value);

Ref<Material> get_material(const int index);
void add_material(const Ref<Material> &value);
void set_material(const int index, const Ref<Material> &value);
void remove_material(const int index);
int get_num_materials() const;
void clear_materials();

Vector<Variant> get_materials();
void set_materials(const Vector<Variant> &materials);

Ref<Material> get_liquid_material(const int index);
void add_liquid_material(const Ref<Material> &value);
void set_liquid_material(const int index, const Ref<Material> &value);
void remove_liquid_material(const int index);
int get_num_liquid_materials() const;
void clear_liquid_materials();

Vector<Variant> get_liquid_materials();
void set_liquid_materials(const Vector<Variant> &materials);

Ref<Material> get_prop_material(const int index);
void add_prop_material(const Ref<Material> &value);
void set_prop_material(const int index, const Ref<Material> &value);
void remove_prop_material(const int index);
int get_num_prop_materials() const;
void clear_prop_materials();

Vector<Variant> get_prop_materials();
void set_prop_materials(const Vector<Variant> &materials);

virtual Ref<VoxelSurface> get_voxel_surface(const int index);
virtual void add_voxel_surface(Ref<VoxelSurface> value);
virtual void set_voxel_surface(const int index, Ref<VoxelSurface> value);
virtual void remove_surface(const int index);
virtual int get_num_surfaces() const;
virtual void clear_surfaces();

virtual Ref<PackedScene> get_scene(const int id);
virtual void add_scene(Ref<PackedScene> value);
virtual void set_scene(const int id, Ref<PackedScene> value);
virtual void remove_scene(const int id);
virtual int get_num_scenes() const;
virtual void clear_scenes();
Ref<Material> material_get(const int index);
void material_add(const Ref<Material> &value);
void material_set(const int index, const Ref<Material> &value);
void material_remove(const int index);
int material_get_num() const;
void materials_clear();

Vector<Variant> materials_get();
void materials_set(const Vector<Variant> &materials);

Ref<Material> liquid_material_get(const int index);
void liquid_material_add(const Ref<Material> &value);
void liquid_material_set(const int index, const Ref<Material> &value);
void liquid_material_remove(const int index);
int liquid_material_get_num() const;
void liquid_materials_clear();

Vector<Variant> liquid_materials_get();
void liquid_materials_set(const Vector<Variant> &materials);

Ref<Material> prop_material_get(const int index);
void prop_material_add(const Ref<Material> &value);
void prop_material_set(const int index, const Ref<Material> &value);
void prop_material_remove(const int index);
int prop_material_get_num() const;
void prop_materials_clear();

Vector<Variant> prop_materials_get();
void prop_materials_set(const Vector<Variant> &materials);

virtual Ref<VoxelSurface> voxel_surface_get(const int index);
virtual void voxel_surface_add(Ref<VoxelSurface> value);
virtual void voxel_surface_set(const int index, Ref<VoxelSurface> value);
virtual void voxel_surface_remove(const int index);
virtual int voxel_surface_get_num() const;
virtual void voxel_surfaces_clear();

virtual Ref<PackedScene> scene_get(const int id);
virtual void scene_add(Ref<PackedScene> value);
virtual void scene_set(const int id, Ref<PackedScene> value);
virtual void scene_remove(const int id);
virtual int scene_get_num() const;
virtual void scenes_clear();

#ifdef PROPS_PRESENT
virtual Ref<PropData> get_prop(const int id);
virtual void add_prop(Ref<PropData> value);
virtual bool has_prop(const Ref<PropData> &value) const;
virtual void set_prop(const int id, Ref<PropData> value);
virtual void remove_prop(const int id);
virtual int get_num_props() const;
virtual void clear_props();
virtual Ref<PropData> prop_get(const int id);
virtual void prop_add(Ref<PropData> value);
virtual bool prop_has(const Ref<PropData> &value) const;
virtual void prop_set(const int id, Ref<PropData> value);
virtual void prop_remove(const int id);
virtual int prop_get_num() const;
virtual void props_clear();

virtual Rect2 get_prop_uv_rect(const Ref<Texture> &texture);
#endif
Expand All @@ -125,9 +125,9 @@ class VoxelmanLibrary : public Resource {

private:
bool _initialized;
Vector<Ref<Material>> _materials;
Vector<Ref<Material>> _liquid_materials;
Vector<Ref<Material>> _prop_materials;
Vector<Ref<Material> > _materials;
Vector<Ref<Material> > _liquid_materials;
Vector<Ref<Material> > _prop_materials;
};

#endif // VOXEL_LIBRARY_H
30 changes: 15 additions & 15 deletions library/voxelman_library_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ void VoxelmanLibraryMerger::set_margin(const int margin) {
}

//Surfaces
Ref<VoxelSurface> VoxelmanLibraryMerger::get_voxel_surface(const int index) {
Ref<VoxelSurface> VoxelmanLibraryMerger::voxel_surface_get(const int index) {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));

return _voxel_surfaces[index];
}

void VoxelmanLibraryMerger::add_voxel_surface(Ref<VoxelSurface> value) {
void VoxelmanLibraryMerger::voxel_surface_add(Ref<VoxelSurface> value) {
ERR_FAIL_COND(!value.is_valid());

value->set_library(Ref<VoxelmanLibraryMerger>(this));
Expand All @@ -93,7 +93,7 @@ void VoxelmanLibraryMerger::add_voxel_surface(Ref<VoxelSurface> value) {
_voxel_surfaces.push_back(value);
}

void VoxelmanLibraryMerger::set_voxel_surface(const int index, Ref<VoxelSurface> value) {
void VoxelmanLibraryMerger::voxel_surface_set(const int index, Ref<VoxelSurface> value) {
ERR_FAIL_COND(index < 0);

if (_voxel_surfaces.size() < index) {
Expand All @@ -111,15 +111,15 @@ void VoxelmanLibraryMerger::set_voxel_surface(const int index, Ref<VoxelSurface>
}
}

void VoxelmanLibraryMerger::remove_surface(const int index) {
void VoxelmanLibraryMerger::voxel_surface_remove(const int index) {
_voxel_surfaces.remove(index);
}

int VoxelmanLibraryMerger::get_num_surfaces() const {
int VoxelmanLibraryMerger::voxel_surface_get_num() const {
return _voxel_surfaces.size();
}

void VoxelmanLibraryMerger::clear_surfaces() {
void VoxelmanLibraryMerger::voxel_surfaces_clear() {
_packer->clear();

for (int i = 0; i < _voxel_surfaces.size(); i++) {
Expand Down Expand Up @@ -302,27 +302,27 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con

switch (material_index) {
case MATERIAL_INDEX_VOXELS:
count = get_num_materials();
count = material_get_num();
break;
case MATERIAL_INDEX_LIQUID:
count = get_num_liquid_materials();
count = liquid_material_get_num();
break;
case MATERIAL_INDEX_PROP:
count = get_num_prop_materials();
count = prop_material_get_num();
break;
}

for (int i = 0; i < count; ++i) {

switch (material_index) {
case MATERIAL_INDEX_VOXELS:
mat = get_material(i);
mat = material_get(i);
break;
case MATERIAL_INDEX_LIQUID:
mat = get_liquid_material(i);
mat = liquid_material_get(i);
break;
case MATERIAL_INDEX_PROP:
mat = get_prop_material(i);
mat = prop_material_get(i);
break;
}

Expand All @@ -337,13 +337,13 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con

switch (material_index) {
case MATERIAL_INDEX_VOXELS:
shmat = get_material(i);
shmat = material_get(i);
break;
case MATERIAL_INDEX_LIQUID:
shmat = get_liquid_material(i);
shmat = liquid_material_get(i);
break;
case MATERIAL_INDEX_PROP:
shmat = get_prop_material(i);
shmat = prop_material_get(i);
break;
}

Expand Down
12 changes: 6 additions & 6 deletions library/voxelman_library_merger.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class VoxelmanLibraryMerger : public VoxelmanLibrary {
int get_margin() const;
void set_margin(const int margin);

Ref<VoxelSurface> get_voxel_surface(const int index);
void add_voxel_surface(Ref<VoxelSurface> value);
void set_voxel_surface(const int index, Ref<VoxelSurface> value);
void remove_surface(const int index);
int get_num_surfaces() const;
void clear_surfaces();
Ref<VoxelSurface> voxel_surface_get(const int index);
void voxel_surface_add(Ref<VoxelSurface> value);
void voxel_surface_set(const int index, Ref<VoxelSurface> value);
void voxel_surface_remove(const int index);
int voxel_surface_get_num() const;
void voxel_surfaces_clear();

Vector<Variant> get_voxel_surfaces();
void set_voxel_surfaces(const Vector<Variant> &surfaces);
Expand Down
12 changes: 6 additions & 6 deletions library/voxelman_library_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ void VoxelmanLibrarySimple::set_atlas_rows(int s) {
}

//Surfaces
Ref<VoxelSurface> VoxelmanLibrarySimple::get_voxel_surface(const int index) {
Ref<VoxelSurface> VoxelmanLibrarySimple::voxel_surface_get(const int index) {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>(NULL));

return _voxel_surfaces[index];
}

void VoxelmanLibrarySimple::add_voxel_surface(Ref<VoxelSurface> value) {
void VoxelmanLibrarySimple::voxel_surface_add(Ref<VoxelSurface> value) {
ERR_FAIL_COND(!value.is_valid());

value->set_library(Ref<VoxelmanLibrarySimple>(this));
Expand All @@ -58,7 +58,7 @@ void VoxelmanLibrarySimple::add_voxel_surface(Ref<VoxelSurface> value) {
_voxel_surfaces.push_back(value);
}

void VoxelmanLibrarySimple::set_voxel_surface(const int index, Ref<VoxelSurface> value) {
void VoxelmanLibrarySimple::voxel_surface_set(const int index, Ref<VoxelSurface> value) {
ERR_FAIL_COND(index < 0);

if (_voxel_surfaces.size() < index) {
Expand All @@ -76,15 +76,15 @@ void VoxelmanLibrarySimple::set_voxel_surface(const int index, Ref<VoxelSurface>
}
}

void VoxelmanLibrarySimple::remove_surface(const int index) {
void VoxelmanLibrarySimple::voxel_surface_remove(const int index) {
_voxel_surfaces.remove(index);
}

int VoxelmanLibrarySimple::get_num_surfaces() const {
int VoxelmanLibrarySimple::voxel_surface_get_num() const {
return _voxel_surfaces.size();
}

void VoxelmanLibrarySimple::clear_surfaces() {
void VoxelmanLibrarySimple::voxel_surfaces_clear() {
_voxel_surfaces.clear();
}

Expand Down
12 changes: 6 additions & 6 deletions library/voxelman_library_simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class VoxelmanLibrarySimple : public VoxelmanLibrary {
int get_atlas_rows() const;
void set_atlas_rows(int s);

Ref<VoxelSurface> get_voxel_surface(const int index);
void add_voxel_surface(Ref<VoxelSurface> value);
void set_voxel_surface(const int index, Ref<VoxelSurface> value);
void remove_surface(const int index);
int get_num_surfaces() const;
void clear_surfaces();
Ref<VoxelSurface> voxel_surface_get(const int index);
void voxel_surface_add(Ref<VoxelSurface> value);
void voxel_surface_set(const int index, Ref<VoxelSurface> value);
void voxel_surface_remove(const int index);
int voxel_surface_get_num() const;
void voxel_surfaces_clear();

Vector<Variant> get_voxel_surfaces();
void set_voxel_surfaces(const Vector<Variant> &surfaces);
Expand Down
6 changes: 3 additions & 3 deletions meshers/blocky/voxel_mesher_blocky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void VoxelMesherBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
}

Vector<uint8_t> liquids;
for (int i = 0; i < _library->get_num_surfaces(); ++i) {
Ref<VoxelSurface> surface = _library->get_voxel_surface(i);
for (int i = 0; i < _library->voxel_surface_get_num(); ++i) {
Ref<VoxelSurface> surface = _library->voxel_surface_get(i);

if (!surface.is_valid())
continue;
Expand Down Expand Up @@ -106,7 +106,7 @@ void VoxelMesherBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
if (liquids.find(type) != -1)
continue;

Ref<VoxelSurface> surface = _library->get_voxel_surface(type - 1);
Ref<VoxelSurface> surface = _library->voxel_surface_get(type - 1);

if (!surface.is_valid())
continue;
Expand Down
6 changes: 3 additions & 3 deletions meshers/blocky/voxel_mesher_liquid_blocky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
}

Vector<uint8_t> liquids;
for (int i = 0; i < _library->get_num_surfaces(); ++i) {
Ref<VoxelSurface> surface = _library->get_voxel_surface(i);
for (int i = 0; i < _library->voxel_surface_get_num(); ++i) {
Ref<VoxelSurface> surface = _library->voxel_surface_get(i);

if (!surface.is_valid())
continue;
Expand Down Expand Up @@ -98,7 +98,7 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref<VoxelChunk> p_chunk) {
if (liquids.find(type) == -1)
continue;

Ref<VoxelSurface> surface = _library->get_voxel_surface(type - 1);
Ref<VoxelSurface> surface = _library->voxel_surface_get(type - 1);

if (!surface.is_valid())
continue;
Expand Down
2 changes: 1 addition & 1 deletion meshers/cubic/voxel_mesher_cubic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void VoxelMesherCubic::_add_chunk(Ref<VoxelChunk> p_chunk) {

uint8_t type = cube_points->get_face_type(face) - 1;

Ref<VoxelSurface> surface = _library->get_voxel_surface(type);
Ref<VoxelSurface> surface = _library->voxel_surface_get(type);

if (!surface.is_valid())
continue;
Expand Down
4 changes: 2 additions & 2 deletions meshers/marching_cubes/voxel_mesher_marching_cubes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref<VoxelChunk> p_chunk) {
}
}

Ref<VoxelSurface> surface1 = _library->get_voxel_surface(type_id1 - 1);
Ref<VoxelSurface> surface2 = _library->get_voxel_surface(type_id2 - 1);
Ref<VoxelSurface> surface1 = _library->voxel_surface_get(type_id1 - 1);
Ref<VoxelSurface> surface2 = _library->voxel_surface_get(type_id2 - 1);

for (int i = 0; i < vertex_count; ++i) {
int fv = get_regular_vertex_data_first_vertex(case_code, i);
Expand Down
2 changes: 1 addition & 1 deletion meshers/voxel_mesher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void VoxelMesher::build_mesh_into(RID mesh) {
VS::get_singleton()->mesh_add_surface_from_arrays(mesh, VisualServer::PRIMITIVE_TRIANGLES, arr);

if (_material.is_valid())
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->get_material(0)->get_rid());
VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->material_get(0)->get_rid());
}

void VoxelMesher::generate_normals(bool p_flip) {
Expand Down
Loading

0 comments on commit 9a151ff

Please sign in to comment.