Small Fixes™
This commit is contained in:
parent
354135949f
commit
be6f8888e0
|
|
@ -5,6 +5,9 @@ edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
glm = "0.2.3"
|
glm = "0.2.3"
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
// perspective projection
|
// perspective projection
|
||||||
let off = (img_coords - img_size * 0.5) / img_size.y;
|
let off = (img_coords - img_size * 0.5) / img_size.y;
|
||||||
let base = vec3(0.0, 0.0, -20.0);
|
let base = vec3(0.0, 0.0, -40.0);
|
||||||
let ray = vec3(off.x, off.y, 1.0);
|
let ray = vec3(off.x, off.y, 2.0);
|
||||||
|
|
||||||
// orthographic projection
|
// orthographic projection
|
||||||
// let off = (img_coords - img_size * 0.5) / SCALE;
|
// let off = (img_coords - img_size * 0.5) / SCALE;
|
||||||
|
|
@ -94,7 +94,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
for f in &mesh {
|
for f in &mesh {
|
||||||
let color = clamp(to_ivec3(f.normal * 120.0 + 128.0), ivec3(0, 0, 0), ivec3(255, 255, 255));
|
let color = clamp(to_ivec3(f.normal * 120.0 + 128.0), ivec3(0, 0, 0), ivec3(255, 255, 255));
|
||||||
let fs = (0..3).map(|k| edge_dist(f.vertices[k], f.vertices[(k + 1) % 3], base, ray));
|
let fs = (0..3).map(|k| edge_dist(f.vertices[k], f.vertices[(k + 1) % 3], base, ray));
|
||||||
if fs.into_iter().all(|f| f > 0.0) {
|
if fs.into_iter().all(|f| f >= 0.0) {
|
||||||
let m = Mat3 { c0: f.vertices[1] - f.vertices[0], c1: f.vertices[2] - f.vertices[0], c2: -ray };
|
let m = Mat3 { c0: f.vertices[1] - f.vertices[0], c1: f.vertices[2] - f.vertices[0], c2: -ray };
|
||||||
if let Some(m) = m.inverse() {
|
if let Some(m) = m.inverse() {
|
||||||
let rel = m * (base - f.vertices[0]);
|
let rel = m * (base - f.vertices[0]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user