mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
make far-grab it's own action (which is just like spring) in order to avoid bootstrapping own avatar
This commit is contained in:
parent
2dab3069da
commit
b1dc5be316
8 changed files with 144 additions and 26 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
|
||||
#include <avatar/AvatarActionHold.h>
|
||||
#include <avatar/AvatarActionFarGrab.h>
|
||||
#include <ObjectActionOffset.h>
|
||||
#include <ObjectActionSpring.h>
|
||||
#include <ObjectActionTravelOriented.h>
|
||||
|
@ -35,6 +36,8 @@ EntityDynamicPointer interfaceDynamicFactory(EntityDynamicType type, const QUuid
|
|||
return std::make_shared<ObjectActionTravelOriented>(id, ownerEntity);
|
||||
case DYNAMIC_TYPE_HINGE:
|
||||
return std::make_shared<ObjectConstraintHinge>(id, ownerEntity);
|
||||
case DYNAMIC_TYPE_FAR_GRAB:
|
||||
return std::make_shared<AvatarActionFarGrab>(id, ownerEntity);
|
||||
}
|
||||
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown entity dynamic type");
|
||||
|
|
61
interface/src/avatar/AvatarActionFarGrab.cpp
Normal file
61
interface/src/avatar/AvatarActionFarGrab.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// AvatarActionFarGrab.cpp
|
||||
// interface/src/avatar/
|
||||
//
|
||||
// Created by Seth Alves 2017-4-14
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AvatarActionFarGrab.h"
|
||||
|
||||
AvatarActionFarGrab::AvatarActionFarGrab(const QUuid& id, EntityItemPointer ownerEntity) :
|
||||
ObjectActionSpring(id, ownerEntity) {
|
||||
_type = DYNAMIC_TYPE_FAR_GRAB;
|
||||
#if WANT_DEBUG
|
||||
qCDebug(physics) << "AvatarActionFarGrab::AvatarActionFarGrab";
|
||||
#endif
|
||||
}
|
||||
|
||||
AvatarActionFarGrab::~AvatarActionFarGrab() {
|
||||
#if WANT_DEBUG
|
||||
qCDebug(physics) << "AvatarActionFarGrab::~AvatarActionFarGrab";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QByteArray AvatarActionFarGrab::serialize() const {
|
||||
QByteArray serializedActionArguments;
|
||||
QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly);
|
||||
|
||||
dataStream << DYNAMIC_TYPE_FAR_GRAB;
|
||||
dataStream << getID();
|
||||
dataStream << AvatarActionFarGrab::springVersion;
|
||||
|
||||
serializeParameters(dataStream);
|
||||
|
||||
return serializedActionArguments;
|
||||
}
|
||||
|
||||
void AvatarActionFarGrab::deserialize(QByteArray serializedArguments) {
|
||||
QDataStream dataStream(serializedArguments);
|
||||
|
||||
EntityDynamicType type;
|
||||
dataStream >> type;
|
||||
assert(type == getType());
|
||||
|
||||
QUuid id;
|
||||
dataStream >> id;
|
||||
assert(id == getID());
|
||||
|
||||
uint16_t serializationVersion;
|
||||
dataStream >> serializationVersion;
|
||||
if (serializationVersion != AvatarActionFarGrab::springVersion) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
deserializeParameters(serializedArguments, dataStream);
|
||||
}
|
27
interface/src/avatar/AvatarActionFarGrab.h
Normal file
27
interface/src/avatar/AvatarActionFarGrab.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// AvatarActionFarGrab.h
|
||||
// interface/src/avatar/
|
||||
//
|
||||
// Created by Seth Alves 2017-4-14
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AvatarActionFarGrab_h
|
||||
#define hifi_AvatarActionFarGrab_h
|
||||
|
||||
#include <EntityItem.h>
|
||||
#include <ObjectActionSpring.h>
|
||||
|
||||
class AvatarActionFarGrab : public ObjectActionSpring {
|
||||
public:
|
||||
AvatarActionFarGrab(const QUuid& id, EntityItemPointer ownerEntity);
|
||||
virtual ~AvatarActionFarGrab();
|
||||
|
||||
QByteArray serialize() const override;
|
||||
virtual void deserialize(QByteArray serializedArguments) override;
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarActionFarGrab_h
|
|
@ -114,6 +114,9 @@ EntityDynamicType EntityDynamicInterface::dynamicTypeFromString(QString dynamicT
|
|||
if (normalizedDynamicTypeString == "hinge") {
|
||||
return DYNAMIC_TYPE_HINGE;
|
||||
}
|
||||
if (normalizedDynamicTypeString == "fargrab") {
|
||||
return DYNAMIC_TYPE_FAR_GRAB;
|
||||
}
|
||||
|
||||
qCDebug(entities) << "Warning -- EntityDynamicInterface::dynamicTypeFromString got unknown dynamic-type name"
|
||||
<< dynamicTypeString;
|
||||
|
@ -134,6 +137,8 @@ QString EntityDynamicInterface::dynamicTypeToString(EntityDynamicType dynamicTyp
|
|||
return "travel-oriented";
|
||||
case DYNAMIC_TYPE_HINGE:
|
||||
return "hinge";
|
||||
case DYNAMIC_TYPE_FAR_GRAB:
|
||||
return "far-grab";
|
||||
}
|
||||
assert(false);
|
||||
return "none";
|
||||
|
|
|
@ -30,7 +30,8 @@ enum EntityDynamicType {
|
|||
DYNAMIC_TYPE_SPRING = 2000,
|
||||
DYNAMIC_TYPE_HOLD = 3000,
|
||||
DYNAMIC_TYPE_TRAVEL_ORIENTED = 4000,
|
||||
DYNAMIC_TYPE_HINGE = 5000
|
||||
DYNAMIC_TYPE_HINGE = 5000,
|
||||
DYNAMIC_TYPE_FAR_GRAB = 6000
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1882,6 +1882,16 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
|
|||
}
|
||||
i++;
|
||||
}
|
||||
QList<EntityDynamicPointer> farGrabActions = getActionsOfType(DYNAMIC_TYPE_FAR_GRAB);
|
||||
i = farGrabActions.begin();
|
||||
while (i != farGrabActions.end()) {
|
||||
EntityDynamicPointer action = *i;
|
||||
if (action->isMine()) {
|
||||
iAmHoldingThis = true;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (iAmHoldingThis) {
|
||||
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
|
||||
|
|
|
@ -259,14 +259,7 @@ QVariantMap ObjectActionSpring::getArguments() {
|
|||
return arguments;
|
||||
}
|
||||
|
||||
QByteArray ObjectActionSpring::serialize() const {
|
||||
QByteArray serializedActionArguments;
|
||||
QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly);
|
||||
|
||||
dataStream << DYNAMIC_TYPE_SPRING;
|
||||
dataStream << getID();
|
||||
dataStream << ObjectActionSpring::springVersion;
|
||||
|
||||
QByteArray ObjectActionSpring::serializeParameters(QDataStream& dataStream) const {
|
||||
withReadLock([&] {
|
||||
dataStream << _desiredPositionalTarget;
|
||||
dataStream << _linearTimeScale;
|
||||
|
@ -277,10 +270,41 @@ QByteArray ObjectActionSpring::serialize() const {
|
|||
dataStream << localTimeToServerTime(_expires);
|
||||
dataStream << _tag;
|
||||
});
|
||||
}
|
||||
|
||||
QByteArray ObjectActionSpring::serialize() const {
|
||||
QByteArray serializedActionArguments;
|
||||
QDataStream dataStream(&serializedActionArguments, QIODevice::WriteOnly);
|
||||
|
||||
dataStream << DYNAMIC_TYPE_SPRING;
|
||||
dataStream << getID();
|
||||
dataStream << ObjectActionSpring::springVersion;
|
||||
|
||||
serializeParameters(dataStream);
|
||||
|
||||
return serializedActionArguments;
|
||||
}
|
||||
|
||||
void ObjectActionSpring::deserializeParameters(QByteArray serializedArguments, QDataStream& dataStream) {
|
||||
withWriteLock([&] {
|
||||
dataStream >> _desiredPositionalTarget;
|
||||
dataStream >> _linearTimeScale;
|
||||
dataStream >> _positionalTargetSet;
|
||||
|
||||
dataStream >> _desiredRotationalTarget;
|
||||
dataStream >> _angularTimeScale;
|
||||
dataStream >> _rotationalTargetSet;
|
||||
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
_expires = serverTimeToLocalTime(serverExpires);
|
||||
|
||||
dataStream >> _tag;
|
||||
|
||||
_active = true;
|
||||
});
|
||||
}
|
||||
|
||||
void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
||||
QDataStream dataStream(serializedArguments);
|
||||
|
||||
|
@ -299,21 +323,5 @@ void ObjectActionSpring::deserialize(QByteArray serializedArguments) {
|
|||
return;
|
||||
}
|
||||
|
||||
withWriteLock([&] {
|
||||
dataStream >> _desiredPositionalTarget;
|
||||
dataStream >> _linearTimeScale;
|
||||
dataStream >> _positionalTargetSet;
|
||||
|
||||
dataStream >> _desiredRotationalTarget;
|
||||
dataStream >> _angularTimeScale;
|
||||
dataStream >> _rotationalTargetSet;
|
||||
|
||||
quint64 serverExpires;
|
||||
dataStream >> serverExpires;
|
||||
_expires = serverTimeToLocalTime(serverExpires);
|
||||
|
||||
dataStream >> _tag;
|
||||
|
||||
_active = true;
|
||||
});
|
||||
deserializeParameters(serializedArguments, dataStream);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ protected:
|
|||
glm::vec3 _angularVelocityTarget;
|
||||
|
||||
virtual bool prepareForSpringUpdate(btScalar deltaTimeStep);
|
||||
|
||||
QByteArray serializeParameters(QDataStream& dataStream) const;
|
||||
void deserializeParameters(QByteArray serializedArguments, QDataStream& dataStream);
|
||||
};
|
||||
|
||||
#endif // hifi_ObjectActionSpring_h
|
||||
|
|
Loading…
Reference in a new issue