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) | 22 : m_timestamp(0.0) |
23 { | 23 { |
24 } | 24 } |
25 | 25 |
26 void VRPose::setPose(const device::blink::VRPosePtr& state) | 26 void VRPose::setPose(const device::blink::VRPosePtr& state) |
27 { | 27 { |
28 if (state.is_null()) | 28 if (state.is_null()) |
29 return; | 29 return; |
30 | 30 |
31 m_timeStamp = state->timestamp; | 31 m_timestamp = state->timestamp; |
32 m_orientation = mojoArrayToFloat32Array(state->orientation); | 32 m_orientation = mojoArrayToFloat32Array(state->orientation); |
33 m_position = mojoArrayToFloat32Array(state->position); | 33 m_position = mojoArrayToFloat32Array(state->position); |
34 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); | 34 m_angularVelocity = mojoArrayToFloat32Array(state->angularVelocity); |
35 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); | 35 m_linearVelocity = mojoArrayToFloat32Array(state->linearVelocity); |
36 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); | 36 m_angularAcceleration = mojoArrayToFloat32Array(state->angularAcceleration); |
37 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); | 37 m_linearAcceleration = mojoArrayToFloat32Array(state->linearAcceleration); |
38 } | 38 } |
39 | 39 |
40 DEFINE_TRACE(VRPose) | 40 DEFINE_TRACE(VRPose) |
41 { | 41 { |
42 visitor->trace(m_orientation); | 42 visitor->trace(m_orientation); |
43 visitor->trace(m_position); | 43 visitor->trace(m_position); |
44 visitor->trace(m_angularVelocity); | 44 visitor->trace(m_angularVelocity); |
45 visitor->trace(m_linearVelocity); | 45 visitor->trace(m_linearVelocity); |
46 visitor->trace(m_angularAcceleration); | 46 visitor->trace(m_angularAcceleration); |
47 visitor->trace(m_linearAcceleration); | 47 visitor->trace(m_linearAcceleration); |
48 } | 48 } |
49 | 49 |
50 } // namespace blink | 50 } // namespace blink |
OLD | NEW |