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
|
*.dem
|
||||||
.direnv
|
.direnv
|
||||||
result
|
result
|
||||||
|
.direnv
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "demview"
|
name = "vbspview"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
|
|
|
||||||
54
flake.lock
generated
54
flake.lock
generated
|
|
@ -1,26 +1,72 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1674902473,
|
"lastModified": 1686059680,
|
||||||
"narHash": "sha256-MdKJeeDTjCtmoVPWLEDg10jgknt6rqTO3c1WeNQtho4=",
|
"narHash": "sha256-sp0WlCIeVczzB0G8f8iyRg3IYW7KG31mI66z7HIZwrI=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "548896f4d9f7db2f7205d82727d6c03c86d2f896",
|
"rev": "a558f7ac29f50c4b937fb5c102f587678ae1c9fb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
"ref": "release-22.11",
|
"ref": "nixos-23.05",
|
||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"naersk": "naersk",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
"utils": "utils"
|
"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": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1667395993,
|
||||||
|
|
|
||||||
72
flake.nix
72
flake.nix
|
|
@ -1,42 +1,78 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-23.05";
|
||||||
utils.url = "github:numtide/flake-utils";
|
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 = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
utils,
|
utils,
|
||||||
|
naersk,
|
||||||
|
rust-overlay,
|
||||||
}:
|
}:
|
||||||
utils.lib.eachDefaultSystem (system: let
|
utils.lib.eachDefaultSystem (system: let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
pkgs = (import nixpkgs) {
|
pkgs = (import nixpkgs) {
|
||||||
inherit system;
|
inherit system overlays;
|
||||||
};
|
};
|
||||||
|
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
|
||||||
|
fontconfig
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXrandr
|
||||||
|
xorg.libXi
|
||||||
|
glew-egl
|
||||||
|
egl-wayland
|
||||||
|
libGL
|
||||||
|
];
|
||||||
in rec {
|
in rec {
|
||||||
# `nix develop`
|
packages = (lib.attrsets.genAttrs targets (target: (naerskForTarget target).buildPackage nearskOpt)) // rec {
|
||||||
devShell = pkgs.mkShell {
|
vbspview = packages.${hostTarget};
|
||||||
|
check = hostNaersk.buildPackage (nearskOpt // {
|
||||||
|
mode = "check";
|
||||||
|
});
|
||||||
|
clippy = hostNaersk.buildPackage (nearskOpt // {
|
||||||
|
mode = "clippy";
|
||||||
|
});
|
||||||
|
default = vbspview;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
rustc
|
pkgs.rust-bin.stable.latest.default
|
||||||
cargo
|
|
||||||
bacon
|
bacon
|
||||||
cargo-edit
|
cargo-edit
|
||||||
cargo-outdated
|
cargo-outdated
|
||||||
clippy
|
clippy
|
||||||
cargo-audit
|
cargo-audit
|
||||||
cargo-msrv
|
cargo-msrv
|
||||||
freetype
|
] ++ buildDependencies;
|
||||||
pkgconfig
|
|
||||||
cmake
|
|
||||||
fontconfig
|
|
||||||
xorg.libX11
|
|
||||||
xorg.libXcursor
|
|
||||||
xorg.libXrandr
|
|
||||||
xorg.libXi
|
|
||||||
glew-egl
|
|
||||||
egl-wayland
|
|
||||||
libGL
|
|
||||||
];
|
|
||||||
|
|
||||||
LD_LIBRARY_PATH = with pkgs; "/run/opengl-driver/lib/:${lib.makeLibraryPath ([libGL libGLU])}";
|
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)
|
.map(Either::Left)
|
||||||
.unwrap_or_else(|| Either::Right(face.triangulate().flatten()))
|
.unwrap_or_else(|| Either::Right(face.triangulate().flatten()))
|
||||||
})
|
})
|
||||||
.map(|c| map_coords(c).into())
|
.map(map_coords)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut mesh = CpuMesh {
|
let mut mesh = CpuMesh {
|
||||||
|
|
@ -61,7 +61,7 @@ fn load_props<'a, I: Iterator<Item = Handle<'a, StaticPropLump>>>(
|
||||||
merge_models(props.map(|prop| {
|
merge_models(props.map(|prop| {
|
||||||
let model = load_prop(loader, prop.model())?;
|
let model = load_prop(loader, prop.model())?;
|
||||||
let transform =
|
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 })
|
Ok(ModelData { model, transform })
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,15 +115,12 @@ impl Control for DebugToggle {
|
||||||
_accumulated_time: f64,
|
_accumulated_time: f64,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
for event in events.iter_mut() {
|
for event in events.iter_mut() {
|
||||||
match event {
|
if let Event::Text(text) = event {
|
||||||
Event::Text(text) => {
|
if text == "`" {
|
||||||
if text == "`" {
|
self.enabled = !self.enabled;
|
||||||
self.enabled = !self.enabled;
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
@ -161,19 +158,16 @@ impl Control for DemoCamera {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut change = false;
|
let mut change = false;
|
||||||
for event in events.iter_mut() {
|
for event in events.iter_mut() {
|
||||||
match event {
|
if let Event::Text(text) = event {
|
||||||
Event::Text(text) => {
|
if text == "p" {
|
||||||
if text == "p" {
|
change = true;
|
||||||
change = true;
|
self.playing = !self.playing;
|
||||||
self.playing = !self.playing;
|
if self.playing {
|
||||||
if self.playing {
|
self.playback_start_time = accumulated_time;
|
||||||
self.playback_start_time = accumulated_time;
|
} else {
|
||||||
} else {
|
self.start_tick = self.demo_tick(accumulated_time);
|
||||||
self.start_tick = self.demo_tick(accumulated_time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,34 +112,36 @@ impl<C: Control> Renderer<C> {
|
||||||
.map(|gm| &gm.geometry);
|
.map(|gm| &gm.geometry);
|
||||||
|
|
||||||
match self.gui.debug_type {
|
match self.gui.debug_type {
|
||||||
DebugType::NORMAL => target.render_with_material(
|
DebugType::Normal => target.render_with_material(
|
||||||
&NormalMaterial::default(),
|
&NormalMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries,
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::DEPTH => {
|
DebugType::Depth => {
|
||||||
let mut depth_material = DepthMaterial::default();
|
let depth_material = DepthMaterial {
|
||||||
depth_material.max_distance = Some(self.gui.depth_max);
|
max_distance: Some(self.gui.depth_max),
|
||||||
|
..DepthMaterial::default()
|
||||||
|
};
|
||||||
target.render_with_material(&depth_material, &self.camera, geometries, lights)
|
target.render_with_material(&depth_material, &self.camera, geometries, lights)
|
||||||
}
|
}
|
||||||
DebugType::ORM => target.render_with_material(
|
DebugType::Orm => target.render_with_material(
|
||||||
&ORMMaterial::default(),
|
&ORMMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries,
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::POSITION => {
|
DebugType::Position => {
|
||||||
let position_material = PositionMaterial::default();
|
let position_material = PositionMaterial::default();
|
||||||
target.render_with_material(&position_material, &self.camera, geometries, lights)
|
target.render_with_material(&position_material, &self.camera, geometries, lights)
|
||||||
}
|
}
|
||||||
DebugType::COLOR => target.render_with_material(
|
DebugType::Color => target.render_with_material(
|
||||||
&ColorMaterial::default(),
|
&ColorMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries,
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::NONE => target.render(
|
DebugType::None => target.render(
|
||||||
&self.camera,
|
&self.camera,
|
||||||
self.models.iter().flat_map(|model| model.iter()),
|
self.models.iter().flat_map(|model| model.iter()),
|
||||||
lights,
|
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)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum DebugType {
|
pub enum DebugType {
|
||||||
POSITION,
|
Position,
|
||||||
NORMAL,
|
Normal,
|
||||||
COLOR,
|
Color,
|
||||||
DEPTH,
|
Depth,
|
||||||
ORM,
|
Orm,
|
||||||
NONE,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DebugUI {
|
pub struct DebugUI {
|
||||||
|
|
@ -32,7 +32,7 @@ impl DebugUI {
|
||||||
ambient_intensity: 0.2,
|
ambient_intensity: 0.2,
|
||||||
depth_max: 30.0,
|
depth_max: 30.0,
|
||||||
fov: 60.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.checkbox(&mut self.shadows_enabled, "Shadows");
|
||||||
|
|
||||||
ui.label("Debug options");
|
ui.label("Debug options");
|
||||||
ui.radio_value(&mut self.debug_type, DebugType::NONE, "None");
|
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::Position, "Position");
|
||||||
ui.radio_value(&mut self.debug_type, DebugType::NORMAL, "Normal");
|
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::Color, "Color");
|
||||||
ui.radio_value(&mut self.debug_type, DebugType::DEPTH, "Depth");
|
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::Orm, "ORM");
|
||||||
|
|
||||||
ui.label("View options");
|
ui.label("View options");
|
||||||
ui.add(Slider::new(&mut self.depth_max, 1.0..=30.0).text("Depth max"));
|
ui.add(Slider::new(&mut self.depth_max, 1.0..=30.0).text("Depth max"));
|
||||||
|
|
@ -90,7 +90,7 @@ impl DebugUI {
|
||||||
(change, panel_width)
|
(change, panel_width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&mut self) -> () {
|
pub fn render(&mut self) {
|
||||||
self.ui.render()
|
self.ui.render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue