Skip to content

Commit d4c2e5e

Browse files
committed
Mesh -> Geometry
1 parent b75067d commit d4c2e5e

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

crates/processing_pyo3/examples/animated_mesh.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
from processing import *
22
from math import sin, cos
33

4-
mesh = None
4+
geometry = None
55
grid_size = 20
66
spacing = 10.0
77
offset = (grid_size * spacing) / 2.0;
88
time = 0.0
99

1010
def setup():
11-
global mesh
11+
global geometry
1212
size(800, 600)
1313
mode_3d()
14-
mesh = Mesh()
14+
geometry = Geometry()
1515
for z in range(grid_size):
1616
for x in range(grid_size):
1717
px = x * spacing - offset
1818
pz = z * spacing - offset
19-
mesh.color(x/grid_size, 0.5, z/grid_size, 1.0)
20-
mesh.normal(0.0, 1.0, 0.0)
21-
mesh.vertex(px, 0.0, pz)
19+
geometry.color(x/grid_size, 0.5, z/grid_size, 1.0)
20+
geometry.normal(0.0, 1.0, 0.0)
21+
geometry.vertex(px, 0.0, pz)
2222

2323
for z in range(grid_size-1):
2424
for x in range(grid_size-1):
@@ -27,17 +27,17 @@ def setup():
2727
bl = (z + 1) * grid_size + x
2828
br = bl + 1
2929

30-
mesh.index(tl)
31-
mesh.index(bl)
32-
mesh.index(tr)
30+
geometry.index(tl)
31+
geometry.index(bl)
32+
geometry.index(tr)
3333

34-
mesh.index(tr)
35-
mesh.index(bl)
36-
mesh.index(br)
34+
geometry.index(tr)
35+
geometry.index(bl)
36+
geometry.index(br)
3737

3838

3939
def draw():
40-
global mesh
40+
global geometry
4141
global grid_size
4242
global offset
4343
global spacing
@@ -53,9 +53,9 @@ def draw():
5353
px = x * spacing - offset
5454
pz = z * spacing - offset
5555
wave = sin(px * 0.1 + time) * cos(pz * 0.1 + time) * 20.0
56-
mesh.set_vertex(idx, px, wave, pz)
56+
geometry.set_vertex(idx, px, wave, pz)
5757

58-
draw_mesh(mesh)
58+
draw_geometry(geometry)
5959

6060
time += 0.05
6161

crates/processing_pyo3/src/graphics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Drop for Image {
3636
}
3737

3838
#[pyclass(unsendable)]
39-
pub struct Mesh {
39+
pub struct Geometry {
4040
entity: Entity,
4141
}
4242

@@ -62,7 +62,7 @@ impl Topology {
6262
}
6363

6464
#[pymethods]
65-
impl Mesh {
65+
impl Geometry {
6666
#[new]
6767
#[pyo3(signature = (**kwargs))]
6868
pub fn new(kwargs: Option<&Bound<'_, PyDict>>) -> PyResult<Self> {
@@ -244,8 +244,8 @@ impl Graphics {
244244
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))
245245
}
246246

247-
pub fn draw_mesh(&self, mesh: &Mesh) -> PyResult<()> {
248-
graphics_record_command(self.entity, DrawCommand::Geometry(mesh.entity))
247+
pub fn draw_geometry(&self, geometry: &Geometry) -> PyResult<()> {
248+
graphics_record_command(self.entity, DrawCommand::Geometry(geometry.entity))
249249
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))
250250
}
251251

crates/processing_pyo3/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
mod glfw;
1212
mod graphics;
1313

14-
use graphics::{Graphics, Image, Mesh, Topology, get_graphics, get_graphics_mut};
14+
use graphics::{Graphics, Image, Geometry, Topology, get_graphics, get_graphics_mut};
1515
use pyo3::{exceptions::PyRuntimeError, prelude::*, types::PyTuple};
1616

1717
use std::env;
@@ -20,7 +20,7 @@ use std::env;
2020
fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
2121
m.add_class::<Graphics>()?;
2222
m.add_class::<Image>()?;
23-
m.add_class::<Mesh>()?;
23+
m.add_class::<Geometry>()?;
2424
m.add_class::<Topology>()?;
2525
m.add_function(wrap_pyfunction!(size, m)?)?;
2626
m.add_function(wrap_pyfunction!(run, m)?)?;
@@ -39,7 +39,7 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
3939
m.add_function(wrap_pyfunction!(stroke_weight, m)?)?;
4040
m.add_function(wrap_pyfunction!(rect, m)?)?;
4141
m.add_function(wrap_pyfunction!(image, m)?)?;
42-
m.add_function(wrap_pyfunction!(draw_mesh, m)?)?;
42+
m.add_function(wrap_pyfunction!(draw_geometry, m)?)?;
4343

4444
Ok(())
4545
}
@@ -156,9 +156,9 @@ fn draw_box(module: &Bound<'_, PyModule>, x: f32, y: f32, z: f32) -> PyResult<()
156156
}
157157

158158
#[pyfunction]
159-
#[pyo3(pass_module, signature = (mesh))]
160-
fn draw_mesh(module: &Bound<'_, PyModule>, mesh: &Bound<'_, Mesh>) -> PyResult<()> {
161-
get_graphics(module)?.draw_mesh(&*mesh.extract::<PyRef<Mesh>>()?)
159+
#[pyo3(pass_module, signature = (geometry))]
160+
fn draw_geometry(module: &Bound<'_, PyModule>, geometry: &Bound<'_, Geometry>) -> PyResult<()> {
161+
get_graphics(module)?.draw_geometry(&*geometry.extract::<PyRef<Geometry>>()?)
162162
}
163163

164164
#[pyfunction]

0 commit comments

Comments
 (0)