summaryrefslogtreecommitdiff
path: root/src/renderer/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r--src/renderer/mod.rs36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index 233d66b..403eeb2 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -12,9 +12,10 @@ use crate::{
renderer::ui::draw_egui,
sim::{
cell::materials::MaterialId,
- cell_sim::world::World,
- particle_sim::ParticleManager,
- rb_sim::{RbSimManager, debug_render::DebugVertex, rb_entity::RbEntity},
+ cell_manager::manager::CellManager,
+ particle_manager::ParticleManager,
+ rb_manager::{RbManager, debug_render::DebugVertex, rb_entity::RbEntity},
+ sim_manager::SimManager,
},
};
@@ -573,9 +574,7 @@ impl RendererState {
pub fn render(
&mut self,
- world: &mut World,
- rb_sim_manager: &mut RbSimManager,
- particle_manager: &mut ParticleManager,
+ sim: &mut SimManager,
camera: &mut Camera,
config: &mut Config,
diagnostics: &Diagnostics,
@@ -627,7 +626,7 @@ impl RendererState {
.resizable(false)
// TODO collapse button
.show_collapsible(ui, &mut true, |panel_ui| {
- draw_egui(panel_ui, config, camera, diagnostics, input, world)
+ draw_egui(panel_ui, config, camera, diagnostics, input, sim)
});
});
@@ -671,8 +670,8 @@ impl RendererState {
{
puffin::profile_scope!("Upload chunk cells");
- for &idx in world.chunk_position_to_chunk_idx.values() {
- let chunk = &mut world.chunks[idx];
+ for &idx in sim.cell_manager.chunk_position_to_chunk_idx.values() {
+ let chunk = &mut sim.cell_manager.chunks[idx];
if !chunk.needs_texture_update {
continue;
}
@@ -694,7 +693,7 @@ impl RendererState {
puffin::profile_scope!("Upload entity cells");
// TODO optimize, this is very inefficient, just build it per frame with positions and skip the lookup?
self.renderer_rb_entities.drain();
- for entity in rb_sim_manager.rb_entities.values() {
+ for entity in sim.rb_manager.rb_entities.values() {
// TODO add "needs texture update"?
for i in 0..entity.cells.len() {
cell_buffer[i] = entity.cells[i].material as u8;
@@ -717,15 +716,17 @@ impl RendererState {
{
puffin::profile_scope!("Build instances");
let (xl, xu, yl, yu) = camera.viewport_bounds_world();
- let ((cxl, cyl), _) = World::split_game_position(xl.floor() as i32, yl.floor() as i32);
- let ((cxu, cyu), _) = World::split_game_position(xu.floor() as i32, yu.floor() as i32);
+ let ((cxl, cyl), _) =
+ CellManager::split_game_position(xl.floor() as i32, yl.floor() as i32);
+ let ((cxu, cyu), _) =
+ CellManager::split_game_position(xu.floor() as i32, yu.floor() as i32);
let half_size = [CHUNK_SIZE as f32 / 2.0, CHUNK_SIZE as f32 / 2.0];
let dims = [CHUNK_SIZE as u32, CHUNK_SIZE as u32];
for cx in cxl..=cxu {
for cy in cyl..=cyu {
- if let Some(idx) = world.chunk_position_to_chunk_idx.get(&(cx, cy)) {
+ if let Some(idx) = sim.cell_manager.chunk_position_to_chunk_idx.get(&(cx, cy)) {
instances.push(RendererInstance {
centre: [
(cx * CHUNK_SIZE) as f32 + half_size[0],
@@ -742,8 +743,8 @@ impl RendererState {
}
for (id, slot) in &self.renderer_rb_entities {
- if let Some(&RbEntity { width, height, .. }) = rb_sim_manager.rb_entities.get(id)
- && let Some((x, y, cos, sin)) = rb_sim_manager.get_rb_entity_transform(*id)
+ if let Some(&RbEntity { width, height, .. }) = sim.rb_manager.rb_entities.get(id)
+ && let Some((x, y, cos, sin)) = sim.rb_manager.get_rb_entity_transform(*id)
{
instances.push(RendererInstance {
centre: [x, y],
@@ -765,7 +766,8 @@ impl RendererState {
{
puffin::profile_scope!("Build particles");
// TODO could cull this to visible, maybe it's slower?
- particles = particle_manager
+ particles = sim
+ .particle_manager
.particles
.iter()
.map(|p| RendererParticle {
@@ -781,7 +783,7 @@ impl RendererState {
let debug_vertex_count = if config.debug_render {
puffin::profile_scope!("Build physics debug lines");
- let vertices = rb_sim_manager.debug_render(config.debug_render_mode);
+ let vertices = sim.rb_manager.debug_render(config.debug_render_mode);
if vertices.is_empty() {
0