mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 15:23:05 +02:00
Fix simple traits vector bad init
This commit is contained in:
parent
8ff47659d3
commit
483b7a67b9
2 changed files with 20 additions and 7 deletions
|
@ -28,9 +28,10 @@
|
||||||
namespace AvatarTraits {
|
namespace AvatarTraits {
|
||||||
template<typename T, T defaultValue>
|
template<typename T, T defaultValue>
|
||||||
class AssociatedTraitValues {
|
class AssociatedTraitValues {
|
||||||
|
using SimpleTypesArray = std::array<T, NUM_SIMPLE_TRAITS>;
|
||||||
public:
|
public:
|
||||||
// constructor that pre-fills _simpleTypes with the default value specified by the template
|
// constructor that pre-fills _simpleTypes with the default value specified by the template
|
||||||
AssociatedTraitValues() : _simpleTypes(FirstInstancedTrait, defaultValue) {}
|
AssociatedTraitValues() { std::fill(_simpleTypes.begin(), _simpleTypes.end(), defaultValue); }
|
||||||
|
|
||||||
/// inserts the given value for the given simple trait type
|
/// inserts the given value for the given simple trait type
|
||||||
void insert(TraitType type, T value) { _simpleTypes[type] = value; }
|
void insert(TraitType type, T value) { _simpleTypes[type] = value; }
|
||||||
|
@ -71,12 +72,12 @@ namespace AvatarTraits {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// const iterators for the vector of simple type values
|
/// const iterators for the vector of simple type values
|
||||||
typename std::vector<T>::const_iterator simpleCBegin() const { return _simpleTypes.cbegin(); }
|
typename SimpleTypesArray::const_iterator simpleCBegin() const { return _simpleTypes.cbegin(); }
|
||||||
typename std::vector<T>::const_iterator simpleCEnd() const { return _simpleTypes.cend(); }
|
typename SimpleTypesArray::const_iterator simpleCEnd() const { return _simpleTypes.cend(); }
|
||||||
|
|
||||||
/// non-const iterators for the vector of simple type values
|
/// non-const iterators for the vector of simple type values
|
||||||
typename std::vector<T>::iterator simpleBegin() { return _simpleTypes.begin(); }
|
typename SimpleTypesArray::iterator simpleBegin() { return _simpleTypes.begin(); }
|
||||||
typename std::vector<T>::iterator simpleEnd() { return _simpleTypes.end(); }
|
typename SimpleTypesArray::iterator simpleEnd() { return _simpleTypes.end(); }
|
||||||
|
|
||||||
struct TraitWithInstances {
|
struct TraitWithInstances {
|
||||||
TraitType traitType;
|
TraitType traitType;
|
||||||
|
@ -96,7 +97,7 @@ namespace AvatarTraits {
|
||||||
typename std::vector<TraitWithInstances>::iterator instancedEnd() { return _instancedTypes.end(); }
|
typename std::vector<TraitWithInstances>::iterator instancedEnd() { return _instancedTypes.end(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T> _simpleTypes;
|
SimpleTypesArray _simpleTypes;
|
||||||
|
|
||||||
/// return the iterator to the matching TraitWithInstances object for a given instanced trait type
|
/// return the iterator to the matching TraitWithInstances object for a given instanced trait type
|
||||||
typename std::vector<TraitWithInstances>::iterator instancesForTrait(TraitType traitType) {
|
typename std::vector<TraitWithInstances>::iterator instancesForTrait(TraitType traitType) {
|
||||||
|
|
|
@ -14,19 +14,31 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
namespace AvatarTraits {
|
namespace AvatarTraits {
|
||||||
enum TraitType : int8_t {
|
enum TraitType : int8_t {
|
||||||
|
// Null trait
|
||||||
NullTrait = -1,
|
NullTrait = -1,
|
||||||
SkeletonModelURL,
|
|
||||||
|
// Simple traits
|
||||||
|
SkeletonModelURL = 0,
|
||||||
|
|
||||||
|
|
||||||
|
// Instanced traits
|
||||||
FirstInstancedTrait,
|
FirstInstancedTrait,
|
||||||
AvatarEntity = FirstInstancedTrait,
|
AvatarEntity = FirstInstancedTrait,
|
||||||
Grab,
|
Grab,
|
||||||
|
|
||||||
|
// Traits count
|
||||||
TotalTraitTypes
|
TotalTraitTypes
|
||||||
};
|
};
|
||||||
|
const int NUM_SIMPLE_TRAITS = (int)FirstInstancedTrait;
|
||||||
|
const int NUM_INSTANCED_TRAITS = (int)TotalTraitTypes - (int)FirstInstancedTrait;
|
||||||
|
const int NUM_TRAITS = (int)TotalTraitTypes;
|
||||||
|
|
||||||
using TraitInstanceID = QUuid;
|
using TraitInstanceID = QUuid;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue