OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "modules/vr/VRPositionState.h" | |
7 | |
8 namespace blink { | |
9 | |
10 namespace { | |
11 | |
12 DOMPoint* VecToDomPoint(const blink::WebVRVector4& vec, bool valid) | |
13 { | |
14 if (valid) | |
15 return DOMPoint::create(vec.x, vec.y, vec.z, vec.w); | |
16 return 0; | |
sof
2015/02/24 12:35:29
nullptr
| |
17 } | |
18 DOMPoint* VecToDomPoint(const blink::WebVRVector3& vec, bool valid) | |
19 { | |
20 if (valid) | |
21 return DOMPoint::create(vec.x, vec.y, vec.z, 0.0); | |
22 return 0; | |
sof
2015/02/24 12:35:29
nullptr
| |
23 } | |
24 | |
25 } | |
sof
2015/02/24 12:35:29
// namespace
| |
26 | |
27 VRPositionState::VRPositionState() | |
28 : m_timeStamp(0.0) | |
29 { | |
30 } | |
31 | |
32 VRPositionState::~VRPositionState() | |
33 { | |
34 } | |
35 | |
36 void VRPositionState::setState(const blink::WebHMDSensorState &state) | |
37 { | |
38 m_timeStamp = state.timestamp; | |
39 m_orientation = VecToDomPoint(state.orientation, state.flags & WebVRSensorSt ateOrientation); | |
40 m_position = VecToDomPoint(state.position, state.flags & WebVRSensorStatePos ition); | |
41 m_angularVelocity = VecToDomPoint(state.angularVelocity, state.flags & WebVR SensorStateAngularVelocity); | |
42 m_linearVelocity = VecToDomPoint(state.linearVelocity, state.flags & WebVRSe nsorStateLinearVelocity); | |
43 m_angularAcceleration = VecToDomPoint(state.angularAcceleration, state.flags & WebVRSensorStateAngularAcceleration); | |
44 m_linearAcceleration = VecToDomPoint(state.linearAcceleration, state.flags & WebVRSensorStateLinearAcceleration); | |
45 } | |
46 | |
47 void VRPositionState::trace(Visitor* visitor) | |
48 { | |
49 visitor->trace(m_orientation); | |
50 visitor->trace(m_position); | |
51 visitor->trace(m_angularVelocity); | |
52 visitor->trace(m_linearVelocity); | |
53 visitor->trace(m_angularAcceleration); | |
54 visitor->trace(m_linearAcceleration); | |
55 } | |
56 | |
57 } // namespace blink | |
OLD | NEW |