From fef43d87449cd03ade87635d0886fdcf555d706e Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 8 Jan 2024 21:02:02 -0800 Subject: [PATCH] Minor cleanup --- TODO.md | 8 +++++--- content/effects.toml | 2 -- content/ship.toml | 1 - crates/content/src/part/gun.rs | 6 +++--- crates/content/src/part/system.rs | 10 +++++----- crates/content/src/util.rs | 4 ++-- crates/galactica/src/game.rs | 1 - crates/gameobject/src/outfits.rs | 3 --- crates/gameobject/src/systemobject.rs | 16 ++-------------- crates/packer/src/atlasset.rs | 4 +--- crates/packer/src/lib.rs | 1 - crates/packer/src/main.rs | 2 +- crates/render/src/gpustate/hud.rs | 6 ++---- crates/render/src/renderstate.rs | 2 +- crates/world/src/world.rs | 13 ++++--------- 15 files changed, 26 insertions(+), 53 deletions(-) diff --git a/TODO.md b/TODO.md index 19f2187..9ad9e65 100644 --- a/TODO.md +++ b/TODO.md @@ -14,9 +14,10 @@ - Better loading - incremental? - Higher texture limit (16 x 8096 x 8096 isn't enough) - - GPU limits? (texture size, texture number) + - GPU limits? (texture size, texture number, particle/sprite limits) - Particles when a ship is damaged (events) - Sticky radar + - Clean up world and objects ---------------------------------- @@ -50,7 +51,6 @@ - Orbiting debris (asteroids) - Collectibles (flotsam) - UI - - health, shields (cpu by tinyskia?) - loading screen, menus - Indicators (planet names, enemy ship stats) - Landable planets @@ -126,6 +126,7 @@ - Nova dust parallax - Engine flare ease in/out - Lens flare + - Clustered starfield ## Write and Document - Parallax @@ -141,7 +142,7 @@ - Handles - Content specification and pipeline - How packer and optimizations work, and why - - How big should sprites be? (resize existing) + - How big should sprite resolutions be? How about frame rate? - Naming: atlas, sprite, image, frame, texture @@ -158,4 +159,5 @@ - Find your wreckage when you die (dark souls/HK) - Lose some outfits, lose ship? Real risk for going out! (HK does this well) - Damage to ship subsystems + - Soft and highly armored ship points - Repair your own ship \ No newline at end of file diff --git a/content/effects.toml b/content/effects.toml index 9eb0f0a..9414148 100644 --- a/content/effects.toml +++ b/content/effects.toml @@ -103,7 +103,5 @@ fade_rng = 0.1 # TODO: # effect probabilities & variants # multiple particles in one effect -# fade # document: effect vs particle # sprite lifetime/fps variation (and effects inherit lifetime later) -# universal effect creator diff --git a/content/ship.toml b/content/ship.toml index 1b88b35..76f71af 100644 --- a/content/ship.toml +++ b/content/ship.toml @@ -7,7 +7,6 @@ linear_drag = 0.2 angular_drag = 0.2 # TODO: disable -# TODO: damage effects space.outfit = 200 space.engine = 50 diff --git a/crates/content/src/part/gun.rs b/crates/content/src/part/gun.rs index db37f3f..3a359c7 100644 --- a/crates/content/src/part/gun.rs +++ b/crates/content/src/part/gun.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use cgmath::Deg; +use cgmath::{Deg, Rad}; use serde::Deserialize; use std::collections::HashMap; @@ -109,7 +109,7 @@ pub struct Projectile { /// `spread / 2` degrees in both directions. /// /// (Forming a "fire cone" of `spread` degrees) - pub angle_rng: Deg, + pub angle_rng: Rad, /// The particle this projectile will spawn when it hits something pub impact_effect: Option, @@ -173,7 +173,7 @@ impl crate::Build for Gun { // Divide by 2, so the angle matches the angle of the fire cone. // This should ALWAYS be done in the content parser. - angle_rng: Deg(gun.projectile.angle_rng / 2.0), + angle_rng: Deg(gun.projectile.angle_rng / 2.0).into(), impact_effect, expire_effect, collider: gun.projectile.collider, diff --git a/crates/content/src/part/system.rs b/crates/content/src/part/system.rs index c62ee6f..b24fe81 100644 --- a/crates/content/src/part/system.rs +++ b/crates/content/src/part/system.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use cgmath::{Deg, Point3}; +use cgmath::{Deg, Point3, Rad}; use std::collections::{HashMap, HashSet}; use crate::{handle::SpriteHandle, util::Polar, Content, ContentBuildContext}; @@ -106,8 +106,8 @@ pub struct Object { /// relative to the system's center (0, 0). pub position: Point3, - /// This object's sprite's angle, in degrees. - pub angle: Deg, + /// This object's sprite's angle. + pub angle: Rad, } /// Helper function for resolve_position, never called on its own. @@ -162,7 +162,7 @@ fn resolve_position( let plane = Polar { center: (r.x, r.y).into(), radius: p.radius, - angle: Deg(p.angle), + angle: Deg(p.angle).into(), } .to_cartesian(); Ok(Point3 { @@ -203,7 +203,7 @@ impl crate::Build for System { position: resolve_position(&system.object, &obj, cycle_detector) .with_context(|| format!("In object {:#?}", label))?, size: obj.size, - angle: Deg(obj.angle.unwrap_or(0.0)), + angle: Deg(obj.angle.unwrap_or(0.0)).into(), }); } diff --git a/crates/content/src/util.rs b/crates/content/src/util.rs index fe67707..bbeeb50 100644 --- a/crates/content/src/util.rs +++ b/crates/content/src/util.rs @@ -1,10 +1,10 @@ -use cgmath::{Angle, Deg, Point2, Vector2}; +use cgmath::{Angle, Point2, Rad, Vector2}; #[derive(Debug, Clone, Copy)] pub struct Polar { pub center: Point2, pub radius: f32, - pub angle: Deg, + pub angle: Rad, } impl Polar { diff --git a/crates/galactica/src/game.rs b/crates/galactica/src/game.rs index 3634489..da9178c 100644 --- a/crates/galactica/src/game.rs +++ b/crates/galactica/src/game.rs @@ -162,7 +162,6 @@ impl Game { self.input.v_scroll = 0.0; } - // TODO: Camera physics let r = self .world .get_ship_mut(&self.player) diff --git a/crates/gameobject/src/outfits.rs b/crates/gameobject/src/outfits.rs index b36f1b6..e48f88f 100644 --- a/crates/gameobject/src/outfits.rs +++ b/crates/gameobject/src/outfits.rs @@ -137,7 +137,6 @@ impl<'a> OutfitSet { self.available_space.occupy(&outfit.space); self.stats.add(&outfit); self.outfits.push(o); - //self.update_engine_flares(); return true; } @@ -150,8 +149,6 @@ impl<'a> OutfitSet { }; self.available_space.free(&outfit.space); self.outfits.remove(i); - self.stats.remove(&outfit); - //self.update_engine_flares(); } /// Add a gun to this outfit set. diff --git a/crates/gameobject/src/systemobject.rs b/crates/gameobject/src/systemobject.rs index d0e4c95..5415f57 100644 --- a/crates/gameobject/src/systemobject.rs +++ b/crates/gameobject/src/systemobject.rs @@ -1,4 +1,4 @@ -use cgmath::{Deg, Point3}; +use cgmath::{Point3, Rad}; use galactica_content as content; @@ -6,17 +6,5 @@ pub struct SystemObject { pub sprite: content::SpriteHandle, pub pos: Point3, pub size: f32, - pub angle: Deg, -} - -impl SystemObject { - //pub(crate) fn get_sprite(&self) -> ObjectSprite { - // return ObjectSprite { - // sprite: self.sprite, - // pos: self.pos, - // angle: self.angle, - // size: self.size, - // children: None, - // }; - //} + pub angle: Rad, } diff --git a/crates/packer/src/atlasset.rs b/crates/packer/src/atlasset.rs index ffb74f3..8481fa7 100644 --- a/crates/packer/src/atlasset.rs +++ b/crates/packer/src/atlasset.rs @@ -8,10 +8,8 @@ use std::{ }; // TODO: article -// TODO: rework texturearray -// TODO: reasonable sprite sizes -// TODO: consistent naming // TODO: parallelize +// TODO: consistent naming (document) // spriteatlas: the big images // texture: the same, what we load to wgpu // image: a single file diff --git a/crates/packer/src/lib.rs b/crates/packer/src/lib.rs index 95cc6c1..d385233 100644 --- a/crates/packer/src/lib.rs +++ b/crates/packer/src/lib.rs @@ -1,7 +1,6 @@ #![warn(missing_docs)] //! This crate creates texture atlases from an asset tree. -//! The main interface for this crate is ... TODO use std::{collections::HashMap, path::PathBuf}; diff --git a/crates/packer/src/main.rs b/crates/packer/src/main.rs index e8cfa7e..5a3d8c3 100644 --- a/crates/packer/src/main.rs +++ b/crates/packer/src/main.rs @@ -11,7 +11,7 @@ use walkdir::WalkDir; // TODO: dynamic packing (for plugins) // TODO: standalone cli (galactica should ask to run this) // TODO: randomly assign sprites to textures, for efficiency -// TODO: group images by use case +// TODO: group images by use case (dynamic loading algorithm) fn main() -> Result<()> { let mut files = Vec::new(); diff --git a/crates/render/src/gpustate/hud.rs b/crates/render/src/gpustate/hud.rs index 567736b..b5c027b 100644 --- a/crates/render/src/gpustate/hud.rs +++ b/crates/render/src/gpustate/hud.rs @@ -98,9 +98,7 @@ impl GPUState { if size < 2.0 { continue; } - let angle: Deg = util::rigidbody_rotation(r) - .angle(Vector2 { x: 0.0, y: 1.0 }) - .into(); + 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 = [f[0], f[1], f[2], 1.0]; @@ -124,7 +122,7 @@ impl GPUState { bytemuck::cast_slice(&[UiInstance { anchor: PositionAnchor::NwC.to_int(), position: position.into(), - angle: -Rad::from(angle).0, // TODO: consistent angles + angle: -angle.0, // TODO: consistent angles size, color: f.into(), sprite_index: ship_sprite.get_index(), diff --git a/crates/render/src/renderstate.rs b/crates/render/src/renderstate.rs index 61a4cdd..1d93c21 100644 --- a/crates/render/src/renderstate.rs +++ b/crates/render/src/renderstate.rs @@ -16,7 +16,7 @@ pub struct RenderState<'a> { /// The world state to render pub world: &'a World, - // TODO: handle overflow + // TODO: handle overflow. is it a problem? /// The current time, in seconds pub current_time: f32, diff --git a/crates/world/src/world.rs b/crates/world/src/world.rs index 45662c0..82348fd 100644 --- a/crates/world/src/world.rs +++ b/crates/world/src/world.rs @@ -166,9 +166,7 @@ impl<'a> World { .get(projectile.rigid_body) .unwrap(); let pos = util::rigidbody_position(pr); - let angle: Deg = util::rigidbody_rotation(pr) - .angle(Vector2 { x: 1.0, y: 0.0 }) - .into(); + let angle = util::rigidbody_rotation(pr).angle(Vector2 { x: 1.0, y: 0.0 }); match &projectile.projectile.content.impact_effect { None => {} @@ -182,7 +180,7 @@ impl<'a> World { particles.push(ParticleBuilder::from_content( effect, pos, - Rad::from(-angle), + -angle, parent_velocity, Vector2 { x: target_velocity.x, @@ -323,9 +321,7 @@ impl<'a> World { let x = ct.get_effect(*x); let pos = util::rigidbody_position(&pr); let vel = util::rigidbody_velocity(&pr); - let angle: Deg = util::rigidbody_rotation(&pr) - .angle(Vector2 { x: 1.0, y: 0.0 }) - .into(); + let angle = util::rigidbody_rotation(&pr).angle(Vector2 { x: 1.0, y: 0.0 }); let velocity = { let a = rng @@ -339,7 +335,7 @@ impl<'a> World { particles.push(ParticleBuilder::from_content( x, pos, - Rad::from(-angle), + -angle, velocity, Vector2::zero(), )); @@ -368,7 +364,6 @@ impl<'a> World { &self, s: ShipPhysicsHandle, ) -> Option<(&objects::ShipWorldObject, &RigidBody)> { - // TODO: handle dead handles Some((self.ships.get(&s.1)?, self.wrapper.rigid_body_set.get(s.0)?)) }