mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:08:54 +02:00
still trying to make PhysicsEngine::addEntityInternal be async
This commit is contained in:
parent
4b1fc4fa10
commit
a945421d9d
4 changed files with 31 additions and 18 deletions
|
@ -22,7 +22,9 @@ ToolWindow::ToolWindow(QWidget* parent) :
|
||||||
_hasShown(false),
|
_hasShown(false),
|
||||||
_lastGeometry() {
|
_lastGeometry() {
|
||||||
|
|
||||||
|
# ifndef Q_OS_LINUX
|
||||||
setDockOptions(QMainWindow::ForceTabbedDocks);
|
setDockOptions(QMainWindow::ForceTabbedDocks);
|
||||||
|
# endif
|
||||||
Application::getInstance()->installEventFilter(this);
|
Application::getInstance()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,7 @@ bool ToolWindow::event(QEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
|
bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
|
# ifndef Q_OS_LINUX
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::WindowStateChange:
|
case QEvent::WindowStateChange:
|
||||||
if (Application::getInstance()->getWindow()->isMinimized()) {
|
if (Application::getInstance()->getWindow()->isMinimized()) {
|
||||||
|
@ -77,7 +80,7 @@ bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
#include "ModelEntityItem.h"
|
#include "ModelEntityItem.h"
|
||||||
#include "GeometryCache.h"
|
#include "GeometryCache.h"
|
||||||
|
#include "ResourceCache.h"
|
||||||
|
|
||||||
const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
|
const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
|
||||||
const QString ModelEntityItem::DEFAULT_COLLISION_MODEL_URL = QString("");
|
const QString ModelEntityItem::DEFAULT_COLLISION_MODEL_URL = QString("");
|
||||||
|
@ -417,21 +418,29 @@ QString ModelEntityItem::getAnimationSettings() const {
|
||||||
void ModelEntityItem::getReadyToComputeShape() {
|
void ModelEntityItem::getReadyToComputeShape() {
|
||||||
qDebug() << "ModelEntityItem::getReadyToComputeShape for " << getID().toString();
|
qDebug() << "ModelEntityItem::getReadyToComputeShape for " << getID().toString();
|
||||||
|
|
||||||
if (_collisionModelURL != "" && _collisionNetworkGeometry.isNull()) {
|
if (_collisionModelURL != "") {
|
||||||
qDebug() << " yes";
|
if (! _collisionNetworkGeometry.isNull()) {
|
||||||
// QSharedPointer<NetworkGeometry> networkGeometry =
|
qDebug() << " url is" << _collisionModelURL;
|
||||||
_collisionNetworkGeometry = DependencyManager::get<GeometryCache>()->getGeometry (_collisionModelURL, QUrl(), false);
|
// QSharedPointer<NetworkGeometry> networkGeometry =
|
||||||
|
_collisionNetworkGeometry =
|
||||||
// XXX does this do an unneeded copy?
|
DependencyManager::get<GeometryCache>()->getGeometry (_collisionModelURL, QUrl(), false);
|
||||||
// FBXGeometry _collisionModel = networkGeometry->getFBXGeometry();
|
connect(_collisionNetworkGeometry.data(), SIGNAL(Resource::loaded()), this, SLOT(collisionGeometryLoaded()));
|
||||||
FBXGeometry _collisionModel = _collisionNetworkGeometry->getFBXGeometry();
|
}
|
||||||
|
} else {
|
||||||
// connect(networkGeometry, loaded, this, collisionGeometryLoaded);
|
|
||||||
|
|
||||||
emit entityShapeReady(getID());
|
emit entityShapeReady(getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelEntityItem::collisionGeometryLoaded() {
|
||||||
|
qDebug() << "ModelEntityItem::collisionGeometryLoaded for " << getID().toString();
|
||||||
|
|
||||||
|
// XXX does this do an unneeded copy?
|
||||||
|
// FBXGeometry _collisionModel = networkGeometry->getFBXGeometry();
|
||||||
|
FBXGeometry _collisionModel = _collisionNetworkGeometry->getFBXGeometry();
|
||||||
|
|
||||||
|
emit entityShapeReady(getID());
|
||||||
|
}
|
||||||
|
|
||||||
void ModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
void ModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
qDebug() << "ModelEntityItem::computeShapeInfo for " << getID().toString();
|
qDebug() << "ModelEntityItem::computeShapeInfo for " << getID().toString();
|
||||||
info.setParams(getShapeType(), 0.5f * getDimensions(), NULL, _collisionModelURL);
|
info.setParams(getShapeType(), 0.5f * getDimensions(), NULL, _collisionModelURL);
|
||||||
|
|
|
@ -20,6 +20,8 @@ class NetworkGeometry;
|
||||||
class GeometryCache;
|
class GeometryCache;
|
||||||
|
|
||||||
class ModelEntityItem : public EntityItem {
|
class ModelEntityItem : public EntityItem {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
|
@ -134,6 +136,9 @@ public:
|
||||||
static void cleanupLoadedAnimations();
|
static void cleanupLoadedAnimations();
|
||||||
|
|
||||||
void getReadyToComputeShape();
|
void getReadyToComputeShape();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void collisionGeometryLoaded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,7 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) {
|
||||||
assert(entity);
|
assert(entity);
|
||||||
void* physicsInfo = entity->getPhysicsInfo();
|
void* physicsInfo = entity->getPhysicsInfo();
|
||||||
if (!physicsInfo && !_busyComputingShape.contains(entity->getID())) {
|
if (!physicsInfo && !_busyComputingShape.contains(entity->getID())) {
|
||||||
ShapeInfo shapeInfo;
|
// qDebug() << "in addEntityInternal ID is" << entity->getID().toString();
|
||||||
|
|
||||||
qDebug() << "in addEntityInternal ID is" << entity->getID().toString();
|
|
||||||
|
|
||||||
QPointer<EntityItem> entityWptr(entity);
|
QPointer<EntityItem> entityWptr(entity);
|
||||||
_busyComputingShape[entity->getID()] = entityWptr;
|
_busyComputingShape[entity->getID()] = entityWptr;
|
||||||
connect(entity, SIGNAL(entityShapeReady(QUuid)), this, SLOT(entityShapeReady(QUuid)));
|
connect(entity, SIGNAL(entityShapeReady(QUuid)), this, SLOT(entityShapeReady(QUuid)));
|
||||||
|
@ -72,8 +69,7 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsEngine::entityShapeReady(QUuid entityId) {
|
void PhysicsEngine::entityShapeReady(QUuid entityId) {
|
||||||
|
// qDebug() << "PhysicsEngine::entityShapeReady for" << entityId.toString();
|
||||||
qDebug() << "PhysicsEngine::entityShapeReady for" << entityId.toString();
|
|
||||||
|
|
||||||
QPointer<EntityItem> entityPtr = _busyComputingShape[entityId];
|
QPointer<EntityItem> entityPtr = _busyComputingShape[entityId];
|
||||||
_busyComputingShape.remove(entityId);
|
_busyComputingShape.remove(entityId);
|
||||||
|
|
Loading…
Reference in a new issue