always render yourself, handle change of render values elsewhere

This commit is contained in:
Stephen Birarda 2015-04-01 17:36:43 -07:00
parent 03292fd869
commit b27a86fb25
5 changed files with 37 additions and 14 deletions

View file

@ -70,10 +70,13 @@ Menu.menuItemEvent.connect(function (menuItem) {
} }
}); });
setupMenus(); Scene.shouldRenderAvatarsChanged.connect(function(shouldRenderAvatars) {
Menu.setIsOptionChecked(AVATARS_ITEM, shouldRenderAvatars)
});
// register our scriptEnding callback Scene.shouldRenderEntitiesChanged.connect(function(shouldRenderEntities) {
Script.scriptEnding.connect(scriptEnding); Menu.setIsOptionChecked(ENTITIES_ITEM, shouldRenderEntities)
});
function scriptEnding() { function scriptEnding() {
Menu.removeMenu(ENTITIES_MENU); Menu.removeMenu(ENTITIES_MENU);

View file

@ -2997,7 +2997,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR); bool mirrorMode = (theCamera.getMode() == CAMERA_MODE_MIRROR);
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars()) { {
PerformanceTimer perfTimer("avatars"); PerformanceTimer perfTimer("avatars");
DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, DependencyManager::get<AvatarManager>()->renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE,
false, selfAvatarOnly); false, selfAvatarOnly);

View file

@ -25,6 +25,7 @@
#include "AvatarManager.h" #include "AvatarManager.h"
#include "Menu.h" #include "Menu.h"
#include "MyAvatar.h" #include "MyAvatar.h"
#include "SceneScriptingInterface.h"
// 70 times per second - target is 60hz, but this helps account for any small deviations // 70 times per second - target is 60hz, but this helps account for any small deviations
// in the update loop // in the update loop
@ -122,15 +123,17 @@ void AvatarManager::renderAvatars(Avatar::RenderMode renderMode, bool postLighti
glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition(); glm::vec3 cameraPosition = Application::getInstance()->getCamera()->getPosition();
if (!selfAvatarOnly) { if (!selfAvatarOnly) {
foreach (const AvatarSharedPointer& avatarPointer, _avatarHash) { if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars()) {
Avatar* avatar = static_cast<Avatar*>(avatarPointer.data()); foreach (const AvatarSharedPointer& avatarPointer, _avatarHash) {
if (!avatar->isInitialized()) { Avatar* avatar = static_cast<Avatar*>(avatarPointer.data());
continue; if (!avatar->isInitialized()) {
continue;
}
avatar->render(cameraPosition, renderMode, postLighting);
avatar->setDisplayingLookatVectors(renderLookAtVectors);
} }
avatar->render(cameraPosition, renderMode, postLighting); renderAvatarFades(cameraPosition, renderMode);
avatar->setDisplayingLookatVectors(renderLookAtVectors);
} }
renderAvatarFades(cameraPosition, renderMode);
} else { } else {
// just render myAvatar // just render myAvatar
_myAvatar->render(cameraPosition, renderMode, postLighting); _myAvatar->render(cameraPosition, renderMode, postLighting);

View file

@ -64,4 +64,18 @@ float SceneScriptingInterface::getSunIntensity() const {
model::SunSkyStagePointer SceneScriptingInterface::getSkyStage() const { model::SunSkyStagePointer SceneScriptingInterface::getSkyStage() const {
return _skyStage; return _skyStage;
}
void SceneScriptingInterface::setShouldRenderAvatars(bool shouldRenderAvatars) {
if (shouldRenderAvatars != _shouldRenderAvatars) {
_shouldRenderAvatars = shouldRenderAvatars;
emit shouldRenderAvatarsChanged(_shouldRenderAvatars);
}
}
void SceneScriptingInterface::setShouldRenderEntities(bool shouldRenderEntities) {
if (shouldRenderEntities != _shouldRenderEntities) {
_shouldRenderEntities = shouldRenderEntities;
emit shouldRenderEntitiesChanged(_shouldRenderEntities);
}
} }

View file

@ -45,12 +45,15 @@ public:
model::SunSkyStagePointer getSkyStage() const; model::SunSkyStagePointer getSkyStage() const;
Q_INVOKABLE void setShouldRenderAvatars(bool shouldRenderAvatars) { _shouldRenderAvatars = shouldRenderAvatars; } Q_INVOKABLE void setShouldRenderAvatars(bool shouldRenderAvatars);
Q_INVOKABLE bool shouldRenderAvatars() const { return _shouldRenderAvatars; } Q_INVOKABLE bool shouldRenderAvatars() const { return _shouldRenderAvatars; }
Q_INVOKABLE void setShouldRenderEntities(bool shouldRenderEntities) { _shouldRenderEntities = shouldRenderEntities; } Q_INVOKABLE void setShouldRenderEntities(bool shouldRenderEntities);
Q_INVOKABLE bool shouldRenderEntities() const { return _shouldRenderEntities; } Q_INVOKABLE bool shouldRenderEntities() const { return _shouldRenderEntities; }
signals:
void shouldRenderAvatarsChanged(bool shouldRenderAvatars);
void shouldRenderEntitiesChanged(bool shouldRenderEntities);
protected: protected:
SceneScriptingInterface() {}; SceneScriptingInterface() {};
~SceneScriptingInterface() {}; ~SceneScriptingInterface() {};