still trying to make PhysicsEngine::addEntityInternal be async

This commit is contained in:
Seth Alves 2015-03-12 16:38:55 -07:00
parent 4b1fc4fa10
commit a945421d9d
4 changed files with 31 additions and 18 deletions

View file

@ -22,7 +22,9 @@ ToolWindow::ToolWindow(QWidget* parent) :
_hasShown(false),
_lastGeometry() {
# ifndef Q_OS_LINUX
setDockOptions(QMainWindow::ForceTabbedDocks);
# endif
Application::getInstance()->installEventFilter(this);
}
@ -53,6 +55,7 @@ bool ToolWindow::event(QEvent* event) {
}
bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
# ifndef Q_OS_LINUX
switch (event->type()) {
case QEvent::WindowStateChange:
if (Application::getInstance()->getWindow()->isMinimized()) {
@ -77,7 +80,7 @@ bool ToolWindow::eventFilter(QObject* sender, QEvent* event) {
default:
break;
}
# endif
return false;
}

View file

@ -18,6 +18,7 @@
#include "EntityTreeElement.h"
#include "ModelEntityItem.h"
#include "GeometryCache.h"
#include "ResourceCache.h"
const QString ModelEntityItem::DEFAULT_MODEL_URL = QString("");
const QString ModelEntityItem::DEFAULT_COLLISION_MODEL_URL = QString("");
@ -417,21 +418,29 @@ QString ModelEntityItem::getAnimationSettings() const {
void ModelEntityItem::getReadyToComputeShape() {
qDebug() << "ModelEntityItem::getReadyToComputeShape for " << getID().toString();
if (_collisionModelURL != "" && _collisionNetworkGeometry.isNull()) {
qDebug() << " yes";
// QSharedPointer<NetworkGeometry> networkGeometry =
_collisionNetworkGeometry = DependencyManager::get<GeometryCache>()->getGeometry (_collisionModelURL, QUrl(), false);
// XXX does this do an unneeded copy?
// FBXGeometry _collisionModel = networkGeometry->getFBXGeometry();
FBXGeometry _collisionModel = _collisionNetworkGeometry->getFBXGeometry();
// connect(networkGeometry, loaded, this, collisionGeometryLoaded);
if (_collisionModelURL != "") {
if (! _collisionNetworkGeometry.isNull()) {
qDebug() << " url is" << _collisionModelURL;
// QSharedPointer<NetworkGeometry> networkGeometry =
_collisionNetworkGeometry =
DependencyManager::get<GeometryCache>()->getGeometry (_collisionModelURL, QUrl(), false);
connect(_collisionNetworkGeometry.data(), SIGNAL(Resource::loaded()), this, SLOT(collisionGeometryLoaded()));
}
} else {
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) {
qDebug() << "ModelEntityItem::computeShapeInfo for " << getID().toString();
info.setParams(getShapeType(), 0.5f * getDimensions(), NULL, _collisionModelURL);

View file

@ -20,6 +20,8 @@ class NetworkGeometry;
class GeometryCache;
class ModelEntityItem : public EntityItem {
Q_OBJECT
public:
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
@ -134,6 +136,9 @@ public:
static void cleanupLoadedAnimations();
void getReadyToComputeShape();
public slots:
void collisionGeometryLoaded();
protected:

View file

@ -60,10 +60,7 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) {
assert(entity);
void* physicsInfo = entity->getPhysicsInfo();
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);
_busyComputingShape[entity->getID()] = entityWptr;
connect(entity, SIGNAL(entityShapeReady(QUuid)), this, SLOT(entityShapeReady(QUuid)));
@ -72,8 +69,7 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) {
}
void PhysicsEngine::entityShapeReady(QUuid entityId) {
qDebug() << "PhysicsEngine::entityShapeReady for" << entityId.toString();
// qDebug() << "PhysicsEngine::entityShapeReady for" << entityId.toString();
QPointer<EntityItem> entityPtr = _busyComputingShape[entityId];
_busyComputingShape.remove(entityId);