mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +02:00
more work
This commit is contained in:
parent
c9c311e275
commit
6e5e9d3492
5 changed files with 39 additions and 7 deletions
|
@ -499,8 +499,8 @@ void Agent::processAgentAvatar() {
|
||||||
if (!_scriptEngine->isFinished() && _isAvatar) {
|
if (!_scriptEngine->isFinished() && _isAvatar) {
|
||||||
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||||
|
|
||||||
AvatarData::AvatarDataDetail dataDetail = (randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO) ? AvatarData::SendAllData : AvatarData::CullSmallData;
|
//AvatarData::AvatarDataDetail dataDetail = (randFloat() < AVATAR_SEND_FULL_UPDATE_RATIO) ? AvatarData::SendAllData : AvatarData::CullSmallData;
|
||||||
//AvatarData::AvatarDataDetail dataDetail = AvatarData::SendAllData;
|
AvatarData::AvatarDataDetail dataDetail = AvatarData::SendAllData;
|
||||||
quint64 lastSentTime = 0;
|
quint64 lastSentTime = 0;
|
||||||
QVector<JointData>& lastSentJointData = scriptedAvatar->getLastSentJointData();
|
QVector<JointData>& lastSentJointData = scriptedAvatar->getLastSentJointData();
|
||||||
bool distanceAdjust = false;
|
bool distanceAdjust = false;
|
||||||
|
|
|
@ -416,7 +416,7 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
nodeData->incrementAvatarOutOfView();
|
nodeData->incrementAvatarOutOfView();
|
||||||
} else {
|
} else {
|
||||||
detail = distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO
|
detail = distribution(generator) < AVATAR_SEND_FULL_UPDATE_RATIO
|
||||||
? AvatarData::SendAllData : AvatarData::IncludeSmallData;
|
? AvatarData::SendAllData : AvatarData::CullSmallData;
|
||||||
nodeData->incrementAvatarInView();
|
nodeData->incrementAvatarInView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ void AvatarMixer::broadcastAvatarData() {
|
||||||
auto lastEncodeForOther = nodeData->getLastOtherAvatarEncodeTime(otherNode->getUUID());
|
auto lastEncodeForOther = nodeData->getLastOtherAvatarEncodeTime(otherNode->getUUID());
|
||||||
auto lastSentJointsForOther = nodeData->getLastOtherAvatarSentJoints(otherNode->getUUID());
|
auto lastSentJointsForOther = nodeData->getLastOtherAvatarSentJoints(otherNode->getUUID());
|
||||||
bool distanceAdjust = true;
|
bool distanceAdjust = true;
|
||||||
glm::vec3 viewerPosition = otherAvatar.getPosition();
|
glm::vec3 viewerPosition = nodeData->getPosition();
|
||||||
auto bytes = otherAvatar.toByteArray(detail, lastEncodeForOther, lastSentJointsForOther, distanceAdjust, viewerPosition);
|
auto bytes = otherAvatar.toByteArray(detail, lastEncodeForOther, lastSentJointsForOther, distanceAdjust, viewerPosition);
|
||||||
numAvatarDataBytes += avatarPacketList->write(bytes);
|
numAvatarDataBytes += avatarPacketList->write(bytes);
|
||||||
|
|
||||||
|
|
|
@ -57,18 +57,26 @@ void ScriptableAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
_bind.reset();
|
_bind.reset();
|
||||||
_animSkeleton.reset();
|
_animSkeleton.reset();
|
||||||
AvatarData::setSkeletonModelURL(skeletonModelURL);
|
AvatarData::setSkeletonModelURL(skeletonModelURL);
|
||||||
|
//qDebug() << "skeletonModelURL:" << skeletonModelURL;
|
||||||
|
//qDebug() << "_skeletonFBXURL:" << _skeletonFBXURL;
|
||||||
}
|
}
|
||||||
void ScriptableAvatar::update(float deltatime) {
|
void ScriptableAvatar::update(float deltatime) {
|
||||||
|
//qDebug() << __FUNCTION__ << "delta:" << deltatime;
|
||||||
if (_bind.isNull() && !_skeletonFBXURL.isEmpty()) { // AvatarData will parse the .fst, but not get the .fbx skeleton.
|
if (_bind.isNull() && !_skeletonFBXURL.isEmpty()) { // AvatarData will parse the .fst, but not get the .fbx skeleton.
|
||||||
_bind = DependencyManager::get<AnimationCache>()->getAnimation(_skeletonFBXURL);
|
_bind = DependencyManager::get<AnimationCache>()->getAnimation(_skeletonFBXURL);
|
||||||
|
//qDebug() << "_skeletonFBXURL:" << _skeletonFBXURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//qDebug() << "bind:" << _bind << "isLoaded:" << (!_bind.isNull() && _bind->isLoaded());
|
||||||
|
//qDebug() << "_animation:" << _animation << "isLoaded:" << (_animation && _animation->isLoaded());
|
||||||
|
|
||||||
// Run animation
|
// Run animation
|
||||||
if (_animation && _animation->isLoaded() && _animation->getFrames().size() > 0 && !_bind.isNull() && _bind->isLoaded()) {
|
if (_animation && _animation->isLoaded() && _animation->getFrames().size() > 0 && !_bind.isNull() && _bind->isLoaded()) {
|
||||||
if (!_animSkeleton) {
|
if (!_animSkeleton) {
|
||||||
_animSkeleton = std::make_shared<AnimSkeleton>(_bind->getGeometry());
|
_animSkeleton = std::make_shared<AnimSkeleton>(_bind->getGeometry());
|
||||||
}
|
}
|
||||||
float currentFrame = _animationDetails.currentFrame + deltatime * _animationDetails.fps;
|
float currentFrame = _animationDetails.currentFrame + deltatime * _animationDetails.fps;
|
||||||
|
//qDebug() << "currentFrame:" << currentFrame;
|
||||||
if (_animationDetails.loop || currentFrame < _animationDetails.lastFrame) {
|
if (_animationDetails.loop || currentFrame < _animationDetails.lastFrame) {
|
||||||
while (currentFrame >= _animationDetails.lastFrame) {
|
while (currentFrame >= _animationDetails.lastFrame) {
|
||||||
currentFrame -= (_animationDetails.lastFrame - _animationDetails.firstFrame);
|
currentFrame -= (_animationDetails.lastFrame - _animationDetails.firstFrame);
|
||||||
|
@ -107,6 +115,7 @@ void ScriptableAvatar::update(float deltatime) {
|
||||||
if (data.rotation != pose.rot()) {
|
if (data.rotation != pose.rot()) {
|
||||||
data.rotation = pose.rot();
|
data.rotation = pose.rot();
|
||||||
data.rotationSet = true;
|
data.rotationSet = true;
|
||||||
|
//qDebug() << "joint[" << i << "].rotation:" << data.rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,18 @@ bool AvatarData::faceTrackerInfoChangedSince(quint64 time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::getDistanceBasedMinRotationDOT(glm::vec3 viewerPosition) {
|
float AvatarData::getDistanceBasedMinRotationDOT(glm::vec3 viewerPosition) {
|
||||||
return AVATAR_MIN_ROTATION_DOT; // FIXME
|
auto distance = glm::distance(_globalPosition, viewerPosition);
|
||||||
|
//qDebug() << "_globalPosition:" << _globalPosition << "viewerPosition:" << viewerPosition << "distance:" << distance;
|
||||||
|
float result = ROTATION_90D_DOT; // assume worst
|
||||||
|
if (distance < 1.0f) {
|
||||||
|
result = AVATAR_MIN_ROTATION_DOT;
|
||||||
|
} else if (distance < 5.0f) {
|
||||||
|
result = ROTATION_15D_DOT;
|
||||||
|
} else if (distance < 10.0f) {
|
||||||
|
result = ROTATION_45D_DOT;
|
||||||
|
}
|
||||||
|
//qDebug() << __FUNCTION__ << "result:" << result;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::getDistanceBasedMinTranslationDistance(glm::vec3 viewerPosition) {
|
float AvatarData::getDistanceBasedMinTranslationDistance(glm::vec3 viewerPosition) {
|
||||||
|
@ -241,7 +252,6 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
// this is an iFrame issue... what to do about that?
|
// this is an iFrame issue... what to do about that?
|
||||||
//
|
//
|
||||||
// BUG -- Resizing avatar seems to "take too long"... the avatar doesn't redraw at smaller size right away
|
// BUG -- Resizing avatar seems to "take too long"... the avatar doesn't redraw at smaller size right away
|
||||||
// BUG -- summoned avatars seem low?
|
|
||||||
//
|
//
|
||||||
|
|
||||||
// TODO -
|
// TODO -
|
||||||
|
@ -448,13 +458,17 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
lastSentJointData.resize(_jointData.size());
|
lastSentJointData.resize(_jointData.size());
|
||||||
|
|
||||||
float minRotationDOT = !distanceAdjust ? AVATAR_MIN_ROTATION_DOT : getDistanceBasedMinRotationDOT(viewerPosition);
|
float minRotationDOT = !distanceAdjust ? AVATAR_MIN_ROTATION_DOT : getDistanceBasedMinRotationDOT(viewerPosition);
|
||||||
|
//qDebug() << "sendAll:" << sendAll << "cullSmallChanges:" << cullSmallChanges;
|
||||||
|
|
||||||
for (int i = 0; i < _jointData.size(); i++) {
|
for (int i = 0; i < _jointData.size(); i++) {
|
||||||
const JointData& data = _jointData[i];
|
const JointData& data = _jointData[i];
|
||||||
|
//qDebug() << "joint[" << i << "].dot:" << fabsf(glm::dot(data.rotation, lastSentJointData[i].rotation));
|
||||||
|
|
||||||
|
|
||||||
if (sendAll || lastSentJointData[i].rotation != data.rotation) {
|
if (sendAll || lastSentJointData[i].rotation != data.rotation) {
|
||||||
if (sendAll ||
|
if (sendAll ||
|
||||||
!cullSmallChanges ||
|
!cullSmallChanges ||
|
||||||
fabsf(glm::dot(data.rotation, lastSentJointData[i].rotation)) <= minRotationDOT) {
|
fabsf(glm::dot(data.rotation, lastSentJointData[i].rotation)) > minRotationDOT) {
|
||||||
if (data.rotationSet) {
|
if (data.rotationSet) {
|
||||||
validity |= (1 << validityBit);
|
validity |= (1 << validityBit);
|
||||||
#if 1 //def WANT_DEBUG
|
#if 1 //def WANT_DEBUG
|
||||||
|
@ -1484,6 +1498,9 @@ void AvatarData::detachAll(const QString& modelURL, const QString& jointName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setJointMappingsFromNetworkReply() {
|
void AvatarData::setJointMappingsFromNetworkReply() {
|
||||||
|
|
||||||
|
//qDebug() << __FUNCTION__ << "_skeletonModelURL:" << _skeletonModelURL;
|
||||||
|
|
||||||
QNetworkReply* networkReply = static_cast<QNetworkReply*>(sender());
|
QNetworkReply* networkReply = static_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1577,6 +1594,9 @@ void AvatarData::updateJointMappings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
|
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
|
||||||
|
|
||||||
|
//qDebug() << __FUNCTION__ << "_skeletonModelURL:" << _skeletonModelURL;
|
||||||
|
|
||||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
QNetworkRequest networkRequest = QNetworkRequest(_skeletonModelURL);
|
QNetworkRequest networkRequest = QNetworkRequest(_skeletonModelURL);
|
||||||
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
|
|
|
@ -258,6 +258,9 @@ const float AVATAR_SEND_FULL_UPDATE_RATIO = 0.02f;
|
||||||
const float AVATAR_MIN_ROTATION_DOT = 0.9999999f;
|
const float AVATAR_MIN_ROTATION_DOT = 0.9999999f;
|
||||||
const float AVATAR_MIN_TRANSLATION = 0.0001f;
|
const float AVATAR_MIN_TRANSLATION = 0.0001f;
|
||||||
|
|
||||||
|
const float ROTATION_15D_DOT = 0.9914449f;
|
||||||
|
const float ROTATION_45D_DOT = 0.9238795f;
|
||||||
|
const float ROTATION_90D_DOT = 0.7071068f;
|
||||||
|
|
||||||
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found).
|
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found).
|
||||||
// This is the start location in the Sandbox (xyz: 6270, 211, 6000).
|
// This is the start location in the Sandbox (xyz: 6270, 211, 6000).
|
||||||
|
|
Loading…
Reference in a new issue