History

more removal of immediate mode

ZappoMan committed 11 years ago

Commit 1bfce7d1 parent 0d633915 files · +44 −27Browse files

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

Unified · Split

interface/src/avatar/SkeletonModel.cpp+15−6
@@ -31,6 +31,7 @@ enum StandingFootState { · 30 unmodified lines
3131
3232 SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) :
3333 Model(parent),
34+ _triangleFanID(DependencyManager::get<GeometryCache>()->allocateID()),
3435 _owningAvatar(owningAvatar),
3536 _boundingShape(),
3637 _boundingShapeLocalOffset(0.0f),
@@ -38,7 +39,8 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) : · 1 unmodified line
3839 _defaultEyeModelPosition(glm::vec3(0.0f, 0.0f, 0.0f)),
3940 _standingFoot(NO_FOOT),
4041 _standingOffset(0.0f),
41− _clampedFootPosition(0.0f) {
42+ _clampedFootPosition(0.0f)
43+{
4244 }
4345
4446 SkeletonModel::~SkeletonModel() {
@@ -336,6 +338,9 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 291 unmodified lines
336338 float fanScale = directionSize * 0.75f;
337339 glScalef(fanScale, fanScale, fanScale);
338340 const int AXIS_COUNT = 3;
341+
342+ GeometryCache::SharedPointer geometryCache = DependencyManager::get<GeometryCache>();
343+
339344 for (int i = 0; i < AXIS_COUNT; i++) {
340345 if (joint.rotationMin[i] <= -PI + EPSILON && joint.rotationMax[i] >= PI - EPSILON) {
341346 continue; // unconstrained
@@ -350,16 +355,20 @@ void SkeletonModel::renderJointConstraints(int jointIndex) { · 8 unmodified lines
350355 otherAxis.x = 1.0f;
351356 }
352357 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);
356361 const int FAN_SEGMENTS = 16;
357362 for (int j = 0; j < FAN_SEGMENTS; j++) {
358363 glm::vec3 rotated = glm::angleAxis(glm::mix(joint.rotationMin[i], joint.rotationMax[i],
359364 (float)j / (FAN_SEGMENTS - 1)), axis) * otherAxis;
360− glVertex3f(rotated.x, rotated.y, rotated.z);
365+ points << rotated;
361366 }
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+
363372 }
364373 glPopMatrix();
365374

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