Skip to content

Commit e77dbcd

Browse files
committed
Docs and cleanup comments.
1 parent b376c5d commit e77dbcd

24 files changed

Lines changed: 48 additions & 114 deletions

crates/processing_ffi/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,7 @@ pub unsafe extern "C" fn processing_buffer_write(buf_id: u64, data: *const u8, l
19021902
error::check(|| buffer_write(Entity::from_bits(buf_id), bytes));
19031903
}
19041904

1905-
/// Returns the byte length of a buffer, or 0 if the buffer does not exist
1906-
/// (in which case the error is set).
1905+
/// Returns the byte length of a buffer, or 0 if not found.
19071906
#[unsafe(no_mangle)]
19081907
pub extern "C" fn processing_buffer_size(buf_id: u64) -> u64 {
19091908
error::clear_error();
@@ -1966,7 +1965,7 @@ pub unsafe extern "C" fn processing_compute_set_float(
19661965
}
19671966

19681967
/// # Safety
1969-
/// `name` must be a valid null-terminated C string.
1968+
/// - `name` must be non-null
19701969
#[unsafe(no_mangle)]
19711970
pub unsafe extern "C" fn processing_compute_set_buffer(
19721971
compute_id: u64,

crates/processing_pyo3/src/compute.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ impl Buffer {
140140
}
141141

142142
pub fn write(&mut self, values: &Bound<'_, PyAny>) -> PyResult<()> {
143-
// Bytes path skips per-element conversion — the only viable route for
144-
// multi-million-element uploads.
143+
// bytes path skips per-element conversion for large uploads
145144
if let Ok(b) = values.cast::<PyBytes>() {
146145
return buffer_write(self.entity, b.as_bytes().to_vec())
147146
.map_err(|e| PyRuntimeError::new_err(format!("{e}")));

crates/processing_pyo3/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,7 @@ mod mewnala {
689689
}
690690
}
691691

692-
// Color constructors — promoted to top-level so `from mewnala import *`
693-
// exposes `hsva(...)`, `srgb(...)`, etc. directly. Living in a `color`
694-
// submodule conflicted with the Processing-style `color()` function.
692+
// color constructors live at module level: a `color` submodule conflicted with `color()`
695693

696694
#[pyfunction]
697695
fn color_hex(s: &str) -> PyResult<PyColor> {

crates/processing_pyo3/src/material.rs

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

58-
/// Dispatch `albedo=` by Python type to the matching Rust setter. May swap
59-
/// the backing asset; all other StandardMaterial state survives.
58+
// dispatch `albedo=` by python type; may swap the backing asset
6059
fn apply_albedo(entity: Entity, value: &Bound<'_, PyAny>) -> PyResult<()> {
6160
if let Ok(buf) = value.extract::<PyRef<Buffer>>() {
6261
return material_set_albedo_buffer(entity, buf.entity)
@@ -96,8 +95,7 @@ fn apply_kwargs(entity: Entity, kwargs: &Bound<'_, PyDict>) -> PyResult<()> {
9695

9796
#[pymethods]
9897
impl Material {
99-
/// No args: default PBR. With `shader`: custom material. Kwargs are
100-
/// applied via `set` after construction.
98+
/// No args: default PBR. With `shader`: custom material. Kwargs are applied via `set`.
10199
#[new]
102100
#[pyo3(signature = (shader=None, **kwargs))]
103101
pub fn new(shader: Option<&Shader>, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -114,8 +112,7 @@ impl Material {
114112
Ok(Self { entity })
115113
}
116114

117-
/// PBR-lit material. `albedo` accepts a `Color` or a `Buffer` (the latter
118-
/// being per-particle, used with `Particles`).
115+
/// PBR-lit material. `albedo` accepts a `Color` or a per-particle `Buffer`.
119116
#[staticmethod]
120117
#[pyo3(signature = (**kwargs))]
121118
pub fn pbr(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -139,8 +136,7 @@ impl Material {
139136
Ok(Self { entity })
140137
}
141138

142-
/// Patch material properties. `albedo` may swap the backing asset between
143-
/// color and buffer variants; other StandardMaterial fields are preserved.
139+
/// Set material properties. `albedo` may swap the backing asset; other fields are preserved.
144140
#[pyo3(signature = (**kwargs))]
145141
pub fn set(&self, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<()> {
146142
let Some(kwargs) = kwargs else {

crates/processing_pyo3/src/particles.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ impl Attribute {
9797
#[pyclass(unsendable)]
9898
pub struct Particles {
9999
pub(crate) entity: Entity,
100-
/// Name → (entity, format) so `emit(**kwargs)` can route kwargs to the
101-
/// right attribute and pack them into bytes.
100+
// name → (entity, format), used by `emit(**kwargs)` to route kwargs and pack bytes
102101
name_to_attr: HashMap<String, (Entity, AttributeFormat)>,
103102
}
104103

@@ -116,8 +115,7 @@ impl Particles {
116115

117116
#[pymethods]
118117
impl Particles {
119-
/// Pass `capacity` for empty buffers, or `geometry` to seed positions
120-
/// (and matching attributes) from a source mesh. Exactly one is required.
118+
/// Pass `capacity` for empty buffers, or `geometry` to seed from a source mesh.
121119
#[new]
122120
#[pyo3(signature = (capacity=None, attributes=None, geometry=None))]
123121
pub fn new(
@@ -161,8 +159,6 @@ impl Particles {
161159
}
162160

163161
/// Backing `Buffer` for a registered attribute, or `None` if not registered.
164-
/// The element type matches the attribute's format so `read()` returns
165-
/// typed values.
166162
pub fn buffer(&self, attribute: &Attribute) -> PyResult<Option<Buffer>> {
167163
let buf = particles_buffer(self.entity, attribute.entity)
168164
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
@@ -177,13 +173,8 @@ impl Particles {
177173
Ok(buf.map(|e| Buffer::from_entity(e, Some(element_type))))
178174
}
179175

180-
/// Dispatch a compute kernel against these particles' buffers. Buffers
181-
/// are auto-bound by attribute name; kwargs are forwarded to
182-
/// `compute.set(...)`. For example:
183-
///
184-
/// ```python
185-
/// p.apply(noise, scale=0.25, strength=0.02, time=t)
186-
/// ```
176+
/// Dispatch a compute kernel against these particles' buffers. Buffers are
177+
/// auto-bound by attribute name; kwargs are forwarded to `compute.set(...)`.
187178
#[pyo3(signature = (compute, **kwargs))]
188179
pub fn apply(
189180
&self,
@@ -198,12 +189,8 @@ impl Particles {
198189
}
199190

200191
/// Emit `n` particles into the next ring-buffer slots. Per-attribute data
201-
/// is passed as kwargs keyed by attribute name; each value is a flat list
202-
/// of `n * format.float_count()` floats.
203-
///
204-
/// ```python
205-
/// p.emit(50, position=[x0,y0,z0, x1,y1,z1, ...], color=[r0,g0,b0,a0, ...])
206-
/// ```
192+
/// is a kwarg keyed by attribute name; each value is a flat list of
193+
/// `n * format.float_count()` floats.
207194
#[pyo3(signature = (n, **kwargs))]
208195
pub fn emit(&self, n: u32, kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<()> {
209196
let Some(kwargs) = kwargs else {
@@ -235,9 +222,8 @@ impl Particles {
235222
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))
236223
}
237224

238-
/// Emit `n` particles via a GPU kernel. Buffer bindings and a
239-
/// `emit_range: vec4<f32> = (base_slot, n, capacity, 0)` uniform are
240-
/// auto-bound; set any other uniforms via `compute.set(...)` first.
225+
/// Emit `n` particles via a GPU kernel. Auto-binds buffers and an
226+
/// `emit_range: vec4<f32> = (base_slot, n, capacity, 0)` uniform.
241227
pub fn emit_gpu(&self, n: u32, compute: &Compute) -> PyResult<()> {
242228
particles_emit_gpu(self.entity, n, compute.entity)
243229
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))
@@ -257,8 +243,7 @@ pub fn kernel_noise() -> PyResult<Compute> {
257243
}
258244

259245
/// Built-in transform kernel: scale → axis-angle rotate → translate. Uniforms:
260-
/// `translate: vec3`, `rotation_axis: vec3`, `rotation_angle: f32`,
261-
/// `scale: vec3`. Identity defaults are seeded so unset uniforms are no-ops.
246+
/// `translate: vec3`, `rotation_axis: vec3`, `rotation_angle: f32`, `scale: vec3`.
262247
pub fn kernel_transform() -> PyResult<Compute> {
263248
let entity = particles_kernel_transform().map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
264249
Ok(Compute::from_entity(entity))

crates/processing_render/src/compute.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,7 @@ pub fn set_compute_property(
277277
.get_mut(entity)
278278
.map_err(|_| ProcessingError::ComputeNotFound)?;
279279

280-
// Resource values (buffers / textures) bind directly to top-level parameters
281-
// and need a category check. Scalar / vector / matrix values may target
282-
// either a top-level uniform or a nested struct field (e.g. `params.dt`),
283-
// so we let `apply_reflect_field` handle the path resolution itself.
280+
// resources need a category check; scalars/vectors fall through to apply_reflect_field
284281
match value {
285282
ShaderValue::Buffer(buf_entity) => {
286283
let category = compute

crates/processing_render/src/geometry/attribute.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,11 @@ pub struct BuiltinAttributes {
225225
pub normal: Entity,
226226
pub color: Entity,
227227
pub uv: Entity,
228-
/// Per-instance rotation as a quaternion `(x, y, z, w)`. Field-only.
228+
/// Per-instance rotation as a quaternion `(x, y, z, w)`.
229229
pub rotation: Entity,
230-
/// Per-instance scale `(x, y, z)`. Field-only.
230+
/// Per-instance scale `(x, y, z)`.
231231
pub scale: Entity,
232-
/// Per-particle lifecycle flag: `0.0` = alive, non-zero = dead (skipped in
233-
/// preprocessing). Field-only. The pack pass writes this into
234-
/// `MeshCullingData::dead`.
232+
/// Per-particle lifecycle flag: `0.0` = alive, non-zero = dead.
235233
pub dead: Entity,
236234
}
237235

crates/processing_render/src/lib.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,10 +1533,8 @@ pub fn material_set_albedo_color(entity: Entity, color: [f32; 4]) -> error::Resu
15331533
}
15341534

15351535
/// Set the albedo source to a per-particle color buffer (`Float4` per slot,
1536-
/// indexed by `mesh.tag`). If the material is currently plain PBR, swaps the
1537-
/// asset to a `ParticlesMaterial` while preserving every other
1538-
/// `StandardMaterial` field. `base_color` modulates the buffer color, so
1539-
/// leaving it WHITE renders the buffer color verbatim.
1536+
/// indexed by `mesh.tag`). Preserves all other `StandardMaterial` fields;
1537+
/// `base_color` modulates the buffer color.
15401538
pub fn material_set_albedo_buffer(
15411539
entity: Entity,
15421540
color_buffer_entity: Entity,
@@ -1562,7 +1560,6 @@ pub fn material_set_albedo_buffer(
15621560
.0
15631561
.clone();
15641562

1565-
// Already field-buffer-backed: just swap the buffer handle in place.
15661563
if let Ok(handle) = untyped.clone().try_typed::<ParticlesMaterial>() {
15671564
let mut mats = app.world_mut().resource_mut::<Assets<ParticlesMaterial>>();
15681565
let mat = mats
@@ -2092,11 +2089,9 @@ pub fn particles_buffer(entity: Entity, attribute_entity: Entity) -> error::Resu
20922089
})
20932090
}
20942091

2095-
/// GPU-driven emission. Dispatches `compute_entity` over `count` invocations
2096-
/// to initialize the next `count` ring-buffer slots. Auto-binds attribute
2097-
/// buffers (same convention as [`particles_apply`]) and a `vec4<f32>` uniform
2098-
/// `emit_range = (base_slot, count, capacity, 0)` from which the kernel
2099-
/// derives its target slot. CPU-side counterpart: [`particles_emit`].
2092+
/// GPU-driven emission into the next `count` ring-buffer slots. Auto-binds
2093+
/// attribute buffers (same convention as [`particles_apply`]) and an
2094+
/// `emit_range: vec4<f32> = (base_slot, count, capacity, 0)` uniform.
21002095
pub fn particles_emit_gpu(
21012096
particles_entity: Entity,
21022097
count: u32,
@@ -2241,9 +2236,7 @@ pub fn particles_kernel_noise() -> error::Result<Entity> {
22412236

22422237
/// Built-in transform kernel: scale → axis-angle rotate → translate on
22432238
/// `position`. Uniforms: `translate: vec3`, `rotation_axis: vec3`,
2244-
/// `rotation_angle: f32`, `scale: vec3`. Identity defaults are seeded so
2245-
/// any unset parameter behaves as a no-op (without them, default-zero
2246-
/// `scale` would collapse the field to the origin on the first dispatch).
2239+
/// `rotation_angle: f32`, `scale: vec3`. Identity defaults are seeded.
22472240
pub fn particles_kernel_transform() -> error::Result<Entity> {
22482241
let shader = shader_load(particles::kernels::TRANSFORM_PATH)?;
22492242
let entity = compute_create(shader)?;

crates/processing_render/src/material/custom.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ pub fn load_shader(In(path): In<String>, world: &mut World) -> Result<Entity> {
181181
};
182182
use bevy::ecs::system::RunSystemOnce;
183183

184-
// URL-scheme paths (e.g. `embedded://crate/file.wgsl`) parse as-is — they
185-
// already specify their asset source. Otherwise treat as a relative path
186-
// and fall through to the configured asset directory if any.
184+
// url-scheme paths parse as-is; others go through the configured asset dir
187185
let asset_path: AssetPath = if path.contains("://") {
188186
AssetPath::parse(&path).into_owned()
189187
} else {

crates/processing_render/src/particles/kernels/noise.wgsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Per-particle position displacement by sampled 3D value noise.
2-
31
struct Params {
42
scale: f32,
53
strength: f32,

0 commit comments

Comments
 (0)