Skip to content

Commit

Permalink
mesh with_material & trigger_delta
Browse files Browse the repository at this point in the history
  • Loading branch information
samsartor committed Nov 15, 2017
1 parent 65105ce commit c4c07bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ pub struct Mesh<R: Resources, T: Vertex, M> {
pub mat: M,
}

impl<R: Resources, T: Vertex, M> Mesh<R, T, M> {
/// Set the material of this mesh (usually just textures)
pub fn with_material<N>(self, mat: N) -> Mesh<R, T, N> {
Mesh {
slice: self.slice,
buf: self.buf,
prim: self.prim,
mat: mat,
}
}
}

impl<T: Vertex, M> MeshSource<T, M> {
/// Upload this mesh to the GPU.
pub fn upload<R: Resources, F: FactoryExt<R>>(self, f: &mut F) -> Mesh<R, T, M> {
Expand Down
5 changes: 5 additions & 0 deletions src/vr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ fn pose_transform(ctr: &VRPose) -> Option<Isometry3<f32>> {
}

/// A structure for tracking the state of a vive controller.
#[derive(Clone, Debug)]
pub struct ViveController {
/// The controller that updates this state object
pub is: ControllerRef,
Expand All @@ -384,6 +385,8 @@ pub struct ViveController {
pub pose_delta: Isometry3<f32>,
/// How far is the trigger pulled
pub trigger: f64,
/// The change in the trigger between the second most and most recent updates
pub trigger_delta: f64,
/// The last touched location on the circular pad
pub pad: Point2<f64>,
/// The change in touch location on the circular pad between the second most and most recent updates
Expand All @@ -404,6 +407,7 @@ impl Default for ViveController {
pose: na::one(),
pose_delta: na::one(),
trigger: 0.,
trigger_delta: 0.,
pad: Point2::origin(),
pad_delta: na::zero(),
pad_touched: false,
Expand Down Expand Up @@ -447,6 +451,7 @@ impl ViveController {
self.pad_delta = na::zero();
}

self.trigger_delta = cont.axes[2] - self.trigger;
self.trigger = cont.axes[2];
self.menu = cont.buttons[0].pressed;
self.grip = cont.buttons[1].pressed;
Expand Down

0 comments on commit c4c07bc

Please sign in to comment.