History

Don't bother using a callback to render the eye vectors; just rely on the post-lighting call to Avatar::render, like everything else. This should fix the crash that Philip was seeing (presumably due to avatars' being deleted during the draw process).

Andrzej Kapolka committed 12 years ago

Commit 9855fbc1 parent a701bce4 files · +31 −38Browse files

Unified · Split

4 files
  1. interface/src/avatar/Avatar.cpp +11 −13
  2. interface/src/avatar/Head.cpp +7 −8
  3. interface/src/avatar/Head.h +2 −4
  4. interface/src/avatar/MyAvatar.cpp +11 −13
interface/src/avatar/Avatar.cpp+11−13
@@ -520,20 +520,18 @@ void Avatar::renderBody(RenderMode renderMode, bool postLighting, float glowLeve · 519 unmodified lines
520 renderAttachments(renderMode);520 renderAttachments(renderMode);
521 }521 }
522 }522 }
523 if (!postLighting) {523 getHead()->render(1.0f, modelRenderMode, postLighting);
524 getHead()->render(1.0f, modelRenderMode);
525 524
526 if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {525 if (!postLighting && Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
527 // Render Hair526 // Render Hair
528 glPushMatrix();527 glPushMatrix();
529 glm::vec3 headPosition = getHead()->getPosition();528 glm::vec3 headPosition = getHead()->getPosition();
530 glTranslatef(headPosition.x, headPosition.y, headPosition.z);529 glTranslatef(headPosition.x, headPosition.y, headPosition.z);
531 const glm::quat& rotation = getHead()->getFinalOrientationInWorldFrame();530 const glm::quat& rotation = getHead()->getFinalOrientationInWorldFrame();
532 glm::vec3 axis = glm::axis(rotation);531 glm::vec3 axis = glm::axis(rotation);
533 glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);532 glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
534 _hair.render();533 _hair.render();
535 glPopMatrix();534 glPopMatrix();
536 }
537 }535 }
538}536}
539 537
interface/src/avatar/Head.cpp+7−8
@@ -211,17 +211,16 @@ void Head::relaxLean(float deltaTime) { · 210 unmodified lines
211 _deltaLeanForward *= relaxationFactor;211 _deltaLeanForward *= relaxationFactor;
212}212}
213 213
214void Head::render(float alpha, Model::RenderMode mode) {214void Head::render(float alpha, Model::RenderMode mode, bool postLighting) {
215 _faceModel.render(alpha, mode);215 if (postLighting) {
216 if (_renderLookatVectors && mode != Model::SHADOW_RENDER_MODE) {216 if (_renderLookatVectors) {
217 Application::getInstance()->getDeferredLightingEffect()->addPostLightingRenderable(this);217 renderLookatVectors(_leftEyePosition, _rightEyePosition, getCorrectedLookAtPosition());
218 }
219 } else {
220 _faceModel.render(alpha, mode);
218 }221 }
219}222}
220 223
221void Head::renderPostLighting() {
222 renderLookatVectors(_leftEyePosition, _rightEyePosition, getCorrectedLookAtPosition());
223}
224
225void Head::setScale (float scale) {224void Head::setScale (float scale) {
226 if (_scale == scale) {225 if (_scale == scale) {
227 return;226 return;
interface/src/avatar/Head.h+2−4
@@ -23,7 +23,6 @@ · 22 unmodified lines
23#include "FaceModel.h"23#include "FaceModel.h"
24#include "InterfaceConfig.h"24#include "InterfaceConfig.h"
25#include "world.h"25#include "world.h"
26#include "renderer/DeferredLightingEffect.h"
27 26
28enum eyeContactTargets {27enum eyeContactTargets {
29 LEFT_EYE, 28 LEFT_EYE,
@@ -36,15 +35,14 @@ const float EYE_EAR_GAP = 0.08f; · 6 unmodified lines
36class Avatar;35class Avatar;
37class ProgramObject;36class ProgramObject;
38 37
39class Head : public HeadData, public PostLightingRenderable {38class Head : public HeadData {
40public:39public:
41 Head(Avatar* owningAvatar);40 Head(Avatar* owningAvatar);
42 41
43 void init();42 void init();
44 void reset();43 void reset();
45 void simulate(float deltaTime, bool isMine, bool billboard = false);44 void simulate(float deltaTime, bool isMine, bool billboard = false);
46 void render(float alpha, Model::RenderMode mode);45 void render(float alpha, Model::RenderMode mode, bool postLighting);
47 virtual void renderPostLighting();
48 void setScale(float scale);46 void setScale(float scale);
49 void setPosition(glm::vec3 position) { _position = position; }47 void setPosition(glm::vec3 position) { _position = position; }
50 void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }48 void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }
interface/src/avatar/MyAvatar.cpp+11−13
@@ -1147,20 +1147,18 @@ void MyAvatar::renderBody(RenderMode renderMode, bool postLighting, float glowLe · 1146 unmodified lines
1147 const Camera *camera = Application::getInstance()->getCamera();1147 const Camera *camera = Application::getInstance()->getCamera();
1148 const glm::vec3 cameraPos = camera->getPosition() + (camera->getRotation() * glm::vec3(0.0f, 0.0f, 1.0f)) * camera->getDistance();1148 const glm::vec3 cameraPos = camera->getPosition() + (camera->getRotation() * glm::vec3(0.0f, 0.0f, 1.0f)) * camera->getDistance();
1149 if (shouldRenderHead(cameraPos, renderMode)) {1149 if (shouldRenderHead(cameraPos, renderMode)) {
1150 if (!postLighting) {1150 getHead()->render(1.0f, modelRenderMode, postLighting);
1151 getHead()->render(1.0f, modelRenderMode);
1152 1151
1153 if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {1152 if (!postLighting && Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
1154 // Render Hair1153 // Render Hair
1155 glPushMatrix();1154 glPushMatrix();
1156 glm::vec3 headPosition = getHead()->getPosition();1155 glm::vec3 headPosition = getHead()->getPosition();
1157 glTranslatef(headPosition.x, headPosition.y, headPosition.z);1156 glTranslatef(headPosition.x, headPosition.y, headPosition.z);
1158 const glm::quat& rotation = getHead()->getFinalOrientationInWorldFrame();1157 const glm::quat& rotation = getHead()->getFinalOrientationInWorldFrame();
1159 glm::vec3 axis = glm::axis(rotation);1158 glm::vec3 axis = glm::axis(rotation);
1160 glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);1159 glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
1161 _hair.render();1160 _hair.render();
1162 glPopMatrix();1161 glPopMatrix();
1163 }
1164 }1162 }
1165 }1163 }
1166 if (postLighting) {1164 if (postLighting) {