propagate skeleton's bounding box into AvatarData

This commit is contained in:
Andrew Meadows 2015-03-13 09:39:47 -07:00
parent 645fc7dbc9
commit 924ebe1e54
4 changed files with 15 additions and 1 deletions

View file

@ -4094,6 +4094,7 @@ void Application::checkSkeleton() {
_myAvatar->setSkeletonModelURL(DEFAULT_BODY_MODEL_URL);
_myAvatar->sendIdentityPacket();
} else {
_myAvatar->updateLocalAABox();
_physicsEngine.setAvatarData(_myAvatar);
}
}

View file

@ -954,6 +954,17 @@ glm::vec3 MyAvatar::getSkeletonPosition() const {
return Avatar::getPosition();
}
void MyAvatar::updateLocalAABox() {
const CapsuleShape& capsule = _skeletonModel.getBoundingShape();
float radius = capsule.getRadius();
float height = 2.0f * (capsule.getHalfHeight() + radius);
glm::vec3 offset = _skeletonModel.getBoundingShapeOffset();
glm::vec3 corner(-radius, -0.5f * height, -radius);
corner += offset;
glm::vec3 scale(2.0f * radius, height, 2.0f * radius);
_localAABox.setBox(corner, scale);
}
QString MyAvatar::getScriptedMotorFrame() const {
QString frame = "avatar";
if (_scriptedMotorFrame == SCRIPTED_MOTOR_CAMERA_FRAME) {

View file

@ -121,6 +121,7 @@ public:
virtual void setAttachmentData(const QVector<AttachmentData>& attachmentData);
virtual glm::vec3 getSkeletonPosition() const;
void updateLocalAABox();
void clearJointAnimationPriorities();

View file

@ -403,6 +403,8 @@ protected:
glm::vec3 _velocity;
AABox _localAABox;
private:
// privatize the copy constructor and assignment operator so they cannot be called
AvatarData(const AvatarData&);
@ -410,7 +412,6 @@ private:
QReadWriteLock _lock;
bool _enablePhysics = false;
AABox _localAABox;
};
Q_DECLARE_METATYPE(AvatarData*)