mirror of
https://codeberg.org/icewind/vbspview.git
synced 2026-06-03 18:24:09 +02:00
nix ci
This commit is contained in:
parent
29a36ffbc0
commit
809c68d94a
9 changed files with 198 additions and 66 deletions
53
.github/workflows/ci.yml
vendored
Normal file
53
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: "CI"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#check
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#clippy
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- x86_64-unknown-linux-musl
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v20
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#${{ matrix.target }}
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: parser-${{ matrix.target }}
|
||||
path: result/bin/vbspview
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,3 +6,4 @@ flamegraph.svg
|
|||
*.dem
|
||||
.direnv
|
||||
result
|
||||
.direnv
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "demview"
|
||||
name = "vbspview"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||
|
|
|
|||
54
flake.lock
generated
54
flake.lock
generated
|
|
@ -1,26 +1,72 @@
|
|||
{
|
||||
"nodes": {
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686242667,
|
||||
"narHash": "sha256-I7Kwp06WX/9E+rEND1i1wjdKQQm3XiDxYOyNK9fuJu0=",
|
||||
"owner": "icewind1991",
|
||||
"repo": "naersk",
|
||||
"rev": "6d245a3bbb2ee31ec726bb57b9a8b206302e7110",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "icewind1991",
|
||||
"repo": "naersk",
|
||||
"rev": "6d245a3bbb2ee31ec726bb57b9a8b206302e7110",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1674902473,
|
||||
"narHash": "sha256-MdKJeeDTjCtmoVPWLEDg10jgknt6rqTO3c1WeNQtho4=",
|
||||
"lastModified": 1686059680,
|
||||
"narHash": "sha256-sp0WlCIeVczzB0G8f8iyRg3IYW7KG31mI66z7HIZwrI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "548896f4d9f7db2f7205d82727d6c03c86d2f896",
|
||||
"rev": "a558f7ac29f50c4b937fb5c102f587678ae1c9fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "release-22.11",
|
||||
"ref": "nixos-23.05",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686191569,
|
||||
"narHash": "sha256-8ey5FOXNms9piFGTn6vJeAQmSKk+NL7GTMSoVttsNTs=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "b4b71458b92294e8f1c3a112d972e3cff8a2ab71",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
|
|
|
|||
64
flake.nix
64
flake.nix
|
|
@ -1,30 +1,43 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/release-22.11";
|
||||
naersk.url = "github:icewind1991/naersk?rev=6d245a3bbb2ee31ec726bb57b9a8b206302e7110";
|
||||
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.inputs.flake-utils.follows = "utils";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
naersk,
|
||||
rust-overlay,
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system;
|
||||
inherit system overlays;
|
||||
};
|
||||
in rec {
|
||||
# `nix develop`
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
rustc
|
||||
cargo
|
||||
bacon
|
||||
cargo-edit
|
||||
cargo-outdated
|
||||
clippy
|
||||
cargo-audit
|
||||
cargo-msrv
|
||||
lib = pkgs.lib;
|
||||
naerskForTarget = target: let
|
||||
toolchain = pkgs.rust-bin.stable.latest.default.override { targets = [target]; };
|
||||
in pkgs.callPackage naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
hostTarget = pkgs.hostPlatform.config;
|
||||
targets = ["x86_64-unknown-linux-musl" hostTarget];
|
||||
hostNaersk = naerskForTarget hostTarget;
|
||||
src = lib.sources.sourceByRegex (lib.cleanSource ./.) ["Cargo.*" "(src)(/.*)?"];
|
||||
nearskOpt = {
|
||||
pname = "vbspview";
|
||||
root = src;
|
||||
nativeBuildInputs = buildDependencies;
|
||||
};
|
||||
buildDependencies = with pkgs; [
|
||||
freetype
|
||||
pkgconfig
|
||||
cmake
|
||||
|
|
@ -37,6 +50,29 @@
|
|||
egl-wayland
|
||||
libGL
|
||||
];
|
||||
in rec {
|
||||
packages = (lib.attrsets.genAttrs targets (target: (naerskForTarget target).buildPackage nearskOpt)) // rec {
|
||||
vbspview = packages.${hostTarget};
|
||||
check = hostNaersk.buildPackage (nearskOpt // {
|
||||
mode = "check";
|
||||
});
|
||||
clippy = hostNaersk.buildPackage (nearskOpt // {
|
||||
mode = "clippy";
|
||||
});
|
||||
default = vbspview;
|
||||
};
|
||||
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkgs.rust-bin.stable.latest.default
|
||||
bacon
|
||||
cargo-edit
|
||||
cargo-outdated
|
||||
clippy
|
||||
cargo-audit
|
||||
cargo-msrv
|
||||
] ++ buildDependencies;
|
||||
|
||||
LD_LIBRARY_PATH = with pkgs; "/run/opengl-driver/lib/:${lib.makeLibraryPath ([libGL libGLU])}";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ fn model_to_mesh(model: Handle<vbsp::data::Model>) -> CpuMesh {
|
|||
.map(Either::Left)
|
||||
.unwrap_or_else(|| Either::Right(face.triangulate().flatten()))
|
||||
})
|
||||
.map(|c| map_coords(c).into())
|
||||
.map(map_coords)
|
||||
.collect();
|
||||
|
||||
let mut mesh = CpuMesh {
|
||||
|
|
@ -61,7 +61,7 @@ fn load_props<'a, I: Iterator<Item = Handle<'a, StaticPropLump>>>(
|
|||
merge_models(props.map(|prop| {
|
||||
let model = load_prop(loader, prop.model())?;
|
||||
let transform =
|
||||
Mat4::from_translation(map_coords(prop.origin).into()) * Mat4::from(prop.rotation());
|
||||
Mat4::from_translation(map_coords(prop.origin)) * Mat4::from(prop.rotation());
|
||||
Ok(ModelData { model, transform })
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,15 +115,12 @@ impl Control for DebugToggle {
|
|||
_accumulated_time: f64,
|
||||
) -> bool {
|
||||
for event in events.iter_mut() {
|
||||
match event {
|
||||
Event::Text(text) => {
|
||||
if let Event::Text(text) = event {
|
||||
if text == "`" {
|
||||
self.enabled = !self.enabled;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
false
|
||||
|
|
@ -161,8 +158,7 @@ impl Control for DemoCamera {
|
|||
) -> bool {
|
||||
let mut change = false;
|
||||
for event in events.iter_mut() {
|
||||
match event {
|
||||
Event::Text(text) => {
|
||||
if let Event::Text(text) = event {
|
||||
if text == "p" {
|
||||
change = true;
|
||||
self.playing = !self.playing;
|
||||
|
|
@ -172,8 +168,6 @@ impl Control for DemoCamera {
|
|||
self.start_tick = self.demo_tick(accumulated_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,34 +112,36 @@ impl<C: Control> Renderer<C> {
|
|||
.map(|gm| &gm.geometry);
|
||||
|
||||
match self.gui.debug_type {
|
||||
DebugType::NORMAL => target.render_with_material(
|
||||
DebugType::Normal => target.render_with_material(
|
||||
&NormalMaterial::default(),
|
||||
&self.camera,
|
||||
geometries,
|
||||
lights,
|
||||
),
|
||||
DebugType::DEPTH => {
|
||||
let mut depth_material = DepthMaterial::default();
|
||||
depth_material.max_distance = Some(self.gui.depth_max);
|
||||
DebugType::Depth => {
|
||||
let depth_material = DepthMaterial {
|
||||
max_distance: Some(self.gui.depth_max),
|
||||
..DepthMaterial::default()
|
||||
};
|
||||
target.render_with_material(&depth_material, &self.camera, geometries, lights)
|
||||
}
|
||||
DebugType::ORM => target.render_with_material(
|
||||
DebugType::Orm => target.render_with_material(
|
||||
&ORMMaterial::default(),
|
||||
&self.camera,
|
||||
geometries,
|
||||
lights,
|
||||
),
|
||||
DebugType::POSITION => {
|
||||
DebugType::Position => {
|
||||
let position_material = PositionMaterial::default();
|
||||
target.render_with_material(&position_material, &self.camera, geometries, lights)
|
||||
}
|
||||
DebugType::COLOR => target.render_with_material(
|
||||
DebugType::Color => target.render_with_material(
|
||||
&ColorMaterial::default(),
|
||||
&self.camera,
|
||||
geometries,
|
||||
lights,
|
||||
),
|
||||
DebugType::NONE => target.render(
|
||||
DebugType::None => target.render(
|
||||
&self.camera,
|
||||
self.models.iter().flat_map(|model| model.iter()),
|
||||
lights,
|
||||
|
|
|
|||
28
src/ui.rs
28
src/ui.rs
|
|
@ -5,12 +5,12 @@ use three_d::{Camera, Context, FrameInput, GUI};
|
|||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum DebugType {
|
||||
POSITION,
|
||||
NORMAL,
|
||||
COLOR,
|
||||
DEPTH,
|
||||
ORM,
|
||||
NONE,
|
||||
Position,
|
||||
Normal,
|
||||
Color,
|
||||
Depth,
|
||||
Orm,
|
||||
None,
|
||||
}
|
||||
|
||||
pub struct DebugUI {
|
||||
|
|
@ -32,7 +32,7 @@ impl DebugUI {
|
|||
ambient_intensity: 0.2,
|
||||
depth_max: 30.0,
|
||||
fov: 60.0,
|
||||
debug_type: DebugType::NORMAL,
|
||||
debug_type: DebugType::Normal,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,12 +65,12 @@ impl DebugUI {
|
|||
ui.checkbox(&mut self.shadows_enabled, "Shadows");
|
||||
|
||||
ui.label("Debug options");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::NONE, "None");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::POSITION, "Position");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::NORMAL, "Normal");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::COLOR, "Color");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::DEPTH, "Depth");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::ORM, "ORM");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::None, "None");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::Position, "Position");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::Normal, "Normal");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::Color, "Color");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::Depth, "Depth");
|
||||
ui.radio_value(&mut self.debug_type, DebugType::Orm, "ORM");
|
||||
|
||||
ui.label("View options");
|
||||
ui.add(Slider::new(&mut self.depth_max, 1.0..=30.0).text("Depth max"));
|
||||
|
|
@ -90,7 +90,7 @@ impl DebugUI {
|
|||
(change, panel_width)
|
||||
}
|
||||
|
||||
pub fn render(&mut self) -> () {
|
||||
pub fn render(&mut self) {
|
||||
self.ui.render()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue