From 2f47f7c7bad1361fd5a7884827ba20b31105f9cd Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 24 Mar 2015 16:51:42 -0700 Subject: [PATCH] diff minimization --- .../src/RenderableModelEntityItem.cpp | 1 - libraries/entities/src/EntitySimulation.h | 4 -- libraries/entities/src/EntityTree.cpp | 6 --- libraries/entities/src/EntityTree.h | 3 -- libraries/entities/src/EntityTreeElement.h | 1 - libraries/physics/src/PhysicsEngine.cpp | 38 +++++++++---------- libraries/physics/src/PhysicsEngine.h | 2 - 7 files changed, 18 insertions(+), 37 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 025da1d285..aab9786762 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -369,7 +369,6 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) { glm::vec3 aaBoxDim = aaBox.getDimensions(); aaBoxDim = glm::clamp(aaBoxDim, glm::vec3(FLT_EPSILON), aaBoxDim); - // scale = dimensions / aabox glm::vec3 scale = _dimensions / aaBoxDim; // multiply each point by scale before handing the point-set off to the physics engine diff --git a/libraries/entities/src/EntitySimulation.h b/libraries/entities/src/EntitySimulation.h index 68b42e5ac9..1eb4fdc951 100644 --- a/libraries/entities/src/EntitySimulation.h +++ b/libraries/entities/src/EntitySimulation.h @@ -63,10 +63,6 @@ public: EntityTree* getEntityTree() { return _entityTree; } - /* virtual void reconfigureEntity(EntityItem* entity) { */ - /* qDebug() << "EntitySimulation::reconfigureEntity"; */ - /* } */ - signals: void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index da7194e4bc..3ccff46a04 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -315,12 +315,6 @@ void EntityTree::deleteEntities(QSet entityIDs, bool force, bool i } } -void EntityTree::reconfigureEntity(EntityItem* entity) { - qDebug() << "EntityTree::reconfigureEntity"; - // _simulation->reconfigureEntity(entity); - _simulation->entityChanged(entity); -} - void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator) { const RemovedEntities& entities = theOperator.getEntities(); if (_simulation) { diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 25cc0b0bf4..29fecc88b4 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -95,8 +95,6 @@ public: void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = false); void deleteEntities(QSet entityIDs, bool force = false, bool ignoreWarnings = false); - // void removeEntityFromSimulation(EntityItem* entity); - void reconfigureEntity(EntityItem* entity); /// \param position point of query in world-frame (meters) /// \param targetRadius radius of query (meters) @@ -162,7 +160,6 @@ public: void emitEntityScriptChanging(const EntityItemID& entityItemID); void setSimulation(EntitySimulation* simulation); - EntitySimulation* getSimulation() { return _simulation; } bool wantEditLogging() const { return _wantEditLogging; } void setWantEditLogging(bool value) { _wantEditLogging = value; } diff --git a/libraries/entities/src/EntityTreeElement.h b/libraries/entities/src/EntityTreeElement.h index e93e00cc1c..0b28dd30d0 100644 --- a/libraries/entities/src/EntityTreeElement.h +++ b/libraries/entities/src/EntityTreeElement.h @@ -147,7 +147,6 @@ public: bool hasEntities() const { return _entityItems ? _entityItems->size() > 0 : false; } void setTree(EntityTree* tree) { _myTree = tree; } - EntityTree* getTree() { return _myTree; } bool updateEntity(const EntityItem& entity); void addEntityItem(EntityItem* entity); diff --git a/libraries/physics/src/PhysicsEngine.cpp b/libraries/physics/src/PhysicsEngine.cpp index 37b7035101..a46ba9f819 100644 --- a/libraries/physics/src/PhysicsEngine.cpp +++ b/libraries/physics/src/PhysicsEngine.cpp @@ -62,29 +62,27 @@ void PhysicsEngine::addEntityInternal(EntityItem* entity) { assert(entity); void* physicsInfo = entity->getPhysicsInfo(); if (!physicsInfo) { - if (! entity->isReadyToComputeShape()) { - return; - } - ShapeInfo shapeInfo; - entity->computeShapeInfo(shapeInfo); - btCollisionShape* shape = _shapeManager.getShape(shapeInfo); - if (shape) { - EntityMotionState* motionState = new EntityMotionState(entity); - entity->setPhysicsInfo(static_cast(motionState)); - _entityMotionStates.insert(motionState); - addObject(shapeInfo, shape, motionState); - } else if (entity->isMoving()) { - EntityMotionState* motionState = new EntityMotionState(entity); - entity->setPhysicsInfo(static_cast(motionState)); - _entityMotionStates.insert(motionState); + if (entity->isReadyToComputeShape()) { + ShapeInfo shapeInfo; + entity->computeShapeInfo(shapeInfo); + btCollisionShape* shape = _shapeManager.getShape(shapeInfo); + if (shape) { + EntityMotionState* motionState = new EntityMotionState(entity); + entity->setPhysicsInfo(static_cast(motionState)); + _entityMotionStates.insert(motionState); + addObject(shapeInfo, shape, motionState); + } else if (entity->isMoving()) { + EntityMotionState* motionState = new EntityMotionState(entity); + entity->setPhysicsInfo(static_cast(motionState)); + _entityMotionStates.insert(motionState); - motionState->setKinematic(true, _numSubsteps); - _nonPhysicalKinematicObjects.insert(motionState); - // We failed to add the entity to the simulation. Probably because we couldn't create a shape for it. - //qDebug() << "failed to add entity " << entity->getEntityItemID() << " to physics engine"; + motionState->setKinematic(true, _numSubsteps); + _nonPhysicalKinematicObjects.insert(motionState); + // We failed to add the entity to the simulation. Probably because we couldn't create a shape for it. + //qDebug() << "failed to add entity " << entity->getEntityItemID() << " to physics engine"; + } } } - return; } void PhysicsEngine::removeEntityInternal(EntityItem* entity) { diff --git a/libraries/physics/src/PhysicsEngine.h b/libraries/physics/src/PhysicsEngine.h index a8c9edf2f8..cb637c60b9 100644 --- a/libraries/physics/src/PhysicsEngine.h +++ b/libraries/physics/src/PhysicsEngine.h @@ -88,8 +88,6 @@ public: void setAvatarData(AvatarData *avatarData); - // virtual void reconfigureEntity(EntityItem* entity); - private: /// \param motionState pointer to Object's MotionState void removeObjectFromBullet(ObjectMotionState* motionState);