Use strongly typed enum instead of nested alias

This commit is contained in:
Atlante45 2015-12-08 17:30:26 -08:00
parent 78f7935d53
commit 6f29d9e7b8
5 changed files with 14 additions and 17 deletions

View file

@ -47,7 +47,7 @@ const QString AvatarData::FRAME_NAME = "com.highfidelity.recording.AvatarData";
static std::once_flag frameTypeRegistration; static std::once_flag frameTypeRegistration;
AvatarData::AvatarData() : AvatarData::AvatarData() :
SpatiallyNestable(NestableTypes::Avatar, QUuid()), SpatiallyNestable(NestableType::Avatar, QUuid()),
_handPosition(0.0f), _handPosition(0.0f),
_targetScale(1.0f), _targetScale(1.0f),
_handState(0), _handState(0),

View file

@ -36,7 +36,7 @@ int EntityItem::_maxActionsDataSize = 800;
quint64 EntityItem::_rememberDeletedActionTime = 20 * USECS_PER_SECOND; quint64 EntityItem::_rememberDeletedActionTime = 20 * USECS_PER_SECOND;
EntityItem::EntityItem(const EntityItemID& entityItemID) : EntityItem::EntityItem(const EntityItemID& entityItemID) :
SpatiallyNestable(NestableTypes::Entity, entityItemID), SpatiallyNestable(NestableType::Entity, entityItemID),
_type(EntityTypes::Unknown), _type(EntityTypes::Unknown),
_lastSimulated(0), _lastSimulated(0),
_lastUpdated(0), _lastUpdated(0),
@ -1294,7 +1294,7 @@ void EntityItem::updatePosition(const glm::vec3& value) {
setLocalPosition(value); setLocalPosition(value);
_dirtyFlags |= Simulation::DIRTY_POSITION; _dirtyFlags |= Simulation::DIRTY_POSITION;
forEachDescendant([&](SpatiallyNestablePointer object) { forEachDescendant([&](SpatiallyNestablePointer object) {
if (object->getNestableType() == NestableTypes::Entity) { if (object->getNestableType() == NestableType::Entity) {
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object); EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
entity->_dirtyFlags |= Simulation::DIRTY_POSITION; entity->_dirtyFlags |= Simulation::DIRTY_POSITION;
} }
@ -1317,7 +1317,7 @@ void EntityItem::updateRotation(const glm::quat& rotation) {
setLocalOrientation(rotation); setLocalOrientation(rotation);
_dirtyFlags |= Simulation::DIRTY_ROTATION; _dirtyFlags |= Simulation::DIRTY_ROTATION;
forEachDescendant([&](SpatiallyNestablePointer object) { forEachDescendant([&](SpatiallyNestablePointer object) {
if (object->getNestableType() == NestableTypes::Entity) { if (object->getNestableType() == NestableType::Entity) {
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object); EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
entity->_dirtyFlags |= Simulation::DIRTY_ROTATION; entity->_dirtyFlags |= Simulation::DIRTY_ROTATION;
entity->_dirtyFlags |= Simulation::DIRTY_POSITION; entity->_dirtyFlags |= Simulation::DIRTY_POSITION;

View file

@ -219,7 +219,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
// if the entity has children, run UpdateEntityOperator on them. If the children have children, recurse // if the entity has children, run UpdateEntityOperator on them. If the children have children, recurse
QQueue<SpatiallyNestablePointer> toProcess; QQueue<SpatiallyNestablePointer> toProcess;
foreach (SpatiallyNestablePointer child, entity->getChildren()) { foreach (SpatiallyNestablePointer child, entity->getChildren()) {
if (child && child->getNestableType() == NestableTypes::Entity) { if (child && child->getNestableType() == NestableType::Entity) {
toProcess.enqueue(child); toProcess.enqueue(child);
} }
} }
@ -232,7 +232,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
childEntity, newChildBBRelProperties); childEntity, newChildBBRelProperties);
recurseTreeWithOperator(&theChildOperator); recurseTreeWithOperator(&theChildOperator);
foreach (SpatiallyNestablePointer childChild, childEntity->getChildren()) { foreach (SpatiallyNestablePointer childChild, childEntity->getChildren()) {
if (childChild && childChild->getNestableType() == NestableTypes::Entity) { if (childChild && childChild->getNestableType() == NestableType::Entity) {
toProcess.enqueue(childChild); toProcess.enqueue(childChild);
} }
} }

View file

@ -15,7 +15,7 @@
#include "SpatiallyNestable.h" #include "SpatiallyNestable.h"
SpatiallyNestable::SpatiallyNestable(NestableTypes::NestableType nestableType, QUuid id) : SpatiallyNestable::SpatiallyNestable(NestableType nestableType, QUuid id) :
_nestableType(nestableType), _nestableType(nestableType),
_id(id), _id(id),
_transform() { _transform() {

View file

@ -25,17 +25,14 @@ using SpatiallyNestableWeakConstPointer = std::weak_ptr<const SpatiallyNestable>
using SpatiallyNestablePointer = std::shared_ptr<SpatiallyNestable>; using SpatiallyNestablePointer = std::shared_ptr<SpatiallyNestable>;
using SpatiallyNestableConstPointer = std::shared_ptr<const SpatiallyNestable>; using SpatiallyNestableConstPointer = std::shared_ptr<const SpatiallyNestable>;
class NestableTypes { enum class NestableType {
public: Entity,
using NestableType = enum NestableType_t { Avatar
Entity,
Avatar
};
}; };
class SpatiallyNestable : public std::enable_shared_from_this<SpatiallyNestable> { class SpatiallyNestable : public std::enable_shared_from_this<SpatiallyNestable> {
public: public:
SpatiallyNestable(NestableTypes::NestableType nestableType, QUuid id); SpatiallyNestable(NestableType nestableType, QUuid id);
virtual ~SpatiallyNestable() { } virtual ~SpatiallyNestable() { }
virtual const QUuid& getID() const { return _id; } virtual const QUuid& getID() const { return _id; }
@ -88,17 +85,17 @@ public:
virtual void setLocalScale(const glm::vec3& scale); virtual void setLocalScale(const glm::vec3& scale);
QList<SpatiallyNestablePointer> getChildren() const; QList<SpatiallyNestablePointer> getChildren() const;
NestableTypes::NestableType getNestableType() const { return _nestableType; } NestableType getNestableType() const { return _nestableType; }
// this object's frame // this object's frame
virtual const Transform getAbsoluteJointTransformInObjectFrame(int jointIndex) const; virtual const Transform getAbsoluteJointTransformInObjectFrame(int jointIndex) const;
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { assert(false); return glm::quat(); } virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { assert(false); return glm::quat(); }
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { assert(false); return glm::vec3(); } virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { assert(false); return glm::vec3(); }
SpatiallyNestablePointer getThisPointer() const; SpatiallyNestablePointer getThisPointer() const;
protected: protected:
NestableTypes::NestableType _nestableType; // EntityItem or an AvatarData const NestableType _nestableType; // EntityItem or an AvatarData
QUuid _id; QUuid _id;
QUuid _parentID; // what is this thing's transform relative to? QUuid _parentID; // what is this thing's transform relative to?
quint16 _parentJointIndex { 0 }; // which joint of the parent is this relative to? quint16 _parentJointIndex { 0 }; // which joint of the parent is this relative to?