History

Merge pull request #8 from AndrewMeadows/cadmium

remove unused legacy Shapes from Model and friends

Howard Stearns committed 11 years ago

Commit ef52c072 parents 8196770 81831979 files · +35 −286Browse files

Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 9 files). Show all

Unified · Split

interface/src/avatar/SkeletonModel.cpp+17−30
@@ -12,9 +12,7 @@ · 11 unmodified lines
1212 #include <glm/gtx/transform.hpp>
1313 #include <QMultiMap>
1414
15−#include <CapsuleShape.h>
1615 #include <DeferredLightingEffect.h>
17−#include <SphereShape.h>
1816
1917 #include "Application.h"
2018 #include "Avatar.h"
@@ -34,8 +32,9 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r · 13 unmodified lines
3432 Model(rig, parent),
3533 _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()),
3634 _owningAvatar(owningAvatar),
37− _boundingShape(),
38− _boundingShapeLocalOffset(0.0f),
35+ _boundingCapsuleLocalOffset(0.0f),
36+ _boundingCapsuleRadius(0.0f),
37+ _boundingCapsuleHeight(0.0f),
3938 _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)),
4039 _standingFoot(NO_FOOT),
4140 _standingOffset(0.0f),
@@ -44,7 +43,6 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent, RigPointer r · 2 unmodified lines
4443 {
4544 assert(_rig);
4645 assert(_owningAvatar);
47− _enableShapes = true;
4846 }
4947
5048 SkeletonModel::~SkeletonModel() {
@@ -81,10 +79,7 @@ void SkeletonModel::initJointStates(QVector<JointState> states) { · 30 unmodified lines
8179 _rig->updateJointState(i, parentTransform);
8280 }
8381
84− clearShapes();
85− if (_enableShapes) {
86− buildShapes();
87− }
82+ buildShapes();
8883
8984 Extents meshExtents = getMeshExtents();
9085 _headClipDistance = -(meshExtents.minimum.z / _scale.z - _defaultEyeModelPosition.z);
@@ -183,9 +178,6 @@ void SkeletonModel::simulate(float deltaTime, bool fullUpdate) { · 92 unmodified lines
183178 if (_rig->getJointsAreDirty()) {
184179 updateClusterMatrices();
185180 }
186−
187− _boundingShape.setTranslation(_translation + _rotation * _boundingShapeLocalOffset);
188− _boundingShape.setRotation(_rotation);
189181 }
190182
191183 void SkeletonModel::renderIKConstraints(gpu::Batch& batch) {
@@ -677,12 +669,11 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) { · 485 unmodified lines
677669 // NOTE: we assume that the longest side of totalExtents is the yAxis...
678670 glm::vec3 diagonal = totalExtents.maximum - totalExtents.minimum;
679671 // ... 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));
681− _boundingShape.setRadius(capsuleRadius);
682− _boundingShape.setHalfHeight(0.5f * diagonal.y - capsuleRadius);
672+ _boundingCapsuleRadius = 0.5f * sqrtf(0.5f * (diagonal.x * diagonal.x + diagonal.z * diagonal.z));
673+ _boundingCapsuleHeight = diagonal.y - 2.0f * _boundingCapsuleRadius;
683674
684675 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;
686677 _boundingRadius = 0.5f * glm::length(diagonal);
687678 }
688679
@@ -693,30 +684,26 @@ void SkeletonModel::renderBoundingCollisionShapes(gpu::Batch& batch, float alpha · 4 unmodified lines
693684 auto deferredLighting = DependencyManager::get<DeferredLightingEffect>();
694685 Transform transform; // = Transform();
695686
696− // draw a blue sphere at the capsule end point
697− glm::vec3 endPoint;
698− _boundingShape.getEndPoint(endPoint);
699− endPoint = endPoint + _translation;
700− transform.setTranslation(endPoint);
687+ // draw a blue sphere at the capsule top point
688+ glm::vec3 topPoint = _translation + _boundingCapsuleLocalOffset + (0.5f * _boundingCapsuleHeight) * glm::vec3(0.0f, 1.0f, 0.0f);
689+ transform.setTranslation(topPoint);
701690 batch.setModelTransform(transform);
702691 deferredLighting->bindSimpleProgram(batch);
703− geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
692+ geometryCache->renderSphere(batch, _boundingCapsuleRadius, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
704693 glm::vec4(0.6f, 0.6f, 0.8f, alpha));
705694
706− // draw a yellow sphere at the capsule start point
707− glm::vec3 startPoint;
708− _boundingShape.getStartPoint(startPoint);
709− startPoint = startPoint + _translation;
710− glm::vec3 axis = endPoint - startPoint;
711− transform.setTranslation(startPoint);
695+ // draw a yellow sphere at the capsule bottom point
696+ glm::vec3 bottomPoint = topPoint - glm::vec3(0.0f, -_boundingCapsuleHeight, 0.0f);
697+ glm::vec3 axis = topPoint - bottomPoint;
698+ transform.setTranslation(bottomPoint);
712699 batch.setModelTransform(transform);
713700 deferredLighting->bindSimpleProgram(batch);
714− geometryCache->renderSphere(batch, _boundingShape.getRadius(), BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
701+ geometryCache->renderSphere(batch, _boundingCapsuleRadius, BALL_SUBDIVISIONS, BALL_SUBDIVISIONS,
715702 glm::vec4(0.8f, 0.8f, 0.6f, alpha));
716703
717704 // draw a green cylinder between the two points
718705 glm::vec3 origin(0.0f);
719− Avatar::renderJointConnectingCone(batch, origin, axis, _boundingShape.getRadius(), _boundingShape.getRadius(),
706+ Avatar::renderJointConnectingCone(batch, origin, axis, _boundingCapsuleRadius, _boundingCapsuleRadius,
720707 glm::vec4(0.6f, 0.8f, 0.6f, alpha));
721708 }
722709

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t