Skip to content

Commit c36b693

Browse files
committed
More cleanup.
1 parent e77dbcd commit c36b693

34 files changed

Lines changed: 286 additions & 243 deletions

crates/processing_ffi/src/lib.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,10 +1830,6 @@ pub extern "C" fn processing_material(window_id: u64, mat_id: u64) {
18301830
error::check(|| graphics_record_command(window_entity, DrawCommand::Material(mat_entity)));
18311831
}
18321832

1833-
// Shader
1834-
1835-
/// Create a shader from WGSL source.
1836-
///
18371833
/// # Safety
18381834
/// - `source` must be non-null
18391835
#[unsafe(no_mangle)]
@@ -1847,8 +1843,6 @@ pub unsafe extern "C" fn processing_shader_create(source: *const std::ffi::c_cha
18471843
.unwrap_or(0)
18481844
}
18491845

1850-
/// Load a shader from a file path.
1851-
///
18521846
/// # Safety
18531847
/// - `path` must be non-null
18541848
#[unsafe(no_mangle)]
@@ -1868,8 +1862,6 @@ pub extern "C" fn processing_shader_destroy(shader_id: u64) {
18681862
error::check(|| shader_destroy(Entity::from_bits(shader_id)));
18691863
}
18701864

1871-
// Buffer
1872-
18731865
#[unsafe(no_mangle)]
18741866
pub extern "C" fn processing_buffer_create(size: u64) -> u64 {
18751867
error::clear_error();
@@ -1878,8 +1870,6 @@ pub extern "C" fn processing_buffer_create(size: u64) -> u64 {
18781870
.unwrap_or(0)
18791871
}
18801872

1881-
/// Create a buffer initialized with data.
1882-
///
18831873
/// # Safety
18841874
/// - `data` must point to `len` valid bytes
18851875
#[unsafe(no_mangle)]
@@ -1891,8 +1881,6 @@ pub unsafe extern "C" fn processing_buffer_create_with_data(data: *const u8, len
18911881
.unwrap_or(0)
18921882
}
18931883

1894-
/// Write data to a buffer.
1895-
///
18961884
/// # Safety
18971885
/// - `data` must point to `len` valid bytes
18981886
#[unsafe(no_mangle)]
@@ -1902,15 +1890,13 @@ pub unsafe extern "C" fn processing_buffer_write(buf_id: u64, data: *const u8, l
19021890
error::check(|| buffer_write(Entity::from_bits(buf_id), bytes));
19031891
}
19041892

1905-
/// Returns the byte length of a buffer, or 0 if not found.
1893+
/// returns the byte length of a buffer, or 0 if not found.
19061894
#[unsafe(no_mangle)]
19071895
pub extern "C" fn processing_buffer_size(buf_id: u64) -> u64 {
19081896
error::clear_error();
19091897
error::check(|| buffer_size(Entity::from_bits(buf_id))).unwrap_or(0)
19101898
}
19111899

1912-
/// Read buffer contents into a caller-provided buffer.
1913-
///
19141900
/// # Safety
19151901
/// - `out` must be valid for writes of `out_len` bytes (may be null if
19161902
/// `out_len == 0`, in which case this acts as a size query).
@@ -1933,8 +1919,6 @@ pub extern "C" fn processing_buffer_destroy(buf_id: u64) {
19331919
error::check(|| buffer_destroy(Entity::from_bits(buf_id)));
19341920
}
19351921

1936-
// Compute
1937-
19381922
#[unsafe(no_mangle)]
19391923
pub extern "C" fn processing_compute_create(shader_id: u64) -> u64 {
19401924
error::clear_error();
@@ -1943,8 +1927,6 @@ pub extern "C" fn processing_compute_create(shader_id: u64) -> u64 {
19431927
.unwrap_or(0)
19441928
}
19451929

1946-
/// Set a float property on a compute shader.
1947-
///
19481930
/// # Safety
19491931
/// - `name` must be non-null
19501932
#[unsafe(no_mangle)]

crates/processing_pyo3/examples/particles_emit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup():
2121
attributes=[Attribute.position(), Attribute.color()],
2222
)
2323

24-
# Park unemitted slots far off-screen until the ring buffer fills.
24+
# park unemitted slots far off-screen until the ring buffer fills.
2525
pos_buf = p.buffer(Attribute.position())
2626
pos_buf.write([1.0e6] * (capacity * 3))
2727

@@ -38,7 +38,6 @@ def draw():
3838
use_material(mat)
3939
particles(p, sphere)
4040

41-
# Emit 4 particles per frame in an outward-spiraling ring.
4241
burst = 4
4342
positions = []
4443
colors = []

crates/processing_pyo3/examples/particles_emit_gpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def setup():
148148
],
149149
)
150150

151-
# Park unemitted slots until the spawn kernel fills them.
151+
# park unemitted slots until the spawn kernel fills them.
152152
dead_buf = p.buffer(Attribute.dead())
153153
dead_buf.write([1.0] * CAPACITY)
154154

crates/processing_pyo3/examples/particles_lifecycle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def setup():
7474
attributes=[position_attr, color_attr, scale_attr, dead_attr, age_attr],
7575
)
7676

77-
# Park unemitted slots until the spawn loop fills them.
77+
# park unemitted slots until the spawn loop fills them.
7878
dead_buf = p.buffer(dead_attr)
7979
dead_buf.write([1.0] * capacity)
8080

crates/processing_pyo3/src/compute.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub struct Buffer {
2222
}
2323

2424
impl Buffer {
25-
/// Wrap an existing buffer entity without taking ownership. `Drop` will
26-
/// not destroy it.
25+
/// borrowed wrapper: `Drop` will not destroy the underlying entity.
2726
pub(crate) fn from_entity(entity: Entity, element_type: Option<ShaderValue>) -> Self {
2827
let size = buffer_size(entity).unwrap_or(0);
2928
Self {
@@ -271,8 +270,6 @@ pub struct Compute {
271270
}
272271

273272
impl Compute {
274-
/// Wrap an existing compute entity (e.g., one created by a Rust-side
275-
/// factory like `field_kernel_noise`). Not exposed to Python directly.
276273
pub(crate) fn from_entity(entity: Entity) -> Self {
277274
Self { entity }
278275
}

crates/processing_pyo3/src/graphics.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ impl Geometry {
370370
geometry_vertex_count(self.entity).map_err(|e| PyRuntimeError::new_err(format!("{e}")))
371371
}
372372

373-
/// Retained sphere mesh.
374373
#[staticmethod]
375374
#[pyo3(signature = (radius, sectors=32, stacks=18))]
376375
pub fn sphere(radius: f32, sectors: u32, stacks: u32) -> PyResult<Self> {
@@ -379,18 +378,15 @@ impl Geometry {
379378
Ok(Self { entity })
380379
}
381380

382-
/// Retained box mesh.
383381
#[staticmethod]
384382
pub fn r#box(width: f32, height: f32, depth: f32) -> PyResult<Self> {
385383
let entity = geometry_box(width, height, depth)
386384
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
387385
Ok(Self { entity })
388386
}
389387

390-
/// 3D lattice of `nx * ny * nz` points centered at the origin, with
391-
/// `spacing` units between adjacent points. Topology is `PointList` —
392-
/// typically used as a position source for `Particles(geometry=...)` rather
393-
/// than rasterized directly.
388+
/// lattice centered at the origin; topology is `PointList`, intended as a
389+
/// position source for `Particles(geometry=...)` rather than rasterized.
394390
#[staticmethod]
395391
#[pyo3(signature = (nx, ny, nz, spacing=1.0))]
396392
pub fn grid(nx: u32, ny: u32, nz: u32, spacing: f32) -> PyResult<Self> {

crates/processing_pyo3/src/lib.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub(crate) mod color;
1212
pub(crate) mod compute;
1313
#[cfg(feature = "cuda")]
1414
pub(crate) mod cuda;
15-
pub(crate) mod particles;
1615
mod glfw;
1716
mod gltf;
1817
mod graphics;
@@ -21,6 +20,7 @@ pub(crate) mod material;
2120
pub(crate) mod math;
2221
mod midi;
2322
mod monitor;
23+
pub(crate) mod particles;
2424
pub(crate) mod shader;
2525
mod surface;
2626
mod time;
@@ -332,16 +332,8 @@ mod mewnala {
332332
#[pymodule_export]
333333
use super::Buffer;
334334
#[pymodule_export]
335-
use super::color::PyColor;
336-
#[pymodule_export]
337335
use super::Compute;
338336
#[pymodule_export]
339-
use super::particles::Attribute;
340-
#[pymodule_export]
341-
use super::particles::AttributeFormat;
342-
#[pymodule_export]
343-
use super::particles::Particles;
344-
#[pymodule_export]
345337
use super::Geometry;
346338
#[pymodule_export]
347339
use super::Gltf;
@@ -354,27 +346,35 @@ mod mewnala {
354346
#[pymodule_export]
355347
use super::Material;
356348
#[pymodule_export]
357-
use super::math::PyQuat;
358-
#[pymodule_export]
359-
use super::math::PyVec2;
360-
#[pymodule_export]
361-
use super::math::PyVec3;
362-
#[pymodule_export]
363-
use super::math::PyVec4;
364-
#[pymodule_export]
365349
use super::PyBlendMode;
366350
#[pymodule_export]
367351
use super::Sampler;
368352
#[pymodule_export]
369353
use super::Shader;
370354
#[pymodule_export]
371355
use super::Topology;
356+
#[pymodule_export]
357+
use super::color::PyColor;
372358
#[cfg(feature = "cuda")]
373359
#[pymodule_export]
374360
use super::cuda::CudaImage;
375361
#[pymodule_export]
362+
use super::math::PyQuat;
363+
#[pymodule_export]
364+
use super::math::PyVec2;
365+
#[pymodule_export]
366+
use super::math::PyVec3;
367+
#[pymodule_export]
368+
use super::math::PyVec4;
369+
#[pymodule_export]
376370
use super::monitor::Monitor;
377371
#[pymodule_export]
372+
use super::particles::Attribute;
373+
#[pymodule_export]
374+
use super::particles::AttributeFormat;
375+
#[pymodule_export]
376+
use super::particles::Particles;
377+
#[pymodule_export]
378378
use super::surface::Surface;
379379

380380
// Stroke cap/join
@@ -1351,7 +1351,6 @@ mod mewnala {
13511351
}
13521352
}
13531353

1354-
13551354
#[pyfunction]
13561355
#[pyo3(pass_module, signature = (*args))]
13571356
fn background(module: &Bound<'_, PyModule>, args: &Bound<'_, PyTuple>) -> PyResult<()> {

crates/processing_pyo3/src/material.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ pub(crate) fn py_to_shader_value(value: &Bound<'_, PyAny>) -> PyResult<shader_va
5555
)))
5656
}
5757

58-
// dispatch `albedo=` by python type; may swap the backing asset
5958
fn apply_albedo(entity: Entity, value: &Bound<'_, PyAny>) -> PyResult<()> {
6059
if let Ok(buf) = value.extract::<PyRef<Buffer>>() {
6160
return material_set_albedo_buffer(entity, buf.entity)
6261
.map_err(|e| PyRuntimeError::new_err(format!("{e}")));
6362
}
6463
if let Ok(c) = value.extract::<PyRef<PyColor>>() {
6564
let srgba: bevy::color::Srgba = c.0.into();
66-
return material_set_albedo_color(entity, [srgba.red, srgba.green, srgba.blue, srgba.alpha])
67-
.map_err(|e| PyRuntimeError::new_err(format!("{e}")));
65+
return material_set_albedo_color(
66+
entity,
67+
[srgba.red, srgba.green, srgba.blue, srgba.alpha],
68+
)
69+
.map_err(|e| PyRuntimeError::new_err(format!("{e}")));
6870
}
6971
if let Ok(rgba) = value.extract::<[f32; 4]>() {
7072
return material_set_albedo_color(entity, rgba)
@@ -95,7 +97,6 @@ fn apply_kwargs(entity: Entity, kwargs: &Bound<'_, PyDict>) -> PyResult<()> {
9597

9698
#[pymethods]
9799
impl Material {
98-
/// No args: default PBR. With `shader`: custom material. Kwargs are applied via `set`.
99100
#[new]
100101
#[pyo3(signature = (shader=None, **kwargs))]
101102
pub fn new(shader: Option<&Shader>, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -112,7 +113,6 @@ impl Material {
112113
Ok(Self { entity })
113114
}
114115

115-
/// PBR-lit material. `albedo` accepts a `Color` or a per-particle `Buffer`.
116116
#[staticmethod]
117117
#[pyo3(signature = (**kwargs))]
118118
pub fn pbr(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -123,7 +123,6 @@ impl Material {
123123
Ok(Self { entity })
124124
}
125125

126-
/// Like `pbr` but skips lighting; albedo is the final output color.
127126
#[staticmethod]
128127
#[pyo3(signature = (**kwargs))]
129128
pub fn unlit(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -136,7 +135,6 @@ impl Material {
136135
Ok(Self { entity })
137136
}
138137

139-
/// Set material properties. `albedo` may swap the backing asset; other fields are preserved.
140138
#[pyo3(signature = (**kwargs))]
141139
pub fn set(&self, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<()> {
142140
let Some(kwargs) = kwargs else {

0 commit comments

Comments
 (0)