Skip to content

Commit 8ef8f4b

Browse files
committed
fix: upgrade sk + smithay
1 parent 277dc3c commit 8ef8f4b

File tree

11 files changed

+241
-223
lines changed

11 files changed

+241
-223
lines changed

Cargo.lock

Lines changed: 73 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ serde_repr = "0.1.19"
7979
toml = "0.8.19"
8080

8181
# mathy stuffs
82-
glam = { version = "0.29.0", features = ["mint", "serde"] }
82+
glam = { version = "0.30.0", features = ["mint", "serde"] }
8383
mint = "0.5.9"
8484
tokio = { version = "1.39.2", features = ["rt-multi-thread", "signal", "time"] }
8585

@@ -103,7 +103,6 @@ optional = true
103103

104104
[dependencies.stereokit-rust]
105105
git = "https://github.com/mvvvv/StereoKit-rust.git"
106-
rev = "73ffaae6f42aa369e599a6ea0391f77840d682d8"
107106
features = ["no-event-loop"]
108107
default-features = false
109108

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async fn main() {
189189

190190
tokio::select! {
191191
_ = stereokit_loop => (),
192-
_ = tokio::signal::ctrl_c() => unsafe {sk_quit(QuitReason::SystemClose)},
192+
_ = tokio::signal::ctrl_c() => unsafe {sk_quit(QuitReason::User)},
193193
}
194194
info!("Stopping...");
195195
if let Some(project_dirs) = project_dirs {
@@ -259,7 +259,7 @@ fn stereokit_loop(
259259
TexType::Cubemap,
260260
TexFormat::RGBA32,
261261
));
262-
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_skylight());
262+
let _ = DEFAULT_SKYLIGHT.set(Renderer::get_sky_light());
263263
if let Some(sky) = project_dirs
264264
.as_ref()
265265
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
@@ -268,7 +268,7 @@ fn stereokit_loop(
268268
{
269269
sky.render_as_sky();
270270
} else {
271-
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
271+
Renderer::sky_tex(DEFAULT_SKYTEX.get().unwrap());
272272
}
273273
}
274274

src/nodes/audio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::core::registry::Registry;
66
use crate::core::resource::get_resource_file;
77
use crate::nodes::spatial::{SPATIAL_ASPECT_ALIAS_INFO, Spatial, Transform};
88
use color_eyre::eyre::eyre;
9-
use glam::{Vec4Swizzles, vec3};
9+
use glam::Vec4Swizzles;
1010
use parking_lot::Mutex;
1111
use stardust_xr::values::ResourceID;
1212

@@ -60,7 +60,7 @@ impl Sound {
6060
}
6161
}
6262
if self.instance.lock().is_none() && self.play.lock().take().is_some() {
63-
let instance = sound.play(vec3(0.0, 0.0, 0.0), Some(self.volume));
63+
let instance = sound.play([0.0; 3], Some(self.volume));
6464
self.instance.lock().replace(instance);
6565
}
6666
if let Some(instance) = self.instance.lock().deref_mut() {

src/nodes/drawable/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ pub fn draw(token: &MainThreadToken) {
2828
match QUEUED_SKYTEX.lock().take() {
2929
Some(Some(skytex)) => {
3030
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
31-
Renderer::skytex(skytex.tex);
31+
Renderer::sky_tex(skytex.tex);
3232
}
3333
}
3434
Some(None) => {
35-
Renderer::skytex(DEFAULT_SKYTEX.get().unwrap());
35+
Renderer::sky_tex(DEFAULT_SKYTEX.get().unwrap());
3636
}
3737
None => {}
3838
}
3939
match QUEUED_SKYLIGHT.lock().take() {
4040
Some(Some(skylight)) => {
4141
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
42-
Renderer::skylight(skylight.sh);
42+
Renderer::sky_light(skylight.sh);
4343
}
4444
}
4545
Some(None) => {
46-
Renderer::skylight(*DEFAULT_SKYLIGHT.get().unwrap());
46+
Renderer::sky_light(*DEFAULT_SKYLIGHT.get().unwrap());
4747
}
4848
None => {}
4949
}

src/nodes/drawable/model.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ impl Hash for MaterialWrapper {
3232
self.0.get_shader().0.as_ptr().hash(state);
3333
for param in self.0.get_all_param_info() {
3434
param.name.hash(state);
35-
param.to_string().hash(state);
35+
(param.get_type() as u32).hash(state);
36+
let data = self
37+
.0
38+
.get_all_param_info()
39+
.get_data(&param.name, param.get_type());
40+
data.hash(state);
3641
}
3742
self.0.get_chain().map(MaterialWrapper).hash(state)
3843
}
@@ -53,7 +58,14 @@ impl PartialEq for MaterialWrapper {
5358
else {
5459
return false;
5560
};
56-
if self_param.to_string() != other_param.to_string() {
61+
let Some(self_param) = self
62+
.0
63+
.get_all_param_info()
64+
.get_data(self_param.get_name(), self_param.get_type())
65+
else {
66+
return false;
67+
};
68+
if self_param != other_param {
5769
return false;
5870
}
5971
}
@@ -118,10 +130,10 @@ impl MaterialParameter {
118130
params.set_float(parameter_name, *val);
119131
}
120132
MaterialParameter::Vec2(val) => {
121-
params.set_vec2(parameter_name, Vec2::from(*val));
133+
params.set_vector2(parameter_name, Vec2::from(*val));
122134
}
123135
MaterialParameter::Vec3(val) => {
124-
params.set_vec3(parameter_name, Vec3::from(*val));
136+
params.set_vector3(parameter_name, Vec3::from(*val));
125137
}
126138
MaterialParameter::Color(val) => {
127139
params.set_color(
@@ -172,7 +184,7 @@ impl ModelPart {
172184
let mut parts = model.parts.lock();
173185
let parent_part = part
174186
.get_parent()
175-
.and_then(|part| parts.iter().find(|p| p.id == *part.get_id()));
187+
.and_then(|part| parts.iter().find(|p| p.id == part.get_id()));
176188

177189
let stardust_model_part = model.space.node()?;
178190
let client = stardust_model_part.get_client()?;
@@ -215,7 +227,7 @@ impl ModelPart {
215227
});
216228

217229
let model_part = Arc::new(ModelPart {
218-
id: *part.get_id(),
230+
id: part.get_id(),
219231
path: part_path,
220232
space,
221233
model: Arc::downgrade(model),
@@ -353,7 +365,7 @@ impl Model {
353365
MODEL_REGISTRY.add_raw(&model);
354366

355367
// technically doing this in anything but the main thread isn't a good idea but dangit we need those model nodes ASAP
356-
let sk_model = SKModel::copy(SKModel::from_file(
368+
let sk_model = SKModel::copy(&SKModel::from_file(
357369
pending_model_path.to_str().unwrap(),
358370
None,
359371
)?);

src/nodes/drawable/text.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,38 @@ use std::{
1616
use stereokit_rust::{
1717
font::Font,
1818
sk::MainThreadToken,
19-
system::{TextAlign, TextFit, TextStyle as SkTextStyle},
19+
system::{Align, Pivot, TextFit, TextStyle as SkTextStyle},
2020
util::{Color32, Color128},
2121
};
2222

2323
use super::{TextAspect, TextStyle};
2424

2525
static TEXT_REGISTRY: Registry<Text> = Registry::new();
2626

27-
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> TextAlign {
27+
fn convert_pivot(x_align: super::XAlign, y_align: super::YAlign) -> Pivot {
2828
match (x_align, y_align) {
29-
(super::XAlign::Left, super::YAlign::Top) => TextAlign::TopLeft,
30-
(super::XAlign::Left, super::YAlign::Center) => TextAlign::CenterLeft,
31-
(super::XAlign::Left, super::YAlign::Bottom) => TextAlign::BottomLeft,
32-
(super::XAlign::Center, super::YAlign::Top) => TextAlign::Center,
33-
(super::XAlign::Center, super::YAlign::Center) => TextAlign::Center,
34-
(super::XAlign::Center, super::YAlign::Bottom) => TextAlign::BottomCenter,
35-
(super::XAlign::Right, super::YAlign::Top) => TextAlign::TopRight,
36-
(super::XAlign::Right, super::YAlign::Center) => TextAlign::CenterRight,
37-
(super::XAlign::Right, super::YAlign::Bottom) => TextAlign::BottomRight,
29+
(super::XAlign::Left, super::YAlign::Top) => Pivot::TopLeft,
30+
(super::XAlign::Left, super::YAlign::Center) => Pivot::CenterLeft,
31+
(super::XAlign::Left, super::YAlign::Bottom) => Pivot::BottomLeft,
32+
(super::XAlign::Center, super::YAlign::Top) => Pivot::Center,
33+
(super::XAlign::Center, super::YAlign::Center) => Pivot::Center,
34+
(super::XAlign::Center, super::YAlign::Bottom) => Pivot::BottomCenter,
35+
(super::XAlign::Right, super::YAlign::Top) => Pivot::TopRight,
36+
(super::XAlign::Right, super::YAlign::Center) => Pivot::CenterRight,
37+
(super::XAlign::Right, super::YAlign::Bottom) => Pivot::BottomRight,
38+
}
39+
}
40+
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> Align {
41+
match (x_align, y_align) {
42+
(super::XAlign::Left, super::YAlign::Top) => Align::TopLeft,
43+
(super::XAlign::Left, super::YAlign::Center) => Align::CenterLeft,
44+
(super::XAlign::Left, super::YAlign::Bottom) => Align::BottomLeft,
45+
(super::XAlign::Center, super::YAlign::Top) => Align::Center,
46+
(super::XAlign::Center, super::YAlign::Center) => Align::Center,
47+
(super::XAlign::Center, super::YAlign::Bottom) => Align::BottomCenter,
48+
(super::XAlign::Right, super::YAlign::Top) => Align::TopRight,
49+
(super::XAlign::Right, super::YAlign::Center) => Align::CenterRight,
50+
(super::XAlign::Right, super::YAlign::Bottom) => Align::BottomRight,
3851
}
3952
}
4053

@@ -104,7 +117,7 @@ impl Text {
104117
)),
105118
data.bounds
106119
.as_ref()
107-
.map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)),
120+
.map(|b| convert_pivot(b.anchor_align_x, b.anchor_align_y)),
108121
Some(convert_align(data.text_align_x, data.text_align_y)),
109122
None,
110123
None,
@@ -124,7 +137,7 @@ impl Text {
124137
)),
125138
data.bounds
126139
.as_ref()
127-
.map(|b| convert_align(b.anchor_align_x, b.anchor_align_y)),
140+
.map(|b| convert_pivot(b.anchor_align_x, b.anchor_align_y)),
128141
Some(convert_align(data.text_align_x, data.text_align_y)),
129142
None,
130143
None,

src/objects/input/sk_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ impl SkController {
9797
);
9898
self.material
9999
.color_tint(if self.capture_manager.capture.upgrade().is_none() {
100-
Color128::new_rgb(1.0, 1.0, 1.0)
100+
Color128::rgb(1.0, 1.0, 1.0)
101101
} else {
102-
Color128::new_rgb(0.0, 1.0, 0.75)
102+
Color128::rgb(0.0, 1.0, 0.75)
103103
});
104104
self.model.draw(
105105
token,

src/objects/input/sk_hand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ impl SkHand {
141141
hand.elbow = None;
142142

143143
let hand_color = if self.capture_manager.capture.upgrade().is_none() {
144-
Color128::new_rgb(1.0, 1.0, 1.0)
144+
Color128::rgb(1.0, 1.0, 1.0)
145145
} else {
146-
Color128::new_rgb(0.0, 1.0, 0.75)
146+
Color128::rgb(0.0, 1.0, 0.75)
147147
};
148148
material.color_tint(hand_color);
149149
}

0 commit comments

Comments
 (0)