remove unused legacy Shapes from Model and friends
Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 9 files). Show all
Unified · Split
| @@ -12,9 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <glm/gtx/transform.hpp> | 12 | #include <glm/gtx/transform.hpp> |
| 13 | #include <QMultiMap> | 13 | #include <QMultiMap> |
| 14 | 14 | ||
| 15 | #include <CapsuleShape.h> | ||
| 16 | #include <DeferredLightingEffect.h> | 15 | #include <DeferredLightingEffect.h> |
| 17 | #include <SphereShape.h> | ||
| 18 | 16 | ||
| 19 | #include "Application.h" | 17 | #include "Application.h" |
| 20 | #include "Avatar.h" | 18 | #include "Avatar.h" |
| @@ -34,8 +32,9 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r · 13 unmodified lines | |||
| 34 | Model(rig, parent), | 32 | Model(rig, parent), |
| 35 | _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()), | 33 | _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()), |
| 36 | _owningAvatar(owningAvatar), | 34 | _owningAvatar(owningAvatar), |
| 37 | _boundingShape(), | 35 | _boundingCapsuleLocalOffset(0.0f), |
| 38 | _boundingShapeLocalOffset(0.0f), | 36 | _boundingCapsuleRadius(0.0f), |
| 37 | _boundingCapsuleHeight(0.0f), | ||
| 39 | _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)), | 38 | _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)), |
| 40 | _standingFoot(NO_FOOT), | 39 | _standingFoot(NO_FOOT), |
| 41 | _standingOffset(0.0f), | 40 | _standingOffset(0.0f), |
| @@ -44,7 +43,6 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r · 2 unmodified lines | |||
| 44 | { | 43 | { |
| 45 | assert(_rig); | 44 | assert(_rig); |
| 46 | assert(_owningAvatar); | 45 | assert(_owningAvatar); |
| 47 | _enableShapes = true; | ||
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | SkeletonModel::~SkeletonModel() { | 48 | SkeletonModel::~SkeletonModel() { |
| @@ -81,10 +79,7 @@ void SkeletonModel::initJointStates(QVector<JointState> states) { · 30 unmodified lines | |||
| 81 | _rig->updateJointState(i, parentTransform); | 79 | _rig->updateJointState(i, parentTransform); |
| 82 | } | 80 | } |
| 83 | 81 | ||
| 84 | clearShapes(); | 82 | buildShapes(); |
| 85 | if (_enableShapes) { | ||
| 86 | buildShapes(); | ||
| 87 | } | ||
| 88 | 83 | ||
| 89 | Extents meshExtents = getMeshExtents(); | 84 | Extents meshExtents = getMeshExtents(); |
| 90 | _headClipDistance = -(meshExtents.minimum.z / _scale.z - _defaultEyeModelPosition.z); | 85 | _headClipDistance = -(meshExtents.minimum.z / _scale.z - _defaultEyeModelPosition.z); |
| @@ -183,9 +178,6 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { · 92 unmodified lines | |||
| 183 | if (_rig->getJointsAreDirty()) { | 178 | if (_rig->getJointsAreDirty()) { |
| 184 | updateClusterMatrices(); | 179 | updateClusterMatrices(); |
| 185 | } | 180 | } |
| 186 | |||
| 187 | _boundingShape.setTranslation(_translation + _rotation * _boundingShapeLocalOffset); | ||
| 188 | _boundingShape.setRotation(_rotation); | ||
| 189 | } | 181 | } |
| 190 | 182 | ||
| 191 | void SkeletonModel::renderIKConstraints(gpu::Batch& batch) { | 183 | void SkeletonModel::renderIKConstraints(gpu::Batch& batch) { |
| @@ -677,12 +669,11 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { · 485 unmodified lines | |||
| 677 | // NOTE: we assume that the longest side of totalExtents is the yAxis... | 669 | // NOTE: we assume that the longest side of totalExtents is the yAxis... |
| 678 | glm::vec3 diagonal = totalExtents.maximum - totalExtents.minimum; | 670 | glm::vec3 diagonal = totalExtents.maximum - totalExtents.minimum; |
| 679 | // ... and assume the radius is half the RMS of the X and Z sides: | 671 | // ... and assume the radius is half the RMS of the X and Z sides: |
| 680 | float capsuleRadius = 0.5f * sqrtf(0.5f * (diagonal.x * diagonal.x + diagonal.z * diagonal.z)); | 672 | _boundingCapsuleRadius = 0.5f * sqrtf(0.5f * (diagonal.x * diagonal.x + diagonal.z * diagonal.z)); |
| 681 | _boundingShape.setRadius(capsuleRadius); | 673 | _boundingCapsuleHeight = diagonal.y - 2.0f * _boundingCapsuleRadius; |
| 682 | _boundingShape.setHalfHeight(0.5f * diagonal.y - capsuleRadius); | ||
| 683 | 674 | ||
| 684 | glm::vec3 rootPosition = _rig->getJointState(geometry.rootJointIndex).getPosition(); | 675 | glm::vec3 rootPosition = _rig->getJointState(geometry.rootJointIndex).getPosition(); |
| 685 | _boundingShapeLocalOffset = 0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition; | 676 | _boundingCapsuleLocalOffset = 0.5f * (totalExtents.maximum + totalExtents.minimum) - rootPosition; |
| 686 | _boundingRadius = 0.5f * glm::length(diagonal); | 677 | _boundingRadius = 0.5f * glm::length(diagonal); |
| 687 | } | 678 | } |
| 688 | 679 | ||
| @@ -693,30 +684,26 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha · 4 unmodified lines | |||
| 693 | auto deferredLighting = DependencyManager::get<DeferredLightingEffect>(); | 684 | auto deferredLighting = DependencyManager::get<DeferredLightingEffect>(); |
| 694 | Transform transform; // = Transform(); | 685 | Transform transform; // = Transform(); |
| 695 | 686 | ||
| 696 | // draw a blue sphere at the capsule end point | 687 | // draw a blue sphere at the capsule top point |
| 697 | glm::vec3 endPoint; | 688 | glm::vec3 topPoint = _translation + _boundingCapsuleLocalOffset + (0.5f * _boundingCapsuleHeight) * glm::vec3(0.0f, 1.0f, 0.0f); |
| 698 | _boundingShape.getEndPoint(endPoint); | 689 | transform.setTranslation(topPoint); |
| 699 | endPoint = endPoint + _translation; | ||
| 700 | transform.setTranslation(endPoint); | ||
| 701 | batch.setModelTransform(transform); | 690 | batch.setModelTransform(transform); |
| 702 | deferredLighting->bindSimpleProgram(batch); | 691 | deferredLighting->bindSimpleProgram(batch); |
| 703 | geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, | 692 | geometryCache->renderSphere(batch, _boundingCapsuleRadius, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, |
| 704 | glm::vec4(0.6f, 0.6f, 0.8f, alpha)); | 693 | glm::vec4(0.6f, 0.6f, 0.8f, alpha)); |
| 705 | 694 | ||
| 706 | // draw a yellow sphere at the capsule start point | 695 | // draw a yellow sphere at the capsule bottom point |
| 707 | glm::vec3 startPoint; | 696 | glm::vec3 bottomPoint = topPoint - glm::vec3(0.0f, -_boundingCapsuleHeight, 0.0f); |
| 708 | _boundingShape.getStartPoint(startPoint); | 697 | glm::vec3 axis = topPoint - bottomPoint; |
| 709 | startPoint = startPoint + _translation; | 698 | transform.setTranslation(bottomPoint); |
| 710 | glm::vec3 axis = endPoint - startPoint; | ||
| 711 | transform.setTranslation(startPoint); | ||
| 712 | batch.setModelTransform(transform); | 699 | batch.setModelTransform(transform); |
| 713 | deferredLighting->bindSimpleProgram(batch); | 700 | deferredLighting->bindSimpleProgram(batch); |
| 714 | geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, | 701 | geometryCache->renderSphere(batch, _boundingCapsuleRadius, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS, |
| 715 | glm::vec4(0.8f, 0.8f, 0.6f, alpha)); | 702 | glm::vec4(0.8f, 0.8f, 0.6f, alpha)); |
| 716 | 703 | ||
| 717 | // draw a green cylinder between the two points | 704 | // draw a green cylinder between the two points |
| 718 | glm::vec3 origin(0.0f); | 705 | glm::vec3 origin(0.0f); |
| 719 | Avatar::renderJointConnectingCone(batch, origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(), | 706 | Avatar::renderJointConnectingCone(batch, origin, axis, _boundingCapsuleRadius, _boundingCapsuleRadius, |
| 720 | glm::vec4(0.6f, 0.8f, 0.6f, alpha)); | 707 | glm::vec4(0.6f, 0.8f, 0.6f, alpha)); |
| 721 | } | 708 | } |
| 722 | 709 | ||