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 | SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : | 32 | SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : |
| 33 | Model(parent), | 33 | Model(parent), |
| 34 | _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()), | ||
| 34 | _owningAvatar(owningAvatar), | 35 | _owningAvatar(owningAvatar), |
| 35 | _boundingShape(), | 36 | _boundingShape(), |
| 36 | _boundingShapeLocalOffset(0.0f), | 37 | _boundingShapeLocalOffset(0.0f), |
| @@ -38,7 +39,8 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : · 1 unmodified line | |||
| 38 | _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)), | 39 | _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)), |
| 39 | _standingFoot(NO_FOOT), | 40 | _standingFoot(NO_FOOT), |
| 40 | _standingOffset(0.0f), | 41 | _standingOffset(0.0f), |
| 41 | _clampedFootPosition(0.0f) { | 42 | _clampedFootPosition(0.0f) |
| 43 | { | ||
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | SkeletonModel::~SkeletonModel() { | 46 | SkeletonModel::~SkeletonModel() { |
| @@ -336,6 +338,9 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 291 unmodified lines | |||
| 336 | float fanScale = directionSize * 0.75f; | 338 | float fanScale = directionSize * 0.75f; |
| 337 | glScalef(fanScale, fanScale, fanScale); | 339 | glScalef(fanScale, fanScale, fanScale); |
| 338 | const int AXIS_COUNT = 3; | 340 | const int AXIS_COUNT = 3; |
| 341 | |||
| 342 | GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>(); | ||
| 343 | |||
| 339 | for (int i = 0; i < AXIS_COUNT; i++) { | 344 | for (int i = 0; i < AXIS_COUNT; i++) { |
| 340 | if (joint.rotationMin[i] <= -PI + EPSILON && joint.rotationMax[i] >= PI - EPSILON) { | 345 | if (joint.rotationMin[i] <= -PI + EPSILON && joint.rotationMax[i] >= PI - EPSILON) { |
| 341 | continue; // unconstrained | 346 | continue; // unconstrained |
| @@ -350,16 +355,20 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 8 unmodified lines | |||
| 350 | otherAxis.x = 1.0f; | 355 | otherAxis.x = 1.0f; |
| 351 | } | 356 | } |
| 352 | glColor4f(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f); | 357 | glColor4f(otherAxis.r, otherAxis.g, otherAxis.b, 0.75f); |
| 353 | 358 | ||
| 354 | glBegin(GL_TRIANGLE_FAN); | 359 | QVector<glm::vec3> points; |
| 355 | glVertex3f(0.0f, 0.0f, 0.0f); | 360 | points << glm::vec3(0.0f, 0.0f, 0.0f); |
| 356 | const int FAN_SEGMENTS = 16; | 361 | const int FAN_SEGMENTS = 16; |
| 357 | for (int j = 0; j < FAN_SEGMENTS; j++) { | 362 | for (int j = 0; j < FAN_SEGMENTS; j++) { |
| 358 | glm::vec3 rotated = glm::angleAxis(glm::mix(joint.rotationMin[i], joint.rotationMax[i], | 363 | glm::vec3 rotated = glm::angleAxis(glm::mix(joint.rotationMin[i], joint.rotationMax[i], |
| 359 | (float)j / (FAN_SEGMENTS - 1)), axis) * otherAxis; | 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 | glPopMatrix(); | 373 | glPopMatrix(); |
| 365 | 374 | ||