mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:36:30 +02:00
Bug fixes for switching between head/body and full body avatars
The head model visibility is now updated in preRender() Moved the near clip plane in a bit more Invalidate head bone vector on LOD switching. Removed _currentSkeletonModel pointer, instead use _prevShouldDrawHead to detect when we should flip the visibility bit.
This commit is contained in:
parent
b88d7c2e05
commit
3853395298
4 changed files with 28 additions and 24 deletions
|
@ -98,8 +98,8 @@ MyAvatar::MyAvatar() :
|
||||||
_isLookingAtLeftEye(true),
|
_isLookingAtLeftEye(true),
|
||||||
_realWorldFieldOfView("realWorldFieldOfView",
|
_realWorldFieldOfView("realWorldFieldOfView",
|
||||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
|
||||||
_currentSkeletonModel(nullptr),
|
_firstPersonSkeletonModel(this),
|
||||||
_firstPersonSkeletonModel(this)
|
_prevShouldDrawHead(true)
|
||||||
{
|
{
|
||||||
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
_firstPersonSkeletonModel.setIsFirstPerson(true);
|
||||||
|
|
||||||
|
@ -1203,16 +1203,9 @@ void MyAvatar::renderBody(RenderArgs* renderArgs, ViewFrustum* renderFrustum, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setCurrentSkeletonModel(SkeletonModel* skeletonModel) {
|
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
||||||
if (_currentSkeletonModel != skeletonModel && skeletonModel->isActive() && skeletonModel->isRenderable()) {
|
if (model->isActive() && model->isRenderable()) {
|
||||||
|
model->setVisibleInScene(visible, scene);
|
||||||
render::ScenePointer scene = Application::getInstance()->getMain3DScene();
|
|
||||||
|
|
||||||
if (_currentSkeletonModel) {
|
|
||||||
_currentSkeletonModel->setVisibleInScene(false, scene);
|
|
||||||
}
|
|
||||||
skeletonModel->setVisibleInScene(true, scene);
|
|
||||||
_currentSkeletonModel = skeletonModel;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,14 +1214,26 @@ void MyAvatar::preRender(RenderArgs* renderArgs) {
|
||||||
render::ScenePointer scene = Application::getInstance()->getMain3DScene();
|
render::ScenePointer scene = Application::getInstance()->getMain3DScene();
|
||||||
|
|
||||||
_skeletonModel.initWhenReady(scene);
|
_skeletonModel.initWhenReady(scene);
|
||||||
_firstPersonSkeletonModel.initWhenReady(scene);
|
if (_useFullAvatar) {
|
||||||
|
_firstPersonSkeletonModel.initWhenReady(scene);
|
||||||
// set visiblity on each model
|
|
||||||
if (shouldRenderHead(renderArgs)) {
|
|
||||||
setCurrentSkeletonModel(&_skeletonModel);
|
|
||||||
} else {
|
|
||||||
setCurrentSkeletonModel(&_firstPersonSkeletonModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldDrawHead = shouldRenderHead(renderArgs);
|
||||||
|
if (shouldDrawHead != _prevShouldDrawHead) {
|
||||||
|
if (_useFullAvatar) {
|
||||||
|
if (shouldDrawHead) {
|
||||||
|
_skeletonModel.setVisibleInScene(true, scene);
|
||||||
|
_firstPersonSkeletonModel.setVisibleInScene(false, scene);
|
||||||
|
} else {
|
||||||
|
_skeletonModel.setVisibleInScene(false, scene);
|
||||||
|
_firstPersonSkeletonModel.setVisibleInScene(true, scene);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getHead()->getFaceModel().setVisibleInScene(shouldDrawHead, scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
_prevShouldDrawHead = shouldDrawHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.50f;
|
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.50f;
|
||||||
|
|
|
@ -211,8 +211,7 @@ private:
|
||||||
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
virtual void setFaceModelURL(const QUrl& faceModelURL);
|
||||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL);
|
||||||
|
|
||||||
void setCurrentSkeletonModel(SkeletonModel* skeletonModel);
|
void setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visiblity);
|
||||||
void initModelWhenReady(Model* model);
|
|
||||||
|
|
||||||
glm::vec3 _gravity;
|
glm::vec3 _gravity;
|
||||||
|
|
||||||
|
@ -271,8 +270,8 @@ private:
|
||||||
QString _fullAvatarModelName;
|
QString _fullAvatarModelName;
|
||||||
|
|
||||||
// used for rendering when in first person view or when in an HMD.
|
// used for rendering when in first person view or when in an HMD.
|
||||||
SkeletonModel* _currentSkeletonModel;
|
|
||||||
SkeletonModel _firstPersonSkeletonModel;
|
SkeletonModel _firstPersonSkeletonModel;
|
||||||
|
bool _prevShouldDrawHead;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_MyAvatar_h
|
#endif // hifi_MyAvatar_h
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
||||||
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
||||||
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
||||||
//const float DEFAULT_NEAR_CLIP = 0.08f;
|
const float DEFAULT_NEAR_CLIP = 0.08f;
|
||||||
const float DEFAULT_NEAR_CLIP = 0.1f;
|
|
||||||
const float DEFAULT_FAR_CLIP = (float)TREE_SCALE;
|
const float DEFAULT_FAR_CLIP = (float)TREE_SCALE;
|
||||||
|
|
||||||
class ViewFrustum {
|
class ViewFrustum {
|
||||||
|
|
|
@ -1370,6 +1370,7 @@ void Model::simulate(float deltaTime, bool fullUpdate) {
|
||||||
// because ray picking needs valid boxes to work
|
// because ray picking needs valid boxes to work
|
||||||
_calculatedMeshBoxesValid = false;
|
_calculatedMeshBoxesValid = false;
|
||||||
_calculatedMeshTrianglesValid = false;
|
_calculatedMeshTrianglesValid = false;
|
||||||
|
onInvalidate();
|
||||||
|
|
||||||
// check for scale to fit
|
// check for scale to fit
|
||||||
if (_scaleToFit && !_scaledToFit) {
|
if (_scaleToFit && !_scaledToFit) {
|
||||||
|
|
Loading…
Reference in a new issue