Overte C++ Documentation
TranslationAccumulator.h
1 //
2 // TranslationAccumulator.h
3 //
4 // Copyright 2017 High Fidelity, Inc.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 //
9 
10 #ifndef hifi_TranslationAccumulator_h
11 #define hifi_TranslationAccumulator_h
12 
13 #include <glm/glm.hpp>
14 
15 class TranslationAccumulator {
16 public:
17  TranslationAccumulator() : _accum(0.0f, 0.0f, 0.0f), _totalWeight(0), _isDirty(false) { }
18 
19  int size() const { return _totalWeight > 0.0f; }
20 
23  void add(const glm::vec3& translation, float weight = 1.0f);
24 
25  glm::vec3 getAverage();
26 
28  bool isDirty() const { return _isDirty; }
29 
31  void clear();
32 
34  void clearAndClean();
35 
36 private:
37  glm::vec3 _accum;
38  float _totalWeight;
39  bool _isDirty;
40 };
41 
42 #endif // hifi_TranslationAccumulator_h