add vertices draw limit after I accidentally removed it
This commit is contained in:
@ -48,7 +48,7 @@ constexpr int REPULSION_GRID_REFRESH = 5; // Grid rebuild freq
|
|||||||
constexpr float VERTEX_SIZE = 0.5;
|
constexpr float VERTEX_SIZE = 0.5;
|
||||||
constexpr Color VERTEX_COLOR = GREEN;
|
constexpr Color VERTEX_COLOR = GREEN;
|
||||||
constexpr Color EDGE_COLOR = DARKGREEN;
|
constexpr Color EDGE_COLOR = DARKGREEN;
|
||||||
constexpr int DRAW_VERTICES_LIMIT = 100000;
|
constexpr int DRAW_VERTICES_LIMIT = 1000000;
|
||||||
|
|
||||||
// Klotski Drawing
|
// Klotski Drawing
|
||||||
constexpr int BOARD_PADDING = 5;
|
constexpr int BOARD_PADDING = 5;
|
||||||
|
|||||||
@ -89,6 +89,10 @@ public:
|
|||||||
MassSpringSystem() {
|
MassSpringSystem() {
|
||||||
#ifndef BARNES_HUT
|
#ifndef BARNES_HUT
|
||||||
last_build = REPULSION_GRID_REFRESH;
|
last_build = REPULSION_GRID_REFRESH;
|
||||||
|
std::cout << "Using uniform grid repulsion force calculation." << std::endl;
|
||||||
|
#else
|
||||||
|
std::cout << "Using Barnes-Hut + octree repulsion force calculation."
|
||||||
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WEB
|
#ifndef WEB
|
||||||
|
|||||||
@ -70,7 +70,11 @@ auto main(int argc, char *argv[]) -> int {
|
|||||||
std::chrono::high_resolution_clock::now();
|
std::chrono::high_resolution_clock::now();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (timestep_accumulator > TIMESTEP) {
|
// Do not try to catch up if we're falling behind. Frametimes would get
|
||||||
|
// larger, resulting in more catching up, resulting in even larger
|
||||||
|
// frametimes.
|
||||||
|
// while (timestep_accumulator > TIMESTEP) {
|
||||||
|
if (timestep_accumulator > TIMESTEP) {
|
||||||
mass_springs.ClearForces();
|
mass_springs.ClearForces();
|
||||||
mass_springs.CalculateSpringForces();
|
mass_springs.CalculateSpringForces();
|
||||||
mass_springs.CalculateRepulsionForces();
|
mass_springs.CalculateRepulsionForces();
|
||||||
@ -119,7 +123,8 @@ auto main(int argc, char *argv[]) -> int {
|
|||||||
<< render_time_accumulator / loop_count << "." << std::endl;
|
<< render_time_accumulator / loop_count << "." << std::endl;
|
||||||
std::cout << " - Physics updates avg: "
|
std::cout << " - Physics updates avg: "
|
||||||
<< static_cast<float>(update_accumulator) / loop_count
|
<< static_cast<float>(update_accumulator) / loop_count
|
||||||
<< "x per frame." << std::endl;
|
<< "x per frame (" << timestep_accumulator << "s remaining)."
|
||||||
|
<< std::endl;
|
||||||
last_print_time = GetTime();
|
last_print_time = GetTime();
|
||||||
physics_time_accumulator = std::chrono::duration<double, std::milli>(0);
|
physics_time_accumulator = std::chrono::duration<double, std::milli>(0);
|
||||||
render_time_accumulator = std::chrono::duration<double, std::milli>(0);
|
render_time_accumulator = std::chrono::duration<double, std::milli>(0);
|
||||||
|
|||||||
@ -68,16 +68,18 @@ auto Renderer::DrawMassSprings(const MassSpringSystem &mass_springs,
|
|||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
|
|
||||||
// Prepare cube instancing
|
// Prepare cube instancing
|
||||||
if (transforms == nullptr) {
|
if (mass_springs.masses.size() < DRAW_VERTICES_LIMIT) {
|
||||||
AllocateGraphInstancing(mass_springs);
|
if (transforms == nullptr) {
|
||||||
}
|
AllocateGraphInstancing(mass_springs);
|
||||||
ReallocateGraphInstancingIfNecessary(mass_springs);
|
}
|
||||||
|
ReallocateGraphInstancingIfNecessary(mass_springs);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &[state, mass] : mass_springs.masses) {
|
for (const auto &[state, mass] : mass_springs.masses) {
|
||||||
transforms[i] =
|
transforms[i] =
|
||||||
MatrixTranslate(mass.position.x, mass.position.y, mass.position.z);
|
MatrixTranslate(mass.position.x, mass.position.y, mass.position.z);
|
||||||
++i;
|
++i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginTextureMode(render_target);
|
BeginTextureMode(render_target);
|
||||||
@ -97,12 +99,14 @@ auto Renderer::DrawMassSprings(const MassSpringSystem &mass_springs,
|
|||||||
rlEnd();
|
rlEnd();
|
||||||
|
|
||||||
// Draw masses (instanced)
|
// Draw masses (instanced)
|
||||||
// NOTE: I don't know if drawing all this inside a shader would make it much
|
if (mass_springs.masses.size() < DRAW_VERTICES_LIMIT) {
|
||||||
// faster...
|
// NOTE: I don't know if drawing all this inside a shader would make it much
|
||||||
// The amount of data sent to the GPU would be reduced (just positions
|
// faster...
|
||||||
// instead of matrices), but is this noticable for < 100000 cubes?
|
// The amount of data sent to the GPU would be reduced (just positions
|
||||||
DrawMeshInstanced(cube_instance, vertex_mat, transforms,
|
// instead of matrices), but is this noticable for < 100000 cubes?
|
||||||
mass_springs.masses.size());
|
DrawMeshInstanced(cube_instance, vertex_mat, transforms,
|
||||||
|
mass_springs.masses.size());
|
||||||
|
}
|
||||||
|
|
||||||
// Mark winning states
|
// Mark winning states
|
||||||
if (mark_solutions || connect_solutions) {
|
if (mark_solutions || connect_solutions) {
|
||||||
|
|||||||
Reference in New Issue
Block a user