Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/flocking_duck.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setup():
duck = gltf.geometry("LOD3spShape")

p = create_particles(
geometry=duck,
duck,
attributes=[
Attribute.position(),
Attribute.rotation(),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/flocking_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def setup():
directional_light((0.95, 0.9, 0.85), 800.0)

p = create_particles(
capacity=BOID_COUNT,
BOID_COUNT,
attributes=[
Attribute.position(),
Attribute.rotation(),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup():
for z in range(10):
positions.extend([x - 4.5, y - 4.5, z - 4.5])

p = create_particles(capacity=capacity, attributes=[Attribute.position()])
p = create_particles(capacity, attributes=[Attribute.position()])
pos_buf = p.buffer("position")
pos_buf.write(positions)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup():

source = Geometry.sphere(5.0, 32, 24)
p = create_particles(
geometry=source,
source,
attributes=[Attribute.position(), Attribute.uv(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup():
mode_3d()

p = create_particles(
capacity=N,
N,
attributes=[
Attribute.position(),
Attribute.color(),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setup():

capacity = 2000
p = create_particles(
capacity=capacity,
capacity,
attributes=[Attribute.position(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_emit_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setup():
# so declare them (all built-in here). `velocity`/`age` are built-ins now, so
# no custom `Attribute(...)` is needed.
p = create_particles(
capacity=CAPACITY,
CAPACITY,
attributes=[
Attribute.position(),
Attribute.velocity(),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_from_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup():

source = Geometry.sphere(5.0, 32, 24)
p = create_particles(
geometry=source,
source,
attributes=[Attribute.position(), Attribute.uv(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_gpu_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setup():
window_title("gpu index")
mode_3d()

p = create_particles(capacity=NX * NY, attributes=[Attribute.position()])
p = create_particles(NX * NY, attributes=[Attribute.position()])
idx = p.index_buffer((NX - 1) * (NY - 1) * 6)
gen = create_compute(load_shader("shaders/gen_surface.wesl"))
gen.set(indices=idx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup():
mode_3d()

p = create_particles(
capacity=NX * NY,
NX * NY,
attributes=[Attribute.position(), Attribute.color(), Attribute.normal()],
)
idx = p.index_buffer((NX - 1) * (NY - 1) * 6)
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setup():

capacity = 800
p = create_particles(
capacity=capacity,
capacity,
attributes=[
Attribute.position(),
Attribute.color(),
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup():
mode_3d()

p = create_particles(
capacity=N,
N,
attributes=[Attribute.position()],
)
p.buffer("position").write([list(knot(i / N * tau, 0.0)) for i in range(N)])
Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/examples/particles_lissajous.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def setup():
window_title(f"Lissajous — all points connected — {N:,} pts")
mode_3d()

p = create_particles(capacity=N, attributes=[Attribute.position(), Attribute.color()])
p = create_particles(N, attributes=[Attribute.position(), Attribute.color()])
# One line = 2 vertices; up to N*MAX_LINKS lines.
edges = create_particles(
capacity=N * MAX_LINKS * 2, attributes=[Attribute.position(), Attribute.color()]
N * MAX_LINKS * 2, attributes=[Attribute.position(), Attribute.color()]
)
idx = edges.index_buffer(N * MAX_LINKS * 2) # link fills indices + the dynamic count

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup():

source = Geometry.sphere(5.0, 32, 24)
p = create_particles(
geometry=source,
source,
attributes=[Attribute.position(), Attribute.uv(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_plexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setup():
mode_3d()

p = create_particles(
capacity=N,
N,
attributes=[Attribute.position(), Attribute.velocity(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup():
mode_3d()

p = create_particles(
capacity=COUNT,
COUNT,
attributes=[Attribute.position()],
)

Expand Down
4 changes: 2 additions & 2 deletions crates/processing_pyo3/examples/particles_scatter_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setup():
particle = Geometry.sphere(0.15, 4, 3)

p = create_particles(
capacity=CAPACITY,
CAPACITY,
attributes=[
Attribute.position(),
Attribute.scale(),
Expand All @@ -45,7 +45,7 @@ def draw():
seed = (int(elapsed_time * 1000.0) ^ 0xC0FFEE) & 0xFFFFFFFF
scatter.set(seed=seed)
p.emit_gpu(BURST, scatter)
p.apply(MAP, a="scale", op=AFFINE, scale=0.985, offset=0.0)
p.apply(MAP, "scale", op=AFFINE, scale=0.985, offset=0.0)


run()
4 changes: 2 additions & 2 deletions crates/processing_pyo3/examples/particles_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def setup():
rest = Attribute("rest", AttributeFormat.Float3)
sphere = Geometry.sphere(1.5, 96, 64)
p = create_particles(
geometry=sphere,
sphere,
attributes=[
Attribute.position(),
rest,
],
)
p.apply(MAP, a=Attribute.position(), out=rest, op=AFFINE, scale=1.0, offset=0.0)
p.apply(MAP, Attribute.position(), out=rest, op=AFFINE, scale=1.0, offset=0.0)


def draw():
Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setup():
directional_light((0.0, 0.0, 1.0), 1000.0, position=Vec3.Z, look_at=Vec3.ZERO)

p = create_particles(
geometry=Geometry.grid(GRID, GRID, GRID, SPACING),
Geometry.grid(GRID, GRID, GRID, SPACING),
attributes=[Attribute.position(), Attribute.uv(), Attribute.color()],
)

Expand Down
2 changes: 1 addition & 1 deletion crates/processing_pyo3/examples/particles_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setup():
window_title(f"Particle surface — {N:,}-vertex Mobius strip")
mode_3d()

p = create_particles(capacity=N, attributes=[Attribute.position()])
p = create_particles(N, attributes=[Attribute.position()])


def draw():
Expand Down
3 changes: 1 addition & 2 deletions crates/processing_pyo3/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,7 @@ impl Geometry {
Ok(Self { entity })
}

/// lattice centered at the origin; topology is `POINTS`, intended as a
/// position source for `Particles(geometry=...)` rather than rasterized.
/// A point lattice centered at the origin, to seed `create_particles(geometry)`.
#[staticmethod]
#[pyo3(signature = (nx, ny, nz, spacing=1.0))]
pub fn grid(nx: u32, ny: u32, nz: u32, spacing: f32) -> PyResult<Self> {
Expand Down
13 changes: 5 additions & 8 deletions crates/processing_pyo3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,18 +1626,15 @@ pub mod mewnala {
Ok(window)
}

/// Creates a GPU particle system (Processing `createParticles`). `attributes`
/// defaults to `position`; other built-in attributes (`velocity`, `color`,
/// `scale`, `life`, `age`, ...) and declared custom ones materialize on
/// demand when you call `buffer("name")`.
/// Creates a GPU particle system (Processing `createParticles`) from a count or a `Geometry`.
/// Attributes are created on first use.
#[pyfunction]
#[pyo3(signature = (capacity=None, attributes=None, geometry=None))]
#[pyo3(signature = (source, attributes=None))]
fn create_particles(
capacity: Option<u32>,
source: &Bound<'_, PyAny>,
attributes: Option<Vec<PyRef<'_, super::particles::Attribute>>>,
geometry: Option<&Geometry>,
) -> PyResult<super::particles::Particles> {
super::particles::Particles::create(capacity, attributes, geometry)
super::particles::Particles::create(source, attributes)
}

/// Creates a compute pass from a shader (Processing-style `createCompute`).
Expand Down
Loading
Loading