outline
This commit is contained in:
parent
45c6de5d3c
commit
11a864682a
@ -5,6 +5,8 @@ use strafesnet_deferred_loader::deferred_loader::{MeshDeferredLoader,RenderConfi
|
|||||||
use strafesnet_deferred_loader::mesh::Meshes;
|
use strafesnet_deferred_loader::mesh::Meshes;
|
||||||
use strafesnet_deferred_loader::texture::{RenderConfigs,Texture};
|
use strafesnet_deferred_loader::texture::{RenderConfigs,Texture};
|
||||||
|
|
||||||
|
use vbsp::Plane;
|
||||||
|
|
||||||
use crate::valve_transform;
|
use crate::valve_transform;
|
||||||
|
|
||||||
fn ingest_vertex(
|
fn ingest_vertex(
|
||||||
@ -32,6 +34,22 @@ fn ingest_vertex(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn solve3(c0:&Plane,c1:&Plane,c2:&Plane)->Option<glam::Vec3>{
|
||||||
|
const EPSILON:f32=1.0/1024.0;
|
||||||
|
let n0=glam::Vec3::from_array(c0.normal.into());
|
||||||
|
let n1=glam::Vec3::from_array(c1.normal.into());
|
||||||
|
let n2=glam::Vec3::from_array(c2.normal.into());
|
||||||
|
let n0_n1=n0.cross(n1);
|
||||||
|
let det=n2.dot(n0_n1);
|
||||||
|
if det.abs()<EPSILON{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let d0=c0.dist;
|
||||||
|
let d1=c1.dist;
|
||||||
|
let d2=c2.dist;
|
||||||
|
Some((n1.cross(n2)*d0+n2.cross(n0)*d1+n0.cross(n1)*d2)/det)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert<'a>(
|
pub fn convert<'a>(
|
||||||
bsp:&'a crate::Bsp,
|
bsp:&'a crate::Bsp,
|
||||||
render_config_deferred_loader:&mut RenderConfigDeferredLoader<Cow<'a,str>>,
|
render_config_deferred_loader:&mut RenderConfigDeferredLoader<Cow<'a,str>>,
|
||||||
@ -136,7 +154,7 @@ pub fn convert<'a>(
|
|||||||
let tex=mb.acquire_tex_id(glam::Vec2::ZERO);
|
let tex=mb.acquire_tex_id(glam::Vec2::ZERO);
|
||||||
|
|
||||||
// for each face, determine one edge at a time until you complete the face
|
// for each face, determine one edge at a time until you complete the face
|
||||||
for (face_id,face) in plane_list.iter().enumerate(){
|
for (plane_id,plane0) in plane_list.iter().enumerate(){
|
||||||
// 1. find first edge
|
// 1. find first edge
|
||||||
// 2. follow edges around face
|
// 2. follow edges around face
|
||||||
|
|
||||||
@ -144,8 +162,12 @@ pub fn convert<'a>(
|
|||||||
// 1. pick any two additional planes to make a set of three
|
// 1. pick any two additional planes to make a set of three
|
||||||
// 2. check if any planes occlude the intersection
|
// 2. check if any planes occlude the intersection
|
||||||
// 3. use this test to replace left and right alternating until they are not occluded
|
// 3. use this test to replace left and right alternating until they are not occluded
|
||||||
let mut plane1=&plane_list[(face_id+1).rem_euclid(plane_list.len())];
|
let mut plane1=&plane_list[(plane_id+1).rem_euclid(plane_list.len())];
|
||||||
let mut plane2=&plane_list[(face_id+2).rem_euclid(plane_list.len())];
|
let mut plane2=&plane_list[(plane_id+2).rem_euclid(plane_list.len())];
|
||||||
|
loop{
|
||||||
|
// test if any other faces occlude the intersection
|
||||||
|
solve3(plane0,plane1,plane2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let polygon_groups=model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list));
|
let polygon_groups=model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user