Adjusted renderer for new architecture
parent
85da817ed6
commit
3c0d6786bc
|
@ -21,6 +21,7 @@ galactica-content = { workspace = true }
|
|||
galactica-constants = { workspace = true }
|
||||
galactica-packer = { workspace = true }
|
||||
galactica-world = { workspace = true }
|
||||
galactica-gameobject = { workspace = true }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
cgmath = { workspace = true }
|
||||
|
|
|
@ -22,7 +22,12 @@ impl GPUState {
|
|||
//let system_object_scale = 1.0 / 600.0;
|
||||
let ship_scale = 1.0 / 10.0;
|
||||
|
||||
let (_, player_body) = state.world.get_ship_body(*state.player).unwrap();
|
||||
let player_world_object = state.world.get_ship(state.player_data).unwrap();
|
||||
let player_body = state
|
||||
.world
|
||||
.get_rigid_body(player_world_object.rigid_body)
|
||||
.unwrap();
|
||||
|
||||
let player_position = util::rigidbody_position(player_body);
|
||||
//let planet_sprite = state.content.get_sprite_handle("ui::planetblip");
|
||||
let ship_sprite = state.content.get_sprite_handle("ui::shipblip");
|
||||
|
@ -88,7 +93,8 @@ impl GPUState {
|
|||
|
||||
// Draw ships
|
||||
for (s, r) in state.world.iter_ship_body() {
|
||||
let ship = state.content.get_ship(s.ship.handle);
|
||||
let data = state.data.get_ship(s.data_handle).unwrap();
|
||||
let ship = state.content.get_ship(s.data_handle.content_handle());
|
||||
let size = (ship.size * ship.sprite.aspect) * ship_scale;
|
||||
let p = util::rigidbody_position(r);
|
||||
let d = (p - player_position) / radar_range;
|
||||
|
@ -99,7 +105,7 @@ impl GPUState {
|
|||
continue;
|
||||
}
|
||||
let angle = util::rigidbody_rotation(r).angle(Vector2 { x: 0.0, y: 1.0 });
|
||||
let f = state.content.get_faction(s.ship.faction).color;
|
||||
let f = state.content.get_faction(data.get_faction()).color;
|
||||
let f = [f[0], f[1], f[2], 1.0];
|
||||
|
||||
let position = Point2 {
|
||||
|
@ -264,11 +270,16 @@ impl GPUState {
|
|||
panic!("UI limit exceeded!")
|
||||
}
|
||||
|
||||
let (s, _) = state.world.get_ship_body(*state.player).unwrap();
|
||||
let max_shields = s.ship.outfits.stat_sum().shield_strength;
|
||||
let current_shields = s.ship.shields;
|
||||
let current_hull = s.ship.hull;
|
||||
let max_hull = state.content.get_ship(s.ship.handle).hull;
|
||||
let player_world_object = state.world.get_ship(state.player_data).unwrap();
|
||||
|
||||
let data = state
|
||||
.data
|
||||
.get_ship(player_world_object.data_handle)
|
||||
.unwrap();
|
||||
let max_shields = data.get_outfits().get_shield_strength();
|
||||
let current_shields = data.get_shields();
|
||||
let current_hull = data.get_hull();
|
||||
let max_hull = state.content.get_ship(data.get_content()).hull;
|
||||
|
||||
self.queue.write_buffer(
|
||||
&self.vertex_buffers.ui.instances,
|
||||
|
|
|
@ -21,11 +21,12 @@ impl GPUState {
|
|||
screen_clip: (Point2<f32>, Point2<f32>),
|
||||
s: &ShipWorldObject,
|
||||
) {
|
||||
let (_, r) = state.world.get_ship_body(s.physics_handle).unwrap();
|
||||
let r = state.world.get_rigid_body(s.rigid_body).unwrap();
|
||||
let ship = state.data.get_ship(s.data_handle);
|
||||
let ship_pos = util::rigidbody_position(&r);
|
||||
let ship_rot = util::rigidbody_rotation(r);
|
||||
let ship_ang = -ship_rot.angle(Vector2 { x: 0.0, y: 1.0 }); // TODO: inconsistent angles. Fix!
|
||||
let ship_cnt = state.content.get_ship(s.ship.handle);
|
||||
let ship_cnt = state.content.get_ship(s.data_handle.content_handle());
|
||||
|
||||
// Position adjusted for parallax
|
||||
// TODO: adjust parallax for zoom?
|
||||
|
@ -84,8 +85,10 @@ impl GPUState {
|
|||
);
|
||||
self.vertex_buffers.object_counter += 1;
|
||||
|
||||
/*
|
||||
// Draw engine flares if necessary
|
||||
if s.controls.thrust && !s.ship.is_dead() {
|
||||
//if s.controls.thrust && !s.ship.is_dead() {
|
||||
if s.controls.thrust {
|
||||
for f in s.ship.outfits.iter_enginepoints() {
|
||||
let flare = match s.ship.outfits.get_flare_sprite() {
|
||||
None => continue,
|
||||
|
@ -126,6 +129,7 @@ impl GPUState {
|
|||
self.vertex_buffers.object_counter += 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
pub(super) fn world_push_projectile(
|
||||
|
@ -139,7 +143,7 @@ impl GPUState {
|
|||
let proj_pos = util::rigidbody_position(&r);
|
||||
let proj_rot = util::rigidbody_rotation(r);
|
||||
let proj_ang = -proj_rot.angle(Vector2 { x: 1.0, y: 0.0 });
|
||||
let proj_cnt = &p.projectile.content; // TODO: don't clone this?
|
||||
let proj_cnt = &p.content; // TODO: don't clone this?
|
||||
|
||||
// Position adjusted for parallax
|
||||
// TODO: adjust parallax for zoom?
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
use cgmath::Point2;
|
||||
use galactica_content::Content;
|
||||
use galactica_world::{ParticleBuilder, ShipPhysicsHandle, World};
|
||||
use galactica_gameobject::{GameData, GameShipHandle};
|
||||
use galactica_world::{ParticleBuilder, World};
|
||||
|
||||
/// Bundles parameters passed to a single call to GPUState::render
|
||||
pub struct RenderState<'a> {
|
||||
/// Camera position, in world units
|
||||
pub camera_pos: Point2<f32>,
|
||||
|
||||
/// Player ship
|
||||
pub player: &'a ShipPhysicsHandle,
|
||||
/// Player ship data
|
||||
pub player_data: GameShipHandle,
|
||||
|
||||
/// Height of screen, in world units
|
||||
pub camera_zoom: f32,
|
||||
|
@ -23,6 +24,9 @@ pub struct RenderState<'a> {
|
|||
/// Game content
|
||||
pub content: &'a Content,
|
||||
|
||||
/// Game data
|
||||
pub data: &'a GameData,
|
||||
|
||||
/// Particles to spawn during this frame
|
||||
pub particles: &'a mut Vec<ParticleBuilder>,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue