Skip to content

Commit 9732414

Browse files
authored
Fixes (#88)
1 parent 0d1c35e commit 9732414

File tree

10 files changed

+30
-36
lines changed

10 files changed

+30
-36
lines changed

crates/processing_pyo3/assets

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../assets

crates/processing_pyo3/examples/gltf_load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def draw():
3333
r = math.sin(t * 8.0) * 0.5 + 0.5
3434
g = math.sin(t * 8.0 + 2.0) * 0.5 + 0.5
3535
b = math.sin(t * 8.0 + 4.0) * 0.5 + 0.5
36-
duck_mat.set_float4("base_color", r, g, b, 1.0)
36+
duck_mat.set(base_color=[r, g, b, 1.0])
3737

3838
background(25)
3939
use_material(duck_mat)

crates/processing_pyo3/examples/materials.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ def setup():
1212
point_light.position(200.0, 200.0, 400.0)
1313

1414
mat = Material()
15-
mat.set_float("roughness", 0.3)
16-
mat.set_float("metallic", 0.8)
17-
mat.set_float4("base_color", 1.0, 0.85, 0.57, 1.0)
15+
mat.set(roughness=0.3)
16+
mat.set(metallic=0.8)
17+
mat.set(base_color=[1.0, 0.85, 0.57, 1.0])
1818

1919
def draw():
2020
camera_position(0.0, 0.0, 200.0)
2121
camera_look_at(0.0, 0.0, 0.0)
2222
background(12, 12, 18)
2323

2424
use_material(mat)
25-
draw_sphere(50.0)
25+
sphere(50.0)
2626

2727
run()

crates/processing_pyo3/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
4747
m.add_class::<Material>()?;
4848
m.add_class::<Gltf>()?;
4949
m.add_class::<Shader>()?;
50+
m.add_class::<Geometry>()?;
5051
m.add_function(wrap_pyfunction!(gltf::load_gltf, m)?)?;
5152
m.add_function(wrap_pyfunction!(size, m)?)?;
5253
m.add_function(wrap_pyfunction!(run, m)?)?;

crates/processing_render/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,11 @@ fn create_app(config: Config) -> App {
231231
let has_sketch_file = config
232232
.get(ConfigKey::SketchFileName)
233233
.is_some_and(|f| !f.is_empty());
234-
if has_sketch_file {
235-
if let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) {
236-
app.register_asset_source(
237-
"sketch_directory",
238-
AssetSourceBuilder::platform_default(sketch_path, None),
239-
);
240-
}
234+
if has_sketch_file && let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) {
235+
app.register_asset_source(
236+
"sketch_directory",
237+
AssetSourceBuilder::platform_default(sketch_path, None),
238+
);
241239
}
242240

243241
#[cfg(not(target_arch = "wasm32"))]

crates/processing_render/src/material/custom.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,13 @@ pub fn set_property(
245245
}
246246

247247
let param_name = find_param_containing_field(&material.shader, name);
248-
if let Some(param_name) = param_name {
249-
if let Some(param) = material.shader.field_mut(&param_name) {
250-
if let ReflectMut::Struct(s) = param.reflect_mut() {
251-
if let Some(field) = s.field_mut(name) {
252-
field.apply(&*reflect_value);
253-
return Ok(());
254-
}
255-
}
256-
}
248+
if let Some(param_name) = param_name
249+
&& let Some(param) = material.shader.field_mut(&param_name)
250+
&& let ReflectMut::Struct(s) = param.reflect_mut()
251+
&& let Some(field) = s.field_mut(name)
252+
{
253+
field.apply(&*reflect_value);
254+
return Ok(());
257255
}
258256

259257
Err(ProcessingError::UnknownMaterialProperty(name.to_string()))
@@ -281,12 +279,11 @@ fn material_value_to_reflect(value: &MaterialValue) -> Result<Box<dyn PartialRef
281279

282280
fn find_param_containing_field(shader: &DynamicShader, field_name: &str) -> Option<String> {
283281
for i in 0..shader.field_len() {
284-
if let Some(field) = shader.field_at(i) {
285-
if let ReflectRef::Struct(s) = field.reflect_ref() {
286-
if s.field(field_name).is_some() {
287-
return shader.name_at(i).map(|s: &str| s.to_string());
288-
}
289-
}
282+
if let Some(field) = shader.field_at(i)
283+
&& let ReflectRef::Struct(s) = field.reflect_ref()
284+
&& s.field(field_name).is_some()
285+
{
286+
return shader.name_at(i).map(|s: &str| s.to_string());
290287
}
291288
}
292289
None

crates/processing_render/src/surface.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
//! - macOS: `create_surface_macos`
1818
//! - Windows: `create_surface_windows`
1919
//! - WebAssembly: `create_surface_web`
20-
#[cfg(any(target_os = "linux", target_arch = "wasm32"))]
21-
use std::ffi::c_void;
22-
#[cfg(not(target_os = "windows"))]
23-
use std::ptr::NonNull;
2420
2521
use bevy::{
2622
app::{App, Plugin},
@@ -41,6 +37,8 @@ use crate::{
4137
image::{Image, ImageTextures},
4238
};
4339

40+
use std::ptr::NonNull;
41+
4442
#[derive(Component, Debug, Clone)]
4543
pub struct Surface;
4644

@@ -226,15 +224,15 @@ pub fn create_surface_wayland(
226224
HandleError::Unavailable,
227225
));
228226
}
229-
let window_handle_ptr = NonNull::new(window_handle as *mut c_void).unwrap();
227+
let window_handle_ptr = NonNull::new(window_handle as *mut std::ffi::c_void).unwrap();
230228
let window = WaylandWindowHandle::new(window_handle_ptr);
231229

232230
if display_handle == 0 {
233231
return Err(error::ProcessingError::HandleError(
234232
HandleError::Unavailable,
235233
));
236234
}
237-
let display_handle_ptr = NonNull::new(display_handle as *mut c_void).unwrap();
235+
let display_handle_ptr = NonNull::new(display_handle as *mut std::ffi::c_void).unwrap();
238236
let display = WaylandDisplayHandle::new(display_handle_ptr);
239237

240238
spawn_surface(

examples/custom_material.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn sketch() -> error::Result<()> {
2323
let mut glfw_ctx = GlfwContext::new(width, height)?;
2424
init(Config::default())?;
2525

26-
let surface = glfw_ctx.create_surface(width, height, 1.0)?;
26+
let surface = glfw_ctx.create_surface(width, height)?;
2727
let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?;
2828
let box_geo = geometry_box(100.0, 100.0, 100.0)?;
2929

examples/gltf_load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn sketch() -> error::Result<()> {
2525
init(Config::default())?;
2626

2727
let surface = glfw_ctx.create_surface(width, height)?;
28-
let graphics = graphics_create(surface, width, height)?;
28+
let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?;
2929

3030
let gltf = gltf_load(graphics, "gltf/Duck.glb")?;
3131
let duck = gltf_geometry(gltf, "LOD3spShape")?;

0 commit comments

Comments
 (0)