Skip to content

Commit

Permalink
fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Sep 3, 2023
1 parent 6450e42 commit b291fe0
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/2d/geometry_container_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#ifndef DISABLE_DEBUG_RENDERING
#include "config_2d.h"
#include "debug_draw_2d.h"
#include "stats_2d.h"

GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/main_loop.hpp>
Expand All @@ -18,7 +17,7 @@ GODOT_WARNING_RESTORE()
using namespace godot;

void GeometryPool2D::reset_counter(double _delta) {
for (int i = 0; i < InstanceType2D::ALL; i++) {
for (int i = 0; i < (int)InstanceType2D::ALL; i++) {
instances[i].reset_counter(_delta, i);
}
}
Expand Down Expand Up @@ -64,7 +63,7 @@ void GeometryPool2D::clear_pool() {
}
}

void GeometryPool2D::for_each_instance(const std::function<void(DelayedRendererInstance *)> &_func) {
void GeometryPool2D::for_each_instance(const std::function<void(DelayedRendererInstance2D *)> &_func) {
for (auto &inst : instances) {
for (size_t i = 0; i < inst.used_instant; i++) {
_func(&inst.instant[i]);
Expand Down
11 changes: 6 additions & 5 deletions src/2d/geometry_container_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// #include "render_instances.h"
#include "utils/math_utils.h"
#include "utils/utils.h"
#include "stats_2d.h"

GODOT_WARNING_DISABLE()
#include <godot_cpp/classes/array_mesh.hpp>
Expand All @@ -28,7 +29,7 @@ using namespace godot;

class DebugDrawStats3D;

enum InstanceType2D : char {
enum class InstanceType2D : char {
CUBES,
CUBES_CENTERED,
ARROWHEADS,
Expand Down Expand Up @@ -115,12 +116,12 @@ class DelayedRenderer2D {
}
};

class DelayedRendererInstance : public DelayedRenderer2D<SphereBounds> {
class DelayedRendererInstance2D : public DelayedRenderer2D<SphereBounds> {
public:
Transform3D transform;
InstanceType2D type = InstanceType2D::CUBES;

DelayedRendererInstance();
DelayedRendererInstance2D(){};
// void update(real_t _exp_time, const InstanceType2D &_type, const Transform3D &_transform, const Color &_col, const SphereBounds &_bounds);
};

Expand Down Expand Up @@ -217,7 +218,7 @@ class GeometryPool2D {
}
};

ObjectsPool<DelayedRendererInstance> instances[InstanceType2D::ALL] = {};
ObjectsPool<DelayedRendererInstance2D> instances[(int)InstanceType2D::ALL] = {};

uint64_t time_spent_to_fill_buffers_of_instances = 0;
uint64_t time_spent_to_fill_buffers_of_lines = 0;
Expand All @@ -234,7 +235,7 @@ class GeometryPool2D {
void reset_visible_objects();
Ref<DebugDrawStats2D> get_stats() const;
void clear_pool();
void for_each_instance(const std::function<void(DelayedRendererInstance *)> &_func);
void for_each_instance(const std::function<void(DelayedRendererInstance2D *)> &_func);
void update_visibility(const std::vector<std::vector<Plane> > &t_frustums, const GeometryPoolDistanceCullingData2D &t_distance_data);
void update_expiration(double _delta);
void scan_visible_instances();
Expand Down
10 changes: 5 additions & 5 deletions src/3d/geometry_container_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void DebugGeometryContainer::CreateMMI(InstanceType type, const String &name, Re

Ref<MultiMesh> new_mm;
new_mm.instantiate();
new_mm->set_name(String::num_int64(type));
new_mm->set_name(String::num_int64((int)type));

new_mm->set_transform_format(MultiMesh::TransformFormat::TRANSFORM_3D);
new_mm->set_use_colors(true);
Expand All @@ -108,8 +108,8 @@ void DebugGeometryContainer::CreateMMI(InstanceType type, const String &name, Re
rs->instance_geometry_set_flag(mmi, RenderingServer::INSTANCE_FLAG_USE_DYNAMIC_GI, false);
rs->instance_geometry_set_flag(mmi, RenderingServer::INSTANCE_FLAG_USE_BAKED_LIGHT, false);

multi_mesh_storage[type].instance = mmi;
multi_mesh_storage[type].mesh = new_mm;
multi_mesh_storage[(int)type].instance = mmi;
multi_mesh_storage[(int)type].mesh = new_mm;
}

Ref<ArrayMesh> DebugGeometryContainer::CreateMesh(Mesh::PrimitiveType type, const PackedVector3Array &vertices, const PackedInt32Array &indices, const PackedColorArray &colors) {
Expand Down Expand Up @@ -275,8 +275,8 @@ void DebugGeometryContainer::update_geometry(double delta) {
geometry_pool.fill_lines_data(immediate_mesh_storage.mesh);

// Update MultiMeshInstances
std::array<Ref<MultiMesh> *, InstanceType::ALL> meshes;
for (int i = 0; i < InstanceType::ALL; i++) {
std::array<Ref<MultiMesh> *, (int)InstanceType::ALL> meshes;
for (int i = 0; i < (int)InstanceType::ALL; i++) {
meshes[i] = &multi_mesh_storage[i].mesh;
}

Expand Down
2 changes: 1 addition & 1 deletion src/3d/geometry_container_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DebugGeometryContainer {
mesh.unref();
}
};
MultiMeshStorage multi_mesh_storage[InstanceType::ALL] = {};
MultiMeshStorage multi_mesh_storage[(int)InstanceType::ALL] = {};

struct ImmediateMeshStorage {
RID instance;
Expand Down
10 changes: 5 additions & 5 deletions src/3d/render_instances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ template <class T, size_t _TStepSize>
struct TempBigBuffer {
private:
T m_buffer;
int m_accesses_before_shrink = InstanceType::ALL * 60; // try to shrink after 60 frames
int m_accesses_before_shrink = (int)InstanceType::ALL * 60; // try to shrink after 60 frames
int m_shrink_timer;

public:
Expand Down Expand Up @@ -123,7 +123,7 @@ AABB DelayedRendererLine::calculate_bounds_based_on_lines(const std::vector<Vect
}
}

void GeometryPool::fill_instance_data(const std::array<Ref<MultiMesh> *, InstanceType::ALL> &t_meshes) {
void GeometryPool::fill_instance_data(const std::array<Ref<MultiMesh> *, (int)InstanceType::ALL> &t_meshes) {
time_spent_to_fill_buffers_of_instances = TIME()->get_ticks_usec();

for (size_t i = 0; i < t_meshes.size(); i++) {
Expand All @@ -142,7 +142,7 @@ void GeometryPool::fill_instance_data(const std::array<Ref<MultiMesh> *, Instanc
}

PackedFloat32Array GeometryPool::get_raw_data(InstanceType _type) {
auto &inst = instances[_type];
auto &inst = instances[(int)_type];

size_t buffer_size = (inst.used_instant + inst.delayed.size()) * INSTANCE_DATA_FLOAT_COUNT;
thread_local static auto temp_buffer = TempBigBuffer<PackedFloat32Array, 128 * 1024>();
Expand Down Expand Up @@ -290,7 +290,7 @@ void GeometryPool::fill_lines_data(Ref<ArrayMesh> _ig) {
void GeometryPool::reset_counter(double _delta) {
lines.reset_counter(_delta);

for (int i = 0; i < InstanceType::ALL; i++) {
for (int i = 0; i < (int)InstanceType::ALL; i++) {
instances[i].reset_counter(_delta, i);
}
}
Expand Down Expand Up @@ -430,7 +430,7 @@ void GeometryPool::scan_visible_instances() {
}

void GeometryPool::add_or_update_instance(InstanceType _type, real_t _exp_time, const Transform3D &_transform, const Color &_col, const SphereBounds &_bounds, const std::function<void(DelayedRendererInstance *)> &_custom_upd) {
DelayedRendererInstance *inst = instances[_type].get(_exp_time > 0);
DelayedRendererInstance *inst = instances[(int)_type].get(_exp_time > 0);
inst->update(_exp_time, _type, _transform, _col, _bounds);
if (_custom_upd)
_custom_upd(inst);
Expand Down
6 changes: 3 additions & 3 deletions src/3d/render_instances.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DebugDrawStats3D;

using namespace godot;

enum InstanceType : char {
enum class InstanceType : char {
CUBES,
CUBES_CENTERED,
ARROWHEADS,
Expand Down Expand Up @@ -219,7 +219,7 @@ class GeometryPool {
}
};

ObjectsPool<DelayedRendererInstance> instances[InstanceType::ALL] = {};
ObjectsPool<DelayedRendererInstance> instances[(int)InstanceType::ALL] = {};
ObjectsPool<DelayedRendererLine> lines;

uint64_t time_spent_to_fill_buffers_of_instances = 0;
Expand All @@ -235,7 +235,7 @@ class GeometryPool {
~GeometryPool() {
}

void fill_instance_data(const std::array<Ref<MultiMesh> *, InstanceType::ALL> &t_meshes);
void fill_instance_data(const std::array<Ref<MultiMesh> *, (int)InstanceType::ALL> &t_meshes);
void fill_lines_data(Ref<ArrayMesh> _ig);
void reset_counter(double _delta);
void reset_visible_objects();
Expand Down
3 changes: 2 additions & 1 deletion src/default_sources.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[
"2d/config_2d.cpp",
"2d/debug_draw_2d.cpp",
"2d/geometry_container_2d.cpp",
"2d/graphs.cpp",
"2d/grouped_text.cpp",
"2d/stats_2d.cpp",
"3d/config_3d.cpp",
"3d/debug_draw_3d.cpp",
"3d/debug_geometry_container.cpp",
"3d/geometry_container_3d.cpp",
"3d/geometry_generators.cpp",
"3d/render_instances.cpp",
"3d/stats_3d.cpp",
Expand Down

0 comments on commit b291fe0

Please sign in to comment.