mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:57:58 +02:00
Entities are now added/removed from rendering based on Scene.shouldRenderEntities
This commit is contained in:
parent
cac239ad88
commit
1dce5f80cc
3 changed files with 40 additions and 5 deletions
|
@ -1014,7 +1014,6 @@ void Application::paintGL() {
|
||||||
|
|
||||||
void Application::runTests() {
|
void Application::runTests() {
|
||||||
runTimingTests();
|
runTimingTests();
|
||||||
runUnitTests();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::audioMuteToggled() {
|
void Application::audioMuteToggled() {
|
||||||
|
@ -1183,6 +1182,7 @@ bool Application::event(QEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::eventFilter(QObject* object, QEvent* event) {
|
bool Application::eventFilter(QObject* object, QEvent* event) {
|
||||||
|
|
||||||
if (event->type() == QEvent::ShortcutOverride) {
|
if (event->type() == QEvent::ShortcutOverride) {
|
||||||
if (DependencyManager::get<OffscreenUi>()->shouldSwallowShortcut(event)) {
|
if (DependencyManager::get<OffscreenUi>()->shouldSwallowShortcut(event)) {
|
||||||
event->accept();
|
event->accept();
|
||||||
|
@ -1787,7 +1787,6 @@ void Application::checkFPS() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::idle() {
|
void Application::idle() {
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
|
||||||
static SimpleAverage<float> interIdleDurations;
|
static SimpleAverage<float> interIdleDurations;
|
||||||
static uint64_t lastIdleEnd{ 0 };
|
static uint64_t lastIdleEnd{ 0 };
|
||||||
|
|
||||||
|
@ -3387,6 +3386,14 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
// load the view frustum
|
// load the view frustum
|
||||||
loadViewFrustum(theCamera, _displayViewFrustum);
|
loadViewFrustum(theCamera, _displayViewFrustum);
|
||||||
|
|
||||||
|
// flip x if in mirror mode (also requires reversing winding order for backface culling)
|
||||||
|
if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
//glScalef(-1.0f, 1.0f, 1.0f);
|
||||||
|
//glFrontFace(GL_CW);
|
||||||
|
} else {
|
||||||
|
glFrontFace(GL_CCW);
|
||||||
|
}
|
||||||
|
|
||||||
// transform view according to theCamera
|
// transform view according to theCamera
|
||||||
// could be myCamera (if in normal mode)
|
// could be myCamera (if in normal mode)
|
||||||
// or could be viewFrustumOffsetCamera if in offset mode
|
// or could be viewFrustumOffsetCamera if in offset mode
|
||||||
|
@ -3404,6 +3411,9 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
Transform viewTransform;
|
Transform viewTransform;
|
||||||
viewTransform.setTranslation(theCamera.getPosition());
|
viewTransform.setTranslation(theCamera.getPosition());
|
||||||
viewTransform.setRotation(rotation);
|
viewTransform.setRotation(rotation);
|
||||||
|
if (theCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
// viewTransform.setScale(Transform::Vec3(-1.0f, 1.0f, 1.0f));
|
||||||
|
}
|
||||||
if (renderArgs->_renderSide != RenderArgs::MONO) {
|
if (renderArgs->_renderSide != RenderArgs::MONO) {
|
||||||
glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
|
glm::mat4 invView = glm::inverse(_untranslatedViewMatrix);
|
||||||
|
|
||||||
|
@ -3458,9 +3468,9 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
// Assuming nothing get's rendered through that
|
// Assuming nothing get's rendered through that
|
||||||
|
|
||||||
if (!selfAvatarOnly) {
|
if (!selfAvatarOnly) {
|
||||||
|
auto var = DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities();
|
||||||
// render models...
|
// render models...
|
||||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
//if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||||
PerformanceTimer perfTimer("entities");
|
PerformanceTimer perfTimer("entities");
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"Application::displaySide() ... entities...");
|
"Application::displaySide() ... entities...");
|
||||||
|
@ -3476,7 +3486,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
||||||
}
|
}
|
||||||
renderArgs->_debugFlags = renderDebugFlags;
|
renderArgs->_debugFlags = renderDebugFlags;
|
||||||
_entities.render(renderArgs);
|
_entities.render(renderArgs);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// render the ambient occlusion effect if enabled
|
// render the ambient occlusion effect if enabled
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QScriptSyntaxCheckResult>
|
#include <QScriptSyntaxCheckResult>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <AbstractScriptingServicesInterface.h>
|
#include <AbstractScriptingServicesInterface.h>
|
||||||
#include <AbstractViewStateInterface.h>
|
#include <AbstractViewStateInterface.h>
|
||||||
|
@ -802,6 +803,8 @@ void EntityTreeRenderer::connectSignalsToSlots(EntityScriptingInterface* entityS
|
||||||
connect(this, &EntityTreeRenderer::enterEntity, entityScriptingInterface, &EntityScriptingInterface::enterEntity);
|
connect(this, &EntityTreeRenderer::enterEntity, entityScriptingInterface, &EntityScriptingInterface::enterEntity);
|
||||||
connect(this, &EntityTreeRenderer::leaveEntity, entityScriptingInterface, &EntityScriptingInterface::leaveEntity);
|
connect(this, &EntityTreeRenderer::leaveEntity, entityScriptingInterface, &EntityScriptingInterface::leaveEntity);
|
||||||
connect(this, &EntityTreeRenderer::collisionWithEntity, entityScriptingInterface, &EntityScriptingInterface::collisionWithEntity);
|
connect(this, &EntityTreeRenderer::collisionWithEntity, entityScriptingInterface, &EntityScriptingInterface::collisionWithEntity);
|
||||||
|
|
||||||
|
connect(&(*DependencyManager::get<SceneScriptingInterface>()), &SceneScriptingInterface::shouldRenderEntitiesChanged, this, &EntityTreeRenderer::updateEntityTree, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const EntityItemID& entityID, QMouseEvent* event, unsigned int deviceID) {
|
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const EntityItemID& entityID, QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
@ -1152,3 +1155,19 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
||||||
entityScriptB.property("collisionWithEntity").call(entityScriptA, args);
|
entityScriptB.property("collisionWithEntity").call(entityScriptA, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeRenderer::updateEntityTree(bool shouldRenderEntities) {
|
||||||
|
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||||
|
qDebug() << "SHOULD RENDER ENTITIES NOW";
|
||||||
|
for (auto entityID : _entityIDsLastInScene) {
|
||||||
|
addingEntity(entityID);
|
||||||
|
}
|
||||||
|
_entityIDsLastInScene.clear();
|
||||||
|
} else {
|
||||||
|
qDebug() << "SHOULD NOT RENDER ENTITIES";
|
||||||
|
_entityIDsLastInScene = _entitiesInScene.keys();
|
||||||
|
for (auto entityID : _entityIDsLastInScene) {
|
||||||
|
deletingEntity(entityID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,9 @@ public:
|
||||||
virtual void scriptContentsAvailable(const QUrl& url, const QString& scriptContents);
|
virtual void scriptContentsAvailable(const QUrl& url, const QString& scriptContents);
|
||||||
virtual void errorInLoadingScript(const QUrl& url);
|
virtual void errorInLoadingScript(const QUrl& url);
|
||||||
|
|
||||||
|
// For Scene.shouldRenderEntities
|
||||||
|
QList<EntityItemID>& getEntitiesLastInScene() { return _entityIDsLastInScene; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mousePressOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
void mousePressOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
||||||
void mouseMoveOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
void mouseMoveOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
||||||
|
@ -112,6 +115,7 @@ public slots:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void entitySciptChanging(const EntityItemID& entityID, const bool reload);
|
void entitySciptChanging(const EntityItemID& entityID, const bool reload);
|
||||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||||
|
void updateEntityTree(bool shouldRenderEntities);
|
||||||
|
|
||||||
// optional slots that can be wired to menu items
|
// optional slots that can be wired to menu items
|
||||||
void setDisplayElementChildProxies(bool value) { _displayElementChildProxies = value; }
|
void setDisplayElementChildProxies(bool value) { _displayElementChildProxies = value; }
|
||||||
|
@ -188,6 +192,8 @@ private:
|
||||||
int _previousStageDay;
|
int _previousStageDay;
|
||||||
|
|
||||||
QHash<EntityItemID, EntityItemPointer> _entitiesInScene;
|
QHash<EntityItemID, EntityItemPointer> _entitiesInScene;
|
||||||
|
// For Scene.shouldRenderEntities
|
||||||
|
QList<EntityItemID> _entityIDsLastInScene;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue