mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
remove old avatar culling and LOD logic
This commit is contained in:
parent
08bba5f45f
commit
88bf126168
5 changed files with 21 additions and 53 deletions
|
@ -307,7 +307,7 @@ void Avatar::setShouldDie() {
|
|||
_owningAvatarMixer.clear();
|
||||
}
|
||||
|
||||
void Avatar::simulate(float deltaTime) {
|
||||
void Avatar::simulate(float deltaTime, bool inView) {
|
||||
PROFILE_RANGE(simulation, "simulate");
|
||||
PerformanceTimer perfTimer("simulate");
|
||||
|
||||
|
@ -316,47 +316,18 @@ void Avatar::simulate(float deltaTime) {
|
|||
}
|
||||
animateScaleChanges(deltaTime);
|
||||
|
||||
bool avatarInView = false;
|
||||
{ // update the shouldAnimate flag to match whether or not we will render the avatar.
|
||||
{
|
||||
PROFILE_RANGE(simulation, "cull");
|
||||
// simple frustum check
|
||||
PerformanceTimer perfTimer("inView");
|
||||
ViewFrustum viewFrustum;
|
||||
qApp->copyDisplayViewFrustum(viewFrustum);
|
||||
avatarInView = viewFrustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())
|
||||
|| viewFrustum.boxIntersectsFrustum(_skeletonModel->getRenderableMeshBound());
|
||||
}
|
||||
PROFILE_RANGE(simulation, "LOD");
|
||||
if (avatarInView) {
|
||||
const float MINIMUM_VISIBILITY_FOR_ON = 0.4f;
|
||||
const float MAXIMUM_VISIBILITY_FOR_OFF = 0.6f;
|
||||
ViewFrustum viewFrustum;
|
||||
qApp->copyViewFrustum(viewFrustum);
|
||||
float visibility = calculateRenderAccuracy(viewFrustum.getPosition(),
|
||||
getBounds(), DependencyManager::get<LODManager>()->getOctreeSizeScale());
|
||||
if (!_shouldAnimate) {
|
||||
if (visibility > MINIMUM_VISIBILITY_FOR_ON) {
|
||||
_shouldAnimate = true;
|
||||
qCDebug(interfaceapp) << "Restoring" << (isMyAvatar() ? "myself" : getSessionUUID()) << "for visibility" << visibility;
|
||||
}
|
||||
} else if (visibility < MAXIMUM_VISIBILITY_FOR_OFF) {
|
||||
_shouldAnimate = false;
|
||||
qCDebug(interfaceapp) << "Optimizing" << (isMyAvatar() ? "myself" : getSessionUUID()) << "for visibility" << visibility;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
PROFILE_RANGE(simulation, "updateJoints");
|
||||
uint64_t start = usecTimestampNow();
|
||||
// CRUFT? _shouldSkipRender is never set 'true'
|
||||
if (_shouldAnimate && avatarInView && !_shouldSkipRender) {
|
||||
if (inView) {
|
||||
// adebug BOOKMARK: can avoid copying duplicate joint data
|
||||
// - can avoid some work when transform not changed (see SkeletonModel::simulate() and Model::setTranslation())
|
||||
// - can maybe use _hasNewFoo instead of AvatarData::_jointDataVersion
|
||||
// - can maybe avoid stuff if blendShapes haven't changed
|
||||
_skeletonModel->getRig()->copyJointsFromJointData(_jointData);
|
||||
_skeletonModel->simulate(deltaTime, _hasNewJointRotations || _hasNewJointTranslations);
|
||||
_skeletonModel->simulate(deltaTime, _hasNewJointData);
|
||||
locationChanged(); // joints changed, so if there are any children, update them.
|
||||
_hasNewJointRotations = false;
|
||||
_hasNewJointTranslations = false;
|
||||
_hasNewJointData = false;
|
||||
|
||||
glm::vec3 headPosition = getPosition();
|
||||
if (!_skeletonModel->getHeadPosition(headPosition)) {
|
||||
|
@ -365,7 +336,8 @@ void Avatar::simulate(float deltaTime) {
|
|||
Head* head = getHead();
|
||||
head->setPosition(headPosition);
|
||||
head->setScale(getUniformScale());
|
||||
head->simulate(deltaTime, false, !_shouldAnimate);
|
||||
const bool useBillboard = false; // HACK
|
||||
head->simulate(deltaTime, false, useBillboard);
|
||||
} else {
|
||||
// a non-full update is still required so that the position, rotation, scale and bounds of the skeletonModel are updated.
|
||||
getHead()->setPosition(getPosition());
|
||||
|
@ -1106,7 +1078,7 @@ int Avatar::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
if (_moving && _motionState) {
|
||||
_motionState->addDirtyFlags(Simulation::DIRTY_POSITION);
|
||||
}
|
||||
if (_moving || _hasNewJointRotations || _hasNewJointTranslations) {
|
||||
if (_moving || _hasNewJointData) {
|
||||
locationChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
void init();
|
||||
void updateAvatarEntities();
|
||||
void simulate(float deltaTime);
|
||||
void simulate(float deltaTime, bool inView);
|
||||
virtual void simulateAttachments(float deltaTime);
|
||||
|
||||
virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition);
|
||||
|
@ -141,8 +141,6 @@ public:
|
|||
|
||||
Q_INVOKABLE glm::vec3 getAcceleration() const { return _acceleration; }
|
||||
|
||||
Q_INVOKABLE bool getShouldRender() const { return !_shouldSkipRender; }
|
||||
|
||||
/// Scales a world space position vector relative to the avatar position and scale
|
||||
/// \param vector position to be scaled. Will store the result
|
||||
void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const;
|
||||
|
@ -265,8 +263,6 @@ private:
|
|||
int _rightPointerGeometryID { 0 };
|
||||
int _nameRectGeometryID { 0 };
|
||||
bool _initialized;
|
||||
bool _shouldAnimate { true };
|
||||
bool _shouldSkipRender { false };
|
||||
bool _isLookAtTarget { false };
|
||||
bool _inScene { false };
|
||||
|
||||
|
|
|
@ -165,7 +165,8 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
++avatarIterator;
|
||||
} else {
|
||||
avatar->ensureInScene(avatar);
|
||||
avatar->simulate(deltaTime);
|
||||
const bool inView = true; // HACK
|
||||
avatar->simulate(deltaTime, inView);
|
||||
++avatarIterator;
|
||||
|
||||
avatar->updateRenderItem(pendingChanges);
|
||||
|
@ -210,7 +211,8 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
|||
++fadingIterator;
|
||||
}
|
||||
} else {
|
||||
avatar->simulate(deltaTime);
|
||||
const bool inView = true; // HACK
|
||||
avatar->simulate(deltaTime, inView);
|
||||
++fadingIterator;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,7 @@ AvatarData::AvatarData() :
|
|||
_handState(0),
|
||||
_keyState(NO_KEY_DOWN),
|
||||
_forceFaceTrackerConnected(false),
|
||||
_hasNewJointRotations(true),
|
||||
_hasNewJointTranslations(true),
|
||||
_hasNewJointData(true),
|
||||
_headData(NULL),
|
||||
_displayNameTargetAlpha(1.0f),
|
||||
_displayNameAlpha(1.0f),
|
||||
|
@ -553,7 +552,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
glm::vec3 newEulerAngles(pitch, yaw, roll);
|
||||
glm::quat newOrientation = glm::quat(glm::radians(newEulerAngles));
|
||||
if (currentOrientation != newOrientation) {
|
||||
_hasNewJointRotations = true;
|
||||
_hasNewJointData = true;
|
||||
setLocalOrientation(newOrientation);
|
||||
}
|
||||
|
||||
|
@ -680,7 +679,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
JointData& data = _jointData[i];
|
||||
if (validRotations[i]) {
|
||||
sourceBuffer += unpackOrientationQuatFromSixBytes(sourceBuffer, data.rotation);
|
||||
_hasNewJointRotations = true;
|
||||
_hasNewJointData = true;
|
||||
data.rotationSet = true;
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +714,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
JointData& data = _jointData[i];
|
||||
if (validTranslations[i]) {
|
||||
sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, data.translation, TRANSLATION_COMPRESSION_RADIX);
|
||||
_hasNewJointTranslations = true;
|
||||
_hasNewJointData = true;
|
||||
data.translationSet = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,8 +427,7 @@ protected:
|
|||
KeyState _keyState;
|
||||
|
||||
bool _forceFaceTrackerConnected;
|
||||
bool _hasNewJointRotations; // set in AvatarData, cleared in Avatar
|
||||
bool _hasNewJointTranslations; // set in AvatarData, cleared in Avatar
|
||||
bool _hasNewJointData; // set in AvatarData, cleared in Avatar
|
||||
|
||||
HeadData* _headData;
|
||||
|
||||
|
|
Loading…
Reference in a new issue