Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 5 files). Show all
Unified · Split
| @@ -31,6 +31,7 @@ enum StandingFootState { · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : |
| 33 | 33 | Model(parent), |
| 34 | + _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()), | |
| 34 | 35 | _owningAvatar(owningAvatar), |
| 35 | 36 | _boundingShape(), |
| 36 | 37 | _boundingShapeLocalOffset(0.0f), |
| @@ -38,7 +39,8 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : · 1 unmodified line | ||
| 38 | 39 | _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)), |
| 39 | 40 | _standingFoot(NO_FOOT), |
| 40 | 41 | _standingOffset(0.0f), |
| 41 | − _clampedFootPosition(0.0f) { | |
| 42 | + _clampedFootPosition(0.0f) | |
| 43 | +{ | |
| 42 | 44 | } |
| 43 | 45 | |
| 44 | 46 | SkeletonModel::~SkeletonModel() { |
| @@ -336,6 +338,9 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 291 unmodified lines | ||
| 336 | 338 | float fanScale = directionSize * 0.75f; |
| 337 | 339 | glScalef(fanScale, fanScale, fanScale); |
| 338 | 340 | const int AXIS_COUNT = 3; |
| 341 | + | |
| 342 | + GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>(); | |
| 343 | + | |
| 339 | 344 | for (int i = 0; i < AXIS_COUNT; i++) { |
| 340 | 345 | if (joint.rotationMin[i] <= -PI + EPSILON && joint.rotationMax[i] >= PI - EPSILON) { |
| 341 | 346 | continue; // unconstrained |
| @@ -350,16 +355,20 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 8 unmodified lines | ||
| 350 | 355 | otherAxis.x = 1.0f; |
| 351 | 356 | } |
| 352 | 357 | glColor4f(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f); |
| 353 | − | |
| 354 | − glBegin(GL_TRIANGLE_FAN); | |
| 355 | − glVertex3f(0.0f, 0.0f, 0.0f); | |
| 358 | + | |
| 359 | + QVector<glm::vec3> points; | |
| 360 | + points << glm::vec3(0.0f, 0.0f, 0.0f); | |
| 356 | 361 | const int FAN_SEGMENTS = 16; |
| 357 | 362 | for (int j = 0; j < FAN_SEGMENTS; j++) { |
| 358 | 363 | glm::vec3 rotated = glm::angleAxis(glm::mix(joint.rotationMin[i], joint.rotationMax[i], |
| 359 | 364 | (float)j / (FAN_SEGMENTS - 1)), axis) * otherAxis; |
| 360 | − glVertex3f(rotated.x, rotated.y, rotated.z); | |
| 365 | + points << rotated; | |
| 361 | 366 | } |
| 362 | − glEnd(); | |
| 367 | + // TODO: this is really inefficient constantly recreating these vertices buffers. It would be | |
| 368 | + // better if the skeleton model cached these buffers for each of the joints they are rendering | |
| 369 | + geometryCache->updateVertices(_triangleFanID, points); | |
| 370 | + geometryCache->renderVertices(GL_TRIANGLE_FAN, _triangleFanID); | |
| 371 | + | |
| 363 | 372 | } |
| 364 | 373 | glPopMatrix(); |
| 365 | 374 | |