aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/objects/heightfield.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src_testbed/objects/heightfield.rs')
-rw-r--r--src_testbed/objects/heightfield.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/src_testbed/objects/heightfield.rs b/src_testbed/objects/heightfield.rs
index 0815592..913a732 100644
--- a/src_testbed/objects/heightfield.rs
+++ b/src_testbed/objects/heightfield.rs
@@ -1,15 +1,16 @@
-#[cfg(feature = "dim3")]
-use crate::objects::node::{self, GraphicsNode};
use kiss3d::window::Window;
use na::{self, Point3};
-use ncollide::shape;
-#[cfg(feature = "dim3")]
-use ncollide::transformation::ToTriMesh;
+use parry::shape;
use rapier::geometry::{ColliderHandle, ColliderSet};
#[cfg(feature = "dim2")]
use rapier::math::Point;
#[cfg(feature = "dim3")]
-use rapier::math::Vector;
+use {
+ crate::objects::node::{self, GraphicsNode},
+ kiss3d::resource::Mesh,
+ rapier::math::Vector,
+ std::cell::RefCell,
+};
pub struct HeightField {
color: Point3<f32>,
@@ -25,7 +26,7 @@ impl HeightField {
#[cfg(feature = "dim2")]
pub fn new(
collider: ColliderHandle,
- heightfield: &shape::HeightField<f32>,
+ heightfield: &shape::HeightField,
color: Point3<f32>,
_: &mut Window,
) -> HeightField {
@@ -47,16 +48,23 @@ impl HeightField {
#[cfg(feature = "dim3")]
pub fn new(
collider: ColliderHandle,
- heightfield: &shape::HeightField<f32>,
+ heightfield: &shape::HeightField,
color: Point3<f32>,
window: &mut Window,
) -> HeightField {
- let mesh = heightfield.to_trimesh(());
+ use std::rc::Rc;
+
+ let (vertices, indices) = heightfield.to_trimesh();
+ let indices = indices
+ .into_iter()
+ .map(|idx| Point3::new(idx[0] as u16, idx[1] as u16, idx[2] as u16))
+ .collect();
+ let mesh = Mesh::new(vertices, indices, None, None, false);
let mut res = HeightField {
color,
base_color: color,
- gfx: window.add_trimesh(mesh, Vector::repeat(1.0)),
+ gfx: window.add_mesh(Rc::new(RefCell::new(mesh)), Vector::repeat(1.0)),
collider: collider,
};