Merge pull request #5967 from AndrewMeadows/collision-group-hack

allow physical objects to be set collisionless
This commit is contained in:
Howard Stearns 2015-10-02 16:08:52 -07:00
commit 8153ad7f44
7 changed files with 15 additions and 6 deletions

View file

@ -79,6 +79,7 @@ public:
glm::mat4 localToVoxelMatrix() const;
virtual ShapeType getShapeType() const;
virtual bool shouldBePhysical() const { return true; }
virtual bool isReadyToComputeShape();
virtual void computeShapeInfo(ShapeInfo& info);

View file

@ -52,6 +52,7 @@ public:
}
virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; }
virtual bool shouldBePhysical() const { return true; }
virtual void debugDump() const;

View file

@ -334,7 +334,7 @@ public:
bool getCollisionsWillMove() const { return _collisionsWillMove; }
void setCollisionsWillMove(bool value) { _collisionsWillMove = value; }
virtual bool shouldBePhysical() const { return !_ignoreForCollisions; }
virtual bool shouldBePhysical() const { return false; }
bool getLocked() const { return _locked; }
void setLocked(bool value) { _locked = value; }

View file

@ -466,5 +466,5 @@ QString ModelEntityItem::getAnimationSettings() const {
// virtual
bool ModelEntityItem::shouldBePhysical() const {
return EntityItem::shouldBePhysical() && getShapeType() != SHAPE_TYPE_NONE;
return getShapeType() != SHAPE_TYPE_NONE;
}

View file

@ -51,6 +51,7 @@ public:
}
virtual ShapeType getShapeType() const { return SHAPE_TYPE_SPHERE; }
virtual bool shouldBePhysical() const { return true; }
virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,

View file

@ -596,6 +596,12 @@ QString EntityMotionState::getName() {
// virtual
int16_t EntityMotionState::computeCollisionGroup() {
if (!_entity) {
return COLLISION_GROUP_STATIC;
}
if (_entity->getIgnoreForCollisions()) {
return COLLISION_GROUP_COLLISIONLESS;
}
switch (computeObjectMotionType()){
case MOTION_TYPE_STATIC:
return COLLISION_GROUP_STATIC;

View file

@ -37,11 +37,11 @@ enum MotionStateType {
// The update flags trigger two varieties of updates: "hard" which require the body to be pulled
// and re-added to the physics engine and "easy" which just updates the body properties.
const uint32_t HARD_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_MOTION_TYPE | EntityItem::DIRTY_SHAPE);
const uint32_t HARD_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_MOTION_TYPE | EntityItem::DIRTY_SHAPE |
EntityItem::DIRTY_COLLISION_GROUP);
const uint32_t EASY_DIRTY_PHYSICS_FLAGS = (uint32_t)(EntityItem::DIRTY_TRANSFORM | EntityItem::DIRTY_VELOCITIES |
EntityItem::DIRTY_MASS | EntityItem::DIRTY_COLLISION_GROUP |
EntityItem::DIRTY_MATERIAL | EntityItem::DIRTY_SIMULATOR_ID |
EntityItem::DIRTY_SIMULATOR_OWNERSHIP);
EntityItem::DIRTY_MASS | EntityItem::DIRTY_MATERIAL |
EntityItem::DIRTY_SIMULATOR_ID | EntityItem::DIRTY_SIMULATOR_OWNERSHIP);
// These are the set of incoming flags that the PhysicsEngine needs to hear about:
const uint32_t DIRTY_PHYSICS_FLAGS = (uint32_t)(HARD_DIRTY_PHYSICS_FLAGS | EASY_DIRTY_PHYSICS_FLAGS |