Skip to content

Commit

Permalink
Merge pull request #40 from mattatz/develop
Browse files Browse the repository at this point in the history
0.1.42
  • Loading branch information
mattatz authored Dec 20, 2024
2 parents 2c834ea + a40623b commit 9a02904
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "curvo"
version = "0.1.41"
version = "0.1.42"
authors = ["Masatatsu Nakamura <[email protected]"]
edition = "2021"
keywords = ["nurbs", "modeling", "graphics", "3d"]
Expand Down Expand Up @@ -28,7 +28,7 @@ bevy = { version = "0.15.0", optional = true }
bevy_egui = { version = "0.31.1", optional = true }
bevy-inspector-egui = { version = "0.28.0", optional = true }
bevy_infinite_grid = { version = "0.14.0", optional = true }
bevy_normal_material = { version = "0.7.0", optional = true }
bevy_normal_material = { version = "0.7.1", optional = true }
bevy_panorbit_camera = { version = "0.21.1", optional = true }
bevy_points = { version = "0.7.0", optional = true }
argmin = "0.10.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/closest_point_on_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn setup(
);

let vertices = tess.points().iter().map(|pt| (*pt).into()).collect();
let normals = tess.normals().iter().map(|n| (-n).into()).collect();
let normals = tess.normals().iter().map(|n| (*n).into()).collect();
let uvs = tess.uvs().iter().map(|uv| (*uv).into()).collect();
let indices = tess
.faces()
Expand Down Expand Up @@ -137,9 +137,9 @@ fn setup(
(0..N)
.map(|j| {
let x = i as f64 - hn;
let z = (rng.gen::<f64>() - 0.5) * 2.;
let y = j as f64 - hn;
Point4::new(x, z, y, 1.)
let y = (rng.gen::<f64>() - 0.5) * 2.;
let z = (j as f64) - hn;
Point4::new(x, y, z, 1.)
})
.collect_vec()
})
Expand Down
6 changes: 2 additions & 4 deletions examples/intersect_surface_curve.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::f32::consts::FRAC_PI_2;

use bevy::{
color::palettes::css::TOMATO,
prelude::*,
Expand Down Expand Up @@ -76,7 +74,7 @@ fn setup(
.map(|j| {
let x = i as f64 - hn;
let y = (rng.gen::<f64>() - 0.5) * 2.;
let z = j as f64 - hn;
let z = (j as f64) - hn;
Point4::new(x, y, z, 1.)
})
.collect_vec()
Expand All @@ -86,6 +84,7 @@ fn setup(

commands.spawn((
Mesh3d(meshes.add(surface_2_mesh(&surface, None))),
// Mesh3d(meshes.add(surface_2_regular_mesh(&surface, 64, 64))),
MeshMaterial3d(normal_materials.add(NormalMaterial {
opacity: 0.35,
cull_mode: None,
Expand Down Expand Up @@ -201,7 +200,6 @@ fn setup(
z_axis_color: Color::BLACK,
..Default::default()
},
transform: Transform::from_rotation(Quat::from_rotation_x(FRAC_PI_2)),
..Default::default()
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/surface/nurbs_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ where
let ioff = iu * (divs_v + 1);
(0..divs_v).flat_map(move |iv| {
[
[ioff + iv, ioff + iv + 1, ioff + iv + divs_v + 2],
[ioff + iv, ioff + iv + divs_v + 2, ioff + iv + divs_v + 1],
[ioff + iv, ioff + iv + divs_v + 2, ioff + iv + 1],
[ioff + iv, ioff + iv + divs_v + 1, ioff + iv + divs_v + 2],
]
})
})
Expand Down
29 changes: 11 additions & 18 deletions src/tessellation/surface_tessellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,19 @@ where

match uvs.len() {
4 => {
self.faces.push([ids[0], ids[3], ids[1]]);
self.faces.push([ids[3], ids[2], ids[1]]);
self.faces.push([ids[0], ids[1], ids[3]]);
self.faces.push([ids[3], ids[1], ids[2]]);
}
5 => {
let il = ids.len();
self.faces.push([
ids[split_id],
ids[(split_id + 2) % il],
ids[(split_id + 1) % il],
]);
self.faces.push([
ids[(split_id + 4) % il],
ids[(split_id + 3) % il],
ids[split_id],
]);
self.faces.push([
ids[split_id],
ids[(split_id + 3) % il],
ids[(split_id + 2) % il],
]);
let a = ids[split_id];
let b = ids[(split_id + 1) % il];
let c = ids[(split_id + 2) % il];
let d = ids[(split_id + 3) % il];
let e = ids[(split_id + 4) % il];
self.faces.push([a, b, c]);
self.faces.push([a, d, e]);
self.faces.push([a, c, d]);
}
n => {
let center = node.center(surface);
Expand All @@ -115,7 +108,7 @@ where
let mut j = n - 1;
let mut i = 0;
while i < n {
self.faces.push([center_index, ids[i], ids[j]]);
self.faces.push([center_index, ids[j], ids[i]]);
j = i;
i += 1;
}
Expand Down

0 comments on commit 9a02904

Please sign in to comment.