OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/vr/VRPose.h" | 5 #include "modules/vr/VRPose.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
11 DOMFloat32Array* mojoArrayToFloat32Array(const mojo::WTFArray<float>& vec) | 11 DOMFloat32Array* mojoArrayToFloat32Array(const mojo::WTFArray<float>& vec) |
12 { | 12 { |
13 if (vec.is_null()) | 13 if (vec.is_null()) |
14 return nullptr; | 14 return nullptr; |
15 | 15 |
16 return DOMFloat32Array::create(&(vec.front()), vec.size()); | 16 return DOMFloat32Array::create(&(vec.front()), vec.size()); |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 VRPose::VRPose() | 21 VRPose::VRPose() |
22 : m_timestamp(0.0) | |
23 { | 22 { |
24 } | 23 } |
25 | 24 |
26 void VRPose::setPose(const device::blink::VRPosePtr& state) | 25 void VRPose::setPose(const device::blink::VRPosePtr& state) |
27 { | 26 { |
28 if (state.is_null()) | 27 if (state.is_null()) |
29 return; | 28 return; |
30 | 29 |
31 m_timestamp = state->timestamp; | |
32 m_orientation = mojoArrayToFloat32Array(state->orientation); | 30 m_orientation = mojoArrayToFloat32Array(state->orientation); |
33 m_position = mojoArrayToFloat32Array(state->position); | 31 m_position = mojoArrayToFloat32Array(state->position); |
34 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); | 32 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); |
35 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); | 33 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); |
36 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); | 34 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); |
37 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); | 35 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); |
38 } | 36 } |
39 | 37 |
40 DEFINE_TRACE(VRPose) | 38 DEFINE_TRACE(VRPose) |
41 { | 39 { |
42 visitor->trace(m_orientation); | 40 visitor->trace(m_orientation); |
43 visitor->trace(m_position); | 41 visitor->trace(m_position); |
44 visitor->trace(m_angularVelocity); | 42 visitor->trace(m_angularVelocity); |
45 visitor->trace(m_linearVelocity); | 43 visitor->trace(m_linearVelocity); |
46 visitor->trace(m_angularAcceleration); | 44 visitor->trace(m_angularAcceleration); |
47 visitor->trace(m_linearAcceleration); | 45 visitor->trace(m_linearAcceleration); |
48 } | 46 } |
49 | 47 |
50 } // namespace blink | 48 } // namespace blink |
OLD | NEW |