stubbery for alerting entity that shape changed

This commit is contained in:
Andrew Meadows 2016-07-15 15:24:57 -07:00
parent 1ed76ae442
commit b2dfa49a6f
5 changed files with 22 additions and 4 deletions

View file

@ -61,6 +61,8 @@ public:
virtual bool isReadyToComputeShape() override; virtual bool isReadyToComputeShape() override;
virtual void computeShapeInfo(ShapeInfo& info) override; virtual void computeShapeInfo(ShapeInfo& info) override;
void setCollisionShape(const btCollisionShape* shape) override {}
virtual bool contains(const glm::vec3& point) const override; virtual bool contains(const glm::vec3& point) const override;
virtual bool shouldBePhysical() const override; virtual bool shouldBePhysical() const override;

View file

@ -44,6 +44,7 @@ class EntityTreeElementExtraEncodeData;
class EntityActionInterface; class EntityActionInterface;
class EntityItemProperties; class EntityItemProperties;
class EntityTree; class EntityTree;
class btCollisionShape;
typedef std::shared_ptr<EntityTree> EntityTreePointer; typedef std::shared_ptr<EntityTree> EntityTreePointer;
typedef std::shared_ptr<EntityActionInterface> EntityActionPointer; typedef std::shared_ptr<EntityActionInterface> EntityActionPointer;
typedef std::shared_ptr<EntityTreeElement> EntityTreeElementPointer; typedef std::shared_ptr<EntityTreeElement> EntityTreeElementPointer;
@ -324,6 +325,12 @@ public:
/// return preferred shape type (actual physical shape may differ) /// return preferred shape type (actual physical shape may differ)
virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; } virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; }
virtual void setCollisionShape(const btCollisionShape* shape) {}
// these are only needed because the names don't match
virtual const glm::quat getRotation() const { return getOrientation(); }
virtual void setRotation(glm::quat orientation) { setOrientation(orientation); }
// updateFoo() methods to be used when changes need to be accumulated in the _dirtyFlags // updateFoo() methods to be used when changes need to be accumulated in the _dirtyFlags
virtual void updateRegistrationPoint(const glm::vec3& value); virtual void updateRegistrationPoint(const glm::vec3& value);
void updatePosition(const glm::vec3& value); void updatePosition(const glm::vec3& value);

View file

@ -271,6 +271,14 @@ btCollisionShape* EntityMotionState::computeNewShape() {
return getShapeManager()->getShape(shapeInfo); return getShapeManager()->getShape(shapeInfo);
} }
void EntityMotionState::setShape(btCollisionShape* shape) {
bool shapeChanged = (_shape != shape);
ObjectMotionState::setShape(shape);
if (shapeChanged) {
_entity->setCollisionShape(_shape);
}
}
bool EntityMotionState::isCandidateForOwnership() const { bool EntityMotionState::isCandidateForOwnership() const {
assert(_body); assert(_body);
assert(_entity); assert(_entity);

View file

@ -88,9 +88,10 @@ protected:
bool entityTreeIsLocked() const; bool entityTreeIsLocked() const;
#endif #endif
virtual bool isReadyToComputeShape() const override; bool isReadyToComputeShape() const override;
virtual btCollisionShape* computeNewShape() override; btCollisionShape* computeNewShape() override;
virtual void setMotionType(PhysicsMotionType motionType); void setShape(btCollisionShape* shape) override;
void setMotionType(PhysicsMotionType motionType) override;
// In the glorious future (when entities lib depends on physics lib) the EntityMotionState will be // In the glorious future (when entities lib depends on physics lib) the EntityMotionState will be
// properly "owned" by the EntityItem and will be deleted by it in the dtor. In pursuit of that // properly "owned" by the EntityItem and will be deleted by it in the dtor. In pursuit of that

View file

@ -151,7 +151,7 @@ public:
protected: protected:
virtual bool isReadyToComputeShape() const = 0; virtual bool isReadyToComputeShape() const = 0;
virtual btCollisionShape* computeNewShape() = 0; virtual btCollisionShape* computeNewShape() = 0;
void setMotionType(PhysicsMotionType motionType); virtual void setMotionType(PhysicsMotionType motionType);
void updateCCDConfiguration(); void updateCCDConfiguration();
void setRigidBody(btRigidBody* body); void setRigidBody(btRigidBody* body);