mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-10 08:12:08 +02:00
Bypass position updates from mixer
This commit is contained in:
parent
889e033048
commit
ff319ebd95
6 changed files with 61 additions and 25 deletions
|
@ -81,7 +81,7 @@ AvatarManager::AvatarManager(QObject* parent) :
|
|||
|
||||
const float AVATAR_TRANSIT_MAX_DISTANCE = 1.0f;
|
||||
const int AVATAR_TRANSIT_FRAME_COUNT = 20;
|
||||
const int AVATAR_TRANSIT_FRAMES_PER_METER = 5;
|
||||
const int AVATAR_TRANSIT_FRAMES_PER_METER = 15;
|
||||
|
||||
_avatarTransitMaxDistance = AVATAR_TRANSIT_MAX_DISTANCE;
|
||||
_avatarTransitFrameCount = AVATAR_TRANSIT_FRAME_COUNT;
|
||||
|
@ -136,7 +136,23 @@ void AvatarManager::setSpace(workload::SpacePointer& space ) {
|
|||
void AvatarManager::updateMyAvatar(float deltaTime) {
|
||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "AvatarManager::updateMyAvatar()");
|
||||
|
||||
/*
|
||||
std::shared_ptr<AvatarTransit> transit = _myAvatar->getTransit();
|
||||
bool initTransit = false;
|
||||
if (!transit->isTransiting()) {
|
||||
initTransit = transit->update(_myAvatar->getWorldPosition(), _avatarTransitFrameCount, _avatarTransitFramesPerMeter, _avatarTransitDistanceBased, _avatarTransitMaxDistance);
|
||||
if (initTransit) {
|
||||
_myAvatar->getSkeletonModel()->getRig().restoreAnimation();
|
||||
_myAvatar->getSkeletonModel()->getRig().overrideAnimation("https://hifi-content.s3.amazonaws.com/luis/test_scripts/transit_app/animations/teleport01_warp.fbx", 30, false, 0, 49);
|
||||
}
|
||||
}
|
||||
if (transit->isTransiting()){
|
||||
glm::vec3 nextPosition;
|
||||
if (!transit->getNextPosition(nextPosition)) {
|
||||
_myAvatar->getSkeletonModel()->getRig().restoreAnimation();
|
||||
}
|
||||
}
|
||||
*/
|
||||
_myAvatar->update(deltaTime);
|
||||
render::Transaction transaction;
|
||||
_myAvatar->updateRenderItem(transaction);
|
||||
|
@ -259,17 +275,8 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
numAvatarsUpdated++;
|
||||
}
|
||||
// smooth other avatars positions
|
||||
{
|
||||
float oneFrameDistance = glm::length(avatar->_globalPosition - avatar->_lastPosition);
|
||||
if (oneFrameDistance > _avatarTransitMaxDistance) {
|
||||
avatar->_transit.start(avatar->_lastPosition, avatar->_globalPosition, _avatarTransitFrameCount, _avatarTransitFramesPerMeter, _avatarTransitDistanceBased);
|
||||
}
|
||||
if (avatar->_transit.isTransiting()) {
|
||||
glm::vec3 nextPosition;
|
||||
if (avatar->_transit.getNextPosition(nextPosition)) {
|
||||
avatar->setWorldPosition(nextPosition);
|
||||
}
|
||||
}
|
||||
{
|
||||
avatar->_transit.update(avatar->_globalPosition, _avatarTransitFrameCount, _avatarTransitFramesPerMeter, _avatarTransitDistanceBased, _avatarTransitMaxDistance);
|
||||
}
|
||||
|
||||
avatar->simulate(deltaTime, inView);
|
||||
|
|
|
@ -237,7 +237,7 @@ private:
|
|||
|
||||
// Other avatars smooth transit global configuration
|
||||
|
||||
bool _avatarTransitDistanceBased { false };
|
||||
bool _avatarTransitDistanceBased { true };
|
||||
float _avatarTransitMaxDistance;
|
||||
int _avatarTransitFrameCount;
|
||||
int _avatarTransitFramesPerMeter;
|
||||
|
|
|
@ -610,7 +610,6 @@ void MyAvatar::updateChildCauterization(SpatiallyNestablePointer object, bool ca
|
|||
|
||||
void MyAvatar::simulate(float deltaTime) {
|
||||
PerformanceTimer perfTimer("simulate");
|
||||
|
||||
animateScaleChanges(deltaTime);
|
||||
|
||||
setFlyingEnabled(getFlyingEnabled());
|
||||
|
@ -1012,7 +1011,7 @@ glm::vec3 MyAvatar::worldToJointPoint(const glm::vec3& position, const int joint
|
|||
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
||||
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot);
|
||||
} else {
|
||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
//qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
}
|
||||
}
|
||||
glm::vec3 modelOffset = position - jointPos;
|
||||
|
@ -1034,7 +1033,7 @@ glm::vec3 MyAvatar::worldToJointDirection(const glm::vec3& worldDir, const int j
|
|||
glm::quat MyAvatar::worldToJointRotation(const glm::quat& worldRot, const int jointIndex) const {
|
||||
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
//qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
}
|
||||
glm::quat jointSpaceRot = glm::inverse(jointRot) * worldRot;
|
||||
return jointSpaceRot;
|
||||
|
@ -1048,7 +1047,7 @@ glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int
|
|||
if (_skeletonModel->getJointPositionInWorldFrame(jointIndex, jointPos)) {
|
||||
_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot);
|
||||
} else {
|
||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
//qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1060,7 @@ glm::vec3 MyAvatar::jointToWorldPoint(const glm::vec3& jointSpacePos, const int
|
|||
glm::vec3 MyAvatar::jointToWorldDirection(const glm::vec3& jointSpaceDir, const int jointIndex) const {
|
||||
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
//qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
}
|
||||
glm::vec3 worldDir = jointRot * jointSpaceDir;
|
||||
return worldDir;
|
||||
|
@ -1070,7 +1069,7 @@ glm::vec3 MyAvatar::jointToWorldDirection(const glm::vec3& jointSpaceDir, const
|
|||
glm::quat MyAvatar::jointToWorldRotation(const glm::quat& jointSpaceRot, const int jointIndex) const {
|
||||
glm::quat jointRot = getWorldOrientation();//default value if no or invalid joint specified
|
||||
if ((jointIndex != -1) && (!_skeletonModel->getJointRotationInWorldFrame(jointIndex, jointRot))) {
|
||||
qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
//qWarning() << "Invalid joint index specified: " << jointIndex;
|
||||
}
|
||||
glm::quat worldRot = jointRot * jointSpaceRot;
|
||||
return worldRot;
|
||||
|
|
|
@ -113,6 +113,16 @@ void Avatar::setShowNamesAboveHeads(bool show) {
|
|||
showNamesAboveHeads = show;
|
||||
}
|
||||
|
||||
bool AvatarTransit::update(const glm::vec3& avatarPosition, int totalFrames, int framesPerMeter, bool isDistanceBased, float maxDistance) {
|
||||
glm::vec3 currentPosition = _isTransiting ? _currentPosition : avatarPosition;
|
||||
float oneFrameDistance = glm::length(currentPosition - _lastPosition);
|
||||
if (oneFrameDistance > maxDistance && !_isTransiting) {
|
||||
start(_lastPosition, currentPosition, totalFrames, framesPerMeter, isDistanceBased);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AvatarTransit::start(const glm::vec3& startPosition, const glm::vec3& endPosition, int totalFrames, int framesPerMeter, bool isDistanceBased) {
|
||||
_startPosition = startPosition;
|
||||
_endPosition = endPosition;
|
||||
|
@ -140,6 +150,7 @@ void AvatarTransit::calculateSteps(int stepCount) {
|
|||
}
|
||||
|
||||
bool AvatarTransit::getNextPosition(glm::vec3& nextPosition) {
|
||||
_lastPosition = _currentPosition;
|
||||
int lastIdx = (int)_transitSteps.size() - 1;
|
||||
_isTransiting = _step < lastIdx;
|
||||
if (_isTransiting) {
|
||||
|
@ -482,6 +493,18 @@ void Avatar::relayJointDataToChildren() {
|
|||
void Avatar::simulate(float deltaTime, bool inView) {
|
||||
PROFILE_RANGE(simulation, "simulate");
|
||||
|
||||
if (_transit.isTransiting()) {
|
||||
glm::vec3 nextPosition;
|
||||
if (_transit.getNextPosition(nextPosition)) {
|
||||
// setWorldPosition(nextPosition);
|
||||
_globalPosition = nextPosition;
|
||||
_globalPositionChanged = usecTimestampNow();
|
||||
if (!hasParent()) {
|
||||
setLocalPosition(nextPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_simulationRate.increment();
|
||||
if (inView) {
|
||||
_simulationInViewRate.increment();
|
||||
|
@ -492,7 +515,7 @@ void Avatar::simulate(float deltaTime, bool inView) {
|
|||
PROFILE_RANGE(simulation, "updateJoints");
|
||||
if (inView) {
|
||||
Head* head = getHead();
|
||||
if (_hasNewJointData) {
|
||||
if (true) {
|
||||
_skeletonModel->getRig().copyJointsFromJointData(_jointData);
|
||||
glm::mat4 rootTransform = glm::scale(_skeletonModel->getScale()) * glm::translate(_skeletonModel->getOffset());
|
||||
_skeletonModel->getRig().computeExternalPoses(rootTransform);
|
||||
|
@ -517,7 +540,6 @@ void Avatar::simulate(float deltaTime, bool inView) {
|
|||
_skeletonModel->simulate(deltaTime, false);
|
||||
}
|
||||
_skeletonModelSimulationRate.increment();
|
||||
_lastPosition = _globalPosition;
|
||||
}
|
||||
|
||||
// update animation for display name fade in/out
|
||||
|
|
|
@ -53,9 +53,13 @@ class Texture;
|
|||
class AvatarTransit {
|
||||
public:
|
||||
AvatarTransit() {};
|
||||
bool update(const glm::vec3& avatarPosition, int totalFrames, int framesPerMeter, bool isDistanceBased, float maxDistance);
|
||||
void start(const glm::vec3& startPosition, const glm::vec3& endPosition, int totalFrames, int framesPerMeter, bool isDistanceBased);
|
||||
bool getNextPosition(glm::vec3& nextPosition);
|
||||
bool isTransiting() { return _isTransiting; };
|
||||
glm::vec3 getCurrentPosition() { return _currentPosition; };
|
||||
int getCurrentStep() { return _step; };
|
||||
|
||||
private:
|
||||
void calculateSteps(int stepCount);
|
||||
bool _isTransiting{ false };
|
||||
|
@ -63,7 +67,8 @@ private:
|
|||
glm::vec3 _endPosition;
|
||||
glm::vec3 _currentPosition;
|
||||
std::vector<glm::vec3> _transitSteps;
|
||||
int _step{ 0 };
|
||||
glm::vec3 _lastPosition;
|
||||
int _step { 0 };
|
||||
};
|
||||
|
||||
class Avatar : public AvatarData, public scriptable::ModelProvider {
|
||||
|
@ -377,6 +382,8 @@ public:
|
|||
|
||||
virtual scriptable::ScriptableModelBase getScriptableModel() override;
|
||||
|
||||
std::shared_ptr<AvatarTransit> getTransit() { return std::make_shared<AvatarTransit>(_transit); };
|
||||
|
||||
signals:
|
||||
void targetScaleChanged(float targetScale);
|
||||
|
||||
|
@ -534,7 +541,7 @@ protected:
|
|||
bool _isFading { false };
|
||||
bool _reconstructSoftEntitiesJointMap { false };
|
||||
float _modelScale { 1.0f };
|
||||
glm::vec3 _lastPosition;
|
||||
|
||||
AvatarTransit _transit;
|
||||
|
||||
|
||||
|
|
|
@ -247,6 +247,7 @@ AvatarSharedPointer AvatarHashMap::parseAvatarData(QSharedPointer<ReceivedMessag
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// have the matching (or new) avatar parse the data from the packet
|
||||
int bytesRead = avatar->parseDataFromBuffer(byteArray);
|
||||
message->seek(positionBeforeRead + bytesRead);
|
||||
|
@ -297,7 +298,6 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer<ReceivedMessage>
|
|||
// In this case, the "sendingNode" is the Avatar Mixer.
|
||||
avatar->processAvatarIdentity(message->getMessage(), identityChanged, displayNameChanged);
|
||||
_replicas.processAvatarIdentity(identityUUID, message->getMessage(), identityChanged, displayNameChanged);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,6 +310,7 @@ void AvatarHashMap::processBulkAvatarTraits(QSharedPointer<ReceivedMessage> mess
|
|||
// grab the avatar so we can ask it to process trait data
|
||||
bool isNewAvatar;
|
||||
auto avatar = newOrExistingAvatar(avatarID, sendingNode, isNewAvatar);
|
||||
|
||||
// read the first trait type for this avatar
|
||||
AvatarTraits::TraitType traitType;
|
||||
message->readPrimitive(&traitType);
|
||||
|
|
Loading…
Reference in a new issue